-
zhangwei
2025-03-05 16213c0f85aa3ac8317797bf4a05fd12940e16d3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
import {
    navLinkType
} from '@/common/setting/constVarsHelper.js';
 
/**
 * 全局混入型
 */
module.exports = {
    beforeCreate() {
 
    },
    data() {
        return {
            /**
             * 页面加载
             */
            pageLoading: true
        }
    },
    methods: {
        /**
         * //常用链接操作
         */
 
        //返回首页
        goHome() {
            uni.switchTab({
                url: '/pages/index/default/default'
            });
        },
        //返回上一页
        goNavigateBack(el) {
            // let pages = getCurrentPages(); // 当前页页⾯实例
            // if (pages.length > 1) {
            //     uni.navigateBack();
            // } else {
            //     this.goHome()
            // }
            
            uni.navigateBack();
        },
 
        //路由跳转
        goRoute(url) {
            // 无参数
            this.$u.route(url);
        },
        goRoute(url, params) {
            // 带参数,传递的对象形式的参数,如{name: 'lisa', age: 18}
            this.$u.route(url, params);
        },
        //查看所在坐标地图位置
        goShopMap() {
            var reshipCoordinate = this.$store.state.config.reshipCoordinate;
            if (reshipCoordinate && reshipCoordinate.indexOf(",") != -1) {
                var arr = reshipCoordinate.split(',')
                this.$u.route('/pages/map/map', {
                    id: 1,
                    latitude: arr[0],
                    longitude: arr[1],
                });
            }
        },
        //查看所在坐标地图位置
        goMapDetails(id, latitude, longitude) {
            this.$u.route('/pages/map/map', {
                id: id,
                latitude: latitude,
                longitude: longitude,
            });
        },
        goUserCenter() {
            this.$u.route({
                url: '/pages/index/member/member',
                type: 'switchTab'
            });
        },
        goSearch() {
            this.$u.route({
                url: '/pages/search/search',
            });
        },
        // 返回上一页
        toBackBtn() {
            var pages = getCurrentPages();
            if (pages.length > 1) {
                uni.navigateBack({
                    delta: 1
                });
            } else {
                this.$u.route({
                    type: 'switchTab',
                    url: '/pages/index/default/default'
                });
            }
        },
        //返回操作处理
        toOnBackPress(options) {
            if (options.from === 'navigateBack') {
                return false
            }
            let loginPages = ['/pages/index/cart/cart', '/pages/index/member/member']
            let backPage = this.$store.state.redirectPage
            if (loginPages.indexOf(backPage) > -1) {
                this.$store.commit({
                    type: 'redirect',
                    page: ''
                })
                this.$u.route({
                    type: 'switchTab',
                    url: '/pages/index/default/default'
                })
                return true
            }
        },
        //登录成功统一跳转处理
        toLoginSuccessHandleBack() {
            let redirect = this.$store.state.redirectPage
            this.$store.commit({
                type: 'redirect',
                page: ''
            })
            let switchTabs = ['/pages/index/default/default', '/pages/index/member/member']
            if (switchTabs.indexOf(redirect) > -1) {
                this.$u.route({
                    type: 'switchTab',
                    url: redirect
                })
            } else if (redirect) {
                this.$u.route({
                    type: 'switchTab',
                    url: redirect
                })
            } else {
                this.$u.route({
                    type: 'switchTab',
                    url: '/pages/index/default/default'
                })
            }
        },
 
        // 购物车页面跳转
        redirectCart() {
            this.$u.route({
                type: 'switchTab',
                url: '/pages/index/cart/cart'
            });
        },
 
        /**
         * 订单接口信息
         */
 
        // 查看订单详情
        goOrderDetail(orderId) {
            this.$u.route('/pages/member/order/detail/detail', {
                orderId: orderId
            });
        },
        // 取消订单
 
        // 去支付
        goToPay(orderId) {
            this.$u.route('/pages/payment/pay/pay', {
                orderId: orderId,
                type: 1
            });
        },
        // 确认收货
 
        // 去评价
        toEvaluate(orderId) {
            this.$u.route('/pages/member/order/evaluate/evaluate', {
                orderId: orderId
            });
        },
        // 申请售后
 
        // 查看物流信息
        goShowExpress(code, no, address = '', mobile = '') {
            let params = encodeURIComponent(
                'code=' + code + '&no=' + no + '&add=' + address + '&mobile=' + mobile
            )
            this.$u.route('/pages/member/order/expressDelivery/expressDelivery', {
                params: params
            });
        },
 
 
        /**
         * 商品接口信息
         */
 
        // 查看商品详情
        goGoodsDetail(goodsId) {
            this.$u.route('/pages/goods/goodDetails/goodDetails', {
                id: goodsId
            });
        },
        // 查看商品评论详情
        goGoodComments(goodsId) {
            this.$u.route('/pages/goods/goodComments/goodComments', {
                id: goodsId
            });
        },
        // 跳转商品列表页
        goGoodsList(obj = {}) {
            let url = '/pages/category/list/list'
            if (Object.keys(obj).length) {
                url = url + this.$u.queryParams(obj)
            }
            this.$u.route(url)
        },
        // 秒杀详情
        goSeckillDetail(id) {
            this.$u.route('/pages/activity/seckill/seckillDetails/seckillDetails', {
                id: id
            });
        },
        // 团购详情
        goGroupBuyingDetail(id) {
            this.$u.route('/pages/activity/groupBuying/groupBuyingDetails/groupBuyingDetails', {
                id: id
            });
        },
        //拼团详情页
        goPinTuanDetail(id, teamId) {
            if (teamId) {
                this.$u.route('/pages/activity/pinTuan/pinTuanDetails/pinTuanDetails', {
                    id: id,
                    teamId: teamId,
                });
            } else {
                this.$u.route('/pages/activity/pinTuan/pinTuanDetails/pinTuanDetails', {
                    id: id
                });
            }
        },
        // 查看团购列表
        goGroupPurchase() {
            this.$u.route('/pages/activity/groupBuying/list/list')
        },
        // 查看秒杀列表
        goSeckillList() {
            this.$u.route('/pages/activity/seckill/list/list')
        },
        // 查看拼团列表
        goPinTuanList() {
            this.$u.route('/pages/activity/pinTuan/list/list')
        },
 
 
        /**
         * 文章接口
         */
 
        // 查看文章分类
        goArticleClassify(id) {
            this.$u.route('/pages/article/list/list', {
                id: id
            });
        },
        goArticleList() {
            this.$u.route('/pages/article/list/list')
        },
        // 查看文章详情
        goArticleDetail(id) {
            this.$u.route('/pages/article/details/details', {
                idType: 1,
                id: id
            });
        },
 
        /**
         * 公告接口
         */
 
        // 查看公告列表
        goNoticeList() {
            this.$u.route('/pages/notice/list/list')
        },
        // 查看公告详情
        goNoticeDetail(id) {
            this.$u.route('/pages/notice/details/details', {
                id: id
            });
        },
 
        // 前往用户协议
        goUserAgreementPage() {
            var id = this.$store.state.config.userAgreementId;
            this.$u.route('/pages/article/details/details', {
                idType: 1,
                id: id
            });
        },
        // 前往隐私协议
        goUserPrivacyPolicy() {
            var id = this.$store.state.config.privacyPolicyId;
            this.$u.route('/pages/article/details/details', {
                idType: 1,
                id: id
            });
        },
        // 关于我们
        goAboutUs() {
            let id = this.$store.state.config.aboutArticleId;
            this.$u.route('/pages/article/details/details', {
                idType: 1,
                id: id
            });
        },
 
        /**
         * 接龙接口信息
         */
 
        // 查看接龙详情
        goSolitaireDetail(id) {
            this.$u.route('/pages/activity/solitaire/solitaireDetails/solitaireDetails', {
                id: id
            });
        },
        // 查看服务列表
        goSolitaireList() {
            this.$u.route('/pages/activity/solitaire/list/list')
        },
 
        //服务接口信息
        goServicesDetail(serviceId) {
            this.$u.route('/pages/serviceGoods/details/details', {
                id: serviceId
            });
        },
        // 查看服务列表
        goServicesList() {
            this.$u.route('/pages/serviceGoods/index/index')
        },
        // 查看个人详情
        goServicesUserDetail(serviceId) {
            this.$u.route('/pages/member/serviceOrder/details/details', {
                id: serviceId
            });
        },
 
 
        /**
         * 广告相关
         */
 
        // 广告点击查看详情
        showSliderInfo(type, val) {
            if (!val) {
                return;
            }
            if (type == navLinkType.urlLink) {
                if (val.indexOf('http') != -1) {
                    // #ifdef APP-PLUS || APP-PLUS-NVUE || MP
                    this.$u.route('/pages/webview/webview', {
                        src: val
                    });
                    // #endif
                } else {
                    // #ifdef APP-PLUS || APP-PLUS-NVUE || MP
                    if (val == '/pages/index/default/default' || val == '/pages/category/index/index' || val ==
                        '/pages/index/cart/cart' || val == '/pages/index/member/member') {
                        this.$u.route({
                            type: 'switchTab',
                            url: val
                        });
                        return;
                    } else if (val.indexOf('/pages/coupon/coupon?id=') > -1) {
                        var id = val.replace('/pages/coupon/coupon?id=', "");
                        this.receiveCoupon(id)
                    } else {
                        this.$u.route(val);
                        return;
                    }
                    // #endif
                }
            } else if (type == navLinkType.shop) {
                // 商品详情
                this.$u.route('/pages/goods/goodDetails/goodDetails', {
                    id: val
                });
            } else if (type == navLinkType.article) {
                // 文章详情
                this.$u.route('/pages/article/details/details', {
                    idType: 1,
                    id: val
                });
            } else if (type == navLinkType.articleCategory) {
                // 文章列表
                //this.$u.route('/pages/article/list/list')
                this.$u.route('/pages/article/category/category', {
                    id: val
                });
            } else if (type == navLinkType.intelligentForms) {
                //自定义表单
                this.$u.route('/pages/form/details/details', {
                    id: val
                });
            } else if (type == navLinkType.shopCategory) {
                //商品分类
                this.$u.route('/pages/category/list/list', {
                    id: val
                });
            } else {
                this.$u.route(val);
            }
        },
        // 用户领取优惠券
        receiveCoupon(couponId) {
            uni.showLoading({
                title: '加载中',
                mask: true
            });
            let _this = this;
            let coreshopdata = {
                id: couponId
            }
            this.$u.api.getCoupon(coreshopdata).then(res => {
                if (res.status) {
                    uni.hideLoading();
                    _this.$refs.uToast.show({
                        message: res.msg,
                        type: 'success',
                        back: false
                    })
                } else {
                    uni.hideLoading();
                    _this.$u.toast(res.msg)
                }
            })
        },
 
 
        /**
         * 工具函数
         */
 
        doCopyData(data) {
            var _this = this;
            uni.setClipboardData({
                data: data,
                success: function() {
                    _this.$u.toast('复制成功')
                }
            });
        },
        doPhoneCall() {
            var phome = this.$store.state.config.shopMobile || 0;
            if (phome != 0) {
                uni.makePhoneCall({
                    phoneNumber: phome
                });
            }
        },
        goBack() {
            //处理兼容,如果没有上一级界面则返回首页
            const pages = getCurrentPages();
            if (pages.length === 2) {
                uni.navigateBack({
                    delta: 1
                });
            } else if (pages.length === 1) {
                uni.switchTab({
                    url: '/pages/index/default/default',
                })
            } else {
                uni.navigateBack({
                    delta: 1
                });
            }
        },
 
    }
}