editBank.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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. };
  90. },
  91. onLoad(option) {
  92. if(option.type){
  93. if(option.type == 'alipay'){
  94. this.tabIndex = 1
  95. }else if(option.type == 'wx'){
  96. this.tabIndex = 2
  97. }else{
  98. this.tabIndex = 0
  99. }
  100. }
  101. if(option.id){
  102. this.info.id = option.id
  103. this.type = option.type
  104. this.getList()
  105. }
  106. // getMoneyLog({
  107. // page: navItem.page,
  108. // limit: navItem.limit
  109. // },navItem.type)
  110. },
  111. onShow() {},
  112. methods: {
  113. tabClick(index) {
  114. this.tabIndex = index
  115. if(index == 0){
  116. this.type = 'bank'
  117. }else if(index == 1){
  118. this.type = 'alipay'
  119. this.info.name = ''
  120. this.info.phone = ''
  121. this.info.qrcode = ''
  122. }else{
  123. this.type = 'wx'
  124. this.info.name = ''
  125. this.info.phone = ''
  126. this.info.qrcode = ''
  127. }
  128. },
  129. getList(){
  130. let obj = this
  131. bankInfo({
  132. id:obj.info.id
  133. }).then(res => {
  134. obj.info = res.data.info
  135. });
  136. },
  137. submission(){
  138. let obj = this
  139. if(obj.tabIndex == 0){
  140. if(!obj.info.bank_real_name){
  141. uni.showToast({
  142. title: '请输入真实姓名',
  143. icon: 'none',
  144. })
  145. return
  146. }
  147. if(!obj.info.bank){
  148. uni.showToast({
  149. title: '请输入银行',
  150. icon: 'none',
  151. })
  152. return
  153. }
  154. if(!obj.info.bank_code){
  155. uni.showToast({
  156. title: '请输入银行卡号',
  157. icon: 'none',
  158. })
  159. return
  160. }
  161. if(obj.info.bank_code.length < 16){
  162. uni.showToast({
  163. title: '请输入正确的银行卡号',
  164. icon: 'none',
  165. })
  166. return
  167. }
  168. if(!obj.info.bank_name){
  169. uni.showToast({
  170. title: '请输入开户行',
  171. icon: 'none',
  172. })
  173. return
  174. }
  175. }else{
  176. if(!obj.info.name){
  177. uni.showToast({
  178. title: '请输入姓名',
  179. icon: 'none',
  180. })
  181. return
  182. }
  183. if(!obj.info.phone){
  184. uni.showToast({
  185. title: '请输入账号',
  186. icon: 'none',
  187. })
  188. return
  189. }
  190. if(!obj.info.qrcode){
  191. uni.showToast({
  192. title: '请输入收款码',
  193. icon: 'none',
  194. })
  195. return
  196. }
  197. }
  198. let data = ''
  199. if(obj.info.id){
  200. data = {
  201. bank:obj.info.bank,//银行
  202. bank_name:obj.info.bank_name,//开户行
  203. bank_code:obj.info.bank_code,//银行卡号
  204. real_name:obj.info.bank_real_name,//开户人
  205. default:0,//1设为默认,0取消默认
  206. id:obj.info.id,
  207. type:obj.type,
  208. name:obj.info.name,
  209. phone:obj.info.phone,
  210. qrcode:obj.info.qrcode,
  211. }
  212. }else{
  213. data = {
  214. bank:obj.info.bank,//银行
  215. bank_name:obj.info.bank_name,//开户行
  216. bank_code:obj.info.bank_code,//银行卡号
  217. real_name:obj.info.bank_real_name,//开户人
  218. default:0,//1设为默认,0取消默认
  219. name:obj.info.name,
  220. phone:obj.info.phone,
  221. qrcode:obj.info.qrcode,
  222. type:obj.type
  223. }
  224. }
  225. addBank(data).then(res => {
  226. uni.showToast({
  227. title: res.msg,
  228. icon: 'none',
  229. duration: 1000
  230. })
  231. setTimeout(function () {
  232. uni.navigateTo({
  233. url:'/pages/user/set/bindBank'
  234. })
  235. }, 1000);
  236. });
  237. },
  238. //上传图片
  239. scImg() {
  240. upload({
  241. file: ''
  242. }).then((e) => {
  243. console.log(e, 55)
  244. this.xinxi.qrcode = e[0].url;
  245. });
  246. },
  247. },
  248. };
  249. </script>
  250. <style lang="scss" scoped>
  251. .login_text {
  252. width: 100%;
  253. // padding: 25rpx 0rpx;
  254. font-size: 28rpx !important;
  255. padding: 0rpx 25rpx;
  256. }
  257. .login_input {
  258. border-bottom: 1px solid #464755;
  259. padding: 35rpx;
  260. }
  261. .uni-input {
  262. width: 450rpx;
  263. text-align: left !important;
  264. font-size: 26rpx;
  265. }
  266. .submission {
  267. padding: 80rpx 25rpx;
  268. .golden {
  269. background: #0C5AFA;
  270. color: #ffffff;
  271. }
  272. }
  273. .login_name {
  274. color: #ffffff;
  275. }
  276. .login_name image {
  277. width: 100rpx;
  278. height: 100rpx;
  279. }
  280. .navList {
  281. padding: 20rpx 50rpx;
  282. background: #1F2A4A;
  283. width: 100%;
  284. z-index: 9;
  285. .navItem {
  286. color: #fff;
  287. font-size: 30rpx;
  288. text-align: center;
  289. width: 50%;
  290. &.activeItem {
  291. color: #0C5AFA;
  292. position: relative;
  293. &:after {
  294. content: '';
  295. position: absolute;
  296. left: 36%;
  297. bottom: -20rpx;
  298. width: 30%;
  299. height: 8rpx;
  300. // transform: translateX(-50%);
  301. border-bottom: 4rpx solid #0C5AFA;
  302. border-radius: 0rpx 20rpx 0rpx 0rpx;
  303. }
  304. }
  305. &.tip {
  306. border-right: 1rpx solid #333D5B;
  307. }
  308. }
  309. }
  310. </style>