forget.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <view class="container">
  3. <view class="container_text" >
  4. <image class="banner-img" src="../../users/static/beijing.jpg" mode="scaleToFill"></image>
  5. </view>
  6. <!-- <view class="loginTitle"><text>注册</text></view> -->
  7. <view class="login_text">
  8. <view class="login_input flex">
  9. <view class="login_img"><image src="../../users/static/phone.png"></image></view>
  10. <view class="login_name"><input class="uni-input" v-model="phone" focus placeholder="请输入手机号" /></view>
  11. </view>
  12. <view class="login_input flex">
  13. <view class="login_img"><image src="../../users/static/code.png"></image></view>
  14. <view class="login_name"><input class="uni-input" type="password" v-model="password" focus placeholder="请输入新密码" /></view>
  15. </view>
  16. <view class="login_input flex">
  17. <view class="login_img"><image src="../../users/static/code.png"></image></view>
  18. <view class="login_name"><input class="uni-input" type="text" v-model="invitation" focus placeholder="请重新输入新密码" /></view>
  19. </view>
  20. <view class="login_input flex">
  21. <view class="login_img"><image src="../../users/static/yzm.png"></image></view>
  22. <view class="login_name flex">
  23. <input class="uni-input width" v-model="code" focus placeholder="请输入验证码" />
  24. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  25. </view>
  26. </view>
  27. <view><button type="green" @click="register" class="uni-button uni-button-yello">确认修改</button></view>
  28. <!-- <view class="choose">
  29. <view class="reg">忘记密码</view>
  30. <view class="xian">|</view>
  31. <view class="zhuce">手机登录</view>
  32. </view> -->
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. // import { register, verify } from '@/api/login.js';
  38. export default {
  39. data() {
  40. return {
  41. phone: '', //用户
  42. password: '', //密码
  43. repassword: '',
  44. invitation: '', //邀请码
  45. code: '', //验证码
  46. time: '', //保存倒计时对象
  47. countDown: 0 ,//倒计时
  48. nickname: '', // 昵称
  49. };
  50. },
  51. onLoad() {
  52. this.invitation = uni.getStorageSync('spread')||'';
  53. console.log(this.invitation);
  54. },
  55. watch: {
  56. // 监听倒计时
  57. countDown(i) {
  58. if (i == 0) {
  59. clearInterval(this.time);
  60. }
  61. }
  62. },
  63. methods: {
  64. // 注册
  65. register() {
  66. let obj = this;
  67. if (obj.phone == '') {
  68. obj.$api.msg('请输入电话号码');
  69. return;
  70. }
  71. if (obj.nickname == '') {
  72. obj.$api.msg('请输入昵称');
  73. return;
  74. }
  75. if (!/(^1[1|2|3|4|5|6|7|8|9][0-9]{9}$)/.test(this.phone)) {
  76. obj.$api.msg('请输入正确的手机号');
  77. return;
  78. }
  79. if (obj.password == '') {
  80. obj.$api.msg('请输入密码');
  81. return;
  82. }
  83. if (obj.repassword == '') {
  84. obj.$api.msg('请再次输入密码');
  85. return;
  86. }
  87. if (obj.repassword != obj.password) {
  88. obj.$api.msg('两次密码不正确');
  89. return;
  90. }
  91. // if (obj.invitation == '') {
  92. // obj.$api.msg('请输入邀请码');
  93. // return;
  94. // }
  95. if (obj.code == '') {
  96. obj.$api.msg('请输入验证码');
  97. return;
  98. }
  99. register({
  100. nickname:obj.nickname,
  101. account: obj.phone, //账号
  102. captcha: obj.code, //验证码
  103. password: obj.password ,//密码
  104. spread:obj.invitation//上级推广人
  105. }).then(function(e) {
  106. uni.showToast({
  107. title:'注册成功',
  108. duration:2000,
  109. position:'top'
  110. });
  111. setTimeout(function () {
  112. uni.navigateTo({
  113. url: '/pages/public/login'
  114. });
  115. },1000)
  116. });
  117. //调用注册接口,成功跳转登录页
  118. },
  119. //发送验证码
  120. verification() {
  121. let obj = this;
  122. if (this.phone == '') {
  123. this.$api.msg('请输入电话号码');
  124. return;
  125. }
  126. if (this.phone.length < 11) {
  127. this.$api.msg('请输入正确的手机号');
  128. return;
  129. }
  130. // 判断是否在倒计时
  131. if (obj.countDown > 0) {
  132. return false;
  133. } else {
  134. obj.countDown = 60;
  135. obj.time = setInterval(() => {
  136. obj.countDown--;
  137. }, 1000);
  138. //调用验证码接口
  139. verify({
  140. phone: obj.phone,
  141. type: 'register'
  142. })
  143. .then(({ data }) => {})
  144. .catch(err => {
  145. console.log(err);
  146. });
  147. }
  148. },
  149. login() {
  150. //返回登录
  151. // uni.navigateTo({
  152. // url: '/pages/public/login'
  153. // });
  154. }
  155. }
  156. };
  157. </script>
  158. <style lang="scss">
  159. page {
  160. height: 100%;
  161. }
  162. .container {
  163. width: 100%;
  164. height: 100%;
  165. background-size: 100%;
  166. }
  167. .container_text {
  168. width: 100%;
  169. height: 500rpx;
  170. top: 0rpx;
  171. .banner-img {
  172. width: 100%;
  173. height: 100%;
  174. }
  175. }
  176. .login_text {
  177. // margin: auto 30rpx;
  178. position: relative;
  179. padding: 100rpx 102rpx;
  180. background-color: #ffffff;
  181. margin-top: -20rpx;
  182. border-radius: 20rpx;
  183. .login_input {
  184. border-bottom: 1px solid #f0f0f0;
  185. margin-bottom: 65rpx;
  186. .login_img image {
  187. height: 35rpx;
  188. width: 29rpx;
  189. margin-right: 20rpx;
  190. }
  191. .uni-input {
  192. text-align: left;
  193. width: 470rpx;
  194. font-size: 28rpx !important;
  195. }
  196. .login_name {
  197. color: #333333;
  198. }
  199. }
  200. .other {
  201. margin-top: 60rpx;
  202. .fenge {
  203. width: 30%;
  204. height: 2rpx;
  205. background-color: #eeeeee;
  206. }
  207. .qita {
  208. font-size: 28rpx;
  209. color: #999999;
  210. }
  211. }
  212. .weixin {
  213. width: 75rpx;
  214. height: 75rpx;
  215. margin: 25rpx auto;
  216. }
  217. .weixin image {
  218. width: 100%;
  219. height: 100%;
  220. }
  221. .weixin_text {
  222. text-align: center;
  223. font-size: 28rpx;
  224. color: #999999;
  225. }
  226. .forget {
  227. font-size: 28rpx;
  228. width: 100%;
  229. text-align: right;
  230. color: #999999;
  231. }
  232. .uni-button-yello {
  233. color: #ffffff;
  234. // margin: 40rpx 10rpx;
  235. // border-radius: 50rpx;
  236. background: linear-gradient(-30deg, #FF3106, #FF8F3B);
  237. border-radius: 10rpx;
  238. }
  239. .uni-button {
  240. height: 85rpx;
  241. line-height: 85rpx;
  242. }
  243. }
  244. .loginTitle {
  245. position: absolute;
  246. top: 250rpx;
  247. width: 100%;
  248. text-align: center;
  249. color: white;
  250. font-size: 40rpx;
  251. }
  252. .forget {
  253. width: 100rpx;
  254. font-size: 24rpx;
  255. color: #ffffff;
  256. margin: 0px auto;
  257. border-bottom: 1px solid #ffffff;
  258. }
  259. .width {
  260. width: 325rpx !important;
  261. }
  262. .code {
  263. color: #ff762d;
  264. font-size: 23rpx;
  265. border-left: 1px solid #eeeeee;
  266. width: 150rpx;
  267. flex-shrink: 0;
  268. text-align: center;
  269. }
  270. .choose {
  271. display: flex;
  272. justify-content: center;
  273. margin-top: 15rpx;
  274. .reg {
  275. font-size: 28rpx;
  276. font-weight: 500;
  277. color: #ff8d3a;
  278. }
  279. .xian {
  280. color: #FF4C4C;
  281. padding-left: 10rpx;
  282. }
  283. .zhuce {
  284. font-size: 28rpx;
  285. font-weight: 500;
  286. color: #FF4C4C;
  287. padding-left: 10rpx;
  288. }
  289. }
  290. uni-button {
  291. height: 80rpx !important;
  292. line-height: 80rpx !important;
  293. }
  294. </style>