chore(组件): 全局组件改为按需引用

This commit is contained in:
2025-12-26 14:29:38 +08:00
parent e949b14090
commit 86831b8551
27 changed files with 287 additions and 103 deletions

22
main.js
View File

@@ -40,27 +40,7 @@ App.mpType = 'app';
// 重写存储,增加前缀 // 重写存储,增加前缀
uniStorage(); uniStorage();
//常用组件 // 组件已改为按需引入,不再全局注册
import loadingCover from '@/components/loading-cover/loading-cover.vue';
Vue.component('loading-cover', loadingCover);
import nsMpHtml from '@/components/ns-mp-html/ns-mp-html.vue';
Vue.component('ns-mp-html', nsMpHtml);
import nsEmpty from '@/components/ns-empty/ns-empty.vue';
Vue.component('ns-empty', nsEmpty);
import MescrollUni from "@/components/mescroll/my-list-mescroll.vue";
Vue.component("mescroll-uni", MescrollUni); //上拉加载,下拉刷新组件
import MescrollBody from "@/components/mescroll/mescroll-body.vue"
Vue.component('mescroll-body', MescrollBody);
import NsLogin from "@/components/ns-login/ns-login.vue"
Vue.component('ns-login', NsLogin);
import PrivacyPopup from '@/components/wx-privacy-popup/privacy-popup.vue';
Vue.component('privacy-popup', PrivacyPopup)
const app = new Vue({ const app = new Vue({
...App, ...App,

View File

@@ -26,8 +26,19 @@
</template> </template>
<script> <script>
import nsLogin from '@/components/ns-login/ns-login.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
// #ifdef MP-WEIXIN
import privacyPopup from '@/components/wx-privacy-popup/privacy-popup.vue';
// #endif
export default { export default {
components: {}, components: {
nsLogin,
loadingCover,
// #ifdef MP-WEIXIN
privacyPopup
// #endif
},
data() { data() {
return { return {
diyData: null diyData: null

View File

@@ -134,6 +134,10 @@
<script> <script>
import uniPopup from '@/components/uni-popup/uni-popup.vue'; import uniPopup from '@/components/uni-popup/uni-popup.vue';
import nsNavbar from '@/components/ns-navbar/ns-navbar.vue'; import nsNavbar from '@/components/ns-navbar/ns-navbar.vue';
import nsLogin from '@/components/ns-login/ns-login.vue';
// #ifdef MP-WEIXIN
import privacyPopup from '@/components/wx-privacy-popup/privacy-popup.vue';
// #endif
import diyJs from '@/common/js/diy.js'; import diyJs from '@/common/js/diy.js';
import indexJs from './public/js/index.js'; import indexJs from './public/js/index.js';
import toTop from '@/components/toTop/toTop.vue'; import toTop from '@/components/toTop/toTop.vue';
@@ -144,7 +148,11 @@
components: { components: {
uniPopup, uniPopup,
nsNavbar, nsNavbar,
toTop toTop,
nsLogin,
// #ifdef MP-WEIXIN
privacyPopup
// #endif
}, },
mixins: [diyJs, scroll, indexJs] mixins: [diyJs, scroll, indexJs]
}; };

View File

@@ -319,15 +319,27 @@
import nsGoodsRecommend from '@/components/ns-goods-recommend/ns-goods-recommend.vue'; import nsGoodsRecommend from '@/components/ns-goods-recommend/ns-goods-recommend.vue';
import uniNumberBox from '@/components/uni-number-box/uni-number-box.vue'; import uniNumberBox from '@/components/uni-number-box/uni-number-box.vue';
import toTop from '@/components/toTop/toTop.vue'; import toTop from '@/components/toTop/toTop.vue';
import nsEmpty from '@/components/ns-empty/ns-empty.vue';
import nsLogin from '@/components/ns-login/ns-login.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
import scroll from '@/common/js/scroll-view.js'; import scroll from '@/common/js/scroll-view.js';
import cart from './public/js/cart.js'; import cart from './public/js/cart.js';
// #ifdef MP-WEIXIN
import privacyPopup from '@/components/wx-privacy-popup/privacy-popup.vue';
// #endif
export default { export default {
components: { components: {
nsGoodsRecommend, nsGoodsRecommend,
uniNumberBox, uniNumberBox,
toTop toTop,
}, nsEmpty,
nsLogin,
loadingCover,
// #ifdef MP-WEIXIN
privacyPopup
// #endif
},
mixins: [scroll, cart] mixins: [scroll, cart]
}; };
</script> </script>

View File

@@ -534,19 +534,30 @@ import toTop from '@/components/toTop/toTop.vue';
import nsGoodsPromotion from '@/components/ns-goods-promotion/ns-goods-promotion.vue'; import nsGoodsPromotion from '@/components/ns-goods-promotion/ns-goods-promotion.vue';
import goodsDetailBase from '@/common/js/goods_detail_base.js'; import goodsDetailBase from '@/common/js/goods_detail_base.js';
import goodsDetailView from '@/components/goods-detail-view/goods-detail-view.vue'; import goodsDetailView from '@/components/goods-detail-view/goods-detail-view.vue';
// 按需引入全局组件
import nsLogin from '@/components/ns-login/ns-login.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
// #ifdef MP-WEIXIN
import privacyPopup from '@/components/wx-privacy-popup/privacy-popup.vue';
// #endif
export default { export default {
components: { components: {
nsGoodsAction, nsGoodsAction,
nsGoodsActionIcon, nsGoodsActionIcon,
nsGoodsActionButton, nsGoodsActionButton,
uniPopup, uniPopup,
nsGoodsSku, nsGoodsSku,
uniCountDown, uniCountDown,
nsGoodsPromotion, nsGoodsPromotion,
goodsDetailView, goodsDetailView,
toTop toTop,
}, nsLogin,
loadingCover,
// #ifdef MP-WEIXIN
privacyPopup,
// #endif
},
mixins: [goodsDetailBase, detail, scroll] mixins: [goodsDetailBase, detail, scroll]
}; };
</script> </script>

View File

@@ -288,14 +288,26 @@
import uniDrawer from '@/components/uni-drawer/uni-drawer.vue'; import uniDrawer from '@/components/uni-drawer/uni-drawer.vue';
import uniTag from '@/components/uni-tag/uni-tag.vue'; import uniTag from '@/components/uni-tag/uni-tag.vue';
import nsGoodsSkuIndex from '@/components/ns-goods-sku/ns-goods-sku-index.vue'; import nsGoodsSkuIndex from '@/components/ns-goods-sku/ns-goods-sku-index.vue';
import nsEmpty from '@/components/ns-empty/ns-empty.vue';
import MescrollUni from '@/components/mescroll/mescroll-uni.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
// #ifdef MP-WEIXIN
import privacyPopup from '@/components/wx-privacy-popup/privacy-popup.vue';
// #endif
import list from './public/js/list.js'; import list from './public/js/list.js';
export default { export default {
components: { components: {
uniDrawer, uniDrawer,
uniTag, uniTag,
nsGoodsSkuIndex nsGoodsSkuIndex,
}, nsEmpty,
MescrollUni,
loadingCover,
// #ifdef MP-WEIXIN
privacyPopup
// #endif
},
data() { data() {
return {}; return {};
}, },

View File

@@ -149,8 +149,19 @@
<script> <script>
import orderMethod from './public/js/orderMethod.js'; import orderMethod from './public/js/orderMethod.js';
import nsPayment from '@/components/payment/payment.vue'; import nsPayment from '@/components/payment/payment.vue';
import MescrollUni from '@/components/mescroll/mescroll-uni.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';
export default { export default {
components: {
nsPayment,
MescrollUni,
nsLogin,
loadingCover,
nsEmpty
},
data() { data() {
return { return {
scrollInto: '', scrollInto: '',
@@ -175,9 +186,7 @@
isTradeManaged: false // 检测微信小程序是否已开通发货信息管理服务 isTradeManaged: false // 检测微信小程序是否已开通发货信息管理服务
}; };
}, },
components: {
nsPayment
},
mixins: [orderMethod], mixins: [orderMethod],
onLoad(option) { onLoad(option) {
if (option.status) this.orderStatus = option.status; if (option.status) this.orderStatus = option.status;

View File

@@ -63,7 +63,16 @@
</template> </template>
<script> <script>
import MescrollUni from '@/components/mescroll/mescroll-uni.vue';
import nsLogin from '@/components/ns-login/ns-login.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
export default { export default {
components: {
MescrollUni,
nsLogin,
loadingCover
},
data() { data() {
return { return {
dataList: [], //账号列表 dataList: [], //账号列表

View File

@@ -91,8 +91,16 @@
import { import {
Weixin Weixin
} from 'common/js/wx-jssdk.js'; } from 'common/js/wx-jssdk.js';
import MescrollUni from '@/components/mescroll/mescroll-uni.vue';
import nsLogin from '@/components/ns-login/ns-login.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
export default { export default {
components: {
MescrollUni,
nsLogin,
loadingCover
},
data() { data() {
return { return {
addressList: [], addressList: [],

View File

@@ -73,7 +73,11 @@
</template> </template>
<script> <script>
import nsLogin from '@/components/ns-login/ns-login.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
export default { export default {
components: { nsLogin, loadingCover },
data() { data() {
return { return {
balanceInfo: { balanceInfo: {

View File

@@ -51,7 +51,17 @@
</template> </template>
<script> <script>
export default { import nsEmpty from '@/components/ns-empty/ns-empty.vue';
import nsLogin from '@/components/ns-login/ns-login.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
import MescrollUni from '@/components/mescroll/mescroll-uni.vue';
export default {
components: {
nsEmpty,
nsLogin,
loadingCover,
MescrollUni
},
data() { data() {
const currentDate = this.getDate({ const currentDate = this.getDate({
format: true format: true
@@ -83,7 +93,6 @@
related_id: 0 related_id: 0
}; };
}, },
components: {},
onLoad(option) { onLoad(option) {
if (option.group_id) this.related_id = option.group_id ? option.group_id : 0; if (option.group_id) this.related_id = option.group_id ? option.group_id : 0;
if (option.from_type) this.searchType.from_type = option.from_type; if (option.from_type) this.searchType.from_type = option.from_type;

View File

@@ -120,13 +120,15 @@
<script> <script>
import uniPopup from '@/components/uni-popup/uni-popup.vue'; import uniPopup from '@/components/uni-popup/uni-popup.vue';
import nsGoodsRecommend from '@/components/ns-goods-recommend/ns-goods-recommend.vue'; import nsGoodsRecommend from '@/components/ns-goods-recommend/ns-goods-recommend.vue';
import scroll from '@/common/js/scroll-view.js'; import scroll from '@/common/js/scroll-view.js';
import nsLogin from '@/components/ns-login/ns-login.vue';
export default { export default {
components: { components: {
uniPopup, uniPopup,
nsGoodsRecommend nsGoodsRecommend,
nsLogin
}, },
mixins: [scroll], mixins: [scroll],
data() { data() {

View File

@@ -211,11 +211,19 @@
<script> <script>
import scroll from '@/common/js/scroll-view.js'; import scroll from '@/common/js/scroll-view.js';
import uniPopup from '@/components/uni-popup/uni-popup.vue'; import uniPopup from '@/components/uni-popup/uni-popup.vue';
import nsEmpty from '@/components/ns-empty/ns-empty.vue';
import nsLogin from '@/components/ns-login/ns-login.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
import nsPayment from '@/components/ns-payment/ns-payment.vue';
export default { export default {
components: { components: {
uniPopup uniPopup,
nsEmpty,
nsLogin,
loadingCover,
nsPayment
}, },
mixins: [scroll], mixins: [scroll],
data() { data() {

View File

@@ -37,12 +37,20 @@
<script> <script>
import nsGoodsRecommend from '@/components/ns-goods-recommend/ns-goods-recommend.vue'; import nsGoodsRecommend from '@/components/ns-goods-recommend/ns-goods-recommend.vue';
import collection from './public/js/collection.js'; import nsEmpty from '@/components/ns-empty/ns-empty.vue';
import nsLogin from '@/components/ns-login/ns-login.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
import MescrollUni from '@/components/mescroll/mescroll-uni.vue';
import collection from './public/js/collection.js';
export default { export default {
components: { components: {
nsGoodsRecommend nsGoodsRecommend,
}, nsEmpty,
nsLogin,
loadingCover,
MescrollUni
},
mixins: [collection], mixins: [collection],
data() { data() {
return {}; return {};

View File

@@ -71,8 +71,18 @@
</template> </template>
<script> <script>
export default { import nsEmpty from '@/components/ns-empty/ns-empty.vue';
data() { import nsLogin from '@/components/ns-login/ns-login.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
import MescrollUni from '@/components/mescroll/mescroll-uni.vue';
export default {
components: {
nsEmpty,
nsLogin,
loadingCover,
MescrollUni
},
data() {
return { return {
type: '', type: '',
types: '', types: '',

View File

@@ -65,8 +65,18 @@
<script> <script>
var dateList = []; var dateList = [];
import nsEmpty from '@/components/ns-empty/ns-empty.vue';
import nsLogin from '@/components/ns-login/ns-login.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
import MescrollUni from '@/components/mescroll/mescroll-uni.vue';
export default { export default {
components: {
nsEmpty,
nsLogin,
loadingCover,
MescrollUni
},
data() { data() {
return { return {
goodsList: [], goodsList: [],

View File

@@ -233,7 +233,15 @@
<script> <script>
import inviteFriends from './public/js/invite_friends.js'; import inviteFriends from './public/js/invite_friends.js';
import nsEmpty from '@/components/ns-empty/ns-empty.vue';
import nsLogin from '@/components/ns-login/ns-login.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
export default { export default {
components: {
nsEmpty,
nsLogin,
loadingCover
},
data() { data() {
return { return {
inviteList: [], inviteList: [],

View File

@@ -173,6 +173,8 @@
import toTop from '@/components/toTop/toTop.vue'; import toTop from '@/components/toTop/toTop.vue';
import scroll from '@/common/js/scroll-view.js'; import scroll from '@/common/js/scroll-view.js';
import uniPopup from '@/components/uni-popup/uni-popup.vue'; import uniPopup from '@/components/uni-popup/uni-popup.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
import nsLogin from '@/components/ns-login/ns-login.vue';
export default { export default {
components: { components: {

View File

@@ -76,7 +76,14 @@
</template> </template>
<script> <script>
import nsLogin from '@/components/ns-login/ns-login.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
export default { export default {
components: {
nsLogin,
loadingCover
},
data() { data() {
return { return {
pointInfo: { pointInfo: {

View File

@@ -46,7 +46,17 @@
</template> </template>
<script> <script>
import nsEmpty from '@/components/ns-empty/ns-empty.vue';
import nsLogin from '@/components/ns-login/ns-login.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
import MescrollUni from '@/components/mescroll/mescroll-uni.vue';
export default { export default {
components: {
nsEmpty,
nsLogin,
loadingCover,
MescrollUni
},
data() { data() {
const currentDate = this.getDate({ const currentDate = this.getDate({
format: true format: true

View File

@@ -31,7 +31,17 @@
</template> </template>
<script> <script>
import nsEmpty from '@/components/ns-empty/ns-empty.vue';
import nsLogin from '@/components/ns-login/ns-login.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
import MescrollUni from '@/components/mescroll/mescroll-uni.vue';
export default { export default {
components: {
nsEmpty,
nsLogin,
loadingCover,
MescrollUni
},
data() { data() {
return { return {
dataList: [] dataList: []

View File

@@ -54,7 +54,12 @@
</template> </template>
<script> <script>
import loadingCover from '@/components/loading-cover/loading-cover.vue';
export default { export default {
components: {
loadingCover
},
data() { data() {
return { return {
id: 0, id: 0,

View File

@@ -57,8 +57,14 @@
<script> <script>
import refundMethod from './public/js/refundMethod.js'; import refundMethod from './public/js/refundMethod.js';
import MescrollUni from '@/components/mescroll/mescroll-uni.vue';
import nsEmpty from '@/components/ns-empty/ns-empty.vue';
export default { export default {
components: {
MescrollUni,
nsEmpty
},
data() { data() {
return { return {
refundList: [], refundList: [],

View File

@@ -32,8 +32,11 @@
<script> <script>
import { Weixin } from 'common/js/wx-jssdk.js'; import { Weixin } from 'common/js/wx-jssdk.js';
import nsLogin from '@/components/ns-login/ns-login.vue';
import nsEmpty from '@/components/ns-empty/ns-empty.vue';
export default { export default {
components: { nsLogin, nsEmpty },
data() { data() {
return { return {
payIndex: 0, payIndex: 0,

View File

@@ -104,7 +104,10 @@
</template> </template>
<script> <script>
import nsPayment from '@/components/ns-payment/ns-payment.vue';
import loadingCover from '@/components/loading-cover/loading-cover.vue';
export default { export default {
components: { nsPayment, loadingCover },
data() { data() {
return { return {
list: [], list: [],

View File

@@ -41,7 +41,17 @@
</template> </template>
<script> <script>
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';
import MescrollUni from '@/components/mescroll/mescroll-uni.vue';
export default { export default {
components: {
nsLogin,
loadingCover,
nsEmpty,
MescrollUni
},
data() { data() {
return { return {
orderList: [] orderList: []

View File

@@ -12,7 +12,16 @@
</template> </template>
<script> <script>
// #ifdef MP-WEIXIN
import privacyPopup from '@/components/wx-privacy-popup/privacy-popup.vue';
// #endif
export default { export default {
components: {
// #ifdef MP-WEIXIN
privacyPopup
// #endif
},
data() { data() {
return { return {
src: '' src: ''