瀏覽代碼

解决更换管理员通过手机和密保传token参数时数据结构不一致的问题;移动端验证手机设置新手机

wangcz 7 年之前
父節點
當前提交
e01d7fdabe

+ 1 - 1
components/change/ChangeManager.vue

@@ -394,7 +394,7 @@
             .then(response => {
               this.isShowLoading = false
               if (response.data.success) {
-                this.$store.commit('login/GET_TOKEN', response.data.content)
+                this.$store.commit('login/GET_TOKEN', response.data.content.token)
                 this.showPhoneValid = false
                 this.$router.push({ path: '/change/changeManagerSecondStep' })
               } else {

+ 73 - 0
components/mobile/validation/ValidationPhoneStepEmail.vue

@@ -0,0 +1,73 @@
+<template>
+  <div class="f-main">
+    <div class="content-top">
+      <p>验证手机</p>
+      <a href="javascript:void(0)" class="back" @click="jump('select')"><i class="el-icon-back"></i></a>
+    </div>
+    <div class="f-form">
+      <div class="page-part">
+        <span>使用电子邮箱 <strong>{{info | hide}}</strong> 进行验证,有效期7天</span>
+      </div>
+      <div class="page-part">
+        <mt-button :disabled="hasSend" size="large"
+                   type="primary"
+                   @click="sureAccount()"
+                   v-text="secretEmail">发送验证请求</mt-button>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+  export default {
+    name: 'step-email',
+    props: ['info'],
+    data () {
+      return {
+        secretEmail: '发送验证请求',
+        hasSend: false
+      }
+    },
+    filters: {
+      hide: function (value) {
+        let getEmailIndex = value.indexOf('@')
+        if (getEmailIndex > 3) {
+          let len = value.substring(3, getEmailIndex)
+          value = value.replace(len, '***')
+        }
+        return value
+      }
+    },
+    methods: {
+      jump (type) {
+        this.$emit('stepEvent', type)
+      },
+      // 警告弹窗
+      downToast (type) {
+        this.$toast({
+          message: type,
+          iconClass: 'el-icon-warning'
+        })
+      },
+      // 发送邮件
+      sureAccount () {
+        this.$indicator.open('发送过程中...')
+        this.$http.get(`/update/user/check/email`, {params: {email: this.info, operate: 'mobile'}})
+          .then(response => {
+            this.$indicator.close()
+            if (response.data.success) {
+              console.log('email', response.data)
+              this.hasSend = true
+              this.secretEmail = '已发送验证邮件,请查收'
+            } else {
+              this.hasSend = false
+              this.downToast(response.data.errMsg)
+            }
+          }).catch(() => {
+            this.$indicator.close()
+            this.downToast('请检查网络是否正常或联系服务商')
+          })
+      }
+    }
+  }
+</script>

+ 31 - 11
components/mobile/validation/ValidationPhoneStepMobile.vue

@@ -62,7 +62,24 @@
           this.downToast('请填写验证码信息')
           this.state.token = 'error'
         } else {
-          this.state.token = 'success'
+          let param = new FormData()
+          param.append('mobile', this.info)
+          param.append('code', this.token)
+          param.append('token', this.tokenCode)
+          let config = {
+            headers: {'Content-Type': 'multipart/form-data'}
+          }
+          this.$http.post(`/update/user/checkCode/mobile`, param, config)
+            .then(response => {
+              if (response.data.success) {
+                this.state.token = 'success'
+              } else {
+                this.state.token = 'error'
+                return Promise.reject(response.data)
+              }
+            }).catch(err => {
+              this.downToast(err.errMsg)
+            })
         }
       },
       // 获取验证码
@@ -72,11 +89,12 @@
         } else {
           this.$indicator.open('获取中...')
           let _this = this
-          this.$http.get('/sso/personal/register/checkCode', {params: {mobile: this.info}})
+          this.$http.get('/update/user/check/mobile', {params: {mobile: this.info}})
             .then(response => {
               this.$indicator.close()
               if (response.data) {
-                this.tokenCode = response.data.token
+                console.log('token', response.data.content.token)
+                this.tokenCode = response.data.content.token
                 this.$toast({
                   message: '验证码已经发送到您的手机,请注意查收',
                   iconClass: 'el-icon-success'
@@ -93,9 +111,9 @@
                 }, 1000)
               }
             }).catch(() => {
-            this.$indicator.close()
-            this.downToast('请检查网络是否正常或联系服务商')
-          })
+              this.$indicator.close()
+              this.downToast('请检查网络是否正常或联系服务商')
+            })
         }
       },
       // 验证信息
