huangb 7 éve
szülő
commit
5893a0222d

+ 1 - 1
components/main/Header.vue

@@ -22,7 +22,7 @@
         <!--立即入驻 新手指南-->
         <div class="header-count pull-right">
           <!--立即入驻-->
-          <a class="enter enter02" @click="goStoreApply()">
+          <a  class="enter enter02" href="/businessEnter">
             <img src="/images/all/goInto.png"/>
           </a>
           <!--新手指南-->

+ 364 - 73
pages/businessEnter/index.vue

@@ -29,7 +29,7 @@
                   <div class="valid-code">
                     <input type="text"
                            v-model="enterprise.ImgCode">
-                    <img id="captchaImage2" :src="`${address}/sso/login/checkCode`" alt="">
+                    <img id="captchaImage2" alt="">
                     <span @click="getImgCode">看不清换一张</span>
                   </div>
                   <div class="valid-btn">
@@ -39,7 +39,7 @@
                   <button class="code-btn"
                           slot="reference"
                           v-show="sendEnterpriseCode"
-                          :disabled="mobileChecked">获取验证码</button>
+                          :disabled="!mobileChecked">获取验证码</button>
                 </el-popover>
               </template>
               <button class="code-btn" v-show="!sendEnterpriseCode">已发送({{enterprise_time}}s)</button>
@@ -86,55 +86,61 @@
                      @blur="checkVipName(enterprise.vipName)"/>
               <span class="help-list" v-text="vipNameErrMsg"></span>
             </div>
-            <div class="form-group">
-              <input type="text" class="form-control"
+            <div class="form-group" v-if="!isHasRegister">
+              <input type="password" class="form-control"
                      placeholder="登录密码"
                      v-model="enterprise.password"
                      maxlength="20"
+                     :class="{'err': !passwordChecked}"
                      @blur="checkPassword(enterprise.password)"
-                     @change="passwordStrength(enterprise.password)"/>
-              <span class="help-list" v-text="mobileErrMsg"></span>
+                     @input="passwordStrength(enterprise.password)"/>
+              <span class="help-list" v-text="passwordErrMsg"></span>
             </div>
-            <div class="pwd" v-if="!isHasRegister"
-                 :class="{sm: strength === '弱', md: strength === '中', lar: strength === '强', low: strength === ''}">
-                 密码强度 <em></em><em></em><em></em>
-              <span v-text="strength === '弱' ? '弱' : strength === '中' ? '中' : strength === '强' ? '强' : ''">弱</span>
+            <div v-if="enterprise.password">
+              <div class="pwd" v-if="!isHasRegister"
+                   :class="{sm: strength === '弱', md: strength === '中', lar: strength === '强', low: strength === ''}">
+                密码强度 <em></em><em></em><em></em>
+                <span v-text="strength === '弱' ? '弱' : strength === '中' ? '中' : strength === '强' ? '强' : ''">弱</span>
+              </div>
             </div>
             <div class="form-group" v-if="isHasRegister">
-              <input type="text" class="form-control"
+              <input type="password" class="form-control"
                      placeholder="密码确认"
                      v-model="enterprise.password"
                      maxlength="20"
+                     :class="{'err': !passwordChecked}"
                      @blur="checkRegisterPassword(enterprise.password)"/>
               <span class="help-list" v-text="phoneIsRegisterTip"></span>
             </div>
             <div class="form-group" v-if="!isHasRegister">
-              <input type="text" class="form-control"
+              <input type="password" class="form-control"
                      placeholder="密码确认"
                      v-model="enterprise.confirm"
                      maxlength="20"
+                     :class="{'err': !passwordConfirmChecked}"
                      @blur="checkConfirm(enterprise.confirm)"/>
-              <span class="help-list" v-text="mobileErrMsg"></span>
+              <span class="help-list" v-text="confirmErrMsg"></span>
             </div>
             <div class="form-group" v-if="!isHasEmail">
               <input type="text" class="form-control"
                      placeholder="联系邮箱"
                      v-model="enterprise.email"
                      maxlength="20"
+                     :class="{'err': !emailChecked}"
                      @blur="checkEmail(enterprise.email)"/>
-              <span class="help-list" v-text="mobileErrMsg"></span>
+              <span class="help-list" v-text="emailErrMsg"></span>
             </div>
             <div class="form-group">
               <label class="check-box-wrap">
                 <input type="checkbox"
                        id="check-boxes"
-                       v-model="isRead"
-                       :checked="isRead">
+                       v-model="isReads"
+                       :checked="isReads">
                 <label class="agr" for="check-box">我已阅读并同意<a :href="`${address}/common/agreement`" target="_blank">《优软云服务条款》</a></label>
               </label>
             </div>
             <div class="form-group">
-              <span class="next-btn" @click="nextStep">确认注册</span>
+              <span class="next-btn" @click="sureRegister">确认注册</span>
             </div>
           </div>
         </div>
@@ -172,16 +178,23 @@
           confirm: '',
           email: ''
         },
+        imageCode: `${this.address}/sso/login/checkCode`,
         mobileErrMsg: '一个手机可注册多个企业',
         codeErrMsg: '',
         spaceNameErrMsg: '',
         businessCodeErrMsg: '',
         vipNameErrMsg: '',
-        mobileChecked: true,
+        passwordErrMsg: '',
+        confirmErrMsg: '',
+        emailErrMsg: '',
+        mobileChecked: false,
         codeChecked: false,
         spaceNameChecked: false,
         businessCodeChecked: false,
         vipNameChecked: false,
+        passwordChecked: false,
+        passwordConfirmChecked: false,
+        emailChecked: true,
         showLoading: false,
         visible: false,
         address: '',
@@ -189,17 +202,18 @@
         token: '',
         enterprise_time: 0,
         isRead: true,
+        isReads: true,
         isHasRegister: false,
         isHasEmail: false,
-        goNextStep: false,
+        goNextStep: true,
         phoneIsRegisterTip: '该手机号已有优软账号,请输入原账号的登录密码进行校验确认',
         strength: ''
       }
     },
     mounted () {
       this.$nextTick(() => {
-        this.getImgCode()
         this.getAddress()
+        this.getImgCode()
       })
     },
     methods: {
@@ -214,15 +228,15 @@
       checkMobile (flg) {
         let reg = /^1[0-9]{10}$/
         if (flg === '' && !flg) {
-          this.mobileChecked = true
+          this.mobileChecked = false
           this.mobileErrMsg = '请填写正确的手机号'
         } else {
           if (!reg.test(flg)) {
-            this.mobileChecked = true
+            this.mobileChecked = false
             this.mobileErrMsg = '请填写正确的手机号'
           } else {
             this.mobileErrMsg = ''
-            this.mobileChecked = false
+            this.mobileChecked = true
           }
         }
       },
@@ -235,7 +249,7 @@
       },
       getCode () {
         this.showLoading = true
-        if (!this.mobileChecked) {
+        if (this.mobileChecked) {
           this.$http.get(`${this.address}/sso/userspace/register/checkCode`, {params: {mobile: this.enterprise.mobile, timestamp: new Date().getTime() + '', code: this.enterprise.ImgCode}})
             .then(response => {
               this.showLoading = false
@@ -320,47 +334,54 @@
         }
       },
       nextStep () {
-        if (this.mobileChecked && !this.codeChecked) {
-          this.checkMobile(this.enterprise.mobile)
-          this.checkMsgCode(this.enterprise.code)
-        } else {
-          if(!this.isRead) {
-            this.$message.error('您对阅读条款未做勾选')
-          } else {
-            this.showLoading = true
-            let param = new FormData()
-            param.append('mobile', this.enterprise.mobile)
-            param.append('code', this.enterprise.code)
-            param.append('appId', 'mall')
-            param.append('token', this.token)
-            let config = {
-              headers: {'Content-Type': 'multipart/form-data'}
-            }
-            this.$http.post(`${this.address}/sso/userspace/register/checkAdminTel`, param, config)
-              .then(response => {
-                this.showLoading = false
-                if (response.data.success) {
-                  this.goNextStep = false
-                  if (response.data.content.hasRegister) {
-                    this.isHasRegister = true
-                    if (response.data.content.hasEmail) {
-                      this.isHasEmail = true
-                    } else {
-                      this.isHasEmail = false
-                    }
+        if (this.mobileChecked && this.codeChecked && this.isRead) {
+          this.showLoading = true
+          let param = new FormData()
+          param.append('mobile', this.enterprise.mobile)
+          param.append('code', this.enterprise.code)
+          param.append('appId', 'mall')
+          param.append('token', this.token)
+          let config = {
+            headers: {'Content-Type': 'multipart/form-data'}
+          }
+          this.$http.post(`${this.address}/sso/userspace/register/checkAdminTel`, param, config)
+            .then(response => {
+              this.showLoading = false
+              if (response.data.success) {
+                this.goNextStep = false
+                if (response.data.content.hasRegister) {
+                  this.isHasRegister = true
+                  if (response.data.content.hasEmail) {
+                    this.isHasEmail = true
                   } else {
-                    this.isHasRegister = false
                     this.isHasEmail = false
                   }
                 } else {
-                  this.goNextStep = true
-                  return Promise.reject(response.data)
+                  this.isHasRegister = false
+                  this.isHasEmail = false
                 }
-              }).catch(err => {
-                this.$message.error(err.errMsg)
-                this.showLoading = false
-                this.enterprise_time = 0
-              })
+              } else {
+                this.goNextStep = true
+                return Promise.reject(response.data)
+              }
+            }).catch(err => {
+            this.$message.error(err.errMsg)
+            this.showLoading = false
+            this.enterprise_time = 0
+          })
+        } else {
+          if (!this.enterprise.mobile) {
+            this.$message.error('手机号不能为空')
+          } else if (!this.mobileChecked) {
+            this.$message.error('手机号输入有误,请按提示重新输入')
+          } else if (!this.token) {
+            this.$message.error('请先获取验证码')
+          } else if (!this.enterprise.code) {
+            this.$message.error('验证码不能为空')
+          } else if (!this.codeChecked) {
+            this.$message.error('验证码输入有误,请按提示重新输入')
+          } else if (!this.isRead) {
+            this.$message.error('您对阅读条款未做勾选')
           }
         }
       },
@@ -393,7 +414,7 @@
             this.businessCodeErrMsg = '请填写正确的营业执照号'
             this.businessCodeChecked = false
           } else {
-            this.$http.get(`${this.address}/api/userspace/checkBusinessCode`, {params: {spaceName: this.enterprise.businessCode}})
+            this.$http.get(`${this.address}/api/userspace/checkBusinessCode`, {params: {businessCode: this.enterprise.businessCode}})
               .then(response => {
                 if (response.data.success) {
                   this.businessCodeChecked = true
@@ -422,20 +443,289 @@
         }
       },
       passwordStrength (flg) {
+        console.log(flg)
         let reg1 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]))|((?=.*[0-9])((?=.*[a-zA-Z]))(?=.*[^a-zA-Z0-9]))).*$/
         let reg2 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/
-        if (reg1.test(flg)) {
-          this.strength = '强'
-        } else if (reg2.test(flg)) {
-          this.strength = '中'
+        if (flg.length <= 20 && flg.length >= 8) {
+          if (reg1.test(flg)) {
+            this.strength = '强'
+          } else if (reg2.test(flg)) {
+            this.strength = '中'
+          } else {
+            this.strength = '弱'
+          }
         } else {
-          this.strength = '弱'
+          this.strength = ''
         }
       },
-      checkPassword (flg) {},
-      checkRegisterPassword (flg) {},
-      checkConfirm (flg) {},
-      checkEmail (flg) {}
+      checkPassword (flg) {
+        if (!flg && flg === '') {
+          this.passwordErrMsg = '请输入密码'
+        } else {
+          if (flg.length <= 20 && flg.length >= 8) {
+            let reg1 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]))|((?=.*[0-9])((?=.*[a-zA-Z]))(?=.*[^a-zA-Z0-9]))).*$/
+            let reg2 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/
+            if (reg1.test(flg)) {
+              this.passwordChecked = true
+              this.passwordErrMsg = ''
+            } else if (reg2.test(flg)) {
+              this.passwordChecked = true
+              this.passwordErrMsg = ''
+            } else {
+              this.passwordErrMsg = '密码强度弱'
+              this.passwordChecked = false
+            }
+          } else {
+            this.passwordErrMsg = '密码须为8-20字符的英文、数字混合'
+            this.passwordChecked = false
+          }
+        }
+      },
+      checkRegisterPassword (flg) {
+        if (this.isHasRegister) {
+          if (!flg && flg === '') {
+            this.phoneIsRegisterTip = '请输入密码'
+            this.passwordChecked = false
+          } else {
+            this.passwordChecked = true
+            this.phoneIsRegisterTip = ''
+          }
+        } else {
+          if (!flg && flg === '') {
+            this.phoneIsRegisterTip = '请输入密码'
+            this.passwordChecked = false
+          } else {
+            if (flg.length <= 20 && flg.length >= 8) {
+              let reg1 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]))|((?=.*[0-9])((?=.*[a-zA-Z]))(?=.*[^a-zA-Z0-9]))).*$/
+              let reg2 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/
+              if (reg1.test(flg)) {
+                this.passwordChecked = true
+              } else if (reg2.test(flg)) {
+                this.passwordChecked = true
+              } else {
+                this.phoneIsRegisterTip = '密码须为8-20字符的英文、数字混合'
+                this.passwordChecked = false
+              }
+            } else {
+              this.phoneIsRegisterTip = '密码须为8-20字符的英文、数字混合'
+              this.passwordChecked = false
+            }
+            if (this.enterprise.confirm && this.enterprise.confirm !== '') {
+              if (flg !== this.enterprise.confirm) {
+                this.phoneIsRegisterTip = '两次输入密码不一致!'
+                this.passwordConfirmChecked = false
+              } else {
+                this.passwordConfirmChecked = true
+                this.phoneIsRegisterTip = ''
+              }
+            }
+          }
+        }
+      },
+      checkConfirm (flg) {
+        if (this.isHasRegister) {
+          this.passwordConfirmChecked = true
+        } else {
+          if (!flg && flg === '') {
+            this.confirmErrMsg = '请再次输入密码'
+            this.passwordConfirmChecked = false
+          } else if (flg !== this.enterprise.password) {
+            this.confirmErrMsg = '两次输入密码不一致!'
+            this.passwordConfirmChecked = false
+          } else {
+            this.passwordConfirmChecked = true
+            this.confirmErrMsg = ''
+          }
+        }
+      },
+      checkEmail (flg) {
+        if (this.isHasEmail) {
+          this.emailChecked = true
+          this.emailErrMsg = ''
+        } else {
+          if (flg) {
+            let reg = /^([\w-])+(\.\w+)*@([\w-])+((\.\w{2,3}){1,3})$/
+            if (!reg.test(flg)) {
+              this.emailErrMsg = '请输入正确的邮箱地址格式'
+              this.emailChecked = false
+            } else {
+              this.$http.get(`${this.address}/api/user/checkEmail`, {params: {email: this.enterprise.email}})
+                .then(response => {
+                  if (response.data.hasRegister) {
+                    this.emailChecked = false
+                    this.emailErrMsg = '该邮箱已被注册'
+                  } else {
+                    this.emailChecked = true
+                    this.emailErrMsg = ''
+                    return Promise.reject(response.data)
+                  }
+                }).catch(err => {
+                  this.$message.error(err.errMsg)
+                })
+            }
+          } else {
+            this.emailChecked = true
+            this.emailErrMsg = ''
+          }
+        }
+      },
+      sureRegister () {
+        if (!this.isHasRegister) {
+          if (this.spaceNameChecked && this.businessCodeChecked && this.vipNameChecked && this.passwordChecked && this.passwordConfirmChecked && this.emailChecked && this.isReads) {
+            this.submitRegister()
+          } else {
+            if (!this.enterprise.spaceName) {
+              this.$message.error('企业名不能为空')
+            } else if (!this.spaceNameChecked) {
+              this.$message.error('企业名称输入有误,请按提示重新输入')
+            } else if (!this.enterprise.businessCode) {
+              this.$message.error('营业执照号不能为空')
+            } else if (!this.businessCodeChecked) {
+              this.$message.error('营业执照号输入有误,请按提示重新输入')
+            } else if (!this.enterprise.vipName) {
+              this.$message.error('管理员姓名不能为空')
+            } else if (!this.vipNameChecked) {
+              this.$message.error('管理员姓名输入有误,请按提示重新输入')
+            } else if (!this.enterprise.password) {
+              this.$message.error('密码不能为空')
+            } else if (!this.passwordChecked) {
+              this.$message.error('密码输入有误,请按提示重新输入')
+            } else if (!this.enterprise.confirm) {
+              this.$message.error('请再次输入密码')
+            } else if (this.enterprise.password !== this.enterprise.confirm) {
+              this.$message.error('请确认两次填写密码是否一致')
+            } else if (this.enterprise.email && !this.emailChecked) {
+              this.$message.error('邮箱输入有误,请按提示重新输入')
+            } else if (!this.isReads) {
+              this.$message.error('您对阅读条款未做勾选')
+            }
+          }
+        } else {
+          if (this.isHasEmail) {
+            if (this.spaceNameChecked && this.businessCodeChecked && this.passwordChecked && this.isReads) {
+              this.submitRegister()
+            } else {
+              if (!this.enterprise.spaceName) {
+                this.$message.error('企业名不能为空')
+              } else if (!this.spaceNameChecked) {
+                this.$message.error('企业名称输入有误,请按提示重新输入')
+              } else if (!this.enterprise.businessCode) {
+                this.$message.error('营业执照号不能为空')
+              } else if (!this.businessCodeChecked) {
+                this.$message.error('营业执照号输入有误,请按提示重新输入')
+              } else if (!this.enterprise.password) {
+                this.$message.error('密码不能为空')
+              } else if (!this.isReads) {
+                this.$message.error('您对阅读条款未做勾选')
+              }
+            }
+          } else {
+            if (this.spaceNameChecked && this.businessCodeChecked && this.passwordChecked && this.emailChecked && this.isReads) {
+              this.submitRegister()
+            } else {
+              if (!this.enterprise.spaceName) {
+                this.$message.error('企业名不能为空')
+              } else if (!this.spaceNameChecked) {
+                this.$message.error('企业名称输入有误,请按提示重新输入')
+              } else if (!this.enterprise.businessCode) {
+                this.$message.error('营业执照号不能为空')
+              } else if (!this.businessCodeChecked) {
+                this.$message.error('营业执照号输入有误,请按提示重新输入')
+              } else if (!this.enterprise.password) {
+                this.$message.error('密码不能为空')
+              } else if (this.enterprise.email && !this.emailChecked) {
+                this.$message.error('邮箱输入有误,请按提示重新输入')
+              } else if (!this.isReads) {
+                this.$message.error('您对阅读条款未做勾选')
+              }
+            }
+          }
+        }
+      },
+      submitRegister () {
+        this.showLoading = true
+        let param = new FormData()
+        param.append('spaceName', this.enterprise.spaceName)
+        param.append('businessCode', this.enterprise.businessCode)
+        param.append('vipName', this.enterprise.vipName || '')
+        param.append('password', this.enterprise.password)
+        param.append('email', this.enterprise.email || '')
+        param.append('appId', 'mall')
+        param.append('returnUrl', window.location.origin)
+        param.append('t', '')
+        let config = {
+          headers: {'Content-Type': 'multipart/form-data'}
+        }
+        this.$http.post(`${this.address}/sso/userspace/register`, param, config)
+          .then(response => {
+            this.showLoading = false
+            if (response.data.success) {
+              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.showLoading = true
+              response.data.content.currentUrl = window.location.hash + '/newLogin/other'
+              this.$jsonp(`${response.data.content.currentUrl}?${params}`, {
+                name: 'successCallback',
+                timeout: 3000
+              }, (err, data) => {
+                if (err) {
+                  this.$message.error('注册成功,返回首页完成登录')
+                  this.showLoading = false
+                  throw err
+                } else {
+                  this.loginOther(response, params)
+                }
+              })
+            } else {
+              return Promise.reject(response.data)
+            }
+          }).catch(err => {
+            this.showLoading = false
+            this.$message.error(err.errMsg)
+          })
+      },
+      getJsonp: function (url, timeout = 500) {
+        return new Promise((resolve, reject) => {
+          this.$jsonp(url, {
+            name: 'successCallback',
+            timeout: timeout
+          }, function (err, data) {
+            if (err) {
+              reject(err)
+              throw err
+            } else {
+              resolve(data)
+            }
+          })
+        })
+      },
+      crossAfter (url) {
+        try {
+          console.log(url, 'url')
+          window.location.href = url
+        } catch (err) {
+          console.log(err)
+        }
+      },
+      loginOther (response, a, timeout) {
+        const crossAfter = this.crossAfter
+        let promises = []
+        for (let i in response.data.content.loginUrls) {
+          if (response.data.content.currentUrl !== response.data.content.loginUrls[i]) {
+            promises.push(this.getJsonp(`${response.data.content.loginUrls[i]}?${a}`))
+          }
+        }
+        let returnUrl = decodeURIComponent(window.location.origin)
+        Promise.all(promises).then(() => {
+          crossAfter(returnUrl, timeout)
+        }).catch(() => {
+          crossAfter(returnUrl, timeout)
+        })
+      }
     }
   }
 </script>
@@ -525,9 +815,9 @@
             input.code{
               width: 208px;
             }
-            input.err{
-              border-color: #f56c6c;
-            }
+            /*input.err{*/
+              /*border-color: #f56c6c;*/
+            /*}*/
             .code-btn{
               float: left;
               margin-left: 10px;
@@ -586,6 +876,7 @@
               color: #3d00ff;
               background-color: #ffffff;
               border-radius: 5px;
+              cursor: pointer;
             }
             &:first-child {
               margin-bottom: 14px;

BIN
static/images/bussinessEnter/banner02.png