register.vue 7.4 KB

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