register.vue 6.8 KB

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