editBank.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <view class="container">
  3. <view class="navList flex" v-if="!info.id">
  4. <template v-for="(item, index) in navList">
  5. <view class="navItem" v-if="bankInfo[item.type]=='1'"
  6. :class="{ activeItem: tabIndex === index,tip:index == 0 }" @click="tabClick(index)">{{ item.name }}
  7. </view>
  8. </template>
  9. </view>
  10. <view class="login_text" v-if="tabIndex == 0">
  11. <view class="login_input flex" style="padding-top: 45rpx;">
  12. <view class="login_name">姓名</view>
  13. <view class="login_name"><input class="uni-input" type="text" v-model="info.bank_real_name"
  14. placeholder="请输入真实姓名" /></view>
  15. </view>
  16. <view class="login_input flex">
  17. <view class="login_name"><text>银行</text></view>
  18. <view class="login_name"><input class="uni-input" type="idcard" v-model="info.bank"
  19. placeholder="请输入银行" /></view>
  20. </view>
  21. <view class="login_input flex">
  22. <view class="login_name"><text>银行卡账号</text></view>
  23. <view class="login_name"><input class="uni-input" type="idcard" v-model="info.bank_code"
  24. placeholder="请输入银行卡账号" /></view>
  25. </view>
  26. <view class="login_input flex">
  27. <view class="login_name"><text>开户行</text></view>
  28. <view class="login_name"><input class="uni-input" type="idcard" v-model="info.bank_name"
  29. placeholder="请输入开户行" /></view>
  30. </view>
  31. </view>
  32. <view class="login_text" v-if="tabIndex == 1">
  33. <view class="login_input flex" style="padding-top: 45rpx;">
  34. <view class="login_name">姓名</view>
  35. <view class="login_name"><input class="uni-input" type="text" v-model="info.name"
  36. placeholder="请输入真实姓名" /></view>
  37. </view>
  38. <view class="login_input flex">
  39. <view class="login_name"><text>支付宝账号</text></view>
  40. <view class="login_name"><input class="uni-input" type="idcard" v-model="info.phone"
  41. placeholder="请输入支付宝账号" /></view>
  42. </view>
  43. <view class="login_input">
  44. <view class="login_name" @click="scImg">
  45. <image :src="info.qrcode||'/static/image/img19.png'"></image>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="login_text" v-if="tabIndex == 2">
  50. <view class="login_input flex" style="padding-top: 45rpx;">
  51. <view class="login_name">姓名</view>
  52. <view class="login_name"><input class="uni-input" type="text" v-model="info.name"
  53. placeholder="请输入真实姓名" /></view>
  54. </view>
  55. <!-- <view class="login_input flex">
  56. <view class="login_name"><text>微信账号</text></view>
  57. <view class="login_name"><input class="uni-input" type="idcard" v-model="info.phone"
  58. placeholder="请输入微信账号" /></view>
  59. </view> -->
  60. <view class="login_input">
  61. <view class="login_name" @click="scImg">
  62. <image :src="info.qrcode||'/static/image/img19.png'"></image>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="submission">
  67. <button class="golden" type="golden" hover-class="none" @click="submission">确认</button>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. import {
  73. bankInfo,
  74. addBank,
  75. getBank
  76. } from '@/api/set.js';
  77. import {
  78. upload
  79. } from '@/api/order.js';
  80. export default {
  81. data() {
  82. return {
  83. navList: [{
  84. name: '银行卡',
  85. show: true,
  86. type: "sell_bank_open"
  87. }, {
  88. name: '支付宝',
  89. show: true,
  90. type: "sell_alipay_open"
  91. }, {
  92. name: '微信',
  93. show: true,
  94. type: "sell_weixin_open"
  95. }],
  96. tabIndex: 0,
  97. info: {
  98. id: '',
  99. bank_real_name: '',
  100. bank_code: '',
  101. bank: '',
  102. bank_name: '',
  103. default: 0,
  104. name: '',
  105. phone: '',
  106. qrcode: ''
  107. },
  108. type: 'bank',
  109. loding: false,
  110. bankInfo: {
  111. sell_alipay_open: "0",
  112. sell_bank_open: "0",
  113. sell_weixin_open: "0"
  114. }
  115. };
  116. },
  117. onLoad(option) {
  118. if (option.type) {
  119. if (option.type == 'alipay') {
  120. this.tabIndex = 1
  121. } else if (option.type == 'wx') {
  122. this.tabIndex = 2
  123. } else {
  124. this.tabIndex = 0
  125. }
  126. }
  127. if (option.id) {
  128. this.info.id = option.id
  129. this.type = option.type
  130. this.getList()
  131. }
  132. this.getBank();
  133. // getMoneyLog({
  134. // page: navItem.page,
  135. // limit: navItem.limit
  136. // },navItem.type)
  137. },
  138. onShow() {},
  139. methods: {
  140. getBank() {
  141. getBank({}).then(res => {
  142. this.bankInfo = res.data;
  143. });
  144. },
  145. tabClick(index) {
  146. this.tabIndex = index
  147. if (index == 0) {
  148. this.type = 'bank'
  149. } else if (index == 1) {
  150. this.type = 'alipay'
  151. this.info.name = ''
  152. this.info.phone = ''
  153. this.info.qrcode = ''
  154. } else {
  155. this.type = 'wx'
  156. this.info.name = ''
  157. this.info.phone = ''
  158. this.info.qrcode = ''
  159. }
  160. },
  161. getList() {
  162. let obj = this
  163. bankInfo({
  164. id: obj.info.id
  165. }).then(res => {
  166. obj.info = res.data.info
  167. });
  168. },
  169. submission() {
  170. let obj = this
  171. if (obj.tabIndex == 0) {
  172. if (!obj.info.bank_real_name) {
  173. uni.showToast({
  174. title: '请输入真实姓名',
  175. icon: 'none',
  176. })
  177. return
  178. }
  179. if (!obj.info.bank) {
  180. uni.showToast({
  181. title: '请输入银行',
  182. icon: 'none',
  183. })
  184. return
  185. }
  186. if (!obj.info.bank_code) {
  187. uni.showToast({
  188. title: '请输入银行卡号',
  189. icon: 'none',
  190. })
  191. return
  192. }
  193. if (obj.info.bank_code.length < 16) {
  194. uni.showToast({
  195. title: '请输入正确的银行卡号',
  196. icon: 'none',
  197. })
  198. return
  199. }
  200. if (!obj.info.bank_name) {
  201. uni.showToast({
  202. title: '请输入开户行',
  203. icon: 'none',
  204. })
  205. return
  206. }
  207. } else {
  208. if (!obj.info.name) {
  209. uni.showToast({
  210. title: '请输入姓名',
  211. icon: 'none',
  212. })
  213. return
  214. }
  215. if (!obj.info.phone && obj.tabIndex == 1) {
  216. uni.showToast({
  217. title: '请输入账号',
  218. icon: 'none',
  219. })
  220. return
  221. }
  222. if (!obj.info.qrcode) {
  223. uni.showToast({
  224. title: '请输入收款码',
  225. icon: 'none',
  226. })
  227. return
  228. }
  229. }
  230. let data = ''
  231. if (obj.info.id) {
  232. data = {
  233. id: 0,
  234. bank: obj.info.bank, //银行
  235. bank_name: obj.info.bank_name, //开户行
  236. bank_code: obj.info.bank_code, //银行卡号
  237. real_name: obj.info.bank_real_name, //开户人
  238. default: 0, //1设为默认,0取消默认
  239. id: obj.info.id,
  240. type: obj.type,
  241. name: obj.info.name,
  242. phone: obj.info.phone,
  243. qrcode: obj.info.qrcode,
  244. }
  245. } else {
  246. data = {
  247. id: 0,
  248. bank: obj.info.bank, //银行
  249. bank_name: obj.info.bank_name, //开户行
  250. bank_code: obj.info.bank_code, //银行卡号
  251. real_name: obj.info.bank_real_name, //开户人
  252. default: 0, //1设为默认,0取消默认
  253. name: obj.info.name,
  254. phone: obj.info.phone,
  255. qrcode: obj.info.qrcode,
  256. type: obj.type
  257. }
  258. }
  259. uni.showLoading({
  260. title: '提交中',
  261. mask: true
  262. });
  263. addBank(data).then(res => {
  264. uni.showToast({
  265. title: res.msg,
  266. icon: 'none',
  267. duration: 1000
  268. })
  269. setTimeout(function() {
  270. uni.navigateTo({
  271. url: '/pages/user/set/bindBank'
  272. })
  273. }, 1000);
  274. });
  275. },
  276. //上传图片
  277. scImg() {
  278. upload({
  279. file: ''
  280. }).then((e) => {
  281. console.log(e, 55)
  282. this.info.qrcode = e[0].url;
  283. });
  284. },
  285. },
  286. };
  287. </script>
  288. <style lang="scss" scoped>
  289. .login_text {
  290. width: 100%;
  291. // padding: 25rpx 0rpx;
  292. font-size: 28rpx !important;
  293. padding: 0rpx 25rpx;
  294. }
  295. .login_input {
  296. border-bottom: 1px solid #464755;
  297. padding: 35rpx;
  298. }
  299. .uni-input {
  300. width: 450rpx;
  301. text-align: left !important;
  302. font-size: 26rpx;
  303. }
  304. .submission {
  305. padding: 80rpx 25rpx;
  306. .golden {
  307. background: #0C5AFA;
  308. color: #ffffff;
  309. }
  310. }
  311. .login_name {
  312. color: #ffffff;
  313. }
  314. .login_name image {
  315. width: 100rpx;
  316. height: 100rpx;
  317. }
  318. .navList {
  319. padding: 20rpx 50rpx;
  320. background: #1F2A4A;
  321. width: 100%;
  322. z-index: 9;
  323. .navItem {
  324. color: #fff;
  325. font-size: 30rpx;
  326. text-align: center;
  327. width: 50%;
  328. &.activeItem {
  329. color: #0C5AFA;
  330. position: relative;
  331. &:after {
  332. content: '';
  333. position: absolute;
  334. left: 36%;
  335. bottom: -20rpx;
  336. width: 30%;
  337. height: 8rpx;
  338. // transform: translateX(-50%);
  339. border-bottom: 4rpx solid #0C5AFA;
  340. border-radius: 0rpx 20rpx 0rpx 0rpx;
  341. }
  342. }
  343. &.tip {
  344. border-right: 1rpx solid #333D5B;
  345. }
  346. }
  347. }
  348. </style>