login.js
7.71 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
"use strict";
const common_vendor = require("../../common/vendor.js");
const config = require("../../config.js");
const common_login = require("../../common/login.js");
require("../../common/request.js");
require("../../common/aes.js");
if (!Array) {
const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
const _easycom_uni_countdown2 = common_vendor.resolveComponent("uni-countdown");
(_easycom_uni_easyinput2 + _easycom_uni_countdown2)();
}
const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
const _easycom_uni_countdown = () => "../../uni_modules/uni-countdown/components/uni-countdown/uni-countdown.js";
if (!Math) {
(_easycom_uni_easyinput + _easycom_uni_countdown)();
}
const _sfc_main = {
__name: "login",
setup(__props) {
const isActive = common_vendor.ref(0);
common_vendor.ref(false);
common_vendor.ref(true);
const codeUrl = common_vendor.ref(null);
const inputstyle = common_vendor.ref({
borderColor: "transparent",
fontSize: "30rpx"
});
const form = common_vendor.ref({
username: null,
password: null,
code: null,
uuid: null
});
const form2 = common_vendor.ref({
telNo: null,
captcha: null,
code: null,
uuid: null
});
const countDown = common_vendor.ref({
start: false,
second: 60
});
const app = getApp();
common_vendor.onMounted(() => {
getCode();
});
function changeActive(n) {
isActive.value = n;
}
function login() {
if (isActive.value == 0) {
if (!form.value.username) {
common_vendor.index.showToast({
title: "账号不能为空",
icon: "none"
});
return;
}
if (!form.value.password) {
common_vendor.index.showToast({
title: "密码不能为空",
icon: "none"
});
return;
}
if (!form.value.code) {
common_vendor.index.showToast({
title: "验证码不能为空",
icon: "none"
});
return;
}
common_login.pcLogin(form.value).then((res) => {
app.globalData.isLogin = true;
common_vendor.index.redirectTo({
url: "/pages/index/index"
});
});
} else if (isActive.value == 1) {
if (!form2.value.telNo) {
common_vendor.index.showToast({
title: "手机号不能为空",
icon: "none"
});
return;
}
if (!form2.value.code) {
common_vendor.index.showToast({
title: "短信验证码不能为空",
icon: "none"
});
return;
}
common_login.loginByPhone(form2.value.telNo, form2.value.code).then(() => {
app.globalData.isLogin = true;
common_vendor.index.redirectTo({
url: "/pages/index/index"
});
});
}
}
function goRegister() {
const path = "/pages/index/register";
common_vendor.index.navigateTo({
url: path
});
}
function getCode() {
common_login.getCodeImg().then((res) => {
codeUrl.value = "data:image/gif;base64," + res.data.img;
form.value.uuid = res.data.uuid;
form2.value.uuid = res.data.uuid;
});
}
function getCaptchaSms() {
if (!form2.value.telNo) {
common_vendor.index.showToast({
title: "手机号不能为空",
icon: "none"
});
return;
}
if (!form2.value.captcha) {
common_vendor.index.showToast({
title: "图形验证码不能为空",
icon: "none"
});
return;
}
common_login.getSmsCode({
uuid: form2.value.uuid,
telNo: form2.value.telNo,
code: form2.value.captcha
}).then((res) => {
common_vendor.index.showToast({
title: "短信验证码下发成功",
icon: "none"
});
countDown.value.start = true;
}).catch(getCode);
}
function timeup() {
countDown.value.start = false;
countDown.value.second = 60;
getCode();
}
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.unref(config.config).baseUrl_api + "/fs/static/login/ren1.png",
b: common_vendor.unref(config.config).baseUrl_api + "/fs/static/login/logo@2x.png",
c: common_vendor.n(isActive.value == 0 ? "active" : ""),
d: common_vendor.o(($event) => changeActive(0)),
e: common_vendor.n(isActive.value == 1 ? "active" : ""),
f: common_vendor.o(($event) => changeActive(1)),
g: isActive.value == 0
}, isActive.value == 0 ? {
h: common_vendor.unref(config.config).baseUrl_api + "/fs/static/login/tag01@2x.png",
i: common_vendor.o(($event) => form.value.username = $event),
j: common_vendor.p({
styles: inputstyle.value,
placeholder: "账号",
modelValue: form.value.username
}),
k: common_vendor.unref(config.config).baseUrl_api + "/fs/static/login/tag02@2x.png",
l: common_vendor.o(($event) => form.value.password = $event),
m: common_vendor.p({
styles: inputstyle.value,
placeholder: "密码",
type: "password",
modelValue: form.value.password
}),
n: common_vendor.unref(config.config).baseUrl_api + "/fs/static/login/tag03@2x.png",
o: common_vendor.o(($event) => form.value.code = $event),
p: common_vendor.p({
styles: inputstyle.value,
placeholder: "图形验证码",
modelValue: form.value.code
}),
q: codeUrl.value,
r: common_vendor.o(getCode)
} : {}, {
s: isActive.value == 1
}, isActive.value == 1 ? common_vendor.e({
t: common_vendor.unref(config.config).baseUrl_api + "/fs/static/login/tag01@2x.png",
v: common_vendor.o(($event) => form2.value.telNo = $event),
w: common_vendor.p({
styles: inputstyle.value,
placeholder: "请输入手机号",
modelValue: form2.value.telNo
}),
x: common_vendor.unref(config.config).baseUrl_api + "/fs/static/login/tag02@2x.png",
y: common_vendor.o(($event) => form2.value.captcha = $event),
z: common_vendor.p({
styles: inputstyle.value,
placeholder: "图形验证码",
modelValue: form2.value.captcha
}),
A: codeUrl.value,
B: common_vendor.o(getCode),
C: common_vendor.unref(config.config).baseUrl_api + "/fs/static/login/tag04@2x.png",
D: common_vendor.o(($event) => form2.value.code = $event),
E: common_vendor.p({
styles: inputstyle.value,
placeholder: "短信验证码",
modelValue: form2.value.code
}),
F: !countDown.value.start
}, !countDown.value.start ? {
G: common_vendor.o(getCaptchaSms)
} : {}, {
H: countDown.value.start
}, countDown.value.start ? {
I: common_vendor.o(timeup),
J: common_vendor.p({
color: "#014A9F",
["show-day"]: false,
["show-hour"]: false,
["show-min"]: false,
start: countDown.value.start,
second: countDown.value.second
})
} : {}) : {}, {
K: common_vendor.o(login),
L: common_vendor.o(goRegister),
M: common_vendor.unref(config.config).baseUrl_api + "/fs/static/login/ren2.png"
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-fa14255b"], ["__file", "/Users/yangyang/ztx_wx_minapp/pages/index/login.vue"]]);
wx.createPage(MiniProgramPage);