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
| const $$ = require('../../utils/util');
| const app = getApp();
|
| // 获取手机号码
| function getPhoneNumber(submitData) {
| return $$.request({ url: 'paAccount/getUserPhone', type: 'post', service: 'cust', submitData });
| }
|
| Component({
| /**
| * 组件的属性列表
| * popup: 下拉框的数据;visible:boolean 是否显示;title: string 标题;selectData: array;列数据;可拓展对象属性
| * safeBottom: iphoneX安全距离
| */
| properties: {
| popup: {
| type: Object,
| value: { visible: false }, // default: { visible: false, title: '', selectData: [] }
| },
| safeBottom: {
| type: Boolean,
| value: true,
| },
| },
|
| /**
| * 组件的初始数据
| */
| columnsDefaultIndex: 0,
| data: {
| loginVisible: false,
| popupIndex: null,
| },
|
| pageLifetimes: {
| show: function () {
| if (!app.globalData.token) {
| console.log('测试')
| if (!app.globalData.access_token) {
| $$.showModal({
| content: '抱歉您未登录,是否前往登录?',
| success: (res) => {
| if (res.confirm) {
| wx.redirectTo({
| url: '../../pages/login/index',
| });
| } else {
| wx.navigateBack({
| delta: 1,
| });
| }
| },
| });
|
| }
| }
| if (app.globalData.token && !this.data.loginVisible) {
| this.setData({ loginVisible: true });
| }
| },
| },
|
| observers: {
| 'popup.visible,popup.noPicker': function (data1, data2) {
| if ((data1, data2)) {
| this.setData({ popupIndex: this.data.popup.activeIndex });
| }
| },
| },
|
| /**
| * 组件的方法列表
| */
| methods: {
| // 退出登录
| loginOut() {
| this.setData({ loginVisible: false });
| },
| // 获取手机号码
| async handleGetPhoneNumber(code) {
| $$.showLoading();
| const accountInfo = wx.getAccountInfoSync();
| const res = await getPhoneNumber({ appid: accountInfo.miniProgram.appId, code });
| $$.hideLoading();
| if (res.type) {
| $$.showToast({ title: '获取成功' });
| return res.data;
| }
| },
| // 下拉框底层弹出层方法
| _handleClosePopup() {
| this.triggerEvent('onClosePopup');
| },
| _handleChangePicker(e) {
| this.triggerEvent('onChangePicker', { dataset: e.currentTarget.dataset, detail: e.detail });
| },
| _handleConfirmPicker(e) {
| if (this.data.popup.noPicker) {
| // 当组件不是Picker时
| let index = e.currentTarget.dataset.index;
| let value = e.currentTarget.dataset.value;
| this.triggerEvent('onConfirmPicker', { dataset: e.currentTarget.dataset, detail: { index, value } });
| return;
| }
| this.triggerEvent('onConfirmPicker', { dataset: e.currentTarget.dataset, detail: e.detail });
| },
| },
| });
|
|