password.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <view class="bg">
  3. <app-layout :haveBackground="haveBackground">
  4. <view v-if="!is_success" class="bd-password">
  5. <view v-if="userInfo && userInfo.is_pay_password" class="bd-item dir-left-nowrap cross-center" v-else>
  6. <image src="./image/password.png" class="bd-label box-grow-0"></image>
  7. <input maxlength="6" class="bd-input box-grow-1" v-model="old_pay_password" placeholder="请输入旧密码" :password="isPassword" type="number">
  8. </view>
  9. <view class="bd-item dir-left-nowrap cross-center">
  10. <image src="./image/password.png" class="bd-label box-grow-0"></image>
  11. <input maxlength="6" class="bd-input box-grow-1" v-model="pay_password" :password="isPassword" :placeholder="userInfo && userInfo.is_pay_password ? '请输入新密码' : '请输入密码'" type="number">
  12. </view>
  13. <view class="bd-item dir-left-nowrap cross-center">
  14. <image src="./image/password.png" class="bd-label box-grow-0"></image>
  15. <input maxlength="6" class="bd-input box-grow-1" v-model="verify_pay_password" :password="isPassword" :placeholder="userInfo && userInfo.is_pay_password ? '请确认新密码' : '请确认密码'" type="number">
  16. </view>
  17. <view
  18. class="bd-bottom"
  19. :class="inputPass ? 'bd-yes-agree' : 'bd-no-agree'" @click="modify">
  20. 确认
  21. </view>
  22. <view v-if="userInfo && userInfo.is_pay_password && mall.setting.current_customer_service.qrcode_url" @click="toForget" class="forget">若忘记旧密码请<text style="color: #ff4544;">联系商城客服</text>重置</view>
  23. </view>
  24. <view v-else class="pass-view dir-top-nowrap main-center">
  25. <image class="pass-icon" src="./image/pass.png"></image>
  26. <view>余额支付密码设置成功,请务必牢记该密码</view>
  27. <view @click="toIndex" class="bd-bottom bd-yes-agree">回商城逛逛</view>
  28. </view>
  29. </app-layout>
  30. </view>
  31. </template>
  32. <script>
  33. import { mapGetters, mapState } from "vuex";
  34. export default {
  35. name: "password",
  36. data() {
  37. return {
  38. is_success: false,
  39. old_pay_password: '',
  40. pay_password: '',
  41. verify_pay_password: '',
  42. haveBackground: false,
  43. isPassword: false
  44. }
  45. },
  46. computed: {
  47. ...mapState({
  48. userInfo: state => state.user.info,
  49. mall: state => state.mallConfig.mall
  50. }),
  51. inputPass() {
  52. if(this.userInfo && this.userInfo.is_pay_password) {
  53. return this.old_pay_password.length + this.pay_password.length + this.verify_pay_password.length == 18 ? true : false
  54. }else {
  55. return this.pay_password.length + this.verify_pay_password.length == 12 ? true : false
  56. }
  57. },
  58. },
  59. onLoad() {
  60. const self = this;
  61. self.$request({
  62. url: self.$api.balance.index,
  63. }).then(info => {
  64. if (info.code === 0) {
  65. if(info.data.setting.is_pay_password == 0) {
  66. uni.showToast({
  67. icon: 'none',
  68. title: '支付密码功能未开启'
  69. })
  70. setTimeout(()=>{
  71. uni.navigateBack();
  72. },1000)
  73. }
  74. }
  75. });
  76. // #ifdef MP-WEIXIN || MP-BAIDU
  77. this.isPassword = true;
  78. // #endif
  79. },
  80. methods: {
  81. toForget() {
  82. uni.navigateTo({
  83. url: '/pages/balance/forget'
  84. });
  85. },
  86. toIndex() {
  87. uni.reLaunch({
  88. url:'/pages/index/index'
  89. })
  90. },
  91. modify: function() {
  92. if(this.inputPass) {
  93. this.verify_pay_password = this.verify_pay_password.trim();
  94. this.pay_password = this.pay_password.trim();
  95. this.old_pay_password = this.old_pay_password.trim();
  96. if (this.pay_password === this.verify_pay_password) {
  97. this.$showLoading({
  98. type: 'global',
  99. text: '设置中...'
  100. });
  101. let data = {
  102. pay_password: this.pay_password,
  103. verify_pay_password: this.verify_pay_password,
  104. }
  105. if(this.userInfo.is_pay_password) {
  106. data.old_pay_password = this.old_pay_password;
  107. }
  108. this.$request({
  109. url: this.userInfo.is_pay_password ? this.$api.member.update_password : this.$api.member.set_password,
  110. method: "post",
  111. data: data
  112. }).then(response => {
  113. this.$hideLoading();
  114. if (response.code === 0) {
  115. this.is_success = true;
  116. this.$store.dispatch('user/refresh');
  117. uni.showToast({
  118. title: response.msg,
  119. type: 'success'
  120. });
  121. } else {
  122. uni.showToast({
  123. icon: 'none',
  124. title: response.msg
  125. });
  126. }
  127. });
  128. } else {
  129. uni.showToast({
  130. icon: 'none',
  131. title: '两次输入的密码不一致'
  132. })
  133. }
  134. }
  135. },
  136. }
  137. }
  138. </script>
  139. <style scoped>
  140. .forget {
  141. position: absolute;
  142. bottom: 28upx;
  143. width: 100%;
  144. left: 0;
  145. text-align: center;
  146. color: #999;
  147. font-size: 28upx;
  148. height: 94upx;
  149. line-height: 94upx;
  150. }
  151. .bg {
  152. position: absolute;
  153. top: 0;
  154. left: 0;
  155. width: 100%;
  156. height: 100%;
  157. background: #fff;
  158. }
  159. .pass-view {
  160. font-size: 28upx;
  161. color: #999999;
  162. text-align: center;
  163. background-color: #ffffff;
  164. }
  165. .pass-view .bd-bottom {
  166. width: 354upx;
  167. font-size: 28upx;
  168. margin: 68upx auto;
  169. }
  170. .pass-icon {
  171. width: 228upx;
  172. height: 228upx;
  173. display: block;
  174. margin: 100upx auto 80upx;
  175. }
  176. .bd-password {
  177. min-height: 100vh;
  178. background-color: #ffffff;
  179. padding: 46upx 42upx;
  180. }
  181. .bd-item {
  182. height: 100upx;
  183. border-bottom: 2upx solid #f4f4f4;
  184. }
  185. .bd-label {
  186. width: 36upx;
  187. height: 36upx;
  188. margin: 0 25upx 0 2upx;
  189. }
  190. .bd-input {
  191. height: 100%;
  192. }
  193. .bd-image {
  194. width: 160upx;
  195. height: 67upx;
  196. }
  197. .bd-bottom {
  198. height: 88upx;
  199. line-height: 88upx;
  200. color: #ffffff;
  201. font-size: 36upx;
  202. border-radius: 44upx;
  203. margin-top: 68upx;
  204. text-align: center;
  205. }
  206. .bd-yes-agree {
  207. background: rgba(255, 69, 68, 1);
  208. }
  209. .bd-no-agree {
  210. background: rgba(255, 69, 68, 0.5);
  211. }
  212. .bd-agree-group {
  213. margin-top: 42upx;
  214. }
  215. .bd-color {
  216. font-size: 28upx;
  217. color: #ff4544;
  218. }
  219. .bd-btn {
  220. border-left: 1upx solid #f4f4f4;
  221. width: 226upx;
  222. height: 53upx;
  223. line-height: 53upx;
  224. font-size: 32upx;
  225. color: #ff4544;
  226. text-align: center;
  227. }
  228. </style>