add.vue 4.3 KB

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