leisure-core 0.6.20 → 0.6.21
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 +24 -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: {
|
|
@@ -234,8 +235,12 @@ export default {
|
|
|
234
235
|
const code = res?.data?.code || "";
|
|
235
236
|
if (code === "10000") {
|
|
236
237
|
const data = res.data.data;
|
|
238
|
+
if (data && data.cid && data.cid.length > 0) {
|
|
239
|
+
this.$store.commit("setCid", data.cid);
|
|
240
|
+
}
|
|
237
241
|
this.$store.commit("setUserInfo", data);
|
|
238
|
-
this.$
|
|
242
|
+
this.$emit("loginAfter", data);
|
|
243
|
+
setToken(res.data.data.token);
|
|
239
244
|
this.$message.success("登录成功");
|
|
240
245
|
} else {
|
|
241
246
|
this.$message.error(res?.data?.msg || "登录失败");
|
|
@@ -250,12 +255,25 @@ export default {
|
|
|
250
255
|
return this.formdata;
|
|
251
256
|
},
|
|
252
257
|
|
|
258
|
+
validatePhone(phone) {
|
|
259
|
+
const phoneRegex = /^1[3-9]\d{9}$/;
|
|
260
|
+
return phoneRegex.test(phone);
|
|
261
|
+
},
|
|
262
|
+
|
|
253
263
|
// 发送验证码
|
|
254
264
|
sendCaptcha() {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
this
|
|
258
|
-
|
|
265
|
+
if (
|
|
266
|
+
!this.formdata.account ||
|
|
267
|
+
!this.validatePhone(this.formdata.account)
|
|
268
|
+
) {
|
|
269
|
+
this.$message.error("请输入正确的手机号码");
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// 验证密码
|
|
274
|
+
if (!this.formdata.pwd) {
|
|
275
|
+
this.$message.error("请输入密码");
|
|
276
|
+
return false;
|
|
259
277
|
}
|
|
260
278
|
|
|
261
279
|
this.sending = true;
|
|
@@ -263,6 +281,7 @@ export default {
|
|
|
263
281
|
// 触发发送验证码事件,父组件可以监听这个事件来处理发送逻辑
|
|
264
282
|
this.$emit("sendCaptcha", {
|
|
265
283
|
account: this.formdata.account,
|
|
284
|
+
pwd: this.formdata.pwd,
|
|
266
285
|
success: this.startCountdown,
|
|
267
286
|
fail: () => {
|
|
268
287
|
this.sending = false;
|