forget.vue 6.6 KB

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