register.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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 = false
  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.email == '') {
  172. return obj.$api.msg('請輸入郵箱!')
  173. }
  174. if (!obj.isEmailAvailable(obj.email)) {
  175. return obj.$api.msg('請輸入正確的郵箱!')
  176. }
  177. // 判断是否在倒计时
  178. if (obj.countDown > 0) {
  179. return false;
  180. } else {
  181. obj.countDown = 60;
  182. obj.time = setInterval(() => {
  183. obj.countDown--;
  184. }, 1000);
  185. //调用验证码接口
  186. getYzm({
  187. email: obj.email,
  188. // type: 'register'
  189. })
  190. .then(({
  191. data
  192. }) => {})
  193. .catch(err => {
  194. console.log(err);
  195. });
  196. }
  197. },
  198. login() {
  199. //返回登录
  200. uni.navigateTo({
  201. url: '/pages/public/login'
  202. });
  203. }
  204. }
  205. };
  206. </script>
  207. <style lang="scss">
  208. page {
  209. height: 100%;
  210. background-color: #fff;
  211. font-size: 32rpx;
  212. }
  213. .container {
  214. width: 100%;
  215. height: 100%;
  216. background-size: 100%;
  217. }
  218. .shuru {
  219. display: block;
  220. background-color: #f5f5f5;
  221. width: 673rpx;
  222. height: 95rpx;
  223. margin: auto;
  224. padding-left: 30rpx;
  225. text-align: 95rpx;
  226. }
  227. .tit {
  228. padding: 40rpx 48rpx 20rpx;
  229. }
  230. .gologin {
  231. width: 204rpx;
  232. height: 98rpx;
  233. line-height: 98rpx;
  234. background-color: #fcd535;
  235. text-align: center;
  236. border-radius: 20rpx;
  237. }
  238. .wjmm {
  239. color: #fcd535;
  240. }
  241. .yzm {
  242. width: 400rpx;
  243. height: 95rpx;
  244. padding-left: 30rpx;
  245. background-color: #f5f5f5;
  246. }
  247. .yzmbtn {
  248. width: 234rpx;
  249. height: 95rpx;
  250. background-color: #f5f5f5;
  251. text-align: center;
  252. line-height: 95rpx;
  253. color: #fcd535;
  254. }
  255. </style>