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

@@ -15,51 +15,49 @@
</template>
<script>
import htmlParser from '@/common/js/html-parser';
export default {
data() {
return {
id: 0,
detail: {},
content: ''
};
},
onLoad(options) {
this.id = options.id || 0;
// 小程序扫码进入
if (options.scene) {
var sceneParams = decodeURIComponent(options.scene);
this.id = sceneParams.split('-')[1];
}
if (this.id == 0) {
this.$util.redirectTo('/pages_tool/help/list', {}, 'redirectTo');
}
},
onShow() {
this.getData();
},
methods: {
getData() {
this.$api.sendRequest({
url: '/api/help/info',
data: {
id: this.id
},
success: res => {
if (res.code == 0) {
if (res.data) {
this.detail = res.data;
this.$langConfig.title(this.detail.title);
this.content = htmlParser(res.data.content);
this.setPublicShare();
} else {
this.$util.showToast({
title: res.message
});
setTimeout(() => {
this.$util.redirectTo('/pages_tool/help/list', {}, 'redirectTo');
}, 2000);
}
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 {
id: 0,
detail: {},
content: ''
};
},
onLoad(options) {
this.id = options.id || 0;
// 小程序扫码进入
if (options.scene) {
var sceneParams = decodeURIComponent(options.scene);
this.id = sceneParams.split('-')[1];
}
if (this.id == 0) {
this.$util.redirectTo('/pages_tool/help/list', {}, 'redirectTo');
}
},
onShow() {
this.getData();
},
methods: {
getData() {
this.$api.sendRequest({
url: '/api/help/info',
data: {
id: this.id
},
success: res => {
if (res.code == 0) {
if (res.data) {
this.detail = res.data;
this.$langConfig.title(this.detail.title);
this.content = htmlParser(res.data.content);
this.setPublicShare();
} else {
this.$util.showToast({
title: res.message
@@ -68,73 +66,81 @@
this.$util.redirectTo('/pages_tool/help/list', {}, 'redirectTo');
}, 2000);
}
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
},
fail: res => {
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
} else {
this.$util.showToast({
title: res.message
});
setTimeout(() => {
this.$util.redirectTo('/pages_tool/help/list', {}, 'redirectTo');
}, 2000);
}
});
},
// 设置公众号分享
setPublicShare() {
let shareUrl = this.$config.h5Domain + '/pages_tool/help/detail?id=' + this.id;
this.$util.setPublicShare({
title: this.detail.title,
desc: '',
link: shareUrl,
imgUrl: this.siteInfo ? this.$util.img(this.siteInfo.logo_square) : ''
});
}
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
},
fail: res => {
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}
});
},
onShareAppMessage(res) {
var title = this.detail.title;
var path = '/pages_tool/help/detail?id=' + this.id;
return {
title: title,
path: path,
success: res => {},
fail: res => {}
};
},
//分享到朋友圈
onShareTimeline() {
var title = this.detail.title;
var query = 'id=' + this.id;
return {
title: title,
query: query,
imageUrl: ''
};
// 设置公众号分享
setPublicShare() {
let shareUrl = this.$config.h5Domain + '/pages_tool/help/detail?id=' + this.id;
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/help/detail?id=' + this.id;
return {
title: title,
path: path,
success: res => { },
fail: res => { }
};
},
//分享到朋友圈
onShareTimeline() {
var title = this.detail.title;
var query = 'id=' + this.id;
return {
title: title,
query: query,
imageUrl: ''
};
}
};
</script>
<style lang="scss">
.page {
width: 100%;
height: 100%;
padding: 30rpx;
box-sizing: border-box;
background: #ffffff;
}
.page {
width: 100%;
height: 100%;
padding: 30rpx;
box-sizing: border-box;
background: #ffffff;
}
.help-title {
font-size: $font-size-toolbar;
text-align: center;
}
.help-title {
font-size: $font-size-toolbar;
text-align: center;
}
.help-content {
margin-top: $margin-updown;
word-break: break-all;
}
.help-content {
margin-top: $margin-updown;
word-break: break-all;
}
.help-meta {
text-align: right;
margin-top: $margin-updown;
color: $color-tip;
.help-meta {
text-align: right;
margin-top: $margin-updown;
color: $color-tip;
.help-time {
font-size: $font-size-tag;
}
.help-time {
font-size: $font-size-tag;
}
}
</style>

View File

@@ -3,7 +3,8 @@
<block v-if="dataList.length">
<view class="help-item" v-for="(item, index) in dataList" :key="index">
<view :class="['item-title', item.child_list.length == 0 ? 'empty' : '']">{{ item.class_name }}</view>
<view class="item-content" v-for="(s_item, s_index) in item.child_list" :key="s_index" @click="helpDetail(s_item)">{{ s_item.title }}</view>
<view class="item-content" v-for="(s_item, s_index) in item.child_list" :key="s_index"
@click="helpDetail(s_item)">{{ s_item.title }}</view>
</view>
</block>
<block v-else><ns-empty text="暂无帮助信息" :isIndex="false"></ns-empty></block>
@@ -19,12 +20,18 @@
<script>
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 {
dataList: []
};
},
onLoad() {},
onLoad() { },
onShow() {
this.setPublicShare();
this.getData();
@@ -85,8 +92,8 @@ export default {
return {
title: title,
path: path,
success: res => {},
fail: res => {}
success: res => { },
fail: res => { }
};
}
};
@@ -112,6 +119,7 @@ export default {
font-size: 30rpx;
color: #000;
border-bottom: 2rpx solid #f1f1f1;
&.empty {
padding-bottom: 0;
border-bottom: none;