forget.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <view class="container">
  3. <view class="container_text">
  4. <image class="banner-img" src="/static/img/login.png" mode="scaleToFill"></image>
  5. <!-- <view class="title-img"><image class="title-image" src="../../static/img/login-title.png" mode=""></image></view> -->
  6. </view>
  7. <!-- <view class="loginTitle"><text>修改密码</text></view> -->
  8. <view class="login_text">
  9. <view class="login_input flex_item">
  10. <view class="login_img"><image class="phone" src="/static/icon/img03.png"></image></view>
  11. <view class="login_name"><input class="uni-input" type="text" v-model="phone" focus placeholder="请输入手机" /></view>
  12. </view>
  13. <view class="login_input flex_item">
  14. <view class="login_img"><image src="/static/icon/img04.png"></image></view>
  15. <view class="login_name"><input class="uni-input" type="password" v-model="password" focus placeholder=" 请输入新的不少于6位的密码" /></view>
  16. </view>
  17. <view class="login_input flex_item">
  18. <view class="login_img"><image src="/static/icon/img04.png"></image></view>
  19. <view class="login_name"><input class="uni-input" type="password" v-model="password2" focus placeholder="请重复输入新密码" /></view>
  20. </view>
  21. <view class="login_input flex">
  22. <view class="login_img"><image class="codeimg" src="/static/icon/img06.png"></image></view>
  23. <view class="login_name flex">
  24. <input class="uni-input width" v-model="code" type="number" focus placeholder="请输入验证码" />
  25. <view class="code" @click="verification">{{ countDown == 0 ? '发送验证码' : countDown }}</view>
  26. </view>
  27. </view>
  28. <view class="uni-button uni-button-green" @click="updatalogin">确认修改</view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import { registerReset } from '@/api/set.js';
  34. import { verify } from '@/api/login.js';
  35. export default {
  36. data() {
  37. return {
  38. phone: '', //用户
  39. code: '', //验证码
  40. password2: '',
  41. password: '',
  42. time: '', //保存倒计时对象
  43. countDown: 0 //倒计时
  44. };
  45. },
  46. onLoad() {},
  47. watch: {
  48. // 监听倒计时
  49. countDown(i) {
  50. if (i == 0) {
  51. clearInterval(this.time);
  52. }
  53. }
  54. },
  55. methods: {
  56. updatalogin() {
  57. let obj = this;
  58. if (obj.phone == '') {
  59. obj.$api.msg('请输入手机');
  60. return;
  61. }
  62. 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)) {
  63. obj.$api.msg('请输入正确的手机');
  64. return;
  65. }
  66. if (obj.password == '') {
  67. obj.$api.msg('请输入密码');
  68. return;
  69. }
  70. if (obj.password2 == '') {
  71. obj.$api.msg('请再次输入密码');
  72. return;
  73. }
  74. if (obj.password2 != obj.password) {
  75. obj.$api.msg('两次密码不正确');
  76. return;
  77. }
  78. if (obj.code == '') {
  79. obj.$api.msg('请输入验证码');
  80. return;
  81. }
  82. registerReset({
  83. account: obj.phone, //账号
  84. password: obj.password,
  85. password2: obj.password2,
  86. type: 1,
  87. captcha: obj.code
  88. })
  89. .then(function(e) {
  90. obj.$api.msg(e.msg);
  91. uni.navigateTo({
  92. url: '/pages/public/login'
  93. });
  94. })
  95. .catch(e => {
  96. console.log(e);
  97. });
  98. },
  99. //发送验证码
  100. verification() {
  101. let obj = this;
  102. if (this.phone == '') {
  103. this.$api.msg('请输入邮箱号码');
  104. return;
  105. }
  106. 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)) {
  107. obj.$api.msg('请输入正确的邮箱或手机');
  108. return;
  109. }
  110. // 判断是否在倒计时
  111. if (obj.countDown > 0) {
  112. return false;
  113. } else {
  114. obj.countDown = 60;
  115. obj.time = setInterval(() => {
  116. obj.countDown--;
  117. }, 1000);
  118. //调用验证码接口
  119. verify({
  120. phone: obj.phone,
  121. type: 'login'
  122. })
  123. .then(({ data }) => {
  124. uni.showToast({
  125. title: '验证码已发送',
  126. duration: 2000,
  127. position: 'top',
  128. icon: 'none'
  129. });
  130. })
  131. .catch(err => {
  132. console.log(err);
  133. });
  134. }
  135. }
  136. }
  137. };
  138. </script>
  139. <style lang="scss">
  140. page {
  141. min-height: 100%;
  142. background-color: #ffffff;
  143. .container {
  144. width: 100%;
  145. }
  146. }
  147. .container_text {
  148. position: relative;
  149. width: 100%;
  150. height: 500rpx;
  151. top: 0rpx;
  152. .banner-img {
  153. width: 100%;
  154. height: 100%;
  155. }
  156. .title-img {
  157. position: absolute;
  158. left: 50%;
  159. top: 100rpx;
  160. margin-left: -130rpx;
  161. width: 260rpx;
  162. height: 156rpx;
  163. .title-image {
  164. width: 260rpx;
  165. height: 156rpx;
  166. }
  167. }
  168. }
  169. .loginTitle {
  170. position: absolute;
  171. top: 270rpx;
  172. width: 100%;
  173. text-align: center;
  174. color: white;
  175. font-size: 40rpx;
  176. }
  177. .phone {
  178. height: 43rpx !important;
  179. width: 27rpx !important;
  180. }
  181. .codeimg {
  182. height: 39rpx !important;
  183. width: 31rpx !important;
  184. }
  185. .login_text {
  186. margin: -100rpx 0 0;
  187. position: relative;
  188. padding: 100rpx 102rpx;
  189. background-color: #ffffff;
  190. border-top-left-radius: 40rpx;
  191. border-top-right-radius: 40rpx;
  192. .login_input {
  193. border-bottom: 1px solid #f0f0f0;
  194. margin-bottom: 65rpx;
  195. .login_img image {
  196. height: 36rpx;
  197. width: 30rpx;
  198. margin-right: 20rpx;
  199. }
  200. .uni-input {
  201. text-align: left;
  202. width: 470rpx;
  203. font-size: 28rpx !important;
  204. }
  205. .login_name {
  206. color: #333333;
  207. }
  208. }
  209. .other {
  210. margin-top: 60rpx;
  211. .fenge {
  212. width: 30%;
  213. height: 2rpx;
  214. background-color: #eeeeee;
  215. }
  216. .qita {
  217. font-size: 28rpx;
  218. color: #999999;
  219. }
  220. }
  221. .weixin {
  222. width: 75rpx;
  223. height: 75rpx;
  224. margin: 25rpx auto;
  225. }
  226. .weixin image {
  227. width: 100%;
  228. height: 100%;
  229. }
  230. .weixin_text {
  231. text-align: center;
  232. font-size: 28rpx;
  233. color: #999999;
  234. }
  235. .forget {
  236. font-size: 28rpx;
  237. width: 100%;
  238. text-align: right;
  239. color: #999999;
  240. }
  241. .uni-button-green {
  242. text-align: center;
  243. color: #ffffff;
  244. background-color: #E6C79D;
  245. margin: 40rpx 10rpx;
  246. border-radius: 50rpx;
  247. }
  248. .uni-button-green-plain {
  249. border: 1px solid #E6C79D;
  250. margin: 40rpx 10rpx;
  251. border-radius: 50rpx;
  252. color: #E6C79D;
  253. background-color: #ffffff;
  254. }
  255. .uni-button {
  256. height: 85rpx;
  257. line-height: 85rpx;
  258. }
  259. }
  260. .code {
  261. color: #E6C79D;
  262. font-size: 23rpx;
  263. border-left: 1px solid #eeeeee;
  264. width: 150rpx;
  265. flex-shrink: 0;
  266. text-align: center;
  267. }
  268. .width {
  269. width: 325rpx !important;
  270. }
  271. .login {
  272. background: #E6C79D;
  273. margin-top: 96rpx;
  274. color: #ffffff;
  275. text-align: center;
  276. padding: 26rpx 0rpx;
  277. border-radius: 20rpx;
  278. }
  279. </style>