add.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view>
  3. <view class="bg-white " style="padding: 0rpx 40rpx;margin-top: 30rpx;">
  4. <u-form :model="bankModel" ref="uForm" label-width="180">
  5. <u-form-item label="账户类型">
  6. <u-input type="select" placeholder="请选择账户类型" v-model="bankModel.bankAccountTypeLabel"
  7. @click="bankAccountTypeShow = true" />
  8. </u-form-item>
  9. <u-form-item label="银行类型" >
  10. <u-input type="select" placeholder="请选择银行类型" v-model="bankModel.bankTypeLabel"
  11. @click="bankTypeShow = true" />
  12. </u-form-item>
  13. <u-form-item label="银行卡号">
  14. <u-input v-model="bankModel.cardNo" placeholder="请输入银行卡号" :clearable="false" />
  15. </u-form-item>
  16. </u-form>
  17. </view>
  18. <view class="footer-fixed" style="margin: 0 50rpx 200rpx;z-index: 9;">
  19. <view @click="confirm" class="bg-gradual-base cu-btn round"
  20. style="padding: 46rpx;width: calc(100% - 100rpx);">
  21. <text v-if="$isEmpty(id)">添加银行</text>
  22. <text v-else>确定修改</text>
  23. </view>
  24. </view>
  25. <u-select confirm-color="#EF9944" v-model="bankTypeShow" :list="bankTypeList" @confirm="bankTypeConfirm"></u-select>
  26. <u-select confirm-color="#EF9944" v-model="bankAccountTypeShow" :list="bankAccountTypeList" @confirm="bankAccountTypeConfirm">
  27. </u-select>
  28. <toast ref="toast" ></toast>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. id: '',
  36. //银行类型
  37. bankTypeShow: false,
  38. bankTypeList: [],
  39. //账户类型
  40. bankAccountTypeShow: false,
  41. bankAccountTypeList: [],
  42. //银行对象
  43. bankModel: {
  44. userId: '',
  45. userType: '商户',
  46. cardNo: '',
  47. bankType: '',
  48. bankTypeLabel: '',
  49. bankAccountType: '',
  50. bankAccountTypeLabel: ''
  51. },
  52. }
  53. },
  54. onLoad(options) {
  55. this.id = options.id
  56. this.init()
  57. },
  58. methods: {
  59. async init() {
  60. this.bankModel.userId = this.vuex_shopId
  61. await this.getBankType()
  62. await this.getBankAccountType()
  63. if (this.id) {
  64. uni.setNavigationBarTitle({
  65. title: "编辑银行卡"
  66. })
  67. this.fetchUserBank()
  68. } else {
  69. uni.setNavigationBarTitle({
  70. title: "添加银行卡"
  71. })
  72. }
  73. },
  74. //回显 begin
  75. fetchUserBank() {
  76. let params = {
  77. id: this.id
  78. }
  79. this.$api.userBank.detail(params).then(res => {
  80. if (!this.$isEmpty(res.data)) {
  81. this.bankModel = res.data
  82. }
  83. })
  84. },
  85. //字典 begin
  86. async getBankType() {
  87. let params = {
  88. code: 'bank_type',
  89. size: 9
  90. }
  91. let res = await this.$api.dict.dictionaryPage(params)
  92. let list = res.data.records
  93. list.shift()
  94. list.forEach(item => {
  95. let obj = {
  96. label: JSON.parse(item.dictValue).name,
  97. value: item.dictKey
  98. }
  99. this.bankTypeList.push(obj)
  100. })
  101. this.bankModel.bankTypeLabel = this.bankTypeList[0].label
  102. this.bankModel.bankType = this.bankTypeList[0].value
  103. },
  104. async getBankAccountType() {
  105. let res = await this.$api.dict.list({
  106. code: 'bank_account_type'
  107. })
  108. res.data.forEach(item => {
  109. let obj = {
  110. label: item.dictValue,
  111. value: item.dictKey
  112. }
  113. this.bankAccountTypeList.push(obj)
  114. this.bankModel.bankAccountType = this.bankAccountTypeList[0].value
  115. this.bankModel.bankAccountTypeLabel = this.bankAccountTypeList[0].label
  116. })
  117. },
  118. //字典 end
  119. bankTypeConfirm(e) {
  120. this.bankModel.bankTypeLabel = e[0].label
  121. this.bankModel.bankType = e[0].value
  122. },
  123. bankAccountTypeConfirm(e) {
  124. this.bankModel.bankAccountTypeLabel = e[0].label
  125. this.bankModel.bankAccountType = e[0].value
  126. },
  127. async confirm() {
  128. if (this.$isEmpty(this.bankModel.bankType)) {
  129. this.$refs.toast.warn('请选择银行类型')
  130. return
  131. }
  132. if (this.$isEmpty(this.bankModel.bankAccountType)) {
  133. this.$refs.toast.warn('请选择账户类型')
  134. return
  135. }
  136. if (this.$isEmpty(this.bankModel.cardNo)) {
  137. this.$refs.toast.warn('请输入银行卡号')
  138. return
  139. }
  140. let model = {
  141. merchantNo: this.vuex_merchantNo,
  142. bankCardType: this.bankModel.bankAccountType,
  143. accountNo: this.bankModel.cardNo,
  144. bankCode: this.bankModel.bankType
  145. }
  146. let res=await this.$api.yeepay.withdrawCardBind(model)
  147. let result=JSON.parse(res.data.result)
  148. if (this.$isEmpty(result.bindId)) {
  149. this.$refs.toast.error(result.returnMsg)
  150. return
  151. }
  152. this.$dialog.showModalAndBack('操作成功')
  153. },
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. .custom-style {
  159. background-color: #5b3ee7;
  160. width: 400upx;
  161. color: #ffffff;
  162. }
  163. </style>