lvkun996 8 months ago
parent
commit
425e02e258

+ 20 - 0
src/api/user.js

@@ -27,3 +27,23 @@ export function Login (data) {
 
 
 
+ export function  getCode (phone) {
+    return request({
+        url: `/agent/miniprogram/common/login/sms/code/${phone}`,
+        method: 'POST'
+    })
+}
+
+
+
+
+ export function  loginByCode (phone, code) {
+    return request({
+        url: `/agent/miniprogram/common/login/sms/${phone}/${code}`,
+        method: 'POST'
+    })
+}
+
+
+
+

+ 6 - 0
src/pages.json

@@ -174,6 +174,12 @@
 			"style": {
 				"navigationBarTitleText": "参加园所信息"
 			}
+		},
+		{
+			"path": "pages/webview/index",
+			"style": {
+				"navigationBarTitleText": "成长迹"
+			}
 		}
 	],
 	"globalStyle": {

+ 3 - 3
src/pages/districtGarden/detail.vue

@@ -1,5 +1,5 @@
 <template>
-  <view :class="['schoolDetail', isEdit ? '' : 'schoolDetailLong']">
+  <view :class="['schoolDetail', isEdit ? 'schoolDetailLong' : 'schoolDetailLong']">
     <view
       class="schoolBGI"
       :style="{
@@ -380,12 +380,12 @@ export default {
           object-fit: cover;
         }
         text {
-          height: 42rpx;
+          min-height: 42rpx;
           font-size: 28rpx;
           font-family: PingFangSC-Regular, PingFang SC;
           font-weight: 400;
           color: #333333;
-          line-height: 42rpx;
+          // line-height: 42rpx;
         }
       }
 

+ 175 - 31
src/pages/index/index.vue

@@ -17,15 +17,31 @@
                     获取您的公开信息(昵称、头像等)
                 </view>
             </view>
-            <button 
-                class="auth-btn"
-                open-type="getPhoneNumber" 
-                @getphonenumber="getPhoneNumber"
-                :loading="loading"
-                :disabled="loading"
-            >
-                授权登录
-            </button>
+            <view class="phone-form">
+                <view class="phone-form-phone">
+                    <input
+                        v-model="phone"
+                        :maxlength="11"
+                        type="tel"
+                        class="phone-form-phone-input"
+                        placeholder-style="color: #C7C7C7; font-size: 16px;"
+                        placeholder="手机号"
+                    />
+                    <view
+                        :class="['phone-form-phone-getCode', phoneIsTrue && 'phone-is-true']"
+                        @click.stop="getCode"
+                    >{{ state.codeMsg }}</view>
+                </view>
+
+                <input
+                    v-model="code"
+                    class="phone-form-code"
+                    placeholder-style="color: #C7C7C7; font-size: 16px;"
+                    placeholder="验证码"
+                />
+
+                <view :class="['phone-form-login', codeIsTrue && 'code-is-true']" @click="loginByCode">登录</view>
+                </view>
 
             <view class="rule">
                 仅限中德智慧内部代理商使用
@@ -40,7 +56,7 @@
 </template>
 
 <script>
-import { Login } from '@/api/user.js'
+import { loginByCode, getCode } from '@/api/user.js'
 import { setLocalStorage } from '@/utils/wxTool.js'
 import { staticPicture }  from '@/utils/global.js'
 import Tip from '@/utils/tip'
