setPwd.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <view style="background-color: #FFFFFF;height: 100%;width: 100%;padding-top:80rpx">
  3. <view class="shopping-wrapper">
  4. <view>
  5. <u-icon name="close" bold color="#333333" size="20" @click="goBack()"></u-icon>
  6. </view>
  7. <view class="title">
  8. <view class="title-text mb8" v-if="type=='add'">请设置安全密码</view>
  9. <view class="title-text mb8" v-else-if="type=='set-2'">请输入原密码</view>
  10. <view class="title-text mb8" v-else>请输入新密码</view>
  11. <view class="title-prompt">6位数字</view>
  12. </view>
  13. <view>
  14. <u-input
  15. :type="isPasswordVisible ? 'password' : 'text'"
  16. placeholder="请输入内容"
  17. v-model="password"
  18. maxlength="6"
  19. :disabled="isSetPassword"
  20. shape="circle"
  21. placeholderStyle="color:#888888;"
  22. color="#333333"
  23. border="none"
  24. custom-style="background-color: #F3F6FC;padding-right: 20rpx;padding-left: 20rpx;opacity: 0.6;height: 94rpx;"
  25. >
  26. <template slot="suffix">
  27. <u-icon
  28. v-if="password.length>0&&!this.isSetPassword"
  29. :name="isPasswordVisible ? 'eye' : 'eye-off'"
  30. size="20"
  31. @click="togglePasswordVisibility"
  32. />
  33. </template>
  34. </u-input>
  35. </view>
  36. <view style="height: 108rpx; " class="btn-commnt" @click="setPassword()">
  37. <view class="btn-commnt-text" v-if="type=='add'||type=='set-3'">完成</view>
  38. <view class="btn-commnt-text" v-else>下一步</view>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import {checkPayPswd, setPayPswd} from "@/common/api";
  45. import {getUserInfo} from "@/common/api/user";
  46. export default {
  47. data() {
  48. return {
  49. password: '',
  50. userInfo: {},
  51. isSetPassword: false,
  52. isPasswordVisible: true,
  53. type: "add",
  54. verifyCode:"",
  55. };
  56. },
  57. onLoad(options) {
  58. // 保存查询参数到页面的数据对象中
  59. if (options.type) {
  60. this.type = options.type;
  61. }
  62. console.log("type", this.type)
  63. },
  64. onShow() {
  65. this.initUserInfo()
  66. },
  67. methods: {
  68. async getUserInfo() {
  69. const data = {}
  70. await getUserInfo(data)
  71. .then(res => {
  72. if (res.data) {
  73. uni.setStorageSync('token', res.data.token.token)
  74. uni.setStorageSync('userInfo', JSON.stringify(res.data))
  75. this.userInfo = res.data;
  76. }
  77. })
  78. .catch(() => {
  79. uni.hideLoading();
  80. });
  81. },
  82. async initUserInfo() {
  83. await this.getUserInfo();
  84. if (this.userInfo.pay_pswd && this.userInfo.pay_pswd.length > 0&& this.type == 'add' ) {
  85. this.isSetPassword = true;
  86. this.password = this.userInfo.pay_pswd;
  87. }
  88. },
  89. goBack() {
  90. uni.navigateBack({
  91. delta: 1 // 返回上一级页面
  92. });
  93. },
  94. change(e) {
  95. },
  96. togglePasswordVisibility() {
  97. this.isPasswordVisible = !this.isPasswordVisible;
  98. },
  99. savePad() {
  100. if (this.password.length < 6) {
  101. uni.showToast({
  102. title: '请输入6位数字',
  103. icon: 'none',
  104. duration: 2000
  105. });
  106. return
  107. }
  108. if (this.isSetPassword) {
  109. uni.showToast({
  110. title: '您已设置支付密码,无需重复设置',
  111. icon: 'none',
  112. duration: 2000
  113. });
  114. return
  115. }
  116. setPayPswd({pay_pswd: this.password}).then((res) => {
  117. if (this.type!="set-3"){
  118. uni.showToast({
  119. title: '保存成功'
  120. })
  121. }else{
  122. uni.showToast({
  123. title: '修改成功'
  124. })
  125. }
  126. this.isSetPassword = true
  127. setTimeout(() => {
  128. uni.navigateTo({
  129. url: '/subPages/setting/index',
  130. });
  131. }, 500);
  132. })
  133. },
  134. verifyPad() {
  135. if (this.password.length < 6) {
  136. uni.showToast({
  137. title: '请输入6位数字',
  138. icon: 'none',
  139. duration: 2000
  140. });
  141. return
  142. }
  143. checkPayPswd({pay_pswd: this.password}).then((res) => {
  144. uni.navigateTo({
  145. url: "/subPages/setting/setPwd?type=set-3",
  146. });
  147. })
  148. },
  149. setPassword() {
  150. switch (this.type) {
  151. case "add":
  152. this.savePad();
  153. break;
  154. case "set-1":
  155. break;
  156. case "set-2":
  157. this.verifyPad()
  158. break;
  159. case "set-3":
  160. this.savePad();
  161. break;
  162. default:
  163. break;
  164. }
  165. },
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. .shopping-wrapper {
  171. width: 630rpx;
  172. margin: 0rpx auto 0rpx;
  173. padding: 30rpx 30rpx 178rpx;
  174. .title {
  175. display: flex;
  176. flex-direction: column;
  177. align-items: flex-start; /* 左对齐 */
  178. justify-content: flex-start; /* 左对齐 */
  179. margin-top: 112rpx;
  180. margin-bottom: 124rpx;
  181. .title-text {
  182. font-family: PingFang SC, PingFang SC;
  183. font-weight: 600;
  184. font-size: 48rpx;
  185. color: #262424;
  186. line-height: 68rpx;
  187. text-align: left;
  188. font-style: normal;
  189. text-transform: none;
  190. }
  191. .title-prompt {
  192. font-family: PingFang SC, PingFang SC;
  193. font-weight: 400;
  194. font-size: 24rpx;
  195. color: #888888;
  196. line-height: 36rpx;
  197. text-align: center;
  198. font-style: normal;
  199. text-transform: none;;
  200. }
  201. }
  202. .btn-commnt {
  203. margin-top: 40rpx;
  204. background: linear-gradient(315deg, #CA9359 0%, #E2B98E 100%);
  205. border-radius: 292rpx 292rpx 292rpx 292rpx;
  206. opacity: 0.6;
  207. display: flex;
  208. justify-content: center;
  209. align-items: center;
  210. .btn-commnt-text {
  211. font-family: PingFang SC, PingFang SC;
  212. font-weight: 400;
  213. font-size: 32rpx;
  214. color: #FFFFFF;
  215. line-height: 42rpx;
  216. text-align: center;
  217. font-style: normal;
  218. text-transform: none;
  219. }
  220. }
  221. }
  222. </style>