forget.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view class="container">
  3. <view class="logo-img"><image src="../../static/img/log.png" mode=""></image></view>
  4. <view class="logo">LALA</view>
  5. <view class="login_text">
  6. <view class="login_input flex_item">
  7. <view class="login_img"><image class="phone" src="/static/img/phone.png"></image></view>
  8. <view class="login_name"><input class="uni-input" type="text" v-model="phone" focus placeholder="请输入邮箱或手机" /></view>
  9. </view>
  10. <view class="login_input flex_item">
  11. <view class="login_img"><image src="/static/img/password.png"></image></view>
  12. <view class="login_name"><input class="uni-input" type="password" v-model="password" focus placeholder=" 请输入新的不少于6位的密码" /></view>
  13. </view>
  14. <view class="login_input flex_item">
  15. <view class="login_img"><image src="/static/img/password.png"></image></view>
  16. <view class="login_name"><input class="uni-input" type="password" v-model="password2" focus placeholder="请重复输入新密码" /></view>
  17. </view>
  18. <view class="login_input flex">
  19. <view class="login_img"><image class="codeimg" src="/static/img/yan.png"></image></view>
  20. <view class="login_name flex">
  21. <input class="uni-input width" v-model="code" type="number" focus placeholder="请输入验证码" />
  22. <view class="code" @click="verification">{{ countDown == 0 ? '发送验证码' : countDown }}</view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="login" @click="updatalogin">确认修改</view>
  27. </view>
  28. </template>
  29. <script>
  30. import { registerReset } from '@/api/set.js';
  31. import { verify } from '@/api/login.js';
  32. export default {
  33. data() {
  34. return {
  35. phone: '', //用户
  36. code: '', //验证码
  37. password2: '',
  38. password: '',
  39. time: '', //保存倒计时对象
  40. countDown: 0 //倒计时
  41. };
  42. },
  43. onLoad() {},
  44. watch: {
  45. // 监听倒计时
  46. countDown(i) {
  47. if (i == 0) {
  48. clearInterval(this.time);
  49. }
  50. }
  51. },
  52. methods: {
  53. updatalogin() {
  54. let obj = this;
  55. if (obj.phone == '') {
  56. obj.$api.msg('请输入邮箱');
  57. return;
  58. }
  59. if (!/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(obj.phone) && (!/(^1[3|4|5|6|7|8|9][0-9]{9}$)/.test(this.phone))) {
  60. obj.$api.msg('请输入正确的邮箱或手机');
  61. return;
  62. }
  63. if (obj.password == '') {
  64. obj.$api.msg('请输入密码');
  65. return;
  66. }
  67. if (obj.password2 == '') {
  68. obj.$api.msg('请再次输入密码');
  69. return;
  70. }
  71. if (obj.password2 != obj.password) {
  72. obj.$api.msg('两次密码不正确');
  73. return;
  74. }
  75. if (obj.code == '') {
  76. obj.$api.msg('请输入验证码');
  77. return;
  78. }
  79. registerReset({
  80. account: obj.phone, //账号
  81. password: obj.password,
  82. password2: obj.password2,
  83. type: 1,
  84. captcha: obj.code
  85. })
  86. .then(function(e) {
  87. obj.$api.msg(e.msg);
  88. uni.navigateTo({
  89. url: '/pages/public/login'
  90. });
  91. })
  92. .catch(e => {
  93. console.log(e);
  94. });
  95. },
  96. //发送验证码
  97. verification() {
  98. let obj = this;
  99. if (this.phone == '') {
  100. this.$api.msg('请输入邮箱号码');
  101. return;
  102. }
  103. if (!/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(obj.phone) && (!/(^1[3|4|5|6|7|8|9][0-9]{9}$)/.test(this.phone))) {
  104. obj.$api.msg('请输入正确的邮箱或手机');
  105. return;
  106. }
  107. // 判断是否在倒计时
  108. if (obj.countDown > 0) {
  109. return false;
  110. } else {
  111. obj.countDown = 60;
  112. obj.time = setInterval(() => {
  113. obj.countDown--;
  114. }, 1000);
  115. //调用验证码接口
  116. verify({
  117. phone: obj.phone,
  118. type: 'login'
  119. })
  120. .then(({ data }) => {
  121. uni.showToast({
  122. title: '验证码已发送',
  123. duration: 2000,
  124. position: 'top',
  125. icon: 'none'
  126. });
  127. })
  128. .catch(err => {
  129. console.log(err);
  130. });
  131. }
  132. }
  133. }
  134. };
  135. </script>
  136. <style lang="scss">
  137. page {
  138. min-height: 100%;
  139. background-color: #ffffff;
  140. .container {
  141. width: 100%;
  142. padding: 60rpx 70rpx;
  143. }
  144. }
  145. .logo-img {
  146. width: 161rpx;
  147. height: 161rpx;
  148. margin:auto;
  149. margin-top: 52rpx !important;
  150. margin-bottom: 15rpx !important;
  151. box-shadow: 0px 12rpx 13rpx 0px rgba(68, 150, 157, 0.47);
  152. border-radius: 50%;
  153. image {
  154. width: 161rpx;
  155. height: 161rpx;
  156. border-radius: 50%;
  157. }
  158. }
  159. .logo {
  160. font-size: 36rpx;
  161. font-weight: 400;
  162. color: #44969d;
  163. text-align: center;
  164. }
  165. .phone {
  166. height: 43rpx !important;
  167. width: 27rpx !important;
  168. }
  169. .codeimg {
  170. height: 39rpx !important;
  171. width: 31rpx !important;
  172. }
  173. .login_text {
  174. border-radius: 20rpx;
  175. margin-top: 80rpx;
  176. .login_input {
  177. // border-bottom: 1px solid #C5CEE0;
  178. margin-bottom: 35rpx;
  179. padding-bottom: 60rpx;
  180. .login_img {
  181. height: 35rpx;
  182. width: 31rpx;
  183. margin-right: 20rpx;
  184. image {
  185. width: 100%;
  186. height: 100%;
  187. }
  188. }
  189. .uni-input {
  190. text-align: left;
  191. width: 400rpx;
  192. font-size: 32rpx !important;
  193. }
  194. .login_name {
  195. color: #333333;
  196. .code {
  197. color: #60bab0;
  198. font-size: 23rpx;
  199. border-left: 1px solid #eeeeee;
  200. width: 150rpx;
  201. flex-shrink: 0;
  202. text-align: center;
  203. }
  204. }
  205. }
  206. }
  207. .login {
  208. background: linear-gradient(90deg, #60bab0, #60bab0, #45969b);
  209. margin-top: 96rpx;
  210. color: #ffffff;
  211. text-align: center;
  212. padding: 26rpx 0rpx;
  213. border-radius: 20rpx;
  214. }
  215. </style>