forgetPwd.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <!-- 忘记密码页面 -->
  2. <template>
  3. <view class="container">
  4. <text class="back-btn iconfont iconziyuan2" @click="navBack"></text>
  5. <!-- 设置白色背景防止软键盘把下部绝对定位元素顶上来盖住输入框等 -->
  6. <view class="wrapper">
  7. <view class="login-title">
  8. {{$L('找回密码')}}
  9. </view>
  10. <view class="input-content">
  11. <view class="input-item">
  12. <input type="number" :value="mobile" :placeholder="$L('请输入手机号')" maxlength="11" data-key="mobile" @input="inputChange"
  13. placeholder-class="input_placeholder" @focus="setFocus"/>
  14. <text class="clear-account iconfont iconziyuan34" v-show="mobile&&curFocus=='mobile'" @click="clearContent('mobile')"></text>
  15. </view>
  16. <view class="input-item pwd_wrap">
  17. <input type="number" class="smsCode_input" :value="smsCode" maxlength="6" :placeholder="$L('请输入短信验证码')" data-key="smsCode" @input="inputChange"
  18. placeholder-class="input_placeholder" @confirm="toLogin" @focus="setFocus"/>
  19. <view class="pwd-right">
  20. <text class="clear-pwd iconfont iconziyuan34" v-show="smsCode&&curFocus=='smsCode'" @click="clearContent('smsCode')"></text>
  21. <view :style="{opacity: countDownM?0.3:1}" class="sms-code-view" @click="getSmsCode">
  22. <text class="sms-code">{{countDownM?`${countDownM}s后重新获取`:'获取验证码'}}</text>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="input-item pwd_wrap">
  27. <input :style="password.length? 'width: 81%;':''" type="text" :value="password" :placeholder="$L('请设置6~20位英文、数字或符号的密码')" maxlength="20" :password="!showPwd"
  28. placeholder-class="input_placeholder" data-key="password" @input="inputChange" @confirm="toLogin" @focus="setFocus"/>
  29. <view class="pwd-right">
  30. <text class="clear-pwd iconfont iconziyuan34" v-show="password&&curFocus=='password'" @click="clearContent('password')"></text>
  31. <text :class="pwdState" @click="changePwdState"></text>
  32. </view>
  33. </view>
  34. </view>
  35. <button class="confirm-btn" @click="toResetPwd" :style="{opacity: (!(mobile&&password&&smsCode)||logining)?0.5:1}">{{$L('找回密码')}}</button>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import {
  41. mapMutations
  42. } from 'vuex';
  43. export default {
  44. data() {
  45. return {
  46. mobile: '',
  47. password: '',
  48. smsCode: '',
  49. logining: false,
  50. showPwd: false,
  51. countDownM: 0, //短信验证码倒计时
  52. timeOutId: '', //定时器的返回值
  53. curFocus:'',//当前光标所在的位置
  54. }
  55. },
  56. onLoad() {
  57. },
  58. computed: {
  59. pwdState: function() {
  60. return 'pwd-tab iconfont '+(this.showPwd? 'iconziyuan81':'iconziyuan9')
  61. }
  62. },
  63. methods: {
  64. ...mapMutations(['login', 'setUserCenterData']),
  65. //光标聚焦事件
  66. setFocus(e){
  67. this.curFocus = e.currentTarget.dataset.key;
  68. },
  69. inputChange(e) {
  70. const key = e.currentTarget.dataset.key;
  71. this[key] = e.detail.value;
  72. },
  73. navBack() {
  74. uni.navigateBack();
  75. },
  76. //获取短信验证码
  77. getSmsCode() {
  78. if (this.countDownM) {
  79. return;
  80. }
  81. if (this.$checkMobile(this.mobile)) {
  82. let param = {};
  83. param.url = 'v3/msg/front/commons/smsCode';
  84. param.data = {};
  85. param.data.mobile = this.mobile;
  86. param.data.type = 'free';
  87. this.$request(param).then(res => {
  88. this.$api.msg(res.msg);
  89. if (res.state == 200) {
  90. this.countDownM = 60;
  91. this.countDown();
  92. }
  93. })
  94. }
  95. },
  96. //倒计时
  97. countDown() {
  98. this.countDownM--;
  99. if (this.countDownM == 0) {
  100. clearTimeout(this.timeOutId);
  101. } else {
  102. this.timeOutId = setTimeout(this.countDown, 1000);
  103. }
  104. },
  105. //重置密码接口
  106. toResetPwd() {
  107. const {
  108. mobile,
  109. password,
  110. smsCode,
  111. logining
  112. } = this;
  113. if (!(mobile && password && smsCode) || logining) {
  114. return;
  115. }
  116. if (!this.$checkMobile(this.mobile)){
  117. return false
  118. }
  119. //密码的验证 6~20位,英文、数字或符号
  120. if (!this.$checkPwd(password)) {
  121. return false
  122. }
  123. this.logining = true;
  124. let param = {};
  125. param.url = 'v3/member/front/memberPassword/resetLoginPwd';
  126. param.data = {};
  127. param.data.memberMobile = mobile;
  128. param.data.verifyCode = smsCode;
  129. param.data.loginPwd = password;
  130. param.method = 'POST';
  131. this.$request(param).then(res => {
  132. this.$api.msg(res.msg);
  133. if (res.state == 200) {
  134. setTimeout(() => {
  135. uni.navigateBack();
  136. }, 2000)
  137. }
  138. this.logining = false;
  139. }).catch((e) => {})
  140. },
  141. //清空输入的内容
  142. clearContent(type) {
  143. this[type] = '';
  144. },
  145. //是否显示密码切换事件
  146. changePwdState() {
  147. this.showPwd = !this.showPwd;
  148. },
  149. //跳转事件 type:跳转类型,1为redirectTo 2为navigateTo
  150. navTo(url, type) {
  151. if (type == 1) {
  152. uni.redirectTo({
  153. url
  154. })
  155. } else if (type == 2) {
  156. uni.navigateTo({
  157. url
  158. })
  159. }
  160. },
  161. },
  162. }
  163. </script>
  164. <style lang='scss'>
  165. page {
  166. background: #fff;
  167. width: 750rpx;
  168. margin: 0 auto;
  169. }
  170. .container {
  171. position: relative;
  172. width: 750rpx;
  173. height: 100vh;
  174. overflow: hidden;
  175. background: #fff;
  176. }
  177. .wrapper {
  178. position: relative;
  179. z-index: 90;
  180. background: #fff;
  181. padding-bottom: 40upx;
  182. }
  183. .back-btn {
  184. margin-left: 40rpx;
  185. margin-top: 40rpx;
  186. /* #ifndef H5 */
  187. margin-top: 88rpx;
  188. /* #endif */
  189. font-size: 32rpx;
  190. color: $main-font-color;
  191. display: inline-block;
  192. }
  193. .login-title {
  194. position: relative;
  195. margin-top: 90rpx;
  196. margin-bottom: 70rpx;
  197. margin-left: 65rpx;
  198. font-size: 36rpx;
  199. color: $main-font-color;
  200. font-weight: bold;
  201. &:after {
  202. position: absolute;
  203. left: 0;
  204. bottom: -10rpx;
  205. content: '';
  206. width: 76rpx;
  207. height: 6rpx;
  208. background: linear-gradient(90deg, rgba(252, 28, 28, 1) 0%, rgba(255, 138, 0, 0) 100%);
  209. }
  210. }
  211. .input-content {
  212. padding: 0 65rpx;
  213. }
  214. .input-item {
  215. display: flex;
  216. flex-direction: column;
  217. align-items: flex-start;
  218. justify-content: center;
  219. height: 80rpx;
  220. margin-bottom: 50upx;
  221. border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  222. position: relative;
  223. input {
  224. color: #2D2D2D;
  225. font-size: 30rpx;
  226. }
  227. .smsCode_input{
  228. width: 75%;
  229. }
  230. .input_placeholder {
  231. color: $main-third-color;
  232. font-size: 30rpx;
  233. }
  234. .clear-account {
  235. position: absolute;
  236. right: 6rpx;
  237. top: 28rpx;
  238. font-size: 26rpx;
  239. color: #ddd;
  240. z-index: 999;
  241. }
  242. &:nth-child(2) {
  243. .pwd-right {
  244. position: absolute;
  245. right: 6rpx;
  246. top: 6rpx;
  247. display: flex;
  248. align-items: center;
  249. .clear-pwd {
  250. font-size: 26rpx;
  251. color: #ddd;
  252. position: relative;
  253. z-index: 999;
  254. }
  255. .sms-code-view {
  256. border: 1px solid $main-color;
  257. padding: 14rpx;
  258. border-radius: 6rpx;
  259. line-height: 0;
  260. margin-left: 20rpx;
  261. .sms-code {
  262. color: $main-color;
  263. font-size: 24rpx;
  264. line-height: 24rpx;
  265. }
  266. }
  267. }
  268. }
  269. &:last-child {
  270. margin-bottom: 0;
  271. .pwd-right {
  272. position: absolute;
  273. right: 6rpx;
  274. top: 14rpx;
  275. z-index: 999;
  276. .clear-pwd {
  277. font-size: 26rpx;
  278. color: #ddd;
  279. }
  280. .pwd-tab {
  281. font-size: 30rpx;
  282. color: #666;
  283. margin-left: 20rpx;
  284. margin-right: 28rpx;
  285. &.iconziyuan9 {
  286. font-size: 15rpx;
  287. transform: scale(0.1);
  288. position: relative;
  289. z-index: 999;
  290. }
  291. &.iconziyuan81 {
  292. font-size: 20rpx;
  293. transform: scale(0.1)
  294. }
  295. }
  296. .forget-pwd {
  297. color: #2D2D2D;
  298. font-size: 28rpx;
  299. line-height: 28rpx;
  300. font-weight: 400;
  301. border-left: 1px solid $border-color-split;
  302. padding-left: 28rpx;
  303. }
  304. }
  305. }
  306. .tit {
  307. height: 50upx;
  308. line-height: 56upx;
  309. font-size: $font-sm+2upx;
  310. color: $font-color-base;
  311. }
  312. input {
  313. height: 60upx;
  314. font-size: $font-base + 2upx;
  315. color: $font-color-dark;
  316. width: 100%;
  317. }
  318. }
  319. .confirm-btn {
  320. width: 620rpx;
  321. height: 88rpx;
  322. line-height: 88rpx;
  323. margin-top: 90rpx;
  324. background: linear-gradient(90deg, rgba(252, 31, 29, 1) 0%, rgba(253, 115, 38, 1) 100%);
  325. box-shadow: 0px 3rpx 14rpx 1rpx rgba(253, 38, 29, 0.26);
  326. opacity: 0.7;
  327. border-radius: 44rpx;
  328. color: #fff;
  329. font-size: 36rpx;
  330. }
  331. .other-login {
  332. position: absolute;
  333. left: 0;
  334. bottom: 140rpx;
  335. width: 100%;
  336. display: flex;
  337. flex-direction: column;
  338. .title {
  339. display: flex;
  340. justify-content: center;
  341. align-items: center;
  342. &:before {
  343. content: ' ';
  344. width: 150rpx;
  345. height: 1rpx;
  346. background: #CBCBCB;
  347. }
  348. &:after {
  349. content: ' ';
  350. width: 150rpx;
  351. height: 1rpx;
  352. background: #CBCBCB;
  353. }
  354. text {
  355. color: #999999;
  356. font-size: 26rpx;
  357. margin: 0 20rpx;
  358. }
  359. }
  360. .login-method {
  361. display: flex;
  362. justify-content: center;
  363. margin-top: 20rpx;
  364. .wechat-login {
  365. display: flex;
  366. flex-direction: column;
  367. align-items: center;
  368. width: 100%;
  369. .wechat-icon {
  370. width: 110rpx;
  371. height: 110rpx;
  372. }
  373. text {
  374. color: #666666;
  375. font-size: 26rpx;
  376. }
  377. }
  378. }
  379. }
  380. .agreement-part {
  381. position: absolute;
  382. left: 0;
  383. bottom: 60rpx;
  384. width: 100%;
  385. font-size: 26rpx;
  386. color: #999999;
  387. text-align: center;
  388. .agreement {
  389. color: #FC1E1E;
  390. border-bottom: 1rpx solid #FC1E1E;
  391. }
  392. }
  393. .login-register {
  394. display: flex;
  395. justify-content: center;
  396. margin-top: 33rpx;
  397. .mobile-login {
  398. color: #2D2D2D;
  399. font-size: 28rpx;
  400. line-height: 34rpx;
  401. border-right: 1px solid rgba(0, 0, 0, .1);
  402. padding-right: 30rpx;
  403. margin-right: 30rpx;
  404. }
  405. .register {
  406. color: #FC1C1C;
  407. font-size: 28rpx;
  408. line-height: 34rpx;
  409. }
  410. }
  411. </style>