changePwd.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <!-- 修改登录密码、修改支付密码 -->
  2. <template>
  3. <view class="container flex_column_start_center">
  4. <view class="input-content flex_column_start_center">
  5. <view class="input-item pwd_wrap">
  6. <input type="text" :value="passwordOld" :placeholder="$L('请输入旧密码')" maxlength="20" :password="!showPwdOld" data-key="passwordOld"
  7. placeholder-class='placeholder_class' @input="inputChange" />
  8. <view class="pwd-right">
  9. <text class="clear-pwd iconfont iconziyuan51" v-show="passwordOld" @click="clearContent('passwordOld')"></text>
  10. <text :class="pwdStateOld" @click="changePwdState('showPwdOld')"></text>
  11. </view>
  12. </view>
  13. <!-- <view class="confirmState">
  14. <text>{{passwordOldState}}</text>
  15. </view> -->
  16. <view class="input-item pwd_wrap">
  17. <input type="text" :value="passwordNew" :placeholder="$L('建议设置6~20位英文、数字或符号的新密码')" maxlength="20" :password="!showPwdNew"
  18. data-key="passwordNew" placeholder-class='placeholder_class' @input="inputChange" @confirm="confirm" />
  19. <view class="pwd-right">
  20. <text class="clear-pwd iconfont iconziyuan51" v-show="passwordNew" @click="clearContent('passwordNew')"></text>
  21. <text :class="pwdStateNew" @click="changePwdState('showPwdNew')"></text>
  22. </view>
  23. </view>
  24. <!-- <view class="confirmState">
  25. <text>{{passwordNewState}}</text>
  26. </view> -->
  27. </view>
  28. <button class="confirm-btn" @click="confirm" :disabled="logining">{{$L('确定')}}</button>
  29. </view>
  30. </template>
  31. <script>
  32. import {
  33. mapMutations,
  34. mapState
  35. } from 'vuex';
  36. export default {
  37. data() {
  38. return {
  39. source: '', //页面来源: change_login:重置登录密码change_pay:修改支付密码
  40. passwordOld: '',
  41. passwordNew: '',
  42. smsCode: '',
  43. logining: false,
  44. showPwdOld: false,
  45. showPwdNew: false,
  46. countDownM: 0, //短信验证码倒计时
  47. timeOutId: '', //定时器的返回值,
  48. passwordNewState:'',
  49. passwordOldState:''
  50. }
  51. },
  52. onLoad(options) {
  53. this.source = options.source;
  54. let page_title = ''
  55. if (options.source == 'change_login') {
  56. page_title = '修改登录密码';
  57. } else if (options.source == 'change_pay') {
  58. page_title = '修改支付密码';
  59. }
  60. //设置页面标题
  61. uni.setNavigationBarTitle({
  62. title: page_title
  63. });
  64. },
  65. computed: {
  66. ...mapState(['userInfo', 'userCenterData']),
  67. pwdStateOld: function() {
  68. return {
  69. 'pwd-tab': true,
  70. iconfont: true,
  71. iconziyuan81: this.showPwdOld,
  72. iconziyuan9: !this.showPwdOld,
  73. }
  74. },
  75. pwdStateNew: function() {
  76. return {
  77. 'pwd-tab': true,
  78. iconfont: true,
  79. iconziyuan81: this.showPwdNew,
  80. iconziyuan9: !this.showPwdNew,
  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. if(/[\u4E00-\u9FA5]/g.test(e.detail.value)){
  90. this[key+'State'] = '密码格式不正确'
  91. }else{
  92. this[key+'State'] = ''
  93. }
  94. },
  95. navBack() {
  96. uni.navigateBack();
  97. },
  98. //确认事件
  99. confirm() {
  100. const {
  101. source,
  102. passwordOld,
  103. passwordNew
  104. } = this;
  105. //密码的验证 6~20位,英文、数字或符号
  106. if (!this.$checkPwd(passwordOld)||!this.$checkPwd(passwordNew)) {
  107. return false
  108. }
  109. let param = {};
  110. param.data = {};
  111. param.method = 'POST';
  112. if(this.source == 'change_pay'){ //修改支付密码
  113. param.url = 'v3/member/front/memberPassword/editPayPwd';
  114. param.data.oldPayPwd = passwordOld;
  115. param.data.payPwd = passwordNew;
  116. }else if(this.source == 'change_login'){ //修改登录密码
  117. param.url = 'v3/member/front/memberPassword/editLoginPwd';
  118. param.data.oldLoginPwd = passwordOld;
  119. param.data.loginPwd = passwordNew;
  120. }
  121. this.$request(param).then(res => {
  122. this.$api.msg(res.msg);
  123. if (res.state == 200) {
  124. setTimeout(() => {
  125. uni.navigateBack();
  126. }, 2000)
  127. this.logining = false;
  128. } else {
  129. this.logining = false;
  130. }
  131. }).catch((e) => {})
  132. },
  133. //清空输入的内容
  134. clearContent(type) {
  135. this[type] = '';
  136. },
  137. //是否显示密码切换事件
  138. changePwdState(type) {
  139. this[type] = !this[type];
  140. },
  141. //跳转事件 type:跳转类型,1为redirectTo 2为navigateTo
  142. navTo(url, type) {
  143. if (type == 1) {
  144. uni.redirectTo({
  145. url
  146. })
  147. } else if (type == 2) {
  148. uni.navigateTo({
  149. url
  150. })
  151. }
  152. },
  153. //倒计时
  154. countDown() {
  155. this.countDownM--;
  156. if (this.countDownM == 0) {
  157. clearTimeout(this.timeOutId);
  158. } else {
  159. this.timeOutId = setTimeout(this.countDown, 1000);
  160. }
  161. },
  162. },
  163. }
  164. </script>
  165. <style lang='scss'>
  166. page {
  167. background: $bg-color-split;
  168. display: flex;
  169. flex: 1;
  170. height: 100%;
  171. width: 750rpx;
  172. margin: 0 auto;
  173. }
  174. .container {
  175. flex: 1;
  176. .bind_mobile {
  177. height: 80rpx;
  178. width: 100%;
  179. width: 100%;
  180. background: #F8F8F8;
  181. padding-left: 40rpx;
  182. color: $main-font-color;
  183. font-size: 26rpx;
  184. }
  185. }
  186. .confirmState{
  187. width: 100%;
  188. padding-left: 22rpx;
  189. font-size: 24rpx;
  190. color: #FC1C1C;
  191. margin-top: 10rpx;
  192. margin-bottom: 30rpx;
  193. }
  194. .wrapper {
  195. position: relative;
  196. z-index: 90;
  197. background: #fff;
  198. padding-bottom: 40upx;
  199. }
  200. .back-btn {
  201. position: absolute;
  202. left: 40upx;
  203. z-index: 9999;
  204. padding-top: var(--status-bar-height);
  205. top: 40upx;
  206. font-size: 40upx;
  207. color: $font-color-dark;
  208. }
  209. .input-content {
  210. flex: 1;
  211. width: 100%;
  212. margin-top: 20rpx;
  213. background-color: #fff;
  214. padding: 0 40rpx;
  215. }
  216. .input-item {
  217. display: flex;
  218. flex-direction: column;
  219. align-items: flex-start;
  220. justify-content: center;
  221. width: 100%;
  222. padding: 0 20rpx;
  223. height: 80rpx;
  224. margin-bottom: 40rpx;
  225. border-bottom: 1rpx solid #f2f2f2;
  226. position: relative;
  227. &:first-child {
  228. margin-top: 40rpx;
  229. }
  230. .placeholder_class {
  231. color: #949494;
  232. font-size: 26rpx;
  233. }
  234. .clear-account {
  235. position: absolute;
  236. right: 6rpx;
  237. top: 28rpx;
  238. font-size: 24rpx;
  239. color: #999;
  240. }
  241. .pwd-right {
  242. position: absolute;
  243. right: 6rpx;
  244. top: 14rpx;
  245. .clear-pwd {
  246. font-size: 24rpx;
  247. color: #999;
  248. }
  249. .pwd-tab {
  250. font-size: 22rpx;
  251. color: #666;
  252. margin-left: 20rpx;
  253. margin-right: 28rpx;
  254. }
  255. .forget-pwd {
  256. color: #2D2D2D;
  257. font-size: 28rpx;
  258. line-height: 28rpx;
  259. font-weight: 400;
  260. border-left: 1px solid $border-color-split;
  261. padding-left: 28rpx;
  262. }
  263. }
  264. input {
  265. height: 60upx;
  266. font-size: 28rpx;
  267. color: $main-font-color;
  268. width: 100%;
  269. }
  270. }
  271. .confirm-btn {
  272. position: fixed;
  273. width: 668rpx;
  274. margin: 0 41rpx;
  275. height: 88rpx;
  276. display: flex;
  277. align-items: center;
  278. justify-content: center;
  279. background: linear-gradient(-90deg, rgba(252, 29, 28, 1) 0%, rgba(255, 122, 24, 1) 100%);
  280. border-radius: 44rpx;
  281. left: 50%;
  282. bottom: 40rpx;
  283. transform: translateX(-375rpx);
  284. color: #fff;
  285. font-size: 36rpx;
  286. }
  287. </style>