agent.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <view>
  3. <view class="container">
  4. <view class="title" style="padding: 50upx 0 30upx 30upx;">代理方式</view>
  5. <view style="padding:0 10rpx 36rpx;">
  6. <text class="cuIcon-title btn-color text-bold margin-left-10" style="font-size: 36rpx;"></text>
  7. <text>渠道合伙人</text>
  8. </view>
  9. <view class="title padding">所在城市</view>
  10. <u-picker mode="region" v-model="regionShow" :params="params" @confirm="getRegion"></u-picker>
  11. <view class="flex align-center justify-between" >
  12. <view class="padding-left padding-right" style="width: 100%;">
  13. <u-input type="select" v-model="region" placeholder="请选择代理所在城市" @click="regionShow = true"/>
  14. </view>
  15. </view>
  16. <view class="padding-lr"><u-line color="#eaeaea"></u-line></view>
  17. <view class="title padding">联系方式</view>
  18. <view class="padding-left">
  19. <u-input v-model="model.userPhone" placeholder="请输入手机号码" :clearable="false"/>
  20. </view>
  21. <view class="padding-lr"><u-line color="#eaeaea"></u-line></view>
  22. <view class="title padding">选择银行类型</view>
  23. <view class="flex align-center justify-between padding-bottom-sm" >
  24. <view class="padding-left padding-right" style="width: 100%;">
  25. <u-input type="select" placeholder="请选择银行类型" v-model="bankModel.bankTypeLabel" @click="bankTypeShow = true"/>
  26. </view>
  27. </view>
  28. <view class="title padding">选择账户类型</view>
  29. <view class="flex align-center justify-between padding-bottom-sm" >
  30. <view class="padding-left padding-right" style="width: 100%;">
  31. <u-input type="select" placeholder="请选择账户类型" v-model="bankModel.bankAccountTypeLabel" @click="bankAccountTypeShow = true"/>
  32. </view>
  33. </view>
  34. <view class="padding-lr"><u-line color="#eaeaea"></u-line></view>
  35. <view class="title padding">开户姓名</view>
  36. <view class="padding-left">
  37. <u-input v-model="bankModel.realName" placeholder="请输入开户姓名" :clearable="false" />
  38. </view>
  39. <view class="title padding" >银行卡号</view>
  40. <view class="padding-left padding-bottom-20">
  41. <u-input v-model="bankModel.cardNo" placeholder="请输入银行卡号" :clearable="false" />
  42. </view>
  43. </view>
  44. <view class="bottom-bar safe-area-inset-bottom margin-top-50 margin-bottom-20">
  45. <view @click="confirm" class="bg-gradual-base cu-btn round" style="width: 100%;padding: 46rpx;">
  46. 下一步
  47. </view>
  48. </view>
  49. <u-select v-model="bankTypeShow" :default-value="bankTypeDefaultValue" :list="bankTypeList" @confirm="bankTypeConfirm"></u-select>
  50. <u-select v-model="bankAccountTypeShow" :default-value="bankAccountTypeDefaultValue" :list="bankAccountTypeList" @confirm="bankAccountTypeConfirm"></u-select>
  51. </view>
  52. </template>
  53. <script>
  54. import citySelect from '@/components/u-city-select.vue';
  55. export default {
  56. components: {
  57. citySelect
  58. },
  59. data() {
  60. return {
  61. //代理城市
  62. regionShow: false,
  63. region: '',
  64. params: {
  65. province: true,
  66. city: true,
  67. area: false
  68. },
  69. //银行类型
  70. bankTypeShow:false,
  71. bankTypeList:[],
  72. //账户类型
  73. bankAccountTypeShow:false,
  74. bankAccountTypeList:[],
  75. //原始对象
  76. originalModel:{},
  77. originalBankModel:{},
  78. model:{
  79. userId:'',
  80. userPhone:'',
  81. agenterTypeId:this.$global.agenterTypeId,
  82. enabled:-1,
  83. province:'',
  84. city:'',
  85. },
  86. //银行对象
  87. bankModel:{
  88. userId:'',
  89. userType:2,
  90. cardNo:'',
  91. realName:'',
  92. phone:'',
  93. bankType:'',
  94. bankTypeLabel:'',
  95. bankAccountType:'',
  96. bankAccountTypeLabel:''
  97. },
  98. }
  99. },
  100. onLoad() {
  101. this.init()
  102. },
  103. methods: {
  104. async init(){
  105. this.model.userId=this.vuex_userId
  106. this.model.userPhone=this.vuex_phone
  107. this.bankModel.userId=this.vuex_userId
  108. this.bankModel.phone=this.vuex_phone
  109. await this.getBankType()
  110. await this.getBankAccountType()
  111. this.fetchUserBank()
  112. this.fetchAgenter()
  113. },
  114. //回显 begin
  115. fetchUserBank(){
  116. let params={
  117. userId:this.vuex_userId
  118. }
  119. this.$api.userBank.list(params).then(res=>{
  120. if (!this.$isEmpty(res.data.records)) {
  121. this.originalBankModel=res.data.records[0]
  122. this.bankModel=res.data.records[0]
  123. }
  124. })
  125. },
  126. fetchAgenter(){
  127. let params={
  128. userId:this.vuex_userId
  129. }
  130. this.$api.agenter.list(params).then(res=>{
  131. if (!this.$isEmpty(res.data.records)) {
  132. this.originalModel=res.data.records[0]
  133. this.model=res.data.records[0]
  134. this.region=this.model.province + '-' + this.model.city
  135. }
  136. })
  137. },
  138. //字典 begin
  139. async getBankType() {
  140. let res = await this.$api.dict({code: 'bank_type'})
  141. res.data.forEach(item=>{
  142. let obj={
  143. label:item.dictValue,
  144. value:item.dictKey
  145. }
  146. this.bankTypeList.push(obj)
  147. })
  148. },
  149. async getBankAccountType() {
  150. let res = await this.$api.dict({code: 'bank_account_type'})
  151. res.data.forEach(item=>{
  152. let obj={
  153. label:item.dictValue,
  154. value:item.dictKey
  155. }
  156. this.bankAccountTypeList.push(obj)
  157. })
  158. },
  159. //字典 end
  160. bankTypeConfirm(e){
  161. this.bankModel.bankTypeLabel=e[0].label
  162. this.bankModel.bankType=e[0].value
  163. },
  164. bankAccountTypeConfirm(e){
  165. this.bankModel.bankAccountTypeLabel=e[0].label
  166. this.bankModel.bankAccountType=e[0].value
  167. },
  168. getRegion(data) {
  169. this.model.province=data.province.label
  170. this.model.city=data.city.label
  171. this.region = data.province.label + '-' + data.city.label;
  172. },
  173. confirm() {
  174. if (this.$isEmpty(this.model.userPhone)) {
  175. this.$u.toast('请输入联系方式')
  176. return
  177. }
  178. if (this.$isEmpty(this.bankModel.bankType)) {
  179. this.$u.toast('请选择银行类型')
  180. return
  181. }
  182. if (this.$isEmpty(this.bankModel.bankAccountType)) {
  183. this.$u.toast('请选择账户类型')
  184. return
  185. }
  186. if (this.$isEmpty(this.bankModel.realName)) {
  187. this.$u.toast('请输入开户姓名')
  188. return
  189. }
  190. if (this.$isEmpty(this.bankModel.cardNo)) {
  191. this.$u.toast('请输入银行卡号')
  192. return
  193. }
  194. if (JSON.stringify(this.model)!=JSON.stringify(this.originalModel) &&
  195. JSON.stringify(this.bankModel)!=JSON.stringify(this.originalBankModel)) {
  196. //修改过,提交再跳转
  197. this.$api.userBank.submit(this.bankModel)
  198. this.$api.agenter.submit(this.model).then(res=>{
  199. if (res.success) {
  200. uni.navigateTo({
  201. url: '/pages/agent/pay'
  202. })
  203. }
  204. })
  205. }else{
  206. //没修改,直接跳转
  207. uni.navigateTo({
  208. url: '/pages/agent/pay'
  209. })
  210. }
  211. },
  212. }
  213. }
  214. </script>
  215. <style lang="scss" scoped>
  216. .container {
  217. background-color: #ffffff;
  218. border-radius: 16upx;
  219. margin: 30upx;
  220. .title {
  221. font-size: 32upx;
  222. font-weight: bold;
  223. }
  224. }
  225. .eg {
  226. color: #d1d1d1;
  227. }
  228. .custom-style {
  229. background-color: #5b3ee7;
  230. width: 400upx;
  231. color: #ffffff;
  232. }
  233. </style>