Jacob
2026-10-12 254f055d485935c8408942987f38f75b78e2136d
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
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
<template>
</template>
<script>
import {
   parseQueryString
} from "@/utils/index.js";
import {
   getUserBelong,
   updateUserBelong,
   sceneToParams,
   spread,
   protocolExist
} from "./api/user.js";
import {
   addParentChance
} from "./api/lottery.js";
import {
   checkLogin
} from "./libs/login";
import {
   HTTP_REQUEST_URL
} from './config/app';
import Auth from './libs/wechat.js';
import Routine from './libs/routine.js';
import Apps from './libs/apps.js';
import {
   mapActions
} from 'vuex';
import BigNumber from 'bignumber.js';
 
import {
   getBeanRate
} from '@/api/store.js';
import parseQuery from "./utils/index.js";
import {
   silenceBindingSpread
} from "@/utils";
export default {
   globalData: {
       spid: 0,
       code: 0,
       isLogin: false,
       userInfo: {},
       MyMenus: [],
       windowHeight: 0,
       id: 0,
       source: 'Mall',
       showProtocol: false,
       showLoginFl: false,
       authKey: '',
       thirdToken: '',
       task: null,
       buttonName: null,
       entranceNameVar: null
   },
   data: {
       isFirstLogin: true,
       unionId: '',
       option: {},
       showOption: {},
       _isReloginAfterLogout: false
   },
   onLoad: function () { },
   onLaunch: function (option) {
       let that = this;
       that.watchRouter();
       this.$store.commit('UPDATE_isSystemHide', {
           isSystemHide: false
       });
       uni.$on('onAddTrack', (data) => {
           console.log('onAddTrack', data);
           that.addTrack(data.name, data.data);
       })
       uni.$on('clearTask', (data) => {
           console.error('clear Task')
           that.globalData.task = null;
       })
 
 
       uni.$on('showTips', (data) => {
           let pages = getCurrentPages();
           let curPage = pages[pages.length - 1];
           if (curPage.$vm.$parent) {
               console.log(curPage.$vm.$parent.$refs.showTips);
               curPage.$vm.$parent.$refs.showTips.show(data);
           } else {
               curPage.$vm.$refs.showTips.show(data);
           }
 
       });
       //解决token过期问题
       that.$store.commit("LOGOUT");
       that.checkForUpdate();
       that.option = option;
       console.log('onLaunch option', option);
 
       let source = (that.option.query && that.option.query.source) ? that.option.query.source : (that.option
           .query && that.option.query.thirdToken ? 'MINIP' : 'MALL');
       that.globalData.source = source;
       if (that.option.query && that.option.query.buttonName) {
           that.globalData.buttonName = that.option.query.buttonName;
       }
       if (that.option.query && that.option.query.entranceNameVar) {
           that.globalData.entranceNameVar = that.option.query.entranceNameVar;
       }
       if (HTTP_REQUEST_URL == '') {
           console.error(
               "请配置根目录下的config.js文件中的 'HTTP_REQUEST_URL'\n\n请修改开发者工具中【详情】->【AppID】改为自己的Appid\n\n请前往后台【小程序】->【小程序配置】填写自己的 appId and AppSecret"
           );
           return false;
       }
 
       // 获取导航高度;
       uni.getSystemInfo({
           success: function (res) {
               that.globalData.navHeight = res.statusBarHeight * (750 / res.windowWidth) + 91;
           }
       });
       let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
       that.globalData.navH = menuButtonInfo.top * 2 + menuButtonInfo.height / 2;
 
       uni.$on('paramReady', function (obj) {
           if (that.globalData.spid) {
               //只有会员日专区和会员日商品需要增加抽奖机会
               let pages = getCurrentPages(),
                   currPage = pages[pages.length - 1];
               let path = currPage.$page.fullPath;
               console.log('------------------paramReady' + that.globalData.spid, path)
               if (path.indexOf('pages/zone/index') >= 0 || path.indexOf('pages/goods_details/index') >= 0) {
                   let zoneId = that.option.query.zoneId ? that.option.query.zoneId : (that.option.query.id ? that.option.query.id : false)
                   if (obj && obj.zoneId) {
                       zoneId = obj.zoneId;
                   }
                   if (zoneId && zoneId == 130) {
                       addParentChance({
                           parentUid: that.globalData.spid
                       }).then(() => {
                           console.log('增加抽奖机会' + zoneId)
                       });
                   }
               }
 
 
               if (that.$store.getters.isLogin) {
                   silenceBindingSpread(); //未绑定手机号前是否需要spread参数
               }
           }
       });
       //监听绑定手机号注册成功事件
       uni.$on('registerSuccess', (data) => {
           console.log('app监听到 registerSuccess事件')
           if (that.option.query.thirdToken) { //客经的同意隐私协议才更新belong
               that.parseQuery('isRegisterBack');
           } else {
               that.getLastBelong('isRegisterBack');
           }
       });
       //退出登录/解绑手机号后,重新走匿名登录恢复游客会话(token、unionId、归属信息)
       uni.$on('reloginAfterLogout', () => {
           that.reloginAfterLogout();
       });
       //监听获取到用户信息事件
       uni.$on('updateUserInfo', () => {
           console.log('监听到 userinfo事件')
           let userInfo = that.$store.getters.userInfo;
           that.setGdpAttr();
       });
       //首次请求unionid后回调
       uni.$once('UPDATE_LOGINSTATUS', (data) => {
           //解绑/退出登录后主动发起的匿名重登,由 reloginAfterLogout 自行处理,避免重复 parseQuery
           if (that._isReloginAfterLogout) {
               that._isReloginAfterLogout = false;
               return;
           }
           console.log('app监听到 UPDATE_LOGINSTATUS ' + that.isFirstLogin);
           //首次请求login获取到unionId
           if (that.$store.getters.isLogin) {
               if (that.option.query.thirdToken) {
                   Routine.authThirdUpdate({
                       'thirdToken': that.option.query.thirdToken
                   }).then(res => {
                       Routine.getLastUserInfo().then(() => {
                           that.setGdpUserId();
                           that.parseQuery();
                       });
                   });
               } else {
                   Routine.getLastUserInfo().then(() => {
                       that.setGdpUserId();
                       that.parseQuery()
                   });
               }
               // Routine.getLastUserInfo().then(()=>{
               //     that.setGdpUserId();
               //     if (that.option.query.thirdToken) { //客经的注册过才更新belong
               //         that.parseQuery()
               //     } else {
               //         that.parseQuery()
               //     }
               // })
           } else {
               that.setGdpUserId();
               if (that.option.query.thirdToken) { //客经的注册过才更新belong
 
               } else {
                   that.parseQuery()
               }
           }
 
 
           protocolExist(that.$store.getters.unionId).then((res) => {
               if (!res.data) {
                   that.$nextTick(() => {
                       that.globalData.showProtocol = true;
                       if (uni.showProtocol) {
                           uni.showProtocol();
                       }
                   })
               } else {
                   uni.$emit('protocolAgreed');
               }
           });
       });
 
       //获取悦养豆兑换比率,请求一次
       if (!this.$store.getters.careBeanRate) {
           getBeanRate().then((res) => {
               this.$store.commit('UPDATE_CAREBEANRATE', {
                   careBeanRate: res.data
               });
               uni.$emit('updateCareBeanRate', {});
           })
       }
 
 
       //判断进入场景
       if (option.query.hasOwnProperty('scene')) {
           switch (option.scene) {
               case 1047: //扫描小程序码
               case 1048: //长按图片识别小程序码
               case 1049: //手机相册选取小程序码
               case 1001: //直接进入小程序
                   let value = this.$util.getUrlParams(decodeURIComponent(option.query.scene));
                   let values = value.split(',');
                   if (values.length === 2) {
                       let v1 = values[0].split(":");
                       if (v1[0] === 'pid') {
                           console.log('set spid 22222222')
                           that.globalData.spid = v1[1];
                       } else {
                           that.globalData.id = v1[1];
                       }
                       let v2 = values[1].split(":");
                       if (v2[0] === 'pid') {
                           that.globalData.spid = v2[1];
                       } else {
                           that.globalData.id = v2[1];
                       }
                   } else {
                       console.log('set spid 3333333')
                       that.globalData.spid = values[0].split(":")[1];
                   }
                   break;
           }
       }
       if (that.option.query.spread) {
 
           console.log('set spid 44444')
           that.globalData.spid = that.option.query.spread;
       }
 
       //请求login获取unionid
       console.log('------------------isLogin', that.$store.getters.isLogin);
       if (!that.$store.getters.isLogin) {
           that.appLogin();
       } else { //登录过期
           uni.$on('needLogin', () => {
               that.appLogin()
           })
       }
   },
   onError: function (e) {
       console.log('------------ app error ', e);
   },
   onShow: function (option) {
       let that = this;
       console.log('onShow option', option);
       if (that.$store.getters.isSystemHide) {
           console.log('系统事件触发了app onshow事件,不更新归属等信息');
       } else {
           if (option.referrerInfo && option.referrerInfo.extraData && option.referrerInfo.extraData.task) {
               this.globalData.task = option.referrerInfo.extraData.task;
               console.log('app onShow task', this.globalData.task);
           }
           if (option.scene || option.source || (option.referrerInfo && option.referrerInfo.extraData && option
               .referrerInfo.extraData.source)) {
               console.log('第三方来源进入');
               let isChange = false;
 
               function checkEq(i) {
                   console.log(i, option.query[i], that.option.query[i], option.query[i] !== that.option.query[
                       i]);
                   if (i == 'thirdToken') {
                       let source1 = (that.option.referrerInfo && that.option.referrerInfo.extraData && that
                           .option
                           .referrerInfo.extraData.source) ? that.option.referrerInfo.extraData.source :
                           'MINIP';
                       let agentInfo1 = (that.option.referrerInfo && that.option.referrerInfo.extraData && that
                           .option
                           .referrerInfo.extraData.agentInfo) ? that.option.referrerInfo.extraData.agentInfo :
                           {};
                       let source2 = (option.referrerInfo && option.referrerInfo.extraData && option
                           .referrerInfo.extraData.source) ? option.referrerInfo.extraData.source : 'MINIP';
                       that.globalData.source = source2;
                       let agentInfo2 = (option.referrerInfo && option.referrerInfo.extraData && option
                           .referrerInfo.extraData.agentInfo) ? option.referrerInfo.extraData.agentInfo : {};
                       if (source1 !== source2 || agentInfo1.agentNo !== agentInfo2.agentNo) {
                           isChange = true;
                       }
                       if (option.referrerInfo && option.referrerInfo.extraData && option.referrerInfo.extraData
                           .buttonName) {
                           that.globalData.buttonName = option.referrerInfo.extraData.buttonName;
                       }
                       if (option.referrerInfo && option.referrerInfo.extraData && option.referrerInfo.extraData
                           .entranceNameVar) {
                           that.globalData.entranceNameVar = option.referrerInfo.extraData.entranceNameVar;
                       }
                   } else if ((i == 'scene' || i == 'agentNo' || i == 'source' || i == 'buttonName' || i ==
                       'entranceNameVar') && (option.query[i] !== that.option.query[i])) {
                       isChange = true;
                   }
               }
 
               for (var i in option.query) {
                   if (i == 'source' || i == 'buttonName' || i == 'entranceNameVar') {
                       that.globalData[i] = option.query[i];
                   }
                   checkEq(i);
               }
               for (var i in that.option.query) {
                   checkEq(i);
               }
               console.log('代码更新 2026-01-29');
               console.log('isChange', isChange);
               //会对专区和商品需要重新加载
               if (option.path == "pages/zone/index" || option.path == "pages/goods_details/index") {
                   isChange = true
               }
               if (!that.$store.getters.unionId) {
                   console.log('测试-数据重新初始化');
               } else if (!isChange) {
                   console.log('测试-没有发生变化不需要更新')
               }
               if (isChange && that.$store.getters.unionId) {
                   console.log('参数发生变化 上次的参数', JSON.stringify(that.option));
                   this.$store.commit('CLEAR_BELONG', {});
                   that.option = option;
                   if (that.$store.getters.isLogin) {
                       if (option.query.thirdToken) {
                           Routine.authThirdUpdate({
                               'thirdToken': option.query.thirdToken
                           }).then(res => {
                               Routine.getLastUserInfo().then(() => {
                                   that.parseQuery();
                               });
                           });
                       } else {
                           Routine.getLastUserInfo().then(() => {
                               that.parseQuery()
                           });
                       }
                   } else {
                       if (!option.query.thirdToken) {
                           that.parseQuery()
                       }
                   }
               }
           } else {
               console.log('小程序直接进入')
           }
       }
 
       setTimeout(() => {
           console.log('app onshow 删除系统隐藏标识')
           that.$store.commit('UPDATE_isSystemHide', {
               isSystemHide: false
           });
       }, 500)
   },
   onHide: function () {
       //console.log('App Hide')
   },
   methods: {
       watchRouter() {
           let that = this;
           // 监听 uni-app 所有路由跳转
           const routes = ['navigateTo', 'redirectTo', 'switchTab', 'navigateBack']
 
           routes.forEach(item => {
               const origin = uni[item]
               uni[item] = function (options) {
                   that.$store.commit('UPDATE_isSystemHide', {
                       isSystemHide: false
                   });
                   console.log('跳转类型:', item)
                   console.log('跳转到:', options?.url || '返回')
                   // 执行原来的跳转
                   return origin.call(this, options)
               }
           })
       },
       checkForUpdate() {
           let that = this;
           console.log('--------------------checkForUpdate');
           const updateManager = wx.getUpdateManager()
           updateManager.onCheckForUpdate(function (res) {
               // 请求完新版本信息的回调
               console.log('-----------------hasUpdate', res.hasUpdate)
           })
 
           updateManager.onUpdateReady(function () {
               uni.showModal({
                   title: '更新提示',
                   content: '新版本已经准备好,是否重启应用?',
                   success(res) {
                       if (res.confirm) {
                           // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
                           updateManager.applyUpdate()
                       } else if (res.cancel) {
                           return that.$util.Tips({
                               title: '已取消!'
                           });
                       }
                   }
               })
           })
 
           updateManager.onUpdateFailed(function () {
               // 新版本下载失败
           })
       },
       appLogin() {
           let that = this;
 
           // that.globalData.showLoginFl = true;
           // if (uni.showLoginFl) {
           //     uni.showLoginFl({
           //         authKey: that.globalData.authKey,
           //         thirdToken: that.globalData.thirdToken
           //     });
           // }
 
           let spread = that.globalData.spid ? that.globalData.spid : 0;
           uni.showLoading()
           Routine.getCode()
               .then(code => {
                   Routine.authUserInfo(code, {
                       'spread_spid': spread
                   }).then(res => {
                       uni.hideLoading()
                       that.globalData.authKey = res.data.key;
                       if (res.data.type == 'register' && that.option.query.thirdToken) {
                           that.globalData.thirdToken = that.option.query.thirdToken;
                           that.globalData.showLoginFl = true;
                           if (uni.showLoginFl) {
                               uni.showLoginFl({
                                   authKey: that.globalData.authKey,
                                   thirdToken: that.globalData.thirdToken
                               });
                           }
                       }
                   }).catch(e => {
                       console.log(e);
                   })
               })
               .catch(res => {
                   console.log(res);
                   uni.hideLoading();
               });
       },
       /**
        * 退出登录/解绑手机号后的匿名重登
        * reLaunch 不会重跑 onLaunch,需手动重新获取游客 token、unionId,
        * 再刷新归属信息并触发 BELONG_READY,各 tab 页依赖该状态/事件加载数据
        */
       reloginAfterLogout() {
           let that = this;
           that._isReloginAfterLogout = true;
           let spread = that.globalData.spid ? that.globalData.spid : 0;
           uni.showLoading();
           Routine.getCode().then(code => {
               return Routine.authUserInfo(code, {
                   'spread_spid': spread
               }).then(res=>{
                   that.globalData.authKey = res.data.key;
               });
           }).then(() => {
               uni.hideLoading();
               //authUserInfo 内部已 commit UPDATE_LOGINSTATUS,此时防重入分支已执行完毕
               that._isReloginAfterLogout = false;
               that.setGdpUserId();
               updateUserBelong({
                   'unionId': that.$store.getters.unionId
               }).then(() => {
                   that.getLastBelong();
               }).catch(() => {
                   that.getLastBelong();
               });
           }).catch(e => {
               uni.hideLoading();
               that._isReloginAfterLogout = false;
               console.log('reloginAfterLogout fail', e);
           });
       },
       checkBelongParam(params) {
           if (!params['agentNo']) {
               return false;
           }
           let isValid = true;
           for (var i in params) {
               if (!params[i] || params[i] == '-' || params[i] == 'null' || params[i] == 'undefined') {
                   isValid = false;
               }
           }
           console.log(params);
           if (!isValid) {
               console.log('参数不合法,不更新归属')
           }
           return isValid;
       },
       sceneToParams() {
           let that = this;
           return new Promise((resolve, reject) => {
               sceneToParams(that.option.query.scene).then((res) => {
                   console.log('sceneToParams 返回值:', res);
                   if (res.data.source) {
                       that.globalData.source = res.data.source;
                   }
                   if (res.data.buttonName) {
                       that.globalData.buttonName = res.data.buttonName;
                   }
                   if (res.data.entranceNameVar) {
                       that.globalData.entranceNameVar = res.data.entranceNameVar;
                   }
                   if (res.data.task) {
                       that.globalData.task = JSON.parse(res.data.task);
                       console.log('app sceneToParams task', that.globalData.task);
                   }
                   that.globalData.spid = res.data.pid;
                   that.globalData.id = res.data.id;
                   uni.$emit('finishSceneParam', res)
                   resolve(res);
               }).catch((e) => {
                   console.log(e);
                   uni.$emit('paramReady', false)
                   uni.$emit('finishSceneParam', e)
                   reject();
               })
           });
       },
       parseQuery(isRegisterBack) {
           console.log('开始解析参数')
           let that = this;
           let params = {};
           if (that.option.query && that.option.query.spread) {
               console.log('set spid 1111111')
               that.globalData.spid = that.option.query.spread;
           }
           //小程序码 
           if (that.option.query && that.option.query.scene) {
               that.sceneToParams().then((res) => {
                   uni.$emit('paramReady', {
                       zoneId: res.data.zoneId ? res.data.zoneId : (res.data.id ? res.data.id : false)
                   })
                   let params = {
                       "agentNo": res.data.agentNo,
                       "branchCode": res.data.branchCode,
                       "channel": res.data.channel,
                       "companyCode": res.data.companyCode,
                       "subCode": res.data.subCode,
                       "unionId": that.$store.getters.unionId
                   };
                   if (!params['subCode'] || params['subCode'] == 'null' || params['subCode'] == '-' ||
                       params['subCode'] == 'undefined') {
                       delete params['subCode'];
                   }
                   if (!that.checkBelongParam(params)) {
                       params = {
                           "unionId": that.$store.getters.unionId
                       }
                   }
                   updateUserBelong(params).then((res) => {
                       that.getLastBelong(isRegisterBack);
                   })
               }).catch(() => {
                   updateUserBelong({
                       "unionId": that.$store.getters.unionId
                   }).then((res) => {
                       that.getLastBelong(isRegisterBack);
                   })
               });
           } else {
               uni.$emit('paramReady', false)
               if (that.option.query && that.option.query.agentNo) { //小程序分享跳转-INSMART跳转
                   let params = {
                       "agentNo": that.option.query.agentNo,
                       "branchCode": that.option.query.branchCode,
                       "channel": that.option.query.channel,
                       "companyCode": that.option.query.companyCode,
                       "subCode": that.option.query.subCode,
                       "unionId": that.$store.getters.unionId
                   };
                   if (!params['subCode'] || params['subCode'] == 'null' || params['subCode'] == '-' || params[
                       'subCode'] == 'undefined') {
                       delete params['subCode'];
                   }
                   if (!that.checkBelongParam(params)) {
                       params = {
                           "unionId": that.$store.getters.unionId
                       }
                   }
                   updateUserBelong(params).then((res) => {
                       that.getLastBelong();
                   }).catch(() => {
                       that.getLastBelong(isRegisterBack);
                   })
               }
               //else if (that.option.query && that.option.query.thirdToken) { //客经小程序跳转
               else if (that.option.referrerInfo && that.option.referrerInfo.extraData) { //客经小程序跳转
                   let source = (that.option.referrerInfo && that.option.referrerInfo.extraData && that.option
                       .referrerInfo.extraData.source) ? that.option.referrerInfo.extraData.source : 'MINIP';
                   that.globalData.source = source;
                   if (that.option.referrerInfo && that.option.referrerInfo.extraData && that.option.referrerInfo
                       .extraData.buttonName) {
                       that.globalData.buttonName = that.option.referrerInfo.extraData.buttonName;
                   }
                   if (that.option.referrerInfo && that.option.referrerInfo.extraData && that.option.referrerInfo
                       .extraData.entranceNameVar) {
                       that.globalData.entranceNameVar = that.option.referrerInfo.extraData.entranceNameVar;
                   }
 
                   let agentInfo = (that.option.referrerInfo && that.option.referrerInfo.extraData && that.option
                       .referrerInfo.extraData.agentInfo) ? that.option.referrerInfo.extraData.agentInfo : {};
                   let params = {
                       "agentNo": agentInfo.custAgentNo,
                       "branchCode": agentInfo.custAgentBranch,
                       "channel": agentInfo.custAgentChnl,
                       "companyCode": agentInfo.custAgentCoy,
                       "subCode": agentInfo.custAgentOrgNo,
                       "unionId": that.$store.getters.unionId
                   }
                   if (!params['subCode'] || params['subCode'] == 'null' || params['subCode'] == '-' || params[
                       'subCode'] == 'undefined') {
                       delete params['subCode'];
                   }
                   if (!that.checkBelongParam(params)) {
                       params = {
                           "unionId": that.$store.getters.unionId
                       }
                   }
                   updateUserBelong(params).then((res) => {
                       that.getLastBelong(isRegisterBack);
                   }).catch(() => {
                       that.getLastBelong(isRegisterBack);
                   })
               } else {
                   updateUserBelong({
                       "unionId": that.$store.getters.unionId
                   }).then((res) => {
                       that.getLastBelong(isRegisterBack);
                   });
               }
           }
       },
       getLastBelong(isRegisterBack) {
           let that = this;
           getUserBelong(that.$store.getters.unionId).then((res) => {
               this.$store.commit('UPDATE_BELONG', res.data);
               console.log('获取到belong', that.$store.getters.belong)
               //如果有联合工号
               //经代 分公司 + 所在机构 + 代理人工号;客户所属代理人渠道/代理人渠道= “AB”
               //其他 分公司 + 代理人工号
               if (res.data && res.data.unionCode && res.data.unionCode !== '-') {
                   if (res.data.customerId && res.data.customerId !== 'null' && res.data.customerId !== '-') {
                       that.$gdp('setUserId', res.data.customerId + '@' + res.data.unionCode, 'customer_id');
                   } else {
                       that.$gdp('setUserId', that.$store.getters.unionId + '@' + res.data.unionCode,
                           'union_id');
                   }
               }
               that.setGdpAttr();
               console.log('调用 enter 埋点')
               if (isRegisterBack) {
                   that.addTrack('yy_mobileAuthSuccess', {});
                   if (that.option.query && that.option.query.thirdToken) {
                       that.addTrack('yy_enterMinip', {});
                   } else { }
               } else {
                   if (that.option.query && that.option.query.thirdToken) {
                       if (that.$store.getters.isLogin) {
                           that.addTrack('yy_enterMinip', {});
                       }
                   } else {
                       that.addTrack('yy_enterMinip', {});
                   }
               }
               uni.$emit('BELONG_READY', {
                   isRegister: isRegisterBack ? true : false
               });
           })
       },
       setGdpUserId() {
           let that = this;
           let unionId = that.$store.getters.unionId;
           that.$gdp('identify', unionId);
           that.setGdpAttr();
       },
       setGdpAttr() {
           let that = this;
           let belong = that.$store.getters.belong;
           let param = {
               source: 'M'
           }
           if (that.$store.getters.unionId) {
               param['union_id'] = that.$store.getters.unionId;
           }
           if (that.$store.getters.userInfo) {
               param['is_internal'] = that.$store.getters.userInfo.staff ? true : false;
               if (that.$store.getters.userInfo.extVipLevel) {
                   param['member_level'] = that.$store.getters.userInfo.extVipLevel;
               }
           }
           if (belong) {
               if (belong.mobile) {
                   param['mobile_phone'] = belong.mobile;
               }
               if (belong.customerId) {
                   param['customer_id'] = belong.customerId;
               }
               if (belong.unionCode) {
                   param['operator'] = belong.unionCode;
               }
               if (belong.channel) {
                   param['channel'] = belong.channel;
                   param['multi_channel'] = belong.multi ? 1 : 0;
               }
               if (belong.subCode) {
                   param['operator_agent'] = belong.subCode;
               }
           }
 
           that.$gdp('setUserAttributes', param);
           console.log('设置gdp用户属性', param);
       },
   }
}
</script>
 
<style>
@import "@/plugin/animate/animate.min.css";
@import '@/static/css/base.css';
@import '@/static/iconfont/iconfont.css';
@import '/static/css/guildford.css';
@import '/static/css/style.scss';
 
/* 条件编译,仅在H5平台生效 */
/* #ifdef H5 */
body::-webkit-scrollbar,
html::-webkit-scrollbar {
   display: none;
}
 
/* #endif */
view {
   box-sizing: border-box;
}
 
.bg-color-red {
   background-color: #E93323 !important;
}
 
.syspadding {
   padding-top: var(--status-bar-height);
}
 
.flex {
   display: flex;
}
 
.uni-scroll-view::-webkit-scrollbar {
   /* 隐藏滚动条,但依旧具备可以滚动的功能 */
   display: none
}
 
::-webkit-scrollbar {
   width: 0;
   height: 0;
   color: transparent;
}
</style>