register.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <view class="container">
  3. <view class="wjmm" style="text-align: right;padding-right: 30rpx;font-size: 36rpx;" @click="dl()">{{ $t('login.dl') }}</view>
  4. <view class="tit" style="padding-top:120rpx;">{{ $t('login.yx') }}</view>
  5. <input type="text" class="shuru" :placeholder="$t('login.qsryx')" v-model="email" />
  6. <view class="tit">{{ $t('login.yxyzm') }}</view>
  7. <view class="flex" style="width: 673rpx;justify-content: space-between;margin: auto;">
  8. <input type="text" class=" yzm" :placeholder="$t('login.qsryzm')" v-model="code" />
  9. <view class="code yzmbtn" @click="verification">{{ countDown == 0 ? $t('login.yzm') : countDown }}</view>
  10. </view>
  11. <view class="tit">{{ $t('login.mm') }}</view>
  12. <input type="password" class="shuru" :placeholder="$t('login.qsrmm')" v-model="lpwd" />
  13. <view class="tit">{{ $t('login.qrmm') }}</view>
  14. <input type="password" class="shuru" :placeholder="$t('login.qsrmm')" v-model="relpwd" />
  15. <view class="tit">{{ $t('login.yqm') }}</view>
  16. <input type="text" class="shuru" :placeholder="$t('login.qsryqm')" v-model="invit" />
  17. <view class="flex" style="justify-content: space-between;padding: 50rpx 30rpx;align-items: flex-start;">
  18. <view class="">
  19. {{ $t('login.zcjbsty') }}
  20. <text style="color: #fcd535;">{{ $t('login.yhfwxy') }}</text>
  21. </view>
  22. <image src="../../static/icon/goto.png" mode="" style="width: 97rpx;height: 97rpx;" @click="register()"></image>
  23. </view>
  24. <!-- <view class="login_text">
  25. <view class="login_input flex">
  26. <view class="login_img"><image src="/static/icon/img03.png"></image></view>
  27. <view class="login_name"><input class="uni-input" v-model="phone" focus placeholder="请输入手机号" /></view>
  28. </view>
  29. <view class="login_input flex">
  30. <view class="login_img"><image src="/static/icon/img04.png"></image></view>
  31. <view class="login_name"><input class="uni-input" type="password" v-model="password" focus placeholder="请输入密码" /></view>
  32. </view>
  33. <view class="login_input flex">
  34. <view class="login_img"><image src="/static/icon/img04.png"></image></view>
  35. <view class="login_name"><input class="uni-input" type="password" v-model="repassword" focus placeholder="请重复输入密码" /></view>
  36. </view>
  37. <view class="login_input flex" style="display: none;">
  38. <view class="login_img"><image src="/static/icon/img07.png"></image></view>
  39. <view class="login_name"><input class="uni-input" type="text" v-model="invitation" focus placeholder="请输入邀请码" /></view>
  40. </view>
  41. <view class="login_input flex">
  42. <view class="login_img"><image src="/static/icon/img06.png"></image></view>
  43. <view class="login_name flex">
  44. <input class="uni-input width" v-model="code" focus placeholder="请输入验证码" />
  45. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  46. </view>
  47. </view>
  48. <view><button type="green" @click="register" class="uni-button uni-button-green">注册账号</button></view>
  49. <view><button class="uni-button uni-button-green uni-button-green-plain" type="green" plain="true" hover-class="none" @click="login">返回登录</button></view>
  50. </view> -->
  51. </view>
  52. </template>
  53. <script>
  54. import { register, verify, getYzm, zc } from '@/api/login.js';
  55. export default {
  56. data() {
  57. return {
  58. loaded: false,
  59. lpwd: '',
  60. relpwd: '',
  61. invit: '',
  62. email: '',
  63. phone: '', //用户
  64. password: '', //密码
  65. repassword: '',
  66. invitation: '', //邀请码
  67. code: '', //验证码
  68. time: '', //保存倒计时对象
  69. countDown: 0 //倒计时
  70. };
  71. },
  72. onLoad() {
  73. uni.setNavigationBarTitle({ title: this.$t('login.zc') });
  74. // 获取扫码邀请人id
  75. this.invitation = uni.getStorageSync('spread') || '';
  76. },
  77. watch: {
  78. // 监听倒计时
  79. countDown(i) {
  80. if (i == 0) {
  81. clearInterval(this.time);
  82. }
  83. }
  84. },
  85. methods: {
  86. dl() {
  87. uni.navigateTo({
  88. url: '/pages/public/login'
  89. });
  90. },
  91. // 注册
  92. register() {
  93. let obj = this;
  94. if (obj.loaded) {
  95. return;
  96. }
  97. if (obj.email == '') {
  98. obj.$api.msg(this.$t('login.qsryx'));
  99. return;
  100. }
  101. if (obj.lpwd == '') {
  102. obj.$api.msg(this.$t('login.qsrmm'));
  103. return;
  104. }
  105. if (obj.relpwd == '') {
  106. obj.$api.msg(this.$t('mm.qsrqrmm'));
  107. return;
  108. }
  109. if (obj.relpwd != obj.lpwd) {
  110. obj.$api.msg(this.$t('mm.lcmmbyz'));
  111. return;
  112. }
  113. // if ((obj.invitation = '')) {
  114. // obj.$api.msg('请输入邀请码');
  115. // return;
  116. // }
  117. if (obj.code == '') {
  118. obj.$api.msg(this.$t('login.qsryzm'));
  119. return;
  120. }
  121. obj.loaded = true;
  122. zc({
  123. email: obj.email,
  124. lpwd: obj.lpwd,
  125. invit: obj.invit,
  126. phone: obj.phone,
  127. yincang: 1,
  128. ecode: obj.code
  129. })
  130. .then(function(e) {
  131. obj.loaded = false;
  132. uni.showToast({
  133. title: this.$t('login.zccg'),
  134. duration: 2000,
  135. position: 'top'
  136. });
  137. setTimeout(function() {
  138. uni.navigateTo({
  139. url: '/pages/public/login'
  140. });
  141. }, 1000);
  142. })
  143. .catch(err => {
  144. obj.loaded = false;
  145. });
  146. //调用注册接口,成功跳转登录页
  147. },
  148. isEmailAvailable(obj) {
  149. let email = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
  150. if (!email.test(obj)) {
  151. return false;
  152. }
  153. return true;
  154. },
  155. //发送验证码
  156. verification() {
  157. let obj = this;
  158. if (obj.email == '') {
  159. return obj.$api.msg(this.$t('login.qsryx'));
  160. }
  161. if (!obj.isEmailAvailable(obj.email)) {
  162. return obj.$api.msg(this.$t('login.qsrzqdyx'));
  163. }
  164. // 判断是否在倒计时
  165. if (obj.countDown > 0) {
  166. return false;
  167. } else {
  168. obj.countDown = 60;
  169. obj.time = setInterval(() => {
  170. obj.countDown--;
  171. }, 1000);
  172. //调用验证码接口
  173. getYzm({
  174. email: obj.email
  175. // type: 'register'
  176. })
  177. .then(({ data }) => {})
  178. .catch(err => {
  179. console.log(err);
  180. });
  181. }
  182. },
  183. login() {
  184. //返回登录
  185. uni.navigateTo({
  186. url: '/pages/public/login'
  187. });
  188. }
  189. }
  190. };
  191. </script>
  192. <style lang="scss">
  193. page {
  194. height: 100%;
  195. background-color: #fff;
  196. font-size: 32rpx;
  197. }
  198. .container {
  199. width: 100%;
  200. height: 100%;
  201. background-size: 100%;
  202. }
  203. .shuru {
  204. display: block;
  205. background-color: #f5f5f5;
  206. width: 673rpx;
  207. height: 95rpx;
  208. margin: auto;
  209. padding-left: 30rpx;
  210. text-align: 95rpx;
  211. }
  212. .tit {
  213. padding: 40rpx 48rpx 20rpx;
  214. }
  215. .gologin {
  216. width: 204rpx;
  217. height: 98rpx;
  218. line-height: 98rpx;
  219. background-color: #fcd535;
  220. text-align: center;
  221. border-radius: 20rpx;
  222. }
  223. .wjmm {
  224. color: #fcd535;
  225. }
  226. .yzm {
  227. width: 400rpx;
  228. height: 95rpx;
  229. padding-left: 30rpx;
  230. background-color: #f5f5f5;
  231. }
  232. .yzmbtn {
  233. width: 234rpx;
  234. height: 95rpx;
  235. background-color: #f5f5f5;
  236. text-align: center;
  237. line-height: 95rpx;
  238. color: #fcd535;
  239. }
  240. </style>