@@ -50,41 +66,83 @@ export default {
         statusBarHeight () {
             return this.$store.state.systemInfo.statusBarHeight
 		},
+        phoneIsTrue() {
+            const reg =/^[1][3,4,5,6,7,8,9][0-9]{9}$/;
+            return reg.test(this.phone) && !this.state.codeDisabled
+        },
+        // 验证码格式是否正确
+        codeIsTrue() {
+            const reg =/^[1][3,4,5,6,7,8,9][0-9]{9}$/;
+            return reg.test(this.phone) && this.code && this.code.length === 4
+        }
     },
     onReady () {
-        this.wxLogin()
     },
     data () {
         return {
             code: '',
             staticPicture,
-            loading: false
+            loading: false,
+            phone: undefined,
+            state: {
+                smsTime: 60, // 短信倒计时时间
+                codeDisabled: false, // 短信是否禁用
+                codeMsg: "获取验证码", // 短信按钮上的文字
+                timer: null, // 短信上的定时器
+            }
         }
     },
     
     methods: {
-        //  wx.login 
-        async wxLogin () {
-         
-            const res = await wx.login()
-            console.log(res);
-            const { code } = res
-            if (code) {
-                this.code = code
+         // 获取验证码
+        async getCode() {
+            if(!this.phoneIsTrue) return
+
+            this.getCodeStr();
+
+            const {status, message} = await getCode(this.phone)
+            if(status === 200) {
+                await Tip.success('验证码发送成功')
+            }else {
+                Tip.error(message)
             }
-            
         },
-        //获取手机号 
-        getPhoneNumber (e) {
-            console.log(e);
-            const { encryptedData, iv} = e.detail
-           
-            this.Login(encryptedData, iv)
-            // uni.setStorageSync('token', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIzNCIsImV4cCI6MTYyNDM0OTAyN30.oaZKLHIJT3eTAWXWEoxrpockYEaLedgWpoTpjamHG30')
-            //  uni.reLaunch({
-            //         url: '/pages/user/index'
-            //     })
+        // 获取短信按钮上的文字
+        getCodeStr() {
+         this.state.codeDisabled = true;
+         // 验证码60秒倒计时
+         if (!this.state.timer) {
+             this.state.timer = setInterval(() => {
+             if (this.state.smsTime > 0 && this.state.smsTime <= 60) {
+                 this.state.smsTime--;
+                 if (this.state.smsTime !== 0) {
+                 this.state.codeMsg = "重新发送(" + this.state.smsTime + ")";
+                 } else {
+                 clearInterval(this.state.timer);
+                 this.state.codeMsg = "获取验证码";
+                 this.state.smsTime = 60;
+                 this.state.timer = null;
+                 this.state.codeDisabled = false;
+                 }
+             }
+             }, 1000);
+         }
         },
+        async loginByCode() {
+            if(!this.codeIsTrue) return
+            const {status, message, data} = await loginByCode(this.phone, this.code)
+            if(status === 200) {
+               this.loading = false
+                    Tip.success('登录成功')
+                    setLocalStorage('token', data.token)
+                    this.$store.commit('set_userInfo', data)
+                    uni.reLaunch({
+                        url: '/pages/user/index'
+                    })
+            } else {
+                this.code = ''
+            }
+            },
         // 用户登录
         async Login (encryptedData, iv) {
           this.loading = true
@@ -212,4 +270,90 @@ export default {
         }
     }
 }
+
+.phone-form {
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    margin-top: 76rpx;
+
+    .phone-form-phone {
+      display: flex;
+      justify-content: space-between;
+      align-items: center;
+      padding: 8rpx;
+      width: 622rpx;
+      height: 96rpx;
+      font-size: 32rpx;
+      font-family: PingFangSC-Regular, PingFang SC;
+      font-weight: 400;
+      color: #333333;
+      background: #F7F7F7;
+      border-radius: 48rpx;
+      box-sizing: border-box;
+      overflow: hidden;
+
+      .phone-form-phone-input {
+        padding-left: 32rpx;
+        width: 386rpx;
+        height: 96rpx;
+        line-height: 96rpx;
+      }
+
+      .phone-form-phone-getCode {
+        display: flex;
+        justify-content: center;
+        align-items: center;
+        width: 220rpx;
+        height: 80rpx;
+        font-size: 28rpx;
+        font-family: PingFangSC-Regular, PingFang SC;
+        font-weight: 400;
+        color: #FFFFFF;
+        background: #D8D8D8;
+        border-radius: 40rpx;
+      }
+
+      .phone-is-true {
+        font-size: 28rpx;
+        font-family: PingFangSC-Regular, PingFang SC;
+        font-weight: 400;
+        color: #FFFFFF;
+        background: #193D9D;
+      }
+    }
+
+    .phone-form-code {
+      margin-top: 24rpx;
+      padding-left: 40rpx;
+      width: 622rpx;
+      height: 96rpx;
+      font-size: 32rpx;
+      font-family: PingFangSC-Regular, PingFang SC;
+      font-weight: 400;
+      color: #333333;
+      background: #F7F7F7;
+      border-radius: 48rpx;
+      box-sizing: border-box;
+    }
+
+    .phone-form-login {
+      display: flex;
+      justify-content: center;
+      align-items: center;
+      margin-top: 60rpx;
+      width: 588rpx;
+      height: 96rpx;
+      font-size: 32rpx;
+      font-family: PingFangSC-Regular, PingFang SC;
+      font-weight: 400;
+      color: #FFFFFF;
+      background: #D9D9D9;
+      border-radius: 48rpx;
+    }
+
+    .code-is-true {
+      background: #193D9D;
+    }
+  }
 </style>

+ 7 - 13
src/pages/user/index.vue

@@ -113,10 +113,9 @@
         <image class="regionalGardenImg" :src="staticImg.regionalGardenImg" />
       </view>
     </view>
-    <view class="competitionBox" @click="hanlderInviteCodeWithSchool('3')">
-      <image class="competitionTitle" :src="staticImg.competitionTitle" />
-      <image class="competitionImg" :src="staticImg.competitionImg" />
-    </view>
+     <!-- <view class="competitionBox" @click="hanlderInviteCodeWithSchool('3')">
+      <image class="competitionImg" :src="staticImg.growth" />
+    </view> -->
 
     <!-- 邀请码弹出层 -->
     <view
@@ -180,6 +179,7 @@ const staticImg = {
   regionalGardenImg: "https://img.luojigou.vip/FtEzcQyzA0Bx96MYswy_dRoC3Hg3",
   competitionTitle: "https://img.luojigou.vip/Fp2bpZgQXYbdvGLeP9RNUA-IjJ0C",
   competitionImg: "https://img.luojigou.vip/FvA5SY09bV9e_fOOgKApgW7AJBJk",
+  growth: require('@/static/competition/1.png'),
   // openSchoolAudit: require("@/static/image/openSchoolAudit.png"),
   // inviteCodeImg: require("@/static/image/inviteCodeImg.png"),
   // inviteCodeTitle: require("@/static/image/inviteCodeTitle.png"),
@@ -258,7 +258,7 @@ export default {
           break;
         case "3":
           uni.navigateTo({
-            url: "/pages/competition/index",
+            url: "/pages/webview/index",
           });
           break;
       }
@@ -523,17 +523,11 @@ export default {
     margin: 0 auto;
     width: 686rpx;
     height: 246rpx;
-    background: linear-gradient(227deg, #ff867f 0%, #ffccc1 100%);
     border-radius: 42rpx;
-    .competitionTitle {
-      width: 394rpx;
-      height: 100rpx;
-      object-fit: cover;
-    }
     .competitionImg {
       margin-left: 10rpx;
-      width: 216rpx;
-      height: 194rpx;
+      width: 686rpx;
+      height: 259rpx;
       object-fit: cover;
     }
   }

+ 11 - 0
src/pages/webview/index.vue

@@ -0,0 +1,11 @@
+<template>
+  <web-view src="https://zaojiao.net/invite/#/activity/1" ></web-view>
+</template>
+
+
+<script>
+export default {
+  name: "webview",
+}
+
+</script>

BIN
src/static/competition/1.png