leisure-core 0.6.20 → 0.6.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/le-login/src/main.vue +28 -5
- package/package.json +1 -1
package/le-login/src/main.vue
CHANGED
|
@@ -119,6 +119,7 @@
|
|
|
119
119
|
</template>
|
|
120
120
|
|
|
121
121
|
<script>
|
|
122
|
+
import { setToken } from "../../le-libs/js/tokens";
|
|
122
123
|
export default {
|
|
123
124
|
name: "le-login",
|
|
124
125
|
props: {
|
|
@@ -224,6 +225,10 @@ export default {
|
|
|
224
225
|
},
|
|
225
226
|
this.loginAfter,
|
|
226
227
|
this.nav2Home,
|
|
228
|
+
(fail) => {
|
|
229
|
+
this.loading = false;
|
|
230
|
+
this.$message.error(fail || "登录失败");
|
|
231
|
+
},
|
|
227
232
|
);
|
|
228
233
|
}
|
|
229
234
|
});
|
|
@@ -234,8 +239,12 @@ export default {
|
|
|
234
239
|
const code = res?.data?.code || "";
|
|
235
240
|
if (code === "10000") {
|
|
236
241
|
const data = res.data.data;
|
|
242
|
+
if (data && data.cid && data.cid.length > 0) {
|
|
243
|
+
this.$store.commit("setCid", data.cid);
|
|
244
|
+
}
|
|
237
245
|
this.$store.commit("setUserInfo", data);
|
|
238
|
-
this.$
|
|
246
|
+
this.$emit("loginAfter", data);
|
|
247
|
+
setToken(res.data.data.token);
|
|
239
248
|
this.$message.success("登录成功");
|
|
240
249
|
} else {
|
|
241
250
|
this.$message.error(res?.data?.msg || "登录失败");
|
|
@@ -250,12 +259,25 @@ export default {
|
|
|
250
259
|
return this.formdata;
|
|
251
260
|
},
|
|
252
261
|
|
|
262
|
+
validatePhone(phone) {
|
|
263
|
+
const phoneRegex = /^1[3-9]\d{9}$/;
|
|
264
|
+
return phoneRegex.test(phone);
|
|
265
|
+
},
|
|
266
|
+
|
|
253
267
|
// 发送验证码
|
|
254
268
|
sendCaptcha() {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
this
|
|
258
|
-
|
|
269
|
+
if (
|
|
270
|
+
!this.formdata.account ||
|
|
271
|
+
!this.validatePhone(this.formdata.account)
|
|
272
|
+
) {
|
|
273
|
+
this.$message.error("请输入正确的手机号码");
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// 验证密码
|
|
278
|
+
if (!this.formdata.pwd) {
|
|
279
|
+
this.$message.error("请输入密码");
|
|
280
|
+
return false;
|
|
259
281
|
}
|
|
260
282
|
|
|
261
283
|
this.sending = true;
|
|
@@ -263,6 +285,7 @@ export default {
|
|
|
263
285
|
// 触发发送验证码事件,父组件可以监听这个事件来处理发送逻辑
|
|
264
286
|
this.$emit("sendCaptcha", {
|
|
265
287
|
account: this.formdata.account,
|
|
288
|
+
pwd: this.formdata.pwd,
|
|
266
289
|
success: this.startCountdown,
|
|
267
290
|
fail: () => {
|
|
268
291
|
this.sending = false;
|