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
| // Componet/Componet.js
| let app = getApp();
| Component({
| /**
| * 组件的属性列表
| */
| properties: {
|
| // 是否显示用户授权
| showTele: {
| type: Boolean
| }
| },
| /**
| * 组件的初始数据
| */
| data: {
| canIUse: wx.canIUse('button.open-type.getUserInfo'),
| isShow: true,
| wxIcon: app.globalData.imgUrl + '/images/wx_login.png'
| },
|
| ready: function() {
| console.log('this.properties', this.properties);
| this.setData({
| isShow: this.properties.showTele || true
| })
| },
| /**
| * 组件的方法列表
| */
| methods: {
| bindGetPhoneNumber: function(e) {
| let that = this;
| console.log('手机相关信息', e);
| if (e.detail.errMsg == 'getPhoneNumber:ok') {
| that.triggerEvent('onSetData', { showTele: false });
| wx.setStorageSync('#phoneAuthorization#', 'phone' + Date.now());
| }else {
| //用户按了拒绝按钮
| wx.showModal({
| title: '警告',
| content: '您点击了拒绝授权,将无法进入小程序,请授权之后再进入!',
| showCancel: false,
| confirmText: '返回授权',
| success: function (res) {
| // 用户没有授权成功,不需要改变 isHide 的值
| if (res.confirm) {
| console.log('用户点击了“返回授权”');
| }
| }
| });
| }
| }
| }
| })
|
|