PhoneNumber.js
2.21 KB
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
/*
* @Description:
* @Author: huyue
* @Date: 2022-12-09 13:58:15
* @LastEditors: huyue
* @LastEditTime: 2023-01-11 14:41:24
*/
// components/Login/Login.js
import { ssoApi } from "../../api/api";
import { componentsMixin } from "../../mixins/index";
Component({
externalClasses: ['custom-class'],
behaviors: [componentsMixin],
// options: {
// styleIsolation: 'isolated'
// },
/**
* 组件的属性列表
*/
properties: {
phoneText: {
type: String,
value: '了解更多案例'
},
/**
* type: 场景类型: home.首页,整行;product.详情中的查看更多和申请合作切换;scenario场景详情:转发+合作申请;video 视频详情
*/
type: {
type: String
},
hasPhoneNumber: {
type: Boolean,
observer(n) {
this.setData({
hasPhone: n
})
}
}
},
/**
* 组件的初始数据
*/
data: {
hasPhone: false
},
/**
* 组件的方法列表
*/
methods: {
// 获取手机号
getPhoneNumber({detail}) {
if ( detail.errMsg && detail.errMsg.indexOf('user deny') !== -1 ) {
wx.hideLoading()
return;
}
wx.$util.showLoading('正在授权...')
delete detail.errMsg;
if (detail.iv && detail.encryptedData) {
ssoApi.authUserPhone(detail).then(({ data, code, message }) => {
wx.hideLoading()
if (code==0) {
wx.$util.setUserInfo(data);
// 其他操作
this.triggerEvent("updatePhoneNumber", data.phone);
this.setData({
hasPhone: true
})
} else {
wx.showToast({
title: message,
icon: 'none',
duration: 2000
})
}
});
}
},
jump() {
wx.$router.go("/packagesList/pages/activityApply/activityApply");
},
forward() {
this.triggerEvent('toForward')
},
downVideo() {
let that = this
wx.showModal({
content: '是否下载视频',
success (res) {
if (res.confirm) {
that.triggerEvent('videodown')
} else if (res.cancel) {
}
}
})
}
},
});