chore(组件): 组件尽量使用异步导入模式

This commit is contained in:
2026-01-04 14:40:00 +08:00
parent 4da852944e
commit 9415f397d2
172 changed files with 11520 additions and 10979 deletions

View File

@@ -5,7 +5,7 @@
<text class="notice-time">发表时间: {{ $util.timeStampTurnTime(detail.create_time) }}</text>
</view>
<view class="notice-content"><rich-text :nodes="content"></rich-text></view>
<loading-cover ref="loadingCover"></loading-cover>
<!-- #ifdef MP-WEIXIN -->
@@ -16,126 +16,132 @@
</template>
<script>
import htmlParser from '@/common/js/html-parser';
export default {
data() {
return {
noticeId: 0,
content: '',
detail: {}
};
},
onLoad(options) {
this.noticeId = options.notice_id || 0;
// 小程序扫码进入
if (options.scene) {
var sceneParams = decodeURIComponent(options.scene);
this.noticeId = sceneParams.split('-')[1];
}
if (this.noticeId == 0) {
this.$util.redirectTo('/pages_tool/notice/list', {}, 'redirectTo');
}
},
onShow() {
this.getData();
},
methods: {
getData() {
this.$api.sendRequest({
url: '/api/notice/info',
data: {
id: this.noticeId
},
success: res => {
if (res.code == 0) {
if (res.data) {
this.detail = res.data;
this.content = htmlParser(res.data.content);
this.$langConfig.title(this.detail.title);
this.setPublicShare();
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
} else {
this.$util.redirectTo('/pages_tool/notice/list', {}, 'redirectTo');
}
} else {
this.$util.showToast({
title: res.message
});
setTimeout(() => {
this.$util.redirectTo('/pages_tool/notice/list', {}, 'redirectTo');
}, 2000);
}
},
fail: res => {
this.$util.redirectTo('/pages_tool/notice/list', {}, 'redirectTo');
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}
});
},
// 设置公众号分享
setPublicShare() {
let shareUrl = this.$config.h5Domain + '/pages_tool/notice/detail?notice_id=' + this.noticeId;
this.$util.setPublicShare({
title: this.detail.title,
desc: '',
link: shareUrl,
imgUrl: this.siteInfo ? this.$util.img(this.siteInfo.logo_square) :
''
});
}
},
onShareAppMessage(res) {
var title = '[公告]' + this.detail.title;
var path = '/pages_tool/notice/detail?notice_id=' + this.noticeId;
return {
title: title,
path: path,
success: res => {},
fail: res => {}
};
},
//分享到朋友圈
onShareTimeline() {
var title = this.detail.title;
var query = 'notice_id=' + this.noticeId;
return {
title: title,
query: query,
imageUrl: ''
};
import htmlParser from '@/common/js/html-parser.js';
export default {
components: {
loadingCover: () => import('@/components/loading-cover/loading-cover.vue'),
// #ifdef MP-WEIXIN
privacyPopup: () => import('@/components/wx-privacy-popup/privacy-popup.vue'),
// #endif
},
data() {
return {
noticeId: 0,
content: '',
detail: {}
};
},
onLoad(options) {
this.noticeId = options.notice_id || 0;
// 小程序扫码进入
if (options.scene) {
var sceneParams = decodeURIComponent(options.scene);
this.noticeId = sceneParams.split('-')[1];
}
};
if (this.noticeId == 0) {
this.$util.redirectTo('/pages_tool/notice/list', {}, 'redirectTo');
}
},
onShow() {
this.getData();
},
methods: {
getData() {
this.$api.sendRequest({
url: '/api/notice/info',
data: {
id: this.noticeId
},
success: res => {
if (res.code == 0) {
if (res.data) {
this.detail = res.data;
this.content = htmlParser(res.data.content);
this.$langConfig.title(this.detail.title);
this.setPublicShare();
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
} else {
this.$util.redirectTo('/pages_tool/notice/list', {}, 'redirectTo');
}
} else {
this.$util.showToast({
title: res.message
});
setTimeout(() => {
this.$util.redirectTo('/pages_tool/notice/list', {}, 'redirectTo');
}, 2000);
}
},
fail: res => {
this.$util.redirectTo('/pages_tool/notice/list', {}, 'redirectTo');
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}
});
},
// 设置公众号分享
setPublicShare() {
let shareUrl = this.$config.h5Domain + '/pages_tool/notice/detail?notice_id=' + this.noticeId;
this.$util.setPublicShare({
title: this.detail.title,
desc: '',
link: shareUrl,
imgUrl: this.siteInfo ? this.$util.img(this.siteInfo.logo_square) :
''
});
}
},
onShareAppMessage(res) {
var title = '[公告]' + this.detail.title;
var path = '/pages_tool/notice/detail?notice_id=' + this.noticeId;
return {
title: title,
path: path,
success: res => { },
fail: res => { }
};
},
//分享到朋友圈
onShareTimeline() {
var title = this.detail.title;
var query = 'notice_id=' + this.noticeId;
return {
title: title,
query: query,
imageUrl: ''
};
}
};
</script>
<style lang="scss">
.page {
width: 100%;
height: 100%;
padding: 30rpx;
box-sizing: border-box;
background-color: #fff;
}
.page {
width: 100%;
height: 100%;
padding: 30rpx;
box-sizing: border-box;
background-color: #fff;
}
.notice-title {
font-size: $font-size-toolbar;
text-align: left;
font-weight: bold;
}
.notice-title {
font-size: $font-size-toolbar;
text-align: left;
font-weight: bold;
}
.notice-content {
margin-top: $margin-updown;
word-break: break-all;
font-size: $font-size-base;
}
.notice-content {
margin-top: $margin-updown;
word-break: break-all;
font-size: $font-size-base;
}
.notice-meta {
text-align: left;
margin-top: $margin-updown;
color: $color-tip;
.notice-meta {
text-align: left;
margin-top: $margin-updown;
color: $color-tip;
.notice-time {
font-size: $font-size-tag;
}
.notice-time {
font-size: $font-size-tag;
}
}
</style>

View File

@@ -28,20 +28,15 @@
</template>
<script>
import MescrollUni from "@/components/mescroll/my-list-mescroll.vue";
import nsLogin from '@/components/ns-login/ns-login.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
import nsEmpty from '@/components/ns-empty/ns-empty.vue';
// #ifdef MP-WEIXIN
import privacyPopup from '@/components/wx-privacy-popup/privacy-popup.vue';
// #endif
export default {
components: {
nsLogin,
MescrollUni,
nsEmpty,
loadingCover: () => import('@/components/loading-cover/loading-cover.vue'),
nsLogin: () => import('@/components/ns-login/ns-login.vue'),
MescrollUni: () => import('@/components/mescroll/my-list-mescroll.vue'),
nsEmpty: () => import('@/components/ns-empty/ns-empty.vue'),
// #ifdef MP-WEIXIN
privacyPopup
privacyPopup: () => import('@/components/wx-privacy-popup/privacy-popup.vue'),
// #endif
},
data() {