bank-account.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <!-- 绑定支付宝帐号 alipayAccount -->
  2. <template>
  3. <view>
  4. <!-- 标题栏 -->
  5. <view class="head-box ss-m-b-60">
  6. <view class="head-title ss-m-b-20">
  7. {{ userInfo.bankName && userInfo.accountName && userInfo.bankAccount ? '更换银行卡' : '绑定银行卡' }}
  8. </view>
  9. <!-- <view class="head-subtitle">请绑定已实名认证的支付宝开户行</view> -->
  10. </view>
  11. <!-- 表单项 -->
  12. <uni-forms ref="alipayAccountRef" v-model="state.model" :rules="state.rules" validateTrigger="bind"
  13. labelWidth="160" labelAlign="left" class="loginUniForm" >
  14. <uni-forms-item label="开户行" class="loginUniFormItem">
  15. <uni-easyinput placeholder="例:xx银行股份有限公司xx分行xx支行" v-model="state.model.bankName" :inputBorder="false">
  16. </uni-easyinput>
  17. </uni-forms-item>
  18. <uni-forms-item label="开户名" class="loginUniFormItem">
  19. <uni-easyinput placeholder="个人姓名" v-model="state.model.accountName" :inputBorder="false">
  20. </uni-easyinput>
  21. </uni-forms-item>
  22. <uni-forms-item label="银行卡账号" name="bankCode" class="loginUniFormItem">
  23. <uni-easyinput placeholder="银行卡账号" v-model="state.model.bankAccount" :inputBorder="false">
  24. </uni-easyinput>
  25. </uni-forms-item>
  26. </uni-forms>
  27. <view style="display: flex;justify-content: space-between;margin-top: 20rpx;">
  28. <!-- <button class="ss-reset-button forgot-btn" @tap="showAuthModal('resetPassword')">
  29. 忘记密码
  30. </button> -->
  31. <button class="ss-reset-button login-btn-start" @tap="submit">确定</button>
  32. </view>
  33. </view>
  34. </template>
  35. <script setup>
  36. import {
  37. ref,
  38. reactive,
  39. unref,
  40. computed
  41. } from 'vue';
  42. import sheep from '@/sheep';
  43. import {
  44. bankCode
  45. } from '@/sheep/validate/form';
  46. import {
  47. showAuthModal,
  48. closeAuthModal
  49. } from '@/sheep/hooks/useModal';
  50. import AuthUtil from '@/sheep/api/member/auth';
  51. import UserApi from '@/sheep/api/member/user';
  52. import {
  53. onLoad
  54. } from '@dcloudio/uni-app';
  55. const userInfo = computed(() => sheep.$store('user').userInfo);
  56. const alipayAccountRef = ref(null);
  57. const emits = defineEmits(['onConfirm']);
  58. const props = defineProps({
  59. agreeStatus: {
  60. type: Boolean,
  61. default: false,
  62. },
  63. });
  64. // 数据
  65. const state = reactive({
  66. model: {
  67. accountName: '', // 开户名
  68. bankName: '', // 开户行
  69. bankAccount:'',//银行账号
  70. },
  71. rules:{
  72. bankCode
  73. }
  74. });
  75. // 开户行登录
  76. async function submit() {
  77. // 表单验证
  78. if(!state.model.accountName || !state.model.bankName || !state.model.bankAccount){
  79. return false;
  80. }
  81. const validate = await unref(alipayAccountRef)
  82. .validate()
  83. .catch((error) => {
  84. console.log('error: ', error);
  85. });
  86. if (!validate) return;
  87. // 同意协议
  88. // if (!props.agreeStatus) {
  89. // emits('onConfirm', true)
  90. // sheep.$helper.toast('请勾选同意');
  91. // return;
  92. // }
  93. // 提交数据
  94. const {
  95. code
  96. } = await UserApi.updateUserBankAccount({
  97. accountName: state.model.accountName,
  98. bankName: state.model.bankName,
  99. bankAccount: state.model.bankAccount,
  100. });
  101. // const {
  102. // code,
  103. // data
  104. // } = await AuthUtil.login(state.model);
  105. if (code === 0) {
  106. uni.showToast({
  107. icon: 'success',
  108. title: "修改成功",
  109. });
  110. closeAuthModal();
  111. uni.$emit('bankAccountChangeComplete');
  112. }
  113. }
  114. onLoad(async (options) => {
  115. // getUserInfo();
  116. // state.model.accountName = userInfo.value.accountName;
  117. // state.model.bankName = userInfo.value.bankName;
  118. // state.model.bankAccount = userInfo.value.bankAccount;
  119. });
  120. </script>
  121. <style lang="scss" scoped>
  122. @import '../index.scss';
  123. .login-btn-start {
  124. background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  125. width: 100%;
  126. height: 80rpx;
  127. font-size: 32rpx;
  128. }
  129. .loginUniForm {
  130. border: 1rpx solid #d6d6d6;
  131. padding: 10rpx 15rpx;
  132. border-radius: 10rpx;
  133. }
  134. .loginUniFormItem {
  135. border-bottom: 1rpx solid #d6d6d6;
  136. padding-bottom: 10rpx;
  137. }
  138. .loginUniFormItem:last-child {
  139. border-bottom: none;
  140. padding-top: 10rpx;
  141. }
  142. ::v-deep .loginUniFormItem .uni-forms-item__inner {
  143. padding-bottom: 0;
  144. }
  145. ::v-deep .loginUniFormItem .uni-error-message {
  146. bottom: -20rpx;
  147. }
  148. </style>