agent.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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>{{salesmanId}}</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="model.agentArea" 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="bankModel.phone" 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. <toast ref="toast" ></toast>
  52. <login ref="login" @signIn="signIn"></login>
  53. </view>
  54. </template>
  55. <script>
  56. import login from "@/components/login.vue"
  57. import citySelect from '../../comps/u-city-select.vue';
  58. export default {
  59. components: {
  60. login,
  61. citySelect
  62. },
  63. data() {
  64. return {
  65. //代理城市
  66. regionShow: false,
  67. params: {
  68. province: true,
  69. city: true,
  70. area: false
  71. },
  72. //银行类型
  73. bankTypeShow:false,
  74. bankTypeList:[],
  75. //账户类型
  76. bankAccountTypeShow:false,
  77. bankAccountTypeList:[],
  78. //原始对象
  79. originalModel:{},
  80. originalBankModel:{},
  81. model:{
  82. accountId:'',
  83. agentType:'代理商',
  84. agentArea:'',
  85. areaCode:'',
  86. enabled:0,//是否启用0
  87. salesmanId:''
  88. },
  89. //银行对象
  90. bankModel:{
  91. userId:'',
  92. userType:'用户',
  93. cardNo:'',
  94. realName:'',
  95. phone:'',
  96. bankType:'',
  97. bankTypeLabel:'',
  98. bankAccountType:'',
  99. bankAccountTypeLabel:''
  100. },
  101. }
  102. },
  103. onLoad() {
  104. this.init()
  105. },
  106. onShow() {
  107. this.login()
  108. },
  109. computed:{
  110. salesmanId(){
  111. if (this.$isNotEmpty(this.model.salesmanId)) {
  112. return this.model.salesmanId
  113. }
  114. if (this.$cache.get('salesmanId')) {
  115. return this.$cache.get('salesmanId')
  116. }
  117. return '暂无'
  118. }
  119. },
  120. methods: {
  121. async init(){
  122. if (this.$cache.get('salesmanId')) {
  123. this.model.salesmanId=this.$cache.get('salesmanId')
  124. }
  125. this.model.accountId=this.vuex_userId
  126. this.bankModel.userId=this.vuex_userId
  127. this.bankModel.phone=this.vuex_phone
  128. await this.getBankType()
  129. await this.getBankAccountType()
  130. this.fetchUserBank()
  131. this.fetchAgenter()
  132. },
  133. //回显 begin
  134. fetchUserBank(){
  135. let params={
  136. userId:this.vuex_userId || '-1'
  137. }
  138. this.$api.userBank.list(params).then(res=>{
  139. if (!this.$isEmpty(res.data.records)) {
  140. this.originalBankModel=res.data.records[0]
  141. this.bankModel=res.data.records[0]
  142. }
  143. })
  144. },
  145. fetchAgenter(){
  146. let params={
  147. accountId:this.vuex_userId || '-1'
  148. }
  149. this.$api.agenter.list(params).then(res=>{
  150. if (this.$isNotEmpty(res.data.records)) {
  151. this.originalModel=res.data.records[0]
  152. this.model=res.data.records[0]
  153. this.region=this.model.province + '-' + this.model.city
  154. }
  155. })
  156. },
  157. //字典 begin
  158. async getBankType() {
  159. let params={
  160. code: 'bank_type',
  161. size:9
  162. }
  163. let res = await this.$api.dict.dictionaryPage(params)
  164. let list = res.data.records
  165. list.shift()
  166. list.forEach(item=>{
  167. let obj={
  168. label:JSON.parse(item.dictValue).name,
  169. value:item.dictKey
  170. }
  171. this.bankTypeList.push(obj)
  172. })
  173. this.bankModel.bankTypeLabel=this.bankTypeList[0].label
  174. this.bankModel.bankType=this.bankTypeList[0].value
  175. },
  176. async getBankAccountType() {
  177. let res = await this.$api.dict.list({code: 'bank_account_type'})
  178. res.data.forEach(item=>{
  179. let obj={
  180. label:item.dictValue,
  181. value:item.dictKey
  182. }
  183. this.bankAccountTypeList.push(obj)
  184. })
  185. this.bankModel.bankAccountType=this.bankAccountTypeList[0].value
  186. this.bankModel.bankAccountTypeLabel=this.bankAccountTypeList[0].label
  187. },
  188. //字典 end
  189. bankTypeConfirm(e){
  190. this.bankModel.bankTypeLabel=e[0].label
  191. this.bankModel.bankType=e[0].value
  192. },
  193. bankAccountTypeConfirm(e){
  194. this.bankModel.bankAccountTypeLabel=e[0].label
  195. this.bankModel.bankAccountType=e[0].value
  196. },
  197. getRegion(e) {
  198. this.model.agentArea = e.province.label + '-' + e.city.label
  199. this.model.areaCode=e.province.value+"0000,"+e.city.value+"00"
  200. },
  201. confirm() {
  202. if (this.$isEmpty(this.vuex_userId)) {
  203. this.showLogin()
  204. return
  205. }
  206. if (this.$isEmpty(this.bankModel.phone)) {
  207. this.$refs.toast.warn('请输入联系方式')
  208. return
  209. }
  210. if (this.$isEmpty(this.bankModel.bankType)) {
  211. this.$refs.toast.warn('请选择银行类型')
  212. return
  213. }
  214. if (this.$isEmpty(this.bankModel.bankAccountType)) {
  215. this.$refs.toast.warn('请选择账户类型')
  216. return
  217. }
  218. if (this.$isEmpty(this.bankModel.realName)) {
  219. this.$refs.toast.warn('请输入开户姓名')
  220. return
  221. }
  222. if (this.$isEmpty(this.bankModel.cardNo)) {
  223. this.$refs.toast.warn('请输入银行卡号')
  224. return
  225. }
  226. if (JSON.stringify(this.model)!=JSON.stringify(this.originalModel) ||
  227. JSON.stringify(this.bankModel)!=JSON.stringify(this.originalBankModel)) {
  228. //修改过,提交再跳转
  229. this.$api.userBank.submit(this.bankModel)
  230. this.$api.agenter.submit(this.model).then(res=>{
  231. if (res.success) {
  232. uni.navigateTo({
  233. url: '/pagesB/pages/agent/pay'
  234. })
  235. }
  236. })
  237. }else{
  238. //没修改,直接跳转
  239. uni.navigateTo({
  240. url: '/pagesB/pages/agent/pay'
  241. })
  242. }
  243. },
  244. // 登录 begin
  245. showLogin(){
  246. this.$refs.login.show()
  247. },
  248. showPhoneModal(){
  249. this.$refs.login.showPhoneModal()
  250. },
  251. signIn(resp){
  252. //获取手机号
  253. if (this.$isEmpty(this.vuex_phone)) {
  254. this.showPhoneModal()
  255. }else{
  256. this.$refs.toast.info('登录成功')
  257. }
  258. //获取数据
  259. this.init()
  260. },
  261. async login(e){
  262. if (this.$isEmpty(this.vuex_userId)) {
  263. this.showLogin()
  264. return
  265. }
  266. //获取数据
  267. this.init()
  268. //获取手机号
  269. if (this.$isEmpty(this.vuex_phone)) {
  270. this.showPhoneModal()
  271. }
  272. },
  273. // 登录 end
  274. }
  275. }
  276. </script>
  277. <style lang="scss" scoped>
  278. .container {
  279. background-color: #ffffff;
  280. border-radius: 16upx;
  281. margin: 20upx;
  282. .title {
  283. font-size: 32upx;
  284. font-weight: bold;
  285. }
  286. }
  287. .eg {
  288. color: #d1d1d1;
  289. }
  290. .custom-style {
  291. background-color: #5b3ee7;
  292. width: 400upx;
  293. color: #ffffff;
  294. }
  295. </style>