Browse Source

登录修改

cr 4 years ago
parent
commit
08e22edfaa
1 changed files with 40 additions and 23 deletions
  1. 40 23
      src/pages/index/login.vue

+ 40 - 23
src/pages/index/login.vue

@@ -11,7 +11,12 @@
11 11
                 />
12 12
             </div>
13 13
             <div class="inp-box">
14
-                <input type="password" name="password" v-model="password" placeholder="请输入密码" />
14
+                <input
15
+                    type="password"
16
+                    name="password"
17
+                    v-model="password"
18
+                    placeholder="请输入密码"
19
+                />
15 20
             </div>
16 21
             <button class="btn" @click="submit">确定</button>
17 22
         </div>
@@ -33,6 +38,12 @@ export default {
33 38
     },
34 39
 
35 40
     onLoad() {
41
+        uni.login({
42
+            provider: "weixin",
43
+            success: (result) => {
44
+                console.log(result);
45
+            },
46
+        });
36 47
     },
37 48
 
38 49
     onShow() {},
@@ -40,7 +51,7 @@ export default {
40 51
     // 函数
41 52
     methods: {
42 53
         submit() {
43
-            console.log(this.mobile)
54
+            console.log(this.mobile);
44 55
             if (!this.userName) {
45 56
                 this.fn.showToast(`请输入账号`);
46 57
                 return;
@@ -53,28 +64,34 @@ export default {
53 64
             uni.showLoading({
54 65
                 title: "提交中",
55 66
             });
56
-            this.api
57
-                .post("/Login/LoginByAccount", {
58
-                    userName: this.userName,
59
-                    password: this.password
60
-                })
61
-                .then((res) => {
62
-                    uni.hideLoading();
63
-                    if (res.success) {
64
-                        this.$store.commit("user/login", res.data);
65
-                        this.router.replace({
66
-                            isReLaunch: true,
67
-                            path: "/pages/index/index",
67
+            uni.login({
68
+                provider: "weixin",
69
+                success: (result) => {
70
+                    this.api
71
+                        .post("/Login/LoginByAccount", {
72
+                            userName: this.userName,
73
+                            password: this.password,
74
+                            code: result.code,
75
+                        })
76
+                        .then((res) => {
77
+                            uni.hideLoading();
78
+                            if (res.success) {
79
+                                this.$store.commit("user/login", res.data);
80
+                                this.router.replace({
81
+                                    isReLaunch: true,
82
+                                    path: "/pages/index/index",
83
+                                });
84
+                                this.fn.roleHandle();
85
+                            } else {
86
+                                this.fn.showModal({
87
+                                    title: "提交失败",
88
+                                    content: res.message,
89
+                                    showCancel: false,
90
+                                });
91
+                            }
68 92
                         });
69
-                        this.fn.roleHandle();
70
-                    } else {
71
-                        this.fn.showModal({
72
-                            title: "提交失败",
73
-                            content: res.message,
74
-                            showCancel: false,
75
-                        });
76
-                    }
77
-                });
93
+                },
94
+            });
78 95
         },
79 96
     },
80 97