| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- <template>
- <div class="f-main">
- <div class="content-top">
- <p>个人注册</p>
- <a class="go" href="/register/enterpriseRegistration"><i class="fa fa-long-arrow-right"></i>企业注册</a>
- </div>
- <div class="f-form">
- <div class="page-part">
- <mt-field :state="state.vipName"
- placeholder="会员名"
- v-model="vipName"
- @blur.native.capture="codeVipName" ></mt-field>
- </div>
- <div class="page-part">
- <mt-field :state="state.password"
- placeholder="密码"
- :attr="{ maxlength: 20 }"
- v-model="password"
- @input.native="codePwd"
- type="password"
- @blur.native.capture="codePwdBlur"></mt-field>
- <template v-if="password">
- <p class="pwd">密码强度 <em :class="{sm:step === '弱', md: step === '中', ld:step === '强'}"></em> <em :class="{md: step === '中', ld:step === '强'}"></em> <em :class="{ld:step === '强'}"></em> <span :class="{smstep:step === '弱', mdstep: step === '中', ldstep:step === '强'}" v-text="step">强</span></p>
- <p class="pwd">密码须为8-20字符的英文、数字混合</p>
- </template>
- </div>
- <div class="page-part">
- <mt-field :state="state.confirm"
- placeholder="确认密码"
- v-model="confirm"
- type="password"
- @blur.native.capture="codePassword"></mt-field>
- </div>
- <div class="page-part">
- <mt-field :state="state.mobile"
- placeholder="手机号码"
- v-model="mobile"
- type="tel"
- @blur.native.capture="codeMobile"></mt-field>
- </div>
- <div class="page-part">
- <mt-field :state="state.token"
- placeholder="短信验证码"
- v-model="token"
- @blur.native.capture="codeToken"
- auto-complete="off">
- <span class="token" v-text="tokenText" @click="getCheckCode">获取验证码</span>
- </mt-field>
- </div>
- </div>
- <div class="form-btn">
- <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>
- </div>
- </div>
- </template>
- <script>
- export default {
- name: 'registerPerson',
- data () {
- return {
- step: 1,
- state: {
- vipName: 'error',
- password: 'error',
- confirm: 'error',
- mobile: 'error',
- token: 'error'
- },
- vipName: '',
- password: '',
- confirm: '',
- mobile: '',
- token: '',
- tokenCode: '',
- tokenText: '获取验证码',
- tokenTime: '60',
- checked: true
- }
- },
- methods: {
- // 验证弹窗
- downToast (type) {
- this.$toast({
- message: type,
- iconClass: 'el-icon-warning'
- })
- },
- // 验证会员名
- codeVipName () {
- let count = this.vipName.length
- if (count === 0) {
- this.downToast('会员名不能为空')
- this.state.vipName = 'error'
- } else if (count < 2 || count > 20) {
- this.downToast('请填写合适的会员名称,2~20个字符')
- this.state.vipName = 'warning'
- } else {
- this.state.vipName = 'success'
- }
- },
- // 验证密码强度
- codePwd () {
- 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]))).*$/
- let count = this.password.length
- if (count >= 20) {
- this.downToast('密码须为8-20字符的英文、数字混合')
- } else {
- if (reg1.test(this.password)) {
- this.step = '强'
- } else if (reg2.test(this.password)) {
- this.step = '中'
- } else {
- this.step = '弱'
- }
- }
- },
- // 验证密码格式
- codePwdBlur () {
- let reg2 = /^(?=.{8,20})(((?=.*[0-9])(?=.*[a-z]))|((?=.*[0-9])(?=.*[A-Z]))).*$/
- if (!this.password) {
- this.downToast('请输入密码')
- this.state.password = 'error'
- } else if (!reg2.test(this.password)) {
- this.downToast('密码须为8-20字符的英文、数字混合')
- this.state.password = 'warning'
- } else {
- this.state.password = 'success'
- if (this.confirm) {
- this.codePassword()
- }
- }
- },
- // 验证密码的确认信息
- codePassword () {
- if (!this.confirm) {
- this.downToast('请再次输入密码')
- this.state.confirm = 'error'
- } else if (this.confirm !== this.password) {
- this.downToast('两次输入密码不一致!')
- this.state.confirm = 'warning'
- } else {
- this.state.confirm = 'success'
- }
- },
- // 验证手机号
- codeMobile () {
- let reg = /^1([0-9]{10})$/
- if (!this.mobile) {
- this.downToast('请输入手机号')
- this.state.mobile = 'error'
- } else if (!reg.test(this.mobile)) {
- this.downToast('请填写正确的手机号码')
- this.state.mobile = 'warning'
- } else {
- this.$http.get(`/api/user/checkMobile`, {params: {mobile: this.mobile, mobileArea: ''}})
- .then(response => {
- if (response.data.hasRegister) {
- this.downToast('该手机号已被注册,可直接登录')
- this.state.mobile = 'warning'
- } else {
- this.state.mobile = 'success'
- }
- }).catch(() => {
- this.downToast('请检查网络是否正常或联系服务商')
- })
- }
- },
- // 验证-验证码信息
- codeToken () {
- if (!this.token) {
- this.downToast('请先填写验证码')
- this.state.token = 'error'
- } else {
- if (!this.mobile) {
- this.downToast('请先填写正确的手机号码')
- this.state.token = 'warning'
- } else {
- if (this.tokenCode) {
- let param = new FormData()
- param.append('mobile', this.mobile)
- param.append('token', this.tokenCode)
- param.append('code', this.token)
- let config = {
- headers: {'Content-Type': 'multipart/form-data'}
- }
- this.$http.post('/sso/personal/register/checkCode', param, config)
- .then(response => {
- if (response.data.success) {
- this.state.token = 'success'
- } else {
- this.$toast({
- message: response.data.errMsg,
- iconClass: 'el-icon-error'
- })
- }
- }).catch(() => {
- this.downToast('请检查网络是否正常或联系服务商')
- })
- } else {
- this.downToast('请点击先获取验证码信息')
- this.state.token = 'warning'
- }
- }
- }
- },
- // 获取验证码
- getCheckCode () {
- if (this.tokenTime > 0 && this.tokenTime < 60) {
- this.downToast('请稍后再点击,我在倒计时')
- } else {
- if (this.state.mobile !== 'success') {
- this.downToast('请先输入正确的手机号')
- } else {
- this.$indicator.open('获取中...')
- let _this = this
- this.$http.get('/sso/personal/register/checkCode', {params: {mobile: this.mobile}})
- .then(response => {
- this.$indicator.close()
- if (response.data) {
- this.tokenCode = response.data.token
- this.$toast({
- message: '验证码已经发送到您的手机,请注意查收',
- iconClass: 'el-icon-success'
- })
- this.tokenText = '已发送(' + this.tokenTime + 'S)'
- let setTime = setInterval(() => {
- _this.tokenTime--
- this.tokenText = '已发送(' + this.tokenTime + 'S)'
- if (this.tokenTime <= 0) {
- clearInterval(setTime)
- _this.tokenText = '获取验证码'
- _this.tokenTime = 60
- }
- }, 1000)
- }
- }).catch(() => {
- this.$indicator.close()
- this.downToast('请检查网络是否正常或联系服务商')
- })
- }
- }
- },
- // 表单提交
- submit () {
- if (this.state.vipName !== 'success' &&
- this.state.password !== 'success' &&
- this.state.confirm !== 'success' &&
- this.state.mobile !== 'success' &&
- this.state.token !== 'success') {
- this.downToast('请确认填写部分是否有误')
- } else if (this.checked === false) {
- this.downToast('您对阅读条款未做勾选')
- } else {
- this.$indicator.open('注册中...')
- let param = new FormData()
- param.append('vipName', this.vipName)
- param.append('password', this.password)
- 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)
- let config = {
- header: {'Content-Type': 'multipart/form-data'}
- }
- this.$http.post('/sso/personal/register', param, config)
- .then(response => {
- this.$indicator.close()
- if (response.data.success) {
- 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(() => {
- this.$indicator.close()
- this.downToast('请检查网络是否正常或联系服务商')
- })
- }
- }
- }
- }
- </script>
|