فهرست منبع

一些操作添加验证码步骤

任一存 1 سال پیش
والد
کامیت
b09dab1d1f

+ 1 - 1
game/.env.mytest

@@ -1,4 +1,4 @@
 VUE_APP_CLI_MODE=test
 NODE_ENV=production
 PUBLIC_PATH=./
-VUE_APP_DEPLOY_ORIGIN=https://sit-cnzhengquan.4dage.com
+VUE_APP_DEPLOY_ORIGIN=

BIN
game/public/unity/disaster-relief/Build/Build.data.unityweb


+ 1 - 1
game/public/unity/disaster-relief/index.html

@@ -3,7 +3,7 @@
   <head>
     <meta charset="utf-8">
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-    <title>一起来救灾</title>
+    <title>应急救灾</title>
     <link rel="shortcut icon" href="TemplateData/favicon.ico">
     <link rel="stylesheet" href="TemplateData/style.css">
     <link rel="manifest" href="manifest.webmanifest">

+ 6 - 3
game/src/api.js

@@ -41,7 +41,7 @@ export function getUserFromStorageIfNeed() {
 //   })
 //   return res.data.data
 // }
-export async function login(account, password) {
+export async function login(account, password, verifiCode) {
   const pwdEncrypted = encodeStr(Base64.encode(password))
   const res = await axios({
     method: 'post',
@@ -49,6 +49,7 @@ export async function login(account, password) {
     data: {
       userName: account,
       password: pwdEncrypted,
+      randCode: verifiCode,
     },
   })
   if (res.data.code !== 0) {
@@ -97,7 +98,7 @@ export async function checkLoginStatusAndProcess() {
     return false
   }
 }
-export async function signUp(account, phone, password) {
+export async function signUp(account, phone, password, verifiCode) {
   const pwdEncrypted = encodeStr(Base64.encode(password))
   const res = await axios({
     method: 'post',
@@ -107,6 +108,7 @@ export async function signUp(account, phone, password) {
       phone,
       userName: account,
       verifyPassword: pwdEncrypted,
+      randCode: verifiCode,
     },
   })
   if (res.data.code !== 0) {
@@ -115,13 +117,14 @@ export async function signUp(account, phone, password) {
     return
   }
 }
-export async function findPassowrd(account, phone) {
+export async function findPassowrd(account, phone, verifiCode) {
   const res = await axios({
     method: 'post',
     url: `${process.env.VUE_APP_DEPLOY_ORIGIN}/api/show/findPass`,
     data: {
       phone,
       userName: account,
+      randCode: verifiCode,
     },
   })
   if (res.data.code !== 0) {

+ 106 - 3
game/src/views/FindPassword.vue

@@ -50,6 +50,38 @@
         @blur="isPhoneInputOver=true"
       >
     </div>
+    <div class="form-item form-item-verifi">
+      <div class="title">
+        <img
+          src="@/assets/images/icon-lock.png"
+          alt=""
+          draggable="false"
+        >
+        <span>验证码</span>
+      </div>
+      <div class="row">
+        <input
+          v-model="verifiCode"
+          placeholder="请输入验证码"
+          :class="{
+            invalid: isVerifiCodeInputOver && !isVerifiCodeValid
+          }"
+          @blur="isVerifiCodeInputOver=true"
+        >
+        <button
+          v-if="isShowVerifiCode"
+          class="verifi-code"
+          @click="onClickVerifiCode"
+        >
+          <img
+            class=""
+            src="https://sit-cnzhengquan.4dage.com/api/show/getRandCode"
+            alt=""
+            draggable="false"
+          >
+        </button>
+      </div>
+    </div>
 
     <button
       class="submit"
@@ -69,7 +101,7 @@
 </template>
 
 <script setup>
-import { ref, computed, watch, onMounted } from "vue"
+import { ref, computed, watch, onMounted, nextTick } from "vue"
 import { useRoute, useRouter } from "vue-router"
 import { useStore } from "vuex"
 import { showDialog } from 'vant'
@@ -88,6 +120,7 @@ const account = ref('')
 const phone = ref('')
 const password = ref('')
 const passwordRepeat = ref('')
+const verifiCode = ref('')
 
 const accountTrimed = computed(() => {
   return account.value.trim()
@@ -95,6 +128,9 @@ const accountTrimed = computed(() => {
 const phoneTrimed = computed(() => {
   return phone.value.toString().trim()
 })
+const verifiCodeTrimed = computed(() => {
+  return verifiCode.value.trim()
+})
 
 const isAccountValid = computed(() => {
   return !!accountTrimed.value
@@ -102,11 +138,21 @@ const isAccountValid = computed(() => {
 const isPhoneValid = computed(() => {
   return phoneTrimed.value.length === 11
 })
+const isVerifiCodeValid = computed(() => {
+  return verifiCodeTrimed.value.length > 0
+})
 
 const isAccountInputOver = ref(false)
 const isPhoneInputOver = ref(false)
+const isVerifiCodeInputOver = ref(false)
 
-
+const isShowVerifiCode = ref(true)
+function onClickVerifiCode() {
+  isShowVerifiCode.value = false
+  nextTick(() => {
+    isShowVerifiCode.value = true
+  })
+}
 
 function submit() {
   if (!isAccountValid.value) {
@@ -125,8 +171,16 @@ function submit() {
     isPhoneInputOver.value = true
     return
   }
+  if (!isVerifiCodeValid.value) {
+    showDialog({
+      message: '请输入验证码',
+      theme: 'round-button',
+    })
+    isVerifiCodeInputOver.value = true
+    return
+  }
 
-  findPassowrd(accountTrimed.value, phoneTrimed.value).then(() => {
+  findPassowrd(accountTrimed.value, phoneTrimed.value, verifiCodeTrimed.value).then(() => {
     showDialog({
       message: '已发送邮件到您的邮箱',
       theme: 'round-button',
@@ -211,6 +265,55 @@ function submit() {
       border-bottom: 1px solid red;
     }
   }
+  >.form-item{
+    >.title{
+      width: 100%;
+      display: flex;
+      align-items: center;
+      margin-bottom: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+      >img{
+        width: calc(22 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        height: calc(22 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        margin-right: calc(10 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+      }
+      >span{
+        font-size: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        font-family: Source Han Sans SC, Source Han Sans SC;
+        font-weight: 400;
+        color: #D1B489;
+        line-height: calc(19 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+      }
+    }
+    >div.row{
+      display: flex;
+      justify-content: space-between;
+      align-items: center;
+      >input{
+        width: 50%;
+        height: calc(29 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        border-bottom: 1px solid #D9D9D9;
+        font-size: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        font-family: Source Han Sans SC, Source Han Sans SC;
+        font-weight: 400;
+        color: black;
+        line-height: calc(19 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        &::placeholder {
+          font-size: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+          font-family: Source Han Sans SC, Source Han Sans SC;
+          font-weight: 400;
+          color: #B8B8B8;
+          line-height: calc(19 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        }
+      }
+      >input.invalid{
+        border-bottom: 1px solid red;
+      }
+      >button.get-verifi-code{
+        width: 50%;
+      }
+    }
+  }
+
   >button.submit{
     width: calc(332 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
     height: calc(56 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));

+ 106 - 2
game/src/views/LoginView.vue

@@ -50,6 +50,38 @@
         @blur="isPasswordInputOver=true"
       >
     </div>
+    <div class="form-item form-item-verifi">
+      <div class="title">
+        <img
+          src="@/assets/images/icon-lock.png"
+          alt=""
+          draggable="false"
+        >
+        <span>验证码</span>
+      </div>
+      <div class="row">
+        <input
+          v-model="verifiCode"
+          placeholder="请输入验证码"
+          :class="{
+            invalid: isVerifiCodeInputOver && !isVerifiCodeValid
+          }"
+          @blur="isVerifiCodeInputOver=true"
+        >
+        <button
+          v-if="isShowVerifiCode"
+          class="verifi-code"
+          @click="onClickVerifiCode"
+        >
+          <img
+            class=""
+            src="https://sit-cnzhengquan.4dage.com/api/show/getRandCode"
+            alt=""
+            draggable="false"
+          >
+        </button>
+      </div>
+    </div>
 
     <button
       class="forget"
@@ -84,7 +116,7 @@
 </template>
 
 <script setup>
-import { ref, computed, watch, onMounted } from "vue"
+import { ref, computed, watch, onMounted, nextTick } from "vue"
 import { useRoute, useRouter } from "vue-router"
 import { useStore } from "vuex"
 import { showDialog } from 'vant'
@@ -101,6 +133,7 @@ const {
 
 const account = ref('')
 const password = ref('')
+const verifiCode = ref('')
 
 const accountTrimed = computed(() => {
   return account.value.trim()
@@ -108,6 +141,9 @@ const accountTrimed = computed(() => {
 const passwordTrimed = computed(() => {
   return password.value.trim()
 })
+const verifiCodeTrimed = computed(() => {
+  return verifiCode.value.trim()
+})
 
 const isAccountValid = computed(() => {
   return !!accountTrimed.value
@@ -115,9 +151,21 @@ const isAccountValid = computed(() => {
 const isPasswordValid = computed(() => {
   return passwordTrimed.value.length >= 6 && passwordTrimed.value.length <= 10 && passwordTrimed.value.search(/^[0-9a-zA-Z].*$/) === 0
 })
+const isVerifiCodeValid = computed(() => {
+  return verifiCodeTrimed.value.length > 0
+})
 
 const isAccountInputOver = ref(false)
 const isPasswordInputOver = ref(false)
+const isVerifiCodeInputOver = ref(false)
+
+const isShowVerifiCode = ref(true)
+function onClickVerifiCode() {
+  isShowVerifiCode.value = false
+  nextTick(() => {
+    isShowVerifiCode.value = true
+  })
+}
 
 function submit() {
   if (!isAccountValid.value) {
@@ -136,8 +184,16 @@ function submit() {
     isPasswordInputOver.value = true
     return
   }
+  if (!isVerifiCodeValid.value) {
+    showDialog({
+      message: '请输入验证码',
+      theme: 'round-button',
+    })
+    isVerifiCodeInputOver.value = true
+    return
+  }
 
-  login(accountTrimed.value, passwordTrimed.value).then(() => {
+  login(accountTrimed.value, passwordTrimed.value, verifiCodeTrimed.value).then(() => {
     router.replace({
       name: 'HomeView'
     })
@@ -217,6 +273,54 @@ function submit() {
       border-bottom: 1px solid red;
     }
   }
+  >.form-item{
+    >.title{
+      width: 100%;
+      display: flex;
+      align-items: center;
+      margin-bottom: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+      >img{
+        width: calc(22 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        height: calc(22 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        margin-right: calc(10 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+      }
+      >span{
+        font-size: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        font-family: Source Han Sans SC, Source Han Sans SC;
+        font-weight: 400;
+        color: #D1B489;
+        line-height: calc(19 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+      }
+    }
+    >div.row{
+      display: flex;
+      justify-content: space-between;
+      align-items: center;
+      >input{
+        width: 50%;
+        height: calc(29 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        border-bottom: 1px solid #D9D9D9;
+        font-size: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        font-family: Source Han Sans SC, Source Han Sans SC;
+        font-weight: 400;
+        color: black;
+        line-height: calc(19 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        &::placeholder {
+          font-size: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+          font-family: Source Han Sans SC, Source Han Sans SC;
+          font-weight: 400;
+          color: #B8B8B8;
+          line-height: calc(19 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        }
+      }
+      >input.invalid{
+        border-bottom: 1px solid red;
+      }
+      >button.get-verifi-code{
+        width: 50%;
+      }
+    }
+  }
   >button.forget{
     margin-top: calc(-14 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
     margin-left: auto;

+ 105 - 3
game/src/views/SignUp.vue

@@ -88,6 +88,38 @@
         @blur="isPasswordRepeatInputOver=true"
       >
     </div>
+    <div class="form-item form-item-verifi">
+      <div class="title">
+        <img
+          src="@/assets/images/icon-lock.png"
+          alt=""
+          draggable="false"
+        >
+        <span>验证码</span>
+      </div>
+      <div class="row">
+        <input
+          v-model="verifiCode"
+          placeholder="请输入验证码"
+          :class="{
+            invalid: isVerifiCodeInputOver && !isVerifiCodeValid
+          }"
+          @blur="isVerifiCodeInputOver=true"
+        >
+        <button
+          v-if="isShowVerifiCode"
+          class="verifi-code"
+          @click="onClickVerifiCode"
+        >
+          <img
+            class=""
+            src="https://sit-cnzhengquan.4dage.com/api/show/getRandCode"
+            alt=""
+            draggable="false"
+          >
+        </button>
+      </div>
+    </div>
 
     <button
       class="submit"
@@ -105,7 +137,7 @@
 </template>
 
 <script setup>
-import { ref, computed, watch, onMounted } from "vue"
+import { ref, computed, watch, onMounted, nextTick } from "vue"
 import { useRoute, useRouter } from "vue-router"
 import { useStore } from "vuex"
 import { showDialog } from 'vant'
@@ -124,6 +156,7 @@ const account = ref('')
 const phone = ref('')
 const password = ref('')
 const passwordRepeat = ref('')
+const verifiCode = ref('')
 
 const accountTrimed = computed(() => {
   return account.value.trim()
@@ -137,6 +170,9 @@ const passwordTrimed = computed(() => {
 const passwordRepeatTrimed = computed(() => {
   return passwordRepeat.value.trim()
 })
+const verifiCodeTrimed = computed(() => {
+  return verifiCode.value.trim()
+})
 
 const isAccountValid = computed(() => {
   return !!accountTrimed.value
@@ -150,13 +186,23 @@ const isPasswordValid = computed(() => {
 const isPasswordRepeatValid = computed(() => {
   return passwordTrimed.value === passwordRepeatTrimed.value
 })
+const isVerifiCodeValid = computed(() => {
+  return verifiCodeTrimed.value.length > 0
+})
 
 const isAccountInputOver = ref(false)
 const isPhoneInputOver = ref(false)
 const isPasswordInputOver = ref(false)
 const isPasswordRepeatInputOver = ref(false)
+const isVerifiCodeInputOver = ref(false)
 
-
+const isShowVerifiCode = ref(true)
+function onClickVerifiCode() {
+  isShowVerifiCode.value = false
+  nextTick(() => {
+    isShowVerifiCode.value = true
+  })
+}
 
 function submit() {
   if (!isAccountValid.value) {
@@ -191,8 +237,16 @@ function submit() {
     isPasswordRepeatInputOver.value = true
     return
   }
+  if (!isVerifiCodeValid.value) {
+    showDialog({
+      message: '请输入验证码',
+      theme: 'round-button',
+    })
+    isVerifiCodeInputOver.value = true
+    return
+  }
 
-  signUp(accountTrimed.value, phoneTrimed.value, passwordTrimed.value, passwordRepeatTrimed.value).then(() => {
+  signUp(accountTrimed.value, phoneTrimed.value, passwordTrimed.value, passwordRepeatTrimed.value, verifiCodeTrimed.value).then(() => {
     showDialog({
       message: '注册成功',
       theme: 'round-button',
@@ -284,6 +338,54 @@ function submit() {
       border-bottom: 1px solid red;
     }
   }
+  >.form-item{
+    >.title{
+      width: 100%;
+      display: flex;
+      align-items: center;
+      margin-bottom: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+      >img{
+        width: calc(22 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        height: calc(22 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        margin-right: calc(10 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+      }
+      >span{
+        font-size: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        font-family: Source Han Sans SC, Source Han Sans SC;
+        font-weight: 400;
+        color: #D1B489;
+        line-height: calc(19 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+      }
+    }
+    >div.row{
+      display: flex;
+      justify-content: space-between;
+      align-items: center;
+      >input{
+        width: 50%;
+        height: calc(29 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        border-bottom: 1px solid #D9D9D9;
+        font-size: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        font-family: Source Han Sans SC, Source Han Sans SC;
+        font-weight: 400;
+        color: black;
+        line-height: calc(19 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        &::placeholder {
+          font-size: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+          font-family: Source Han Sans SC, Source Han Sans SC;
+          font-weight: 400;
+          color: #B8B8B8;
+          line-height: calc(19 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
+        }
+      }
+      >input.invalid{
+        border-bottom: 1px solid red;
+      }
+      >button.get-verifi-code{
+        width: 50%;
+      }
+    }
+  }
   >button.submit{
     width: calc(332 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
     height: calc(56 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));