@@ -105,24 +123,26 @@
         } else {
           this.$indicator.open('验证过程中...')
           let param = new FormData()
+          param.append('mobile', this.info)
           param.append('code', this.token)
           param.append('token', this.tokenCode)
           let config = {
             headers: {'Content-Type': 'multipart/form-data'}
           }
-          this.$http.post('/sso/resetPwd/check/mobile', param, config)
+          this.$http.post('/update/user/check/mobile', param, config)
             .then(response => {
               this.$indicator.close()
               if (response.data.success) {
-                this.$emit('stepEvent', 'security')
+                console.log('123', response.data)
+                this.$emit('stepEvent', 'new')
                 this.$emit('tokenEvent', response.data.content.token)
               } else {
                 this.downToast(response.data.errMsg)
               }
             }).catch(() => {
-            this.$indicator.close()
-            this.downToast('请检查网络是否正常或联系服务商')
-          })
+              this.$indicator.close()
+              this.downToast('请检查网络是否正常或联系服务商')
+            })
         }
       }
     }

+ 73 - 0
components/mobile/validation/ValidationPhoneStepNew.vue

@@ -0,0 +1,73 @@
+<template>
+  <div class="f-main">
+    <div class="content-top">
+      <p>验证手机</p>
+      <a href="javascript:void(0)" class="back" @click="jump('select')"><i class="el-icon-back"></i></a>
+    </div>
+    <div class="f-form">
+      <div class="page-part">
+        <span>使用电子邮箱 <strong>{{info | hide}}</strong> 进行验证,有效期7天</span>
+      </div>
+      <div class="page-part">
+        <mt-button :disabled="hasSend" size="large"
+                   type="primary"
+                   @click="sureAccount()"
+                   v-text="secretEmail">发送验证请求</mt-button>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+  export default {
+    name: 'step-email',
+    props: ['info'],
+    data () {
+      return {
+        secretEmail: '发送验证请求',
+        hasSend: false
+      }
+    },
+    filters: {
+      hide: function (value) {
+        let getEmailIndex = value.indexOf('@')
+        if (getEmailIndex > 3) {
+          let len = value.substring(3, getEmailIndex)
+          value = value.replace(len, '***')
+        }
+        return value
+      }
+    },
+    methods: {
+      jump (type) {
+        this.$emit('stepEvent', type)
+      },
+      // 警告弹窗
+      downToast (type) {
+        this.$toast({
+          message: type,
+          iconClass: 'el-icon-warning'
+        })
+      },
+      // 发送邮件
+      sureAccount () {
+        this.$indicator.open('发送过程中...')
+        this.$http.get(`/update/user/check/email`, {params: {email: this.info, operate: 'mobile'}})
+          .then(response => {
+            this.$indicator.close()
+            if (response.data.success) {
+              console.log('email', response.data)
+              this.hasSend = true
+              this.secretEmail = '已发送验证邮件,请查收'
+            } else {
+              this.hasSend = false
+              this.downToast(response.data.errMsg)
+            }
+          }).catch(() => {
+            this.$indicator.close()
+            this.downToast('请检查网络是否正常或联系服务商')
+          })
+      }
+    }
+  }
+</script>

+ 133 - 0
components/mobile/validation/ValidationPhoneStepSecurity.vue

@@ -0,0 +1,133 @@
+<template>
+  <div class="f-main">
+    <div class="content-top">
+      <p>验证手机</p>
+    </div>
+    <div class="f-form">
+      <div class="page-part">
+        <p class="security">密保问题一:<span v-text="questions[0].question"></span></p>
+      </div>
+      <div class="page-part">
+        <mt-field placeholder="请填写答案一"
+                  :state="state.answer1"
+                  @blur.native.capture="validAnswer1"
+                  v-model="valid.answer1"></mt-field>
+      </div>
+      <div class="page-part">
+        <p class="security">密保问题二:<span v-text="questions[1].question"></span></p>
+      </div>
+      <div class="page-part">
+        <mt-field placeholder="请填写答案二"
+                  :state="state.answer2"
+                  @blur.native.capture="validAnswer2"
+                  v-model="valid.answer2"></mt-field>
+      </div>
+
+      <div class="page-part">
+        <mt-button size="large" type="primary" @click="sureAccount('new')">下一步</mt-button>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+  export default {
+    name: 'step-security',
+    props: ['tokenId'],
+    data () {
+      return {
+        state: {
+          answer1: 'error',
+          answer2: 'error'
+        },
+        valid: {
+          answer1: '',
+          answer2: ''
+        },
+        questions: '',
+        token: ''
+      }
+    },
+    mounted () {
+      this.$nextTick(() => {
+        this.loadIssue()
+      })
+    },
+    methods: {
+      // 警告弹窗
+      downToast (type) {
+        this.$toast({
+          message: type,
+          iconClass: 'el-icon-warning'
+        })
+      },
+      // 验证密保答案一
+      validAnswer1 () {
+        if (!this.valid.answer1) {
+          this.downToast('请填写问题一的正确答案')
+          this.state.answer1 = 'error'
+        } else {
+          this.state.answer1 = 'success'
+        }
+      },
+      // 验证密保答案二
+      validAnswer2 () {
+        if (!this.valid.answer2) {
+          this.downToast('请填写问题二的正确答案')
+          this.state.answer2 = 'error'
+        } else {
+          this.state.answer2 = 'success'
+        }
+      },
+      // 获取密保问题
+      loadIssue () {
+        this.$http.get('/update/user/check/question')
+          .then(response => {
+            if (response.data.success) {
+              console.log('question', response.data.content.questions)
+              this.questions = response.data.content.questions
+            } else {
+              this.downToast(response.data.errMsg)
+            }
+          })
+      },
+      sureAccount (type) {
+        if (this.state.answer1 !== 'success' || this.state.answer2 !== 'success') {
+          this.downToast('请确认填写部分是否有误')
+        } else {
+          this.$indicator.open('验证过程中...')
+          let param = new FormData()
+          let answer = []
+          answer.push({'answer': this.valid.answer1, id: this.questions[0].id}, {
+            'answer': this.valid.answer2, id: this.questions[1].id
+          })
+          let answers = JSON.stringify(answer)
+          param.append('answers', answers)
+          param.append('token', this.token)
+          param.append('pageToken', this.tokenId)
+          let config = {
+            headers: {'Content-Type': 'multipart/form-data'}
+          }
+          this.$http.post(`/sso/resetPwd/check/question`, param, config)
+            .then(response => {
+              this.$indicator.close()
+              if (response.data.success) {
+                console.log(response.data, type)
+                this.$emit('stepEvent', type)
+                this.$emit('tokenEvent', response.data.content.token)
+              } else {
+                this.downToast(response.data.errMsg)
+              }
+            }).catch(() => {
+              this.$indicator.close()
+              this.downToast('请检查网络是否正常或联系服务商')
+            })
+        }
+      }
+    }
+  }
+</script>
+
+<style scoped type="text/scss" lang="scss">
+
+</style>

+ 18 - 4
components/mobile/validation/ValidationPhoneStepSelect.vue

@@ -15,7 +15,7 @@
           <span>通过验证邮箱</span>
           <i class="fa fa-angle-right second"></i>
         </li>
-        <li class="item" @click="jump('question')" v-if="hasQuestion">
+        <li class="item" @click="jump('questions')" v-if="hasQuestion">
           <img src="/images/all/icon03.png">
           <span>通过验证密保</span>
           <i class="fa fa-angle-right second"></i>
@@ -33,10 +33,14 @@
 <script>
   export default {
     name: 'step-select',
+    middleware: 'authenticated',
     data () {
       return {
         hasEmail: false,
-        hasQuestion: false
+        hasQuestion: false,
+        mobile: '',
+        email: '',
+        question: ''
       }
     },
     mounted () {
@@ -47,18 +51,28 @@
     methods: {
       jump (type) {
         this.$emit('stepEvent', type)
+        if (type === 'mobile') {
+          this.$emit('setDataEvent', this.mobile)
+        } else if (type === 'email') {
+          this.$emit('setDataEvent', this.email)
+        } else if (type === 'questions') {
+          this.$emit('setDataEvent', this.questions)
+        }
       },
       // 获取验证方式
       getVerifyWay () {
-        this.$http.get('/update/user/checkType' + (this.$store.state.option.isLogin.data.content.isLogin ? 'update' : 'reset'))
+        this.$http.get('/update/user/checkType')
           .then(response => {
             if (response.data.success) {
               console.log(response.data)
+              this.mobile = response.data.content.mobile
               if (response.data.content.email) {
                 this.hasEmail = true
+                this.email = response.data.content.email
               }
-              if (response.data.content.question) {
+              if (response.data.content.questions) {
                 this.hasQuestion = true
+                this.questions = response.data.content.questions
               }
             }
           }).catch(err => {

+ 4 - 1
components/mobile/validation/index.js

@@ -1,4 +1,7 @@
 import ValidationPhoneStepSelect from './ValidationPhoneStepSelect.vue'
 import ValidationPhoneStepMobile from './ValidationPhoneStepMobile.vue'
+import ValidationPhoneStepEmail from './ValidationPhoneStepEmail.vue'
+import ValidationPhoneStepSecurity from './ValidationPhoneStepSecurity'
+import ValidationPhoneStepNew from './ValidationPhoneStepNew.vue'
 
-export {ValidationPhoneStepSelect, ValidationPhoneStepMobile}
+export {ValidationPhoneStepSelect, ValidationPhoneStepMobile, ValidationPhoneStepEmail, ValidationPhoneStepSecurity, ValidationPhoneStepNew}

+ 1 - 1
nuxt.config.js

@@ -1,6 +1,6 @@
 const path = require('path')
 const isProdMode = Object.is(process.env.NODE_ENV, 'production')
-const baseUrl = process.env.BASE_URL || (isProdMode ? 'https://sso.ubtob.com/' : 'http://10.1.51.50:8081/')
+const baseUrl = process.env.BASE_URL || (isProdMode ? 'https://sso.ubtob.com/' : 'http://10.1.51.50:23232/')
 
 module.exports = {
   router: {

+ 25 - 4
pages/validation/phoneValidation.vue

@@ -1,7 +1,11 @@
 <template>
   <div>
     <template v-if="isMobile">
-      <validationPhone-stepSelect v-if="step === 'first'" @stepEvent="setStep"/>
+      <validationPhone-stepSelect v-if="step === 'first'" @stepEvent="setStep" @setDataEvent="setInfo"/>
+      <validationPhone-stepMobile v-if="step === 'mobile'" @stepEvent="setStep" @tokenEvent="loadToken" :info="info"/>
+      <validationPhone-stepEmail v-if="step === 'email'" @stepEvent="setStep" :info="info"/>
+      <validationPhone-stepSecurity v-if="step === 'questions'" @stepEvent="setStep" @tokenEvent="loadToken" :tokenId="tokenId"/>
+      <validationPhone-stepNew v-if="step === 'new'" @stepEvent="setStep" @lastEvent="setStepLast" :stepLast="stepLast" :tokenId="tokenId"/>
     </template>
     <template v-else>
       <accountCenter-header/>
@@ -12,7 +16,7 @@
 <script>
   import AccountCenterHeader from '~components/default/AccountCenterHeader.vue'
   import PhoneValidation from '~components/validation/PhoneValidation.vue'
-  import ValidationPhoneStepSelect from '~components/mobile/validation/ValidationPhoneStepSelect'
+  import {ValidationPhoneStepSelect, ValidationPhoneStepMobile, ValidationPhoneStepEmail, ValidationPhoneStepSecurity, ValidationPhoneStepNew} from '~components/mobile/validation'
   export default {
     layout (context) {
       return context.store.state.option.isMobile ? 'mobile' : 'default'
@@ -23,13 +27,20 @@
     },
     data () {
       return {
-        step: 'first'
+        step: 'first',
+        info: '',
+        tokenId: '',
+        stepLast: 'new'
       }
     },
     components: {
       AccountCenterHeader,
       PhoneValidation,
-      ValidationPhoneStepSelect
+      ValidationPhoneStepSelect,
+      ValidationPhoneStepMobile,
+      ValidationPhoneStepEmail,
+      ValidationPhoneStepSecurity,
+      ValidationPhoneStepNew
     },
     computed: {
       isMobile () {
@@ -39,6 +50,16 @@
     methods: {
       setStep (type) {
         this.step = type
+      },
+      setInfo (style) {
+        this.info = style
+      },
+      loadToken (token) {
+        this.tokenId = token
+      },
+      setStepLast (type) {
+        console.log(type)
+        this.stepLast = type
       }
     }
   }