managePwd.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <!-- 设置登录密码、设置支付密码、重置支付密码页面 -->
  2. <template>
  3. <view class="container flex_column_start_center">
  4. <view class="bind_mobile flex_row_start_center">
  5. {{$L('您已绑定手机号')}}{{userCenterData.memberMobile?this.$replaceConByPosition(this.userCenterData.memberMobile,4,6,'****'):''}},{{$L('请用该手机号接收短信')}}
  6. </view>
  7. <view class="input-content flex_column_start_center">
  8. <view class="input-item pwd_wrap">
  9. <input type="number" :value="smsCode" maxlength="6" :placeholder="$L('请输入短信验证码')" data-key="smsCode" @input="inputChange" placeholder-class='placeholder_class'/>
  10. <view class="pwd-right">
  11. <text class="clear-pwd iconfont iconziyuan51" v-show="smsCode" @click="clearContent('smsCode')"></text>
  12. <view :style="{opacity: countDownM?0.3:1}" class="sms-code-view" @click="getSmsCode">
  13. <text class="sms-code">{{countDownM?`${countDownM}s后重新获取`:'获取验证码'}}</text>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="input-item pwd_wrap">
  18. <input type="text" :value="password" :placeholder="$L('建议6~20位英文、数字或符号的新密码')" maxlength="20" :password="!showPwd" data-key="password" placeholder-class='placeholder_class'
  19. @input="inputChange"/>
  20. <view class="pwd-right">
  21. <text class="clear-pwd iconfont iconziyuan51" v-show="password" @click="clearContent('password')"></text>
  22. <text :class="pwdState" @click="changePwdState"></text>
  23. </view>
  24. </view>
  25. <view class="input-item pwd_wrap">
  26. <input type="text" :value="confirmPwd" placeholder="再次确认密码" maxlength="20" data-key="confirmPwd" :password="!showPwd" placeholder-class='placeholder_class'
  27. @input="inputChange" @confirm="confirmPwds" />
  28. <view class="pwd-right">
  29. <text class="clear-pwd iconfont iconziyuan51" v-show="confirmPwd" @click="clearContent('confirmPwd')"></text>
  30. <text :class="pwdState" @click="changePwdState"></text>
  31. </view>
  32. </view>
  33. <view class="confirmState">
  34. <text>{{confirmState}}</text>
  35. </view>
  36. </view>
  37. <button class="confirm-btn" @click="confirm" :disabled="logining">{{$L('确定')}}</button>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. mapMutations,mapState
  43. } from 'vuex';
  44. export default {
  45. data() {
  46. return {
  47. source: '', //页面来源: reset_pay:重置支付密码 set_login:设置登录密码,set_pay:设置支付密码
  48. password: '',
  49. smsCode: '',
  50. logining: false,
  51. showPwd: false,
  52. countDownM: 0,//短信验证码倒计时
  53. timeOutId:'',//定时器的返回值,
  54. confirmPwd:'',
  55. confirmState:''
  56. }
  57. },
  58. onLoad(options) {
  59. this.source = options.source;
  60. let page_title = ''
  61. if (options.source == 'reset_pay') {
  62. page_title = '重置支付密码';
  63. } else if (options.source == 'set_login') {
  64. page_title = '设置登录密码';
  65. } else if (options.source == 'set_pay') {
  66. page_title = '设置支付密码';
  67. }
  68. //设置页面标题
  69. uni.setNavigationBarTitle({
  70. title: page_title
  71. });
  72. },
  73. computed: {
  74. ...mapState(['userInfo','userCenterData']),
  75. pwdState: function() {
  76. return {
  77. 'pwd-tab': true,
  78. iconfont: true,
  79. iconkejian: this.showPwd,
  80. iconbukejian: !this.showPwd,
  81. }
  82. }
  83. },
  84. methods: {
  85. ...mapMutations(['login', 'setUserCenterData','userInfo']),
  86. inputChange(e) {
  87. const key = e.currentTarget.dataset.key;
  88. this[key] = e.detail.value;
  89. },
  90. navBack() {
  91. uni.navigateBack();
  92. },
  93. //获取短信验证码
  94. getSmsCode() {
  95. if(this.countDownM){
  96. return;
  97. }
  98. let param = {};
  99. param.url = 'v3/msg/front/commons/sendVerifyCode';
  100. param.data = {};
  101. param.method = 'GET';
  102. param.data.verifyType = 2;
  103. param.data.verifyAddr = this.userCenterData.memberMobile;
  104. this.$request(param).then(res => {
  105. this.$api.msg(res.msg);
  106. if(res.state == 200){
  107. this.countDownM = 60;
  108. this.countDown();
  109. }
  110. })
  111. },
  112. confirmPwds(){
  113. if(this.confirmPwd!=this.password){
  114. this.confirmState = '密码确认不一致'
  115. }else {
  116. this.confirmState = ''
  117. }
  118. },
  119. //确认事件
  120. confirm() {
  121. const {
  122. mobile,
  123. password,
  124. smsCode
  125. } = this;
  126. //密码的验证 6~20位,英文、数字或符号
  127. if(!this.smsCode){
  128. this.$api.msg('请填短信验证码')
  129. return false
  130. }
  131. if (!this.$checkPwd(password)) {
  132. return false;
  133. }
  134. if(this.confirmPwd!=this.password){
  135. this.confirmState = '密码确认不一致'
  136. return false
  137. }else {
  138. this.confirmState = ''
  139. }
  140. let param = {};
  141. param.data = {};
  142. param.method = 'POST';
  143. if(this.source == 'reset_pay'||this.source == 'set_pay'){
  144. param.url = 'v3/member/front/memberPassword/addPayPwd';
  145. param.data.memberMobile = this.userCenterData.memberMobile;
  146. param.data.verifyCode = smsCode;
  147. param.data.payPwd = password;
  148. }else if(this.source == 'set_login'){
  149. param.url = 'v3/member/front/memberPassword/addLoginPwd';
  150. param.data.memberMobile = this.userCenterData.memberMobile;
  151. param.data.verifyCode = smsCode;
  152. param.data.loginPwd = password;
  153. }
  154. this.$request(param).then(res => {
  155. this.$api.msg(res.msg);
  156. if (res.state == 200) {
  157. if(this.source == 'set_pay'){
  158. this.userCenterData.hasPayPassword = 1;
  159. }else if(this.source == 'set_login'){
  160. this.userCenterData.hasLoginPassword = 1;
  161. }
  162. //更新个人信息数据
  163. this.setUserCenterData(this.userCenterData);
  164. setTimeout(() => {
  165. uni.navigateBack();
  166. }, 2000)
  167. } else {
  168. this.logining = false;
  169. }
  170. }).catch((e) => {})
  171. },
  172. //清空输入的内容
  173. clearContent(type) {
  174. this[type] = '';
  175. },
  176. //是否显示密码切换事件
  177. changePwdState() {
  178. this.showPwd = !this.showPwd;
  179. },
  180. //跳转事件 type:跳转类型,1为redirectTo 2为navigateTo
  181. navTo(url, type) {
  182. if (type == 1) {
  183. uni.redirectTo({
  184. url
  185. })
  186. } else if (type == 2) {
  187. uni.navigateTo({
  188. url
  189. })
  190. }
  191. },
  192. //倒计时
  193. countDown() {
  194. this.countDownM--;
  195. if (this.countDownM == 0) {
  196. clearTimeout(this.timeOutId);
  197. } else {
  198. this.timeOutId = setTimeout(this.countDown,1000);
  199. }
  200. },
  201. },
  202. }
  203. </script>
  204. <style lang='scss'>
  205. page {
  206. background: $bg-color-split;
  207. display: flex;
  208. flex: 1;
  209. height: 100%;
  210. width: 750rpx;
  211. margin: 0 auto;
  212. }
  213. .container {
  214. flex: 1;
  215. .bind_mobile {
  216. height: 80rpx;
  217. width: 100%;
  218. width: 100%;
  219. background: #F8F8F8;
  220. padding-left: 40rpx;
  221. color: $main-font-color;
  222. font-size: 26rpx;
  223. }
  224. }
  225. .wrapper {
  226. position: relative;
  227. z-index: 90;
  228. background: #fff;
  229. padding-bottom: 40upx;
  230. }
  231. .back-btn {
  232. position: absolute;
  233. left: 40upx;
  234. z-index: 9999;
  235. padding-top: var(--status-bar-height);
  236. top: 40upx;
  237. font-size: 40upx;
  238. color: $font-color-dark;
  239. }
  240. .input-content {
  241. flex: 1;
  242. width: 100%;
  243. background-color: #fff;
  244. padding: 0 40rpx;
  245. }
  246. .confirmState{
  247. width: 100%;
  248. font-size: 24rpx;
  249. color: #FC1C1C;
  250. }
  251. .input-item {
  252. display: flex;
  253. flex-direction: column;
  254. align-items: space-between;
  255. justify-content: center;
  256. width: 100%;
  257. padding: 0 20rpx;
  258. height: 80rpx;
  259. margin-bottom: 40rpx;
  260. border-bottom: 1rpx solid #f2f2f2;
  261. position: relative;
  262. .placeholder_class{
  263. color: #949494;
  264. font-size: 26rpx;
  265. line-height: 80rpx;
  266. }
  267. .clear-account {
  268. position: absolute;
  269. right: 6rpx;
  270. top: 28rpx;
  271. font-size: 24rpx;
  272. color: #999;
  273. }
  274. &:first-child{
  275. margin-top: 40rpx;
  276. .pwd-right {
  277. position: absolute;
  278. right: 6rpx;
  279. top: 6rpx;
  280. display: flex;
  281. align-items: center;
  282. z-index: 100;
  283. .clear-pwd {
  284. font-size: 24rpx;
  285. color: #999;
  286. }
  287. .sms-code-view {
  288. border: 1px solid $main-color;
  289. padding: 14rpx;
  290. border-radius: 6rpx;
  291. line-height: 0;
  292. margin-left: 20rpx;
  293. .sms-code {
  294. color: $main-color;
  295. font-size: 24rpx;
  296. line-height: 24rpx;
  297. }
  298. }
  299. }
  300. }
  301. &:nth-child(3),&:nth-child(2){
  302. margin-bottom: 20rpx;
  303. .pwd-right {
  304. position: absolute;
  305. right: 6rpx;
  306. top: 14rpx;
  307. .clear-pwd {
  308. font-size: 24rpx;
  309. color: #999;
  310. }
  311. .pwd-tab {
  312. font-size: 30rpx;
  313. color: #666;
  314. margin-left: 20rpx;
  315. margin-right: 28rpx;
  316. }
  317. .forget-pwd {
  318. color: #2D2D2D;
  319. font-size: 28rpx;
  320. line-height: 28rpx;
  321. font-weight: 400;
  322. border-left: 1px solid $border-color-split;
  323. padding-left: 28rpx;
  324. }
  325. }
  326. }
  327. input {
  328. height: 60upx;
  329. font-size: 28rpx;
  330. color: $main-font-color;
  331. }
  332. }
  333. .confirm-btn {
  334. position: fixed;
  335. width: 668rpx;
  336. margin: 0 41rpx;
  337. height: 88rpx;
  338. background: linear-gradient(-90deg, rgba(252, 29, 28, 1) 0%, rgba(255, 122, 24, 1) 100%);
  339. border-radius: 44rpx;
  340. left: 50%;
  341. transform: translateX(-375rpx);
  342. bottom: 40rpx;
  343. color: #fff;
  344. font-size: 36rpx;
  345. line-height: 88rpx;
  346. }
  347. </style>