login.vue
4.15 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
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
<template>
<view>
<view>
<view>
<view>
<view class='header'>
<image src='../../static/new_images/wx_login.png'></image>
</view>
<view class='content'>
<view>申请获取以下权限</view>
<text>获得你的公开信息(手机号等)</text>
</view>
<button class='bottom' type='primary' lang="zh_CN" open-type="getPhoneNumber"
@getphonenumber="decryptPhoneNumber">
一键授权登录
</button>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
code: '',
listdata: {},
aesIv: '',
encryptedData: '',
// 上级绑定下级用户
form: {
CommissionerUserId: 0,
ManagerUserId: 0,
},
// 类型
// Type:0,
model:{
username:'',
picture:''
}
}
},
// 打开页面的时候
onLoad(data) {
this.getCode()
console.log('wwwww',data)
console.log('bbbbbb',JSON.parse(decodeURIComponent(data.forms)))
let dataform=JSON.parse(decodeURIComponent(data.forms))
this.form.ManagerUserId=dataform.ManagerUserId
// this.Type=dataform.Type
console.log('登录传参',this.form)
// console.log('登录Type',this.Type)
// console.log('直接跳转login携带分享者id', decodeURIComponent(data.scene))
// this.form.ManagerUserId =parseInt(decodeURIComponent(data.scene).split(',')[0])
// this.form.Type =decodeURIComponent(data.scene).split(',')[1]
// console.log('类型',this.form.Type)
// console.log('登录二维码数据复制后', this.form.ManagerUserId)
},
methods: {
//1,code
getCode() {
//获取code
let that = this
uni.login({
success(res) {
that.code = res.code
}
})
},
IsType(){
//By:wangming
//这里是绑定分享者
this.API.BindUserInfo(this.form).then(res=>{
console.log('绑定后的数据专员', res)
if (res.data.code == 200) {
uni.showToast({
title: '绑定成功',
icon: 'success'
})
let storagedata = uni.getStorageSync('userinfo')
storagedata.data = res.data.data
uni.setStorageSync('userinfo', storagedata)
} else {
uni.showToast({
title: res.data.message,
icon: 'none'
})
}
setTimeout(() => {
uni.switchTab({
url: '../index/index'
})
}, 2000)
})
},
decryptPhoneNumber(res) {
// this.GetUserInfo()
let that = this
let data111 = {
code: this.code,
aesIv: res.detail.iv,
encryptedData: res.detail.encryptedData,
}
//登录
that.API.WeCharLogin(data111).then(res1 => {
console.log('返回数据', res1)
console.log('登录后的信息', res1.data.data)
if (res1.data.code == 200) {
uni.setStorage({
key: 'userinfo',
data: res1.data.data
})
uni.setStorage({
key: 'token',
data: res1.data.data.token
})
uni.showToast({
title: '登录成功',
icon: 'success'
})
console.log('manager',this.form.ManagerUserId)
if (this.form.ManagerUserId == 0 || this.form.ManagerUserId == undefined || this.form.ManagerUserId == 'undefined' || isNaN(this.form.ManagerUserId)) {
// 不分享二维码跳转的页面
setTimeout(() => {
uni.switchTab({
url: '../index/index'
})
}, 1000)
} else {
this.form.CommissionerUserId = parseInt(res1.data.data.data.id)
this.IsType()
}
} else {
uni.showToast({
title: '登录错误',
icon: 'none'
})
}
console.log(res1)
})
},
// ------------------------------------
oneClickLogin() {
let _this = this;
}
}
}
</script>
<style>
.header {
margin: 90rpx 0 90rpx 50rpx;
border-bottom: 1px solid #ccc;
text-align: center;
width: 650rpx;
height: 300rpx;
line-height: 450rpx;
}
.header image {
width: 200rpx;
height: 200rpx;
}
.content {
margin-left: 50rpx;
margin-bottom: 90rpx;
}
.content text {
display: block;
color: #9d9d9d;
margin-top: 40rpx;
}
.bottom {
border-radius: 80rpx;
margin: 70rpx 50rpx;
font-size: 35rpx;
}
</style>