forget.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view class="container">
  3. <!-- <view class="logo-img"><image src="../../static/img/log.png" mode=""></image></view> -->
  4. <view class="logo">满园春</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/zfpwd.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/zfpwd.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. pwd:'123456',
  84. type: 1,
  85. captcha: obj.code
  86. })
  87. .then(function(e) {
  88. obj.$api.msg(e.msg);
  89. uni.navigateTo({
  90. url: '/pages/public/login'
  91. });
  92. })
  93. .catch(e => {
  94. console.log(e);
  95. });
  96. },
  97. //发送验证码
  98. verification() {
  99. let obj = this;
  100. if (this.phone == '') {
  101. this.$api.msg('请输入邮箱号码');
  102. return;
  103. }
  104. 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))) {
  105. obj.$api.msg('请输入正确的邮箱或手机');
  106. return;
  107. }
  108. // 判断是否在倒计时
  109. if (obj.countDown > 0) {
  110. return false;
  111. } else {
  112. obj.countDown = 60;
  113. obj.time = setInterval(() => {
  114. obj.countDown--;
  115. }, 1000);
  116. //调用验证码接口
  117. verify({
  118. phone: obj.phone,
  119. type: 'login'
  120. })
  121. .then(({ data }) => {
  122. uni.showToast({
  123. title: '验证码已发送',
  124. duration: 2000,
  125. position: 'top',
  126. icon: 'none'
  127. });
  128. })
  129. .catch(err => {
  130. console.log(err);
  131. });
  132. }
  133. }
  134. }
  135. };
  136. </script>
  137. <style lang="scss">
  138. page {
  139. min-height: 100%;
  140. background-color: #ffffff;
  141. .container {
  142. width: 100%;
  143. padding: 60rpx 70rpx;
  144. }
  145. }
  146. .logo-img {
  147. width: 161rpx;
  148. height: 161rpx;
  149. margin:auto;
  150. margin-top: 52rpx !important;
  151. margin-bottom: 15rpx !important;
  152. box-shadow: 0px 12rpx 13rpx 0px rgba(68, 150, 157, 0.47);
  153. border-radius: 50%;
  154. image {
  155. width: 161rpx;
  156. height: 161rpx;
  157. border-radius: 50%;
  158. }
  159. }
  160. .logo {
  161. font-size: 36rpx;
  162. font-weight: 400;
  163. color: #2E58FF;
  164. text-align: center;
  165. }
  166. .phone {
  167. height: 43rpx !important;
  168. width: 27rpx !important;
  169. }
  170. .codeimg {
  171. height: 39rpx !important;
  172. width: 31rpx !important;
  173. }
  174. .login_text {
  175. border-radius: 20rpx;
  176. margin-top: 80rpx;
  177. .login_input {
  178. // border-bottom: 1px solid #C5CEE0;
  179. margin-bottom: 35rpx;
  180. padding-bottom: 60rpx;
  181. .login_img {
  182. height: 35rpx;
  183. width: 31rpx;
  184. margin-right: 20rpx;
  185. image {
  186. width: 100%;
  187. height: 100%;
  188. }
  189. }
  190. .uni-input {
  191. text-align: left;
  192. width: 400rpx;
  193. font-size: 32rpx !important;
  194. }
  195. .login_name {
  196. color: #333333;
  197. .code {
  198. color: #2E58FF;
  199. font-size: 23rpx;
  200. border-left: 1px solid #eeeeee;
  201. width: 150rpx;
  202. flex-shrink: 0;
  203. text-align: center;
  204. }
  205. }
  206. }
  207. }
  208. .login {
  209. background: linear-gradient(0deg, #2E58FF, #32C6FF);
  210. margin-top: 96rpx;
  211. color: #ffffff;
  212. text-align: center;
  213. padding: 26rpx 0rpx;
  214. border-radius: 20rpx;
  215. }
  216. </style>