editBank.vue 7.7 KB

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