forget.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <view class="container">
  3. <view class="container_text">
  4. <image class="banner-img" src="/static/img/login-img.png" mode="scaleToFill"></image>
  5. </view>
  6. <view class="login_text">
  7. <view class="login_input flex_item">
  8. <view class="login_img"><image src="/static/icon/login-yq.png"></image></view>
  9. <view class="login_name"><input class="uni-input" type="text" v-model="phone" focus placeholder="请输入手机号" /></view>
  10. </view>
  11. <view class="login_input flex_item">
  12. <view class="login_img"><image src="/static/icon/login-code.png"></image></view>
  13. <view class="login_name"><input class="uni-input" type="password" v-model="password" focus placeholder=" 请输入新密码" /></view>
  14. </view>
  15. <view class="login_input flex_item">
  16. <view class="login_img"><image src="/static/icon/login-code.png"></image></view>
  17. <view class="login_name"><input class="uni-input" type="password" v-model="password2" focus placeholder="请重复输入新密码" /></view>
  18. </view>
  19. <view class="login_input flex">
  20. <view class="login_img"><image class="codeimg" src="/static/icon/login-yz.png"></image></view>
  21. <view class="login_name flex">
  22. <input class="uni-input" v-model="code" type="number" focus placeholder="请输入验证码" />
  23. <view class="code" @click="verification">{{ countDown == 0 ? '发送验证码' : countDown }}</view>
  24. </view>
  25. </view>
  26. <view class="uni-button uni-button-green" @click="updatalogin">确认修改</view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import { registerReset } from '@/api/set.js';
  32. import { verify } from '@/api/login.js';
  33. export default {
  34. data() {
  35. return {
  36. phone: '', //用户
  37. code: '', //验证码
  38. password2: '',
  39. password: '',
  40. time: '', //保存倒计时对象
  41. countDown: 0 //倒计时
  42. };
  43. },
  44. onLoad() {},
  45. watch: {
  46. // 监听倒计时
  47. countDown(i) {
  48. if (i == 0) {
  49. clearInterval(this.time);
  50. }
  51. }
  52. },
  53. methods: {
  54. updatalogin() {
  55. let obj = this;
  56. if (obj.phone == '') {
  57. obj.$api.msg('请输入手机');
  58. return;
  59. }
  60. 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)) {
  61. obj.$api.msg('请输入正确的手机');
  62. return;
  63. }
  64. if (obj.password == '') {
  65. obj.$api.msg('请输入密码');
  66. return;
  67. }
  68. if (obj.password2 == '') {
  69. obj.$api.msg('请再次输入密码');
  70. return;
  71. }
  72. if (obj.password2 != obj.password) {
  73. obj.$api.msg('两次密码不正确');
  74. return;
  75. }
  76. if (obj.code == '') {
  77. obj.$api.msg('请输入验证码');
  78. return;
  79. }
  80. registerReset({
  81. account: obj.phone, //账号
  82. password: obj.password,
  83. password2: obj.password2,
  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. }
  144. }
  145. .container_text {
  146. position: relative;
  147. width: 100%;
  148. height: 500rpx;
  149. top: 0rpx;
  150. .banner-img {
  151. width: 100%;
  152. height: 100%;
  153. }
  154. .title-img {
  155. position: absolute;
  156. left: 50%;
  157. top: 100rpx;
  158. margin-left: -130rpx;
  159. width: 260rpx;
  160. height: 156rpx;
  161. .title-image {
  162. width: 260rpx;
  163. height: 156rpx;
  164. }
  165. }
  166. }
  167. .loginTitle {
  168. position: absolute;
  169. top: 270rpx;
  170. width: 100%;
  171. text-align: center;
  172. color: white;
  173. font-size: 40rpx;
  174. }
  175. .phone {
  176. height: 43rpx !important;
  177. width: 27rpx !important;
  178. }
  179. .codeimg {
  180. height: 39rpx !important;
  181. width: 31rpx !important;
  182. }
  183. .login_text {
  184. margin: -100rpx 0 0;
  185. position: relative;
  186. padding: 100rpx 102rpx;
  187. background-color: #ffffff;
  188. .login_input {
  189. border-bottom: 1px solid #f0f0f0;
  190. margin-bottom: 65rpx;
  191. .login_img image {
  192. height: 36rpx;
  193. width: 30rpx;
  194. // margin-right: 20rpx;
  195. }
  196. .uni-input {
  197. // text-align: left;
  198. font-size: 28rpx !important;
  199. padding-left: 20rpx;
  200. }
  201. .login_name {
  202. color: #333333;
  203. }
  204. }
  205. .other {
  206. margin-top: 60rpx;
  207. .fenge {
  208. width: 30%;
  209. height: 2rpx;
  210. background-color: #eeeeee;
  211. }
  212. .qita {
  213. font-size: 28rpx;
  214. color: #999999;
  215. }
  216. }
  217. .weixin {
  218. width: 75rpx;
  219. height: 75rpx;
  220. margin: 25rpx auto;
  221. }
  222. .weixin image {
  223. width: 100%;
  224. height: 100%;
  225. }
  226. .weixin_text {
  227. text-align: center;
  228. font-size: 28rpx;
  229. color: #999999;
  230. }
  231. .forget {
  232. font-size: 28rpx;
  233. width: 100%;
  234. text-align: right;
  235. color: #999999;
  236. }
  237. .uni-button-green {
  238. text-align: center;
  239. color: #ffffff;
  240. background-color: #01a6a8;
  241. margin: 40rpx 10rpx;
  242. border-radius: 50rpx;
  243. }
  244. .uni-button-green-plain {
  245. border: 1px solid #01a6a8;
  246. margin: 40rpx 10rpx;
  247. border-radius: 50rpx;
  248. color: #01a6a8;
  249. background-color: #ffffff;
  250. }
  251. .uni-button {
  252. height: 85rpx;
  253. line-height: 85rpx;
  254. }
  255. }
  256. .code {
  257. color: #01a6a8;
  258. font-size: 23rpx;
  259. border-left: 1px solid #eeeeee;
  260. width: 150rpx;
  261. flex-shrink: 0;
  262. text-align: center;
  263. }
  264. .width {
  265. width: 325rpx !important;
  266. }
  267. .login {
  268. background: #E6C79D;
  269. margin-top: 96rpx;
  270. color: #ffffff;
  271. text-align: center;
  272. padding: 26rpx 0rpx;
  273. border-radius: 20rpx;
  274. }
  275. </style>