forget.vue 5.5 KB

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