payPassword.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view class="custom-form">
  3. <view class="custom-form-item">
  4. <text>支付密码</text>
  5. <input
  6. v-model="FormData.password"
  7. placeholder="请输入支付密码"
  8. :maxlength="6"
  9. type="number"
  10. :password="!showPassword"
  11. />
  12. <uv-icon
  13. :name="showPassword ? 'eye' : 'eye-fill'"
  14. size="36rpx"
  15. @click="changePassword"
  16. ></uv-icon>
  17. </view>
  18. <view class="custom-form-item">
  19. <text>验证码</text>
  20. <input v-model="FormData.captcha" placeholder="本账户手机验证码" />
  21. <uv-code
  22. :seconds="seconds"
  23. @end="end"
  24. @start="start"
  25. ref="code"
  26. @change="codeChange"
  27. ></uv-code>
  28. <uv-button @tap="getCode" color="#FFECEC" shape="circle">{{
  29. tips
  30. }}</uv-button>
  31. </view>
  32. </view>
  33. <view class="submit">
  34. <uv-button
  35. type="error"
  36. color="#EB5153"
  37. text="确认提交"
  38. shape="circle"
  39. @tap="submit"
  40. ></uv-button>
  41. </view>
  42. </template>
  43. <script setup>
  44. import { ref } from "vue";
  45. import { setPayPassword_Api } from "@/api/userInfo.js";
  46. import { smsCode } from "@/api/login.js";
  47. const FormData = ref({
  48. password: "",
  49. captcha: "",
  50. });
  51. const code = ref();
  52. const seconds = ref(60);
  53. const tips = ref("获取验证码");
  54. const codeChange = (text) => {
  55. tips.value = text;
  56. };
  57. const showPassword = ref(false);
  58. const changePassword = () => {
  59. showPassword.value = !showPassword.value;
  60. };
  61. const getCode = () => {
  62. if (code.value.canGetCode) {
  63. // 模拟向后端请求验证码
  64. uni.showLoading({
  65. title: "正在获取验证码",
  66. });
  67. smsCode({
  68. mobile: FormData.value.mobile,
  69. })
  70. .then((res) => {
  71. uni.$uv.toast("验证码已发送");
  72. })
  73. .finally((e) => {
  74. uni.hideLoading();
  75. // 这里此提示会被this.start()方法中的提示覆盖
  76. code.value.start();
  77. });
  78. } else {
  79. uni.$uv.toast("倒计时结束后再发送");
  80. }
  81. };
  82. const end = () => {
  83. uni.$uv.toast("倒计时结束");
  84. };
  85. const start = () => {
  86. uni.$uv.toast("倒计时开始");
  87. };
  88. const submit = () => {
  89. if (!FormData.value.password) {
  90. return uni.$uv.toast("支付密码不能为空");
  91. }
  92. if (FormData.value.password.length < 6) {
  93. uni.$uv.toast("支付密码长度不能少于6位");
  94. return;
  95. }
  96. if (!FormData.value.captcha) {
  97. return uni.$uv.toast("验证码不能为空");
  98. }
  99. setPayPassword_Api(FormData.value).then((res) => {
  100. uni.showToast({
  101. title: "设置成功",
  102. icon: "success",
  103. });
  104. setTimeout(() => {
  105. uni.navigateBack();
  106. }, 500);
  107. });
  108. };
  109. </script>
  110. <style lang="scss" scoped>
  111. .custom-form {
  112. padding: 20rpx 54rpx;
  113. }
  114. .custom-form {
  115. margin-bottom: 60rpx;
  116. .custom-form-item {
  117. display: flex;
  118. align-items: center;
  119. padding: 30rpx 0;
  120. border-bottom: 1rpx solid #f0f0f0;
  121. text {
  122. margin-right: 24rpx;
  123. font-size: 28rpx;
  124. font-family: PingFang SC, PingFang SC-Regular;
  125. font-weight: normal;
  126. color: #1a1a1a;
  127. flex-shrink: 0;
  128. }
  129. :deep(.input-placeholder) {
  130. font-size: 28rpx;
  131. font-family: PingFang SC, PingFang SC-Regular;
  132. font-weight: normal;
  133. color: #d9d9d9;
  134. }
  135. }
  136. :deep(.uv-button) {
  137. height: 55rpx;
  138. margin-left: auto;
  139. color: #ea3527 !important;
  140. font-size: 26rpx;
  141. font-family: PingFang SC, PingFang SC-Bold;
  142. font-weight: bold;
  143. }
  144. }
  145. .submit {
  146. margin: 0 60rpx;
  147. :deep(.uv-button) {
  148. height: 90rpx;
  149. font-size: 28rpx;
  150. font-family: PingFang SC, PingFang SC-Regular;
  151. font-weight: normal;
  152. text-align: center;
  153. color: #ffffff;
  154. }
  155. }
  156. </style>