add.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. 添加银行
  25. </view>
  26. </view>
  27. <u-select v-model="bankTypeShow" :default-value="bankTypeDefaultValue" :list="bankTypeList" @confirm="bankTypeConfirm"></u-select>
  28. <u-select v-model="bankAccountTypeShow" :default-value="bankAccountTypeDefaultValue" :list="bankAccountTypeList" @confirm="bankAccountTypeConfirm"></u-select>
  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:1,
  46. cardNo:'',
  47. realName:'',
  48. phone:'',
  49. bankType:'',
  50. bankTypeLabel:'',
  51. bankAccountType:'',
  52. bankAccountTypeLabel:''
  53. },
  54. }
  55. },
  56. onLoad(options) {
  57. this.id=options.id
  58. this.init()
  59. },
  60. methods: {
  61. async init(){
  62. this.bankModel.userId=this.vuex_shopId
  63. this.bankModel.phone=this.$cache.get('phone')
  64. await this.getBankType()
  65. await this.getBankAccountType()
  66. if (this.id) {
  67. uni.setNavigationBarTitle({
  68. title:"编辑银行卡"
  69. })
  70. this.fetchUserBank()
  71. }else{
  72. uni.setNavigationBarTitle({
  73. title:"添加银行卡"
  74. })
  75. }
  76. },
  77. //回显 begin
  78. fetchUserBank(){
  79. let params={
  80. id:this.id
  81. }
  82. this.$api.userBank.detail(params).then(res=>{
  83. if (!this.$isEmpty(res.data)) {
  84. this.bankModel=res.data
  85. }
  86. })
  87. },
  88. //字典 begin
  89. async getBankType() {
  90. let res = await this.$api.dict({code: 'bank_type'})
  91. res.data.forEach(item=>{
  92. let obj={
  93. label:item.dictValue,
  94. value:item.dictKey
  95. }
  96. this.bankTypeList.push(obj)
  97. })
  98. },
  99. async getBankAccountType() {
  100. let res = await this.$api.dict({code: 'bank_account_type'})
  101. res.data.forEach(item=>{
  102. let obj={
  103. label:item.dictValue,
  104. value:item.dictKey
  105. }
  106. this.bankAccountTypeList.push(obj)
  107. })
  108. },
  109. //字典 end
  110. bankTypeConfirm(e){
  111. this.bankModel.bankTypeLabel=e[0].label
  112. this.bankModel.bankType=e[0].value
  113. },
  114. bankAccountTypeConfirm(e){
  115. this.bankModel.bankAccountTypeLabel=e[0].label
  116. this.bankModel.bankAccountType=e[0].value
  117. },
  118. confirm() {
  119. if (this.$isEmpty(this.bankModel.phone)) {
  120. this.$u.toast('请输入联系方式')
  121. return
  122. }
  123. if (this.$isEmpty(this.bankModel.bankType)) {
  124. this.$u.toast('请选择银行类型')
  125. return
  126. }
  127. if (this.$isEmpty(this.bankModel.bankAccountType)) {
  128. this.$u.toast('请选择账户类型')
  129. return
  130. }
  131. if (this.$isEmpty(this.bankModel.realName)) {
  132. this.$u.toast('请输入开户姓名')
  133. return
  134. }
  135. if (this.$isEmpty(this.bankModel.cardNo)) {
  136. this.$u.toast('请输入银行卡号')
  137. return
  138. }
  139. this.$api.userBank.submit(this.bankModel).then(res=>{
  140. if (res.success) {
  141. this.$dialog.showModal('操作成功',false).then(()=>{
  142. uni.navigateBack()
  143. })
  144. }
  145. })
  146. },
  147. }
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. .custom-style {
  152. background-color: #5b3ee7;
  153. width: 400upx;
  154. color: #ffffff;
  155. }
  156. </style>