forget.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <view class="container">
  3. <view class="" style="text-align: left;padding-left: 30rpx;font-size: 52rpx;padding-top: 50rpx;">
  4. 重置密碼
  5. </view>
  6. <view class="tit" >
  7. 郵箱
  8. </view>
  9. <input type="text" class="shuru" placeholder="新密碼" v-model="email">
  10. <view class="tit" >
  11. 重置密碼
  12. </view>
  13. <input type="text" class="shuru" placeholder="重置密碼" v-model="email">
  14. <view class="tit">
  15. 郵箱驗證碼
  16. </view>
  17. <view class="flex" style="width: 673rpx;justify-content: space-between;margin: auto;">
  18. <input type="text" class=" yzm" placeholder="請翰入密碼" v-model="code">
  19. <view class="code yzmbtn" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  20. </view>
  21. <view class="tit" >
  22. 新密碼
  23. </view>
  24. <input type="text" class="shuru" placeholder="新密碼" v-model="email">
  25. <!-- <view class="container_text">
  26. <image class="banner-img" src="/static/img/img01.png" mode=" scaleToFill"></image>
  27. </view>
  28. <view class="loginTitle"><text>手机号登录</text></view>
  29. <view class="login_text">
  30. <view class="login_input flex">
  31. <view class="login_img"><image src="/static/icon/img03.png"></image></view>
  32. <view class="login_name"><input class="uni-input" v-model="phone" focus placeholder="请输入手机号" /></view>
  33. </view>
  34. <view class="login_input flex">
  35. <view class="login_img"><image src="/static/icon/img06.png"></image></view>
  36. <view class="login_name flex">
  37. <input class="uni-input width" v-model="code" focus placeholder="请输入验证码" />
  38. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  39. </view>
  40. </view>
  41. <view>
  42. <button type="green" @click="register" class="uni-button uni-button-green">登录</button>
  43. </view>
  44. </view> -->
  45. </view>
  46. </template>
  47. <script>
  48. import { mapMutations } from 'vuex';
  49. import { verify, loginMobile, getUserInfo } from '@/api/login.js';
  50. export default {
  51. data() {
  52. return {
  53. phone: '', //用户
  54. code: '', //验证码
  55. time: '', //保存倒计时对象
  56. countDown: 0 //倒计时
  57. };
  58. },
  59. onLoad() {},
  60. watch: {
  61. // 监听倒计时
  62. countDown(i) {
  63. if (i == 0) {
  64. clearInterval(this.time);
  65. }
  66. }
  67. },
  68. methods: {
  69. ...mapMutations('user', ['setUserInfo', 'login']),
  70. // 手机登录
  71. register() {
  72. let obj = this;
  73. if (obj.phone == '') {
  74. obj.$api.msg('请输入电话号码');
  75. return;
  76. }
  77. if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(this.phone)) {
  78. obj.$api.msg('请输入正确的手机号');
  79. return;
  80. }
  81. if (obj.code == '') {
  82. obj.$api.msg('请输入验证码');
  83. return;
  84. }
  85. loginMobile({
  86. phone: obj.phone, //账号
  87. captcha: obj.code
  88. }).then(function(e) {
  89. uni.setStorageSync('token', e.data.token);
  90. getUserInfo({}).then(e => {
  91. obj.login();
  92. // 保存返回用户数据
  93. obj.setUserInfo(e.data);
  94. //成功跳转首页
  95. uni.switchTab({
  96. url: '/pages/index/index'
  97. });
  98. });
  99. }).catch((e) => {
  100. console.log(e);
  101. });
  102. },
  103. //发送验证码
  104. verification() {
  105. let obj = this;
  106. if (this.phone == '') {
  107. this.$api.msg('请输入电话号码');
  108. return;
  109. }
  110. if (this.phone.length < 11) {
  111. this.$api.msg('请输入正确的手机号');
  112. return;
  113. }
  114. // 判断是否在倒计时
  115. if (obj.countDown > 0) {
  116. return false;
  117. } else {
  118. obj.countDown = 60;
  119. obj.time = setInterval(() => {
  120. obj.countDown--;
  121. }, 1000);
  122. //调用验证码接口
  123. verify({
  124. phone: obj.phone,
  125. type: 'login'
  126. })
  127. .then(({ data }) => {})
  128. .catch(err => {
  129. console.log(err);
  130. });
  131. }
  132. },
  133. login() {
  134. //返回登录
  135. uni.navigateTo({
  136. url: '/pages/public/login'
  137. });
  138. }
  139. }
  140. };
  141. </script>
  142. <style lang="scss">
  143. page {
  144. height: 100%;
  145. background-color: #fff;
  146. font-size: 32rpx;
  147. }
  148. .container {
  149. width: 100%;
  150. height: 100%;
  151. background-size: 100%;
  152. }
  153. .shuru {
  154. display: block;
  155. background-color: #f5f5f5;
  156. width: 673rpx;
  157. height: 95rpx;
  158. margin: auto;
  159. padding-left: 30rpx;
  160. text-align: 95rpx;
  161. }
  162. .tit {
  163. padding: 40rpx 48rpx 20rpx;
  164. }
  165. .gologin {
  166. width: 204rpx;
  167. height: 98rpx;
  168. line-height: 98rpx;
  169. background-color: #fcd535;
  170. text-align: center;
  171. border-radius: 20rpx;
  172. }
  173. .wjmm {
  174. color: #fcd535;
  175. }
  176. .yzm {
  177. width: 400rpx;
  178. height: 95rpx;
  179. padding-left: 30rpx;
  180. background-color: #f5f5f5;
  181. }
  182. .yzmbtn {
  183. width: 234rpx;
  184. height: 95rpx;
  185. background-color: #f5f5f5;
  186. text-align: center;
  187. line-height: 95rpx;
  188. color: #fcd535;
  189. }
  190. </style>