Эх сурвалжийг харах

手机端人个注册增加手机快速登入

wangcz 7 жил өмнө
parent
commit
b327bb432a

+ 120 - 4
components/mobile/registerPersonal/index.vue

@@ -4,14 +4,18 @@
       <p>个人注册</p>
       <a class="go" @click="goRegister"><i class="fa fa-long-arrow-right"></i>企业注册</a>
     </div>
+    <div class="content-tab">
+      <span :class="{speed: speediness === false}" @click="clickWay(false)">用户名注册</span>
+      <span :class="{speed: speediness === true}" @click="clickWay(true)">手机号注册</span>
+    </div>
     <div class="f-form">
-      <div class="page-part">
+      <div class="page-part" v-if="!speediness">
         <mt-field :state="state.vipName"
                   placeholder="会员名"
                   :attr="{ maxlength: 20 }"
                   v-model="vipName"></mt-field>
       </div>
-      <div class="page-part">
+      <div class="page-part" v-if="!speediness">
         <mt-field :state="state.password"
                   placeholder="密码"
                   :attr="{ maxlength: 20 }"
@@ -23,7 +27,7 @@
           <p class="pwd">密码须为8-20字符的英文、数字混合</p>
         </template>
       </div>
-      <div class="page-part">
+      <div class="page-part" v-if="!speediness">
         <mt-field :state="state.confirm"
                   placeholder="确认密码"
                   v-model="confirm"
@@ -53,7 +57,7 @@
       <div class="page-part">
         <el-checkbox v-model="checked">我已阅读并同意 <a class="rgba" href="/common/agreement">《优软云服务条款》</a></el-checkbox>
       </div>
-      <mt-button type="primary" size="large" @click.native="submit">完成注册</mt-button>
+      <mt-button type="primary" size="large" @click.native="allSubmit">完成注册</mt-button>
     </div>
   </div>
 </template>
@@ -64,6 +68,7 @@
     name: 'registerPerson',
     data () {
       return {
+        speediness: false,
         imgSrc: '',
         code: '',
         step: 1,
@@ -102,6 +107,14 @@
       }
     },
     methods: {
+      // 切换注册方式
+      clickWay (type) {
+        if (this.speediness !== type) {
+          this.speediness = type
+          this.imgSrc = ''
+          this.getCode()
+        }
+      },
       getCode () {
         this.imgSrc = '/sso/resetPwd/checkCaptcha?timestamp=' + (new Date()).valueOf()
       },
@@ -356,6 +369,84 @@
             })
         }
       },
+      // 快速登录
+      waySubmit () {
+        if (this.state.mobile !== 'success') {
+          this.codeMobile()
+        } else if (this.state.token !== 'success') {
+          this.codeToken()
+        } else if (this.checked === false) {
+          this.downToast('您对阅读条款未做勾选')
+        } else {
+          this.$indicator.open('注册中...')
+          let param = new FormData()
+          param.append('mobile', this.mobile)
+          // param.append('mobileArea', '')
+          param.append('appId', this.$store.state.option.appId)
+          param.append('code', this.token)
+          param.append('token', this.tokenCode)
+          param.append('t', this.$route.query.tk ? this.$route.query.tk : '')
+          if (this.$route.query.baseUrl) {
+            param.append('baseUrl', this.$route.query.baseUrl)
+          }
+          if (this.$route.query.returnURL) {
+            param.append('returnUrl', this.$route.query.returnURL)
+          }
+          let config = {
+            header: {'Content-Type': 'multipart/form-data'}
+          }
+          this.$http.post('/sso/personal/register/sms', param, config)
+            .then(response => {
+              this.$indicator.close()
+              if (response.data.success) {
+                if (response.data.content.data) {
+                  let param = response.data.content.data
+                  let a = ''
+                  for (let n in param) {
+                    a += (n + '=' + encodeURIComponent(param[n]) + '&')
+                  }
+                  let params = a.substr(0, a.length - 1)
+                  this.isShowLoading = true
+                  if (response.data.content.currentUrl) {
+                    this.$jsonp(`${response.data.content.currentUrl}?${params}`, {
+                      name: 'successCallback',
+                      timeout: 3000
+                    }, (err, data) => {
+                      if (err) {
+                        this.$message.error('注册成功,请点击下方“立即登录”完成登录')
+                        this.isShowLoading = false
+                        throw err
+                      } else {
+                        this.loginOther(response, params)
+                      }
+                    })
+                  } else {
+                    this.loginOther(response, params, 3000)
+                  }
+                } else {
+                  let userUU = response.data.content.userUU
+                  window.location.href = `/overRegister/${userUU}`
+                }
+              } else if (response.data.error) {
+                this.$toast({
+                  message: response.data.errMsg,
+                  iconClass: 'el-icon-error'
+                })
+              }
+            }).catch((err) => {
+              this.$indicator.close()
+              this.downToast(err.errMsg)
+            })
+        }
+      },
+      // 提交注册流程
+      allSubmit () {
+        if (this.speediness) {
+          this.waySubmit()
+        } else {
+          this.submit()
+        }
+      },
       getJsonp: function (url, timeout = 500) {
         return new Promise((resolve, reject) => {
           this.$jsonp(url, {
@@ -397,3 +488,28 @@
   }
 </script>
 
+<style type="text/scss" scoped lang="scss">
+  .content-tab{
+    width: 360px;
+    margin: 0 auto;
+    height: 50px;
+    margin-top: 15px;
+    color: #999;
+    span{
+      display:inline-block;
+      width:50%;
+      vertical-align:top;
+      font-size:20px;
+      text-align: center;
+      line-height:40px;
+      height:40px;
+      border-bottom:2px solid #fff;
+      cursor:pointer;
+      &.speed{
+         color:#3375a7;
+         border-bottom:2px solid #3375a7;
+       }
+    }
+  }
+</style>
+

+ 5 - 3
components/register/PersonalRegistration.vue

@@ -387,9 +387,11 @@
     methods: {
       // 切换注册方式
       clickWay (type) {
-        this.speediness = type
-        this.ImgCode = ''
-        this.$refs.item.resetFields()
+        if (this.speediness !== type) {
+          this.speediness = type
+          this.ImgCode = ''
+          this.$refs.item.resetFields()
+        }
       },
       // 获取链接
       getUrl () {