weChatOffAcc.vue
3.37 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
<template>
<view class="container">
<div>微信公众号-授权认证中</div>
</view>
</template>
<script>
const {Base64} = require('js-base64');
export default {
data() {
return {
currentModeIndex: 2, //1账号密码 2验证码 3忘记密码
inputType: 'password',
codeDisabled: false,
codeTips: '',
formData: {
mobile: '',
password: '',
},
flag: true,
rules: {
mobile: [{
type: 'string',
required: true,
message: '请输入手机号',
trigger: ['blur', 'change']
},
// {
// // 自定义验证函数,见上说明
// validator: (rule, value, callback) => {
// // 上面有说,返回true表示校验通过,返回false表示不通过
// // uni.$u.test.mobile()就是返回true或者false的
// return uni.$u.test.mobile(value)
// },
// message: '手机号码不正确',
// // 触发器可以同时用blur和change
// trigger: ['change', 'blur']
// }
],
password: {
type: 'string',
min: 4,
max: 16,
required: true,
message: '密码长度4-16位密码',
trigger: ['blur', 'change']
},
code: {
type: 'integer',
len: 4,
required: true,
message: '请填写4位验证码',
trigger: ['blur', 'change']
}
},
isAutoLogin: [], //是否自动登录
hasForgot: false, //忘记密码
loginText: "短信登录",
btnText: "发送验证码",
checkValue: ['agree'],
accountTile: "短信验证码登录",
accountTip: "未注册手机号登录后自动生成账号",
accountPlaceholder: "请输入手机号",
appid: this.$config.appid,
openId: null
}
},
created() {
this.handleAuthorization();
},
methods: {
handleAuthorization() {
console.log("================================");
this.code = "";
let local = window.location.href;
console.log("local", local);
console.log("this.code", this.code);
let scope = "snsapi_base"; //静默授权 用户无感知
console.log("this.scope", scope);
this.code = this.getUrlCode().code;
console.log("this.code", this.code);
this.getOpenId(this.code);
console.log("================================");
},
getOpenId(code) {
let that = this;
this.$api.loginApi.getWechatOpenId(code).then(res => {
console.log("11111that.res ", res);
if (res.status == 1000) {
that.openId = res.data.openId;
console.log("that.openId ", that.openId);
} else {
Toast(res.message);
}
});
},
getUrlCode() {
let fullUrl = window.location.href;
console.log("fullUrl ", fullUrl);
let theRequest = new Object();
if (fullUrl.indexOf("?") != -1) {
var temp = fullUrl.split("?");
let str = temp[1];
let strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = strs[i].split("=")[1];
}
}
return theRequest;
},
}
};
</script>
<style lang="scss" scoped>
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
</style>