register.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <div class="register">
  3. <div class="r-header">
  4. <div class="content">
  5. <nuxt-link to="/" class="logo">
  6. <!--<span class="img"></span>-->
  7. <img class="img" v-if="webConfigData.pcLogoImgText" :src="webConfigData.pcLogoImgText"/>
  8. <!--<span class="text">蓝海创新科技</span>-->
  9. </nuxt-link>
  10. <div class="go-login">
  11. {{$t('register.haveAnAccount')}}
  12. <nuxt-link to="/login" class="login-btn">{{$t('register.goToLogin')}}</nuxt-link>
  13. </div>
  14. </div>
  15. </div>
  16. <!-- 第一步 -->
  17. <div class="r-con" v-if="registerStep==1"
  18. :style="{margin:$t('language')=='en'?'80px auto':'100px auto'}"
  19. >
  20. <div class="steps">
  21. <div :class="['item', registerStep==1?'active':'']">
  22. <div class="number">1</div>
  23. <div class="text">{{$t('register.verifyCellPhoneNumber')}}</div>
  24. </div>
  25. <div class="item">
  26. <div class="number">2</div>
  27. <div class="text">{{$t('register.fillInTheAccountInformation')}}</div>
  28. </div>
  29. <div class="item">
  30. <div class="number">3</div>
  31. <div class="text">{{$t('register.completeRegistration')}}</div>
  32. </div>
  33. </div>
  34. <div class="con-box">
  35. <div :class="['item',errorTips==1? 'error':'']">
  36. <div class="input-box phone">
  37. <span class="ic">+86</span>
  38. <input type="text" class="input" v-model="mobile" :placeholder="$t('login.enterUserNumber')" maxlength="11"/>
  39. </div>
  40. <div class="error-text" v-if="errorTips==1">{{$t('register.enterValidPhone')}}</div>
  41. </div>
  42. <div :class="['item',errorTips==2? 'error':'']">
  43. <div class="input-box code">
  44. <input type="text" class="input" v-model="validCode" :placeholder="$t('login.enterCode')" />
  45. <a href="javascript:void(0)" class="send-code" v-show="show" @click="getCode">{{$t('login.getCode')}}</a>
  46. <a
  47. href="javascript:void(0)"
  48. v-show="!show"
  49. class="send-code"
  50. style="cursor: not-allowed;"
  51. >{{count}} s</a>
  52. </div>
  53. <div class="error-text" v-if="errorTips==2">{{$t('login.enterCode')}}</div>
  54. </div>
  55. <div class="item agree">
  56. <!-- <input
  57. type="checkbox"
  58. @click="checkAgree"
  59. :class="['checkbox',isAgree?'checked': 'default']"
  60. class="checkbox default"
  61. style="margin-right:10px"
  62. /> -->
  63. <span class="text" v-if="serviceTermsSwitch || privacyPolicySwitch">
  64. {{$t('login.consentOfRegisteredRepresentative')}}
  65. <a href="javaScript:void(0)" class="agreement" @click="toTermsPage(0)" v-if="serviceTermsSwitch">{{$t('login.termsOfService')}}</a>
  66. <span v-if="privacyPolicySwitch && serviceTermsSwitch">{{$t('login.and')}}</span>
  67. <a href="javaScript:void(0)" class="agreement" @click="toTermsPage(1)" v-if="privacyPolicySwitch">{{$t('login.privacyPolicy')}}</a>
  68. </span>
  69. </div>
  70. <span class="next" @click="registerNext">{{$t('register.nextStep')}}</span>
  71. </div>
  72. </div>
  73. <!-- /第一步 -->
  74. <!-- 第二步 -->
  75. <div class="r-con" v-if="registerStep==2"
  76. :style="{margin:$t('language')=='en'?'80px auto':'100px auto'}"
  77. >
  78. <div class="steps">
  79. <div class="item active">
  80. <div class="number">1</div>
  81. <div class="text">{{$t('register.verifyCellPhoneNumber')}}</div>
  82. </div>
  83. <div :class="['item', registerStep==2?'active':'']">
  84. <div class="number">2</div>
  85. <div class="text">{{$t('register.fillInTheAccountInformation')}}</div>
  86. </div>
  87. <div class="item">
  88. <div class="number">3</div>
  89. <div class="text">{{$t('register.completeRegistration')}}</div>
  90. </div>
  91. </div>
  92. <div class="con-box">
  93. <div :class="['item',errorTips==8? 'error':'']">
  94. <div class="input-box">
  95. <input type="text" class="input" v-model="nickName" :placeholder="$t('register.pleaseSetNickName')" />
  96. </div>
  97. <div class="error-text" v-if="errorTips==8">{{$t('register.pleaseSetNickName')}}</div>
  98. </div>
  99. <div :class="['item',errorTips==3? 'error':'']">
  100. <div class="input-box">
  101. <input type="text" class="input" v-model="userName" :placeholder="$t('register.pleaseSetAccount')" />
  102. </div>
  103. <div class="error-text" v-if="errorTips==3">{{$t('register.setAccountNumberTips')}}</div>
  104. </div>
  105. <div :class="['item',errorTips==4 || errorTips==7? 'error':'']">
  106. <div class="input-box">
  107. <input type="password" class="input" v-model="password" :placeholder="$t('register.pleaseSetYourPassword')" />
  108. </div>
  109. <div class="error-text" v-if="errorTips==4">{{$t('login.enterPassword')}}</div>
  110. <div class="error-text" v-if="errorTips==7">{{$t('register.passwordVerification')}}</div>
  111. </div>
  112. <div :class="['item',errorTips==5? 'error':'']">
  113. <div class="input-box">
  114. <input type="password" class="input" v-model="confirmPwd" :placeholder="$t('register.enterThePasswordAgain')" />
  115. </div>
  116. <div class="error-text" v-if="errorTips==5">{{$t('ucPassword.enterNewPasswordTips5')}}</div>
  117. </div>
  118. <span class="next" @click="registerNext">{{$t('register.nextStep')}}</span>
  119. </div>
  120. </div>
  121. <!-- /第二步 -->
  122. <!-- 第三步 -->
  123. <div class="r-con" v-if="registerStep==3"
  124. :style="{margin:$t('language')=='en'?'80px auto':'100px auto'}"
  125. >
  126. <div class="con-box">
  127. <div class="register-success">
  128. <div class="img">
  129. <!-- <img src="~/assets/images/success.png" alt=""> -->
  130. </div>
  131. <div class="text">
  132. <div class="text-div">{{$t('register.registrationSuccessful')}}</div>
  133. <div class="text-span">
  134. {{$t('register.autoJumpToHome')}} <span style="color:blue">{{loCount}} s</span>
  135. </div>
  136. </div>
  137. </div>
  138. <nuxt-link to="/" class="next suc-btn">{{$t('commonHead.home')}}</nuxt-link>
  139. </div>
  140. </div>
  141. <!-- /第三步 -->
  142. <div class="content r-footer">
  143. <!-- <div class="links">
  144. <nuxt-link to="/" class="item">{{$t('ucPassword.mallHome')}}</nuxt-link>
  145. <nuxt-link to="/user-center" class="item" v-show="!this.$route.name==='register'">{{$t('commonHead.personalCenter')}}</nuxt-link>
  146. <a href='https://www.gz-yami.com/' target="_blank" class="item">{{$t('commonFoot.officialWebsite')}}</a>
  147. <a href="https://www.mall4j.com/" target="_blank" class="item">{{$t('commonFoot.openSourceWebsite')}}</a>
  148. </div> -->
  149. <div class="copyright">{{$t('language')=='zh'?webConfigData.pcCopyrightCn:webConfigData.pcCopyrightEn}}</div>
  150. <!--<div class="copyright">©Copyright 2018 广州市蓝海创新科技有限公司 版权所有 | 粤ICP备18115813号-1</div>-->
  151. </div>
  152. <!-- 登录弹窗组件 -->
  153. <LoginPopup v-if="showLogin" v-on:hideLoginPop="hideLoginPop" />
  154. <!-- /登录弹窗组件 -->
  155. </div>
  156. </template>
  157. <script>
  158. import util from '../plugins/util'
  159. import Cookie from 'js-cookie'
  160. import LoginPopup from '~/components/login-popup'
  161. import { encrypt } from '~/plugins/crypto.js'
  162. export default {
  163. components: {
  164. LoginPopup
  165. },
  166. layout: 'empty',
  167. data () {
  168. return {
  169. registerStep: 1, // 注册步骤
  170. errorTips: 0, // 输入错误提示: 1手机号输入错误 2验证码输入错误 3账号输入错误 4密码输入错误 5验证密码输入错误
  171. mobile: '',
  172. validCode: '',
  173. userName: '',
  174. nickName: '',
  175. password: '',
  176. confirmPwd: '',
  177. checkRegisterSmsFlag: '', // 校验登录注册验证码成功的标识
  178. isAgree: true,
  179. // 验证码相关
  180. show: true,
  181. count: '',
  182. timer: null,
  183. hadGotCode: false,
  184. // 登录弹窗
  185. showLogin: false,
  186. // 完成跳转首页倒计时
  187. loTimer: null,
  188. loCount: 0,
  189. webConfigData: {},// 网站配置信息
  190. serviceTermsSwitch: true,
  191. privacyPolicySwitch: true
  192. }
  193. },
  194. methods: {
  195. /**
  196. * 获取验证码
  197. */
  198. getCode () {
  199. if (!util.checkPhoneNumber(this.mobile)) {
  200. this.errorTips = 1
  201. return
  202. }
  203. if (this.hadGotCode) {
  204. return
  205. }
  206. // 判断值
  207. this.hadGotCode = true
  208. this.errorTips = 0
  209. let sendSmsParam = {
  210. mobile: this.mobile,
  211. }
  212. this.$axios.put('/user/sendRegisterSms', sendSmsParam).then(({ data }) => {
  213. const timeCount = 60;
  214. if (!this.timer) {
  215. this.count = timeCount;
  216. this.show = false;
  217. this.timer = setInterval(() => {
  218. if (this.count > 0 && this.count <= timeCount) {
  219. this.count--;
  220. } else {
  221. this.show = true;
  222. clearInterval(this.timer);
  223. this.timer = null;
  224. this.hadGotCode = false
  225. }
  226. }, 1000)
  227. }
  228. })
  229. //判断值
  230. this.hadGotCode = false
  231. },
  232. /**
  233. * 同意条款
  234. */
  235. checkAgree () {
  236. this.isAgree = !this.isAgree
  237. if (this.errorTips == 6) {
  238. this.errorTips = 0
  239. }
  240. },
  241. /**
  242. * 跳转到《服务条款》或《隐私协议》
  243. */
  244. toTermsPage (sts) {
  245. this.$router.push({ path: '/termsPage?sts=' + sts })
  246. },
  247. /**
  248. * 注册-下一步按钮
  249. */
  250. registerNext () {
  251. if (this.registerStep == 1) {
  252. if (!util.checkPhoneNumber(this.mobile)) {
  253. this.errorTips = 1
  254. return
  255. }
  256. else if (!this.validCode.trim()) {
  257. this.errorTips = 2
  258. return
  259. } else {
  260. this.errorTips = 0
  261. // 校验验证码
  262. let checkRegisterSmsParam = {
  263. mobile: this.mobile,
  264. validCode: this.validCode
  265. }
  266. this.$axios.put('/user/checkRegisterSms', checkRegisterSmsParam)
  267. .then(({ data }) => {
  268. this.checkRegisterSmsFlag = data
  269. this.registerStep += 1;
  270. })
  271. }
  272. // if(!this.isAgree){
  273. // this.$message.error('请同意服务条款和隐私策略')
  274. // this.registerStep == 1;
  275. // return
  276. // }
  277. } else if (this.registerStep == 2) {
  278. var reg = new RegExp("^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z\\W]{6,20}$");
  279. let result = reg.test(this.password);
  280. if (!this.nickName || !this.nickName.trim()) {
  281. this.errorTips = 8
  282. return
  283. }
  284. if (!util.checkUserName(this.userName)) {
  285. this.errorTips = 3
  286. return
  287. } else if (!this.password.trim()) {
  288. this.errorTips = 4
  289. return
  290. } else if(!result){
  291. this.errorTips = 7
  292. return
  293. }
  294. else if (this.password != this.confirmPwd) {
  295. this.errorTips = 5
  296. return
  297. } else {
  298. this.errorTips = 0
  299. // 请求注册
  300. let userRegisterParam = {
  301. checkRegisterSmsFlag: this.checkRegisterSmsFlag, // 校验登录注册验证码成功的标识
  302. mobile: this.mobile,
  303. userName: this.userName,
  304. nickName: this.nickName,
  305. password: encrypt(this.password),
  306. tempUid: ''
  307. }
  308. this.$axios.post('/user/register', userRegisterParam)
  309. .then(({ data }) => {
  310. this.registerStep += 1;
  311. Cookie.set('token', data.accessToken)
  312. setTimeout(() => {
  313. // window.location.pathname == '/register' ? this.$router.push({ path: '/' }) : window.location.reload();
  314. this.$router.push('/')
  315. }, 3000)
  316. const loTimeCount = 3;
  317. if (!this.loTimer) {
  318. this.loCount = loTimeCount;
  319. this.loTimer = setInterval(() => {
  320. if (this.loCount > 0 && this.loCount <= loTimeCount) {
  321. this.loCount--;
  322. } else {
  323. clearInterval(this.loTimer);
  324. this.loTimer = null;
  325. }
  326. }, 1000)
  327. }
  328. })
  329. }
  330. }
  331. },
  332. showLoginPopup () {
  333. this.showLogin = true
  334. },
  335. hideLoginPop () {
  336. this.showLogin = false
  337. },
  338. },
  339. mounted () {
  340. this.$axios.get('/webConfig/getPcWebConfig').then(({ data }) => {
  341. this.webConfigData = data
  342. localStorage.setItem('webConfig', JSON.stringify(data))
  343. })
  344. document.title = this.$t('register.registerAccount')
  345. this.$axios.get('/sys/config/info/getSysServiceSwitch').then(({ data }) => {
  346. this.serviceTermsSwitch = data.serviceTermsSwitch
  347. this.privacyPolicySwitch = data.privacyPolicySwitch
  348. })
  349. },
  350. watch: {
  351. mobile () {
  352. if (this.hadGotCode) {
  353. this.hadGotCode = false
  354. }
  355. }
  356. }
  357. }
  358. </script>
  359. <style scoped src='~/assets/css/register.css'></style>