408249787@qq.com 1 주 전
부모
커밋
a903ac28a6
1개의 변경된 파일과 26개의 추가작업 그리고 61개의 파일을 삭제
  1. 26 61
      pages/login/login.vue

+ 26 - 61
pages/login/login.vue

@@ -7,18 +7,8 @@
         </view>
         <view class="f-weight-bold name text-center">账号登录</view>
         <view class="input">
-            <input
-                type="text"
-                v-model="userName"
-                placeholder="请输入用户名"
-                placeholder-class="placeholder-class"
-            />
-            <input
-                type="password"
-                v-model="passWord"
-                placeholder="请输入密码"
-                placeholder-class="placeholder-class"
-            />
+            <input type="text" v-model="userName" placeholder="请输入用户名" placeholder-class="placeholder-class" />
+            <input type="password" v-model="passWord" placeholder="请输入密码" placeholder-class="placeholder-class" />
         </view>
         <view class="tip" @tap="forgetPass">
             忘记密码
@@ -28,20 +18,15 @@
         </view>
         <view class=" mui-input-row mui-checkbox ">
             <checkbox-group @change="checkboxChange">
-                <checkbox
-                    id="chkRem"
-                    type="checkbox"
-                    :checked="rememberPsw"
-                    @tap="rememberPsw = !rememberPsw"
-                    class="RememberCheck"
-                >
+                <checkbox id="chkRem" type="checkbox" :checked="rememberPsw" @tap="rememberPsw = !rememberPsw"
+                    class="RememberCheck">
                     记住密码
                 </checkbox>
             </checkbox-group>
         </view>
         <button class="main-color-bg text-color-white login" @tap="login">登录</button>
         <view class="wechat p-fixed left0 right0" style="bottom: 60rpx;">
-            <button open-type="getUserInfo" @click="getUserInfo" class="d-flex j-center a-center">
+            <button @click="quickLogin" class="d-flex j-center a-center">
                 <image src="/static/images/weixin.png" mode=""></image>
             </button>
         </view>
@@ -56,10 +41,7 @@ export default {
         return {
             userName: '', // 用户名
             passWord: '', // 密码
-            rememberPsw: true, // 记住密码
-            Code: '',
-            session_key: '',
-            openid: ''
+            rememberPsw: true // 记住密码
         };
     },
     // 页面初始加载
@@ -90,7 +72,7 @@ export default {
         forgetPass() {
         },
         // 复选框
-        checkboxChange: function(e) {
+        checkboxChange: function (e) {
             if (e.detail.value.length == 1) {
                 // 获取缓存的账号
                 uni.getStorageSync('cache_userName', this.userName);
@@ -142,37 +124,14 @@ export default {
                     }
                 });
         },
-        // 微信登录获取openid
-        getUserInfo() {
-            // 登录
-            uni.login({
-                provider: 'weixin',
-                success: res => {
-                    // console.log('登录成功:', res);
-                    // 获取临时登录凭证code
-                    this.Code = res.code;
-                    // 获取openid,session_key
-                    const appid = 'wx38f46845be704faa' // 需替换
-                    const secret = '9bt1F6ojLU6JLv76Boo4qaeEU6PcW75nGjjLyauDtAF' // 需替换
-                    const url = 'https://api.weixin.qq.com/sns/jscode2session?appid=' + appid + '&secret=' + secret +
-                        '&js_code=' +
-                        this.Code + '&grant_type=authorization_code';
-                    uni.request({
-                        url: url, // 请求路径
-                        success: res => {
-                            // console.log('openid session_key:', res.data);
-                            this.openid = res.data.openid
-                            this.session_key = res.data.session_key
-                            console.log('openid:', this.openid)
-                            uni.showToast({ title: this.openid, icon: 'none' })
-                        },
-                        fail: err => {
-                            console.log('请求失败:', err)
-                        }
-                    });
-                },
-                fail: err => {
-                    console.log('登录失败:', err)
+        // 微信快捷登录
+        quickLogin() {
+            this.$Http.loginQuickly().then(res => {
+                const url = res.data
+
+                if (url !== '' && url !== null && url != undefined) {
+                    // 请求用户授权
+                    window.location.href = url
                 }
             })
         }
@@ -222,14 +181,18 @@ export default {
     font-size: unit(26, rpx);
     font-weight: 500;
 }
-.wechat{
-    margin-top:  unit(90, rpx);
-    button{
+
+.wechat {
+    margin-top: unit(90, rpx);
+
+    button {
         background-color: #FFFFFF;
-        &::after{
+
+        &::after {
             border: none;
         }
-        image{
+
+        image {
             width: unit(90, rpx);
             height: unit(90, rpx);
         }
@@ -239,10 +202,12 @@ export default {
 .mui-checkbox input[type='checkbox']:checked:before {
     color: #00bbb1;
 }
+
 .RememberPass {
     color: #adadad;
     margin-top: 5px;
 }
+
 .RememberCheck {
     margin-left: 30px;
     color: #adadad;