bankCard.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <view class="content">
  3. <view class="top-title flex flex-space-between">
  4. <!-- <view class="left flex">
  5. <view class="text1">我的卡</view>
  6. <view class="text2">(共{{bankList?bankList.length:0}}张)</view>
  7. </view> -->
  8. <view @click="addBankCard" class="add-bankcard flex">
  9. <view class="car-text">添加银行卡</view>
  10. <u-icon class="icon" name="plus-circle-fill" color="#2979ff" size="24"></u-icon>
  11. </view>
  12. </view>
  13. <view class="card-list" v-for="(item,index) in bankList" :key='index' >
  14. <view class="card-list-item" :style='{"background-image":"url("+item.cardColor+")"}' @click="bankOk(item)">
  15. <view class="flex flex-end number carNumber">{{item.bankCard}}</view>
  16. <view class="flex align-center">
  17. <!-- @/static/images/mine/bank/gflogo.png -->
  18. <image class="img left" :src="item.imgLogo" mode='widthFix'>
  19. <!-- <image class="img left" src="@/static/images/mine/bank/zhaoshang.png" mode='widthFix'> -->
  20. </image>
  21. <view class="right">
  22. <view class="text1">{{item.bankDeposit}}</view>
  23. <view class="text2">收款人:{{item.payeeName}}</view>
  24. </view>
  25. </view>
  26. </view>
  27. <!-- <view class="flex flex-space-between row2 align-center">
  28. <view class="flex align-center">
  29. <radio :checked="item.defaultFlag==1" @click='radioChange(item)' />
  30. <view class="default-card">设为默认收款账户</view>
  31. </view>
  32. <view>
  33. <u-icon name="trash" size="24" @click="del(item,index)"></u-icon>
  34. </view>
  35. </view> -->
  36. </view>
  37. <!-- <view @click="addBankCard">添加银行卡</view> -->
  38. <u-modal :show="isShowAlert" :title="alertTitle" :closeOnClickOverlay='true' :showCancelButton='true' confirmColor='#F5BA3C' @confirm="confirmClick" @close="cancelClick" @cancel="cancelClick"></u-modal>
  39. <u-toast ref="uToast"></u-toast>
  40. </view>
  41. </template>
  42. <script>
  43. import {
  44. mapState
  45. } from 'vuex';
  46. export default {
  47. data() {
  48. return {
  49. bankList: [],
  50. obj:{},
  51. index:null,
  52. isShowAlert:false,
  53. alertTitle:'确认删除该银行卡?'
  54. };
  55. },
  56. computed: {
  57. ...mapState(['hasLogin', 'userInfo']),
  58. },
  59. onLoad() {
  60. if (!this.hasLogin) {
  61. uni.$u.route('/pages/public/login');
  62. }
  63. this.init();
  64. },
  65. methods: {
  66. bankOk(item){//设置收款账户
  67. let obj = {
  68. bankCard : item.bankNo,
  69. bankDeposit:item.bankDeposit,
  70. bankDepositBranch :item.bankDepositBranch,
  71. payeeName :item.payeeName
  72. }
  73. uni.setStorageSync("payInfo",obj)
  74. uni.navigateBack({
  75. delta:1
  76. })
  77. },
  78. confirmClick(){
  79. this.isShowAlert = false
  80. this.$request.baseRequest('post', '/driverPayeeInfo/api/deleteDriverPayee', {
  81. id: this.obj.id
  82. }).then(res => {
  83. if (res.code == '200') {
  84. this.$refs.uToast.show({
  85. type: 'success',
  86. message: "删除成功!",
  87. })
  88. this.bankList.splice(this.index, 1)
  89. }
  90. })
  91. .catch(res => {
  92. uni.$u.toast(res.message);
  93. });
  94. },
  95. cancelClick(){
  96. this.isShowAlert = false
  97. },
  98. radioChange(val) {
  99. for (let i = 0; i < this.bankList.length; i++) {
  100. if (val.id == this.bankList[i].id) {
  101. this.bankList[i].defaultFlag = 1
  102. this.$request.baseRequest('post', '/driverPayeeInfo/api/setDefault', val).then(res => {
  103. if (res.code == '200') {
  104. // this.bankList = res.data
  105. this.$refs.uToast.show({
  106. type: 'success',
  107. message: "设置成功!",
  108. })
  109. } else {
  110. uni.$u.toast(res.message);
  111. }
  112. })
  113. .catch(res => {
  114. uni.$u.toast(res.message);
  115. });
  116. } else {
  117. this.bankList[i].defaultFlag = 0
  118. }
  119. }
  120. },
  121. number(value){
  122. if(value&&value.length>8) {
  123. let reg = /^(\d{4})(\d*)(\d{4})$/;
  124. let str = value.replace(reg, (a, b, c, d)=> {
  125. return b + c.replace(/\d/g, "*") + d;
  126. });
  127. return str
  128. }else {
  129. return value
  130. }
  131. },
  132. init() {
  133. this.$request.baseRequest('post', '/driverPayeeInfo/selectDriverPayee', {
  134. // driverId: this.userInfo.driverId,
  135. commonId: this.userInfo.id,
  136. }).then(res => {
  137. if (res.code == '200') {
  138. this.bankList = res.data
  139. for (let i = 0; i < this.bankList.length; i++) {
  140. let _obj = this.bankList[i]
  141. _obj.bankNo = this.bankList[i].bankCard
  142. _obj.bankCard = this.number(_obj.bankCard)
  143. switch (_obj.bankDeposit) {
  144. case "建设银行":
  145. this.bankList[i].imgLogo = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/jiansheogo.png"
  146. this.bankList[i].cardColor = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/jh.png"
  147. break
  148. case "招商银行":
  149. this.bankList[i].imgLogo =
  150. "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/zhaoshang.png"
  151. this.bankList[i].cardColor = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/zsbg.png"
  152. break
  153. case "中国银行":
  154. this.bankList[i].imgLogo = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/zhongyin.png"
  155. this.bankList[i].cardColor = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/zsbg.png"
  156. break
  157. case "邮政银行":
  158. this.bankList[i].imgLogo =
  159. "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/youzhenglogo.png"
  160. this.bankList[i].cardColor = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/nh.png"
  161. break
  162. case "交通银行":
  163. this.bankList[i].imgLogo =
  164. "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/jiaotognlogo.png"
  165. this.bankList[i].cardColor = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/jh.png"
  166. break
  167. case "工商银行":
  168. this.bankList[i].imgLogo = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/gslogo.png"
  169. this.bankList[i].cardColor = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/zsbg.png"
  170. break
  171. case "农业银行":
  172. this.bankList[i].imgLogo = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/nongyelogo.png"
  173. this.bankList[i].cardColor = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/nh.png"
  174. break
  175. case "民生银行":
  176. this.bankList[i].imgLogo ="https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/minshenglogo.png"
  177. this.bankList[i].cardColor = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/nh.png"
  178. break
  179. case "中信银行":
  180. this.bankList[i].imgLogo =
  181. "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/zhongxinlogo.png"
  182. this.bankList[i].cardColor = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/zsbg.png"
  183. break
  184. case "广发银行":
  185. this.bankList[i].imgLogo = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/gflogo.png"
  186. this.bankList[i].cardColor = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/zsbg.png"
  187. break
  188. case "华夏银行":
  189. this.bankList[i].imgLogo = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/huaxia.png"
  190. this.bankList[i].cardColor = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/zsbg.png"
  191. break
  192. case "兴业银行":
  193. this.bankList[i].imgLogo = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/xingye.png"
  194. this.bankList[i].cardColor = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/jh.png"
  195. break
  196. default:
  197. this.bankList[i].imgLogo = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/qitalogo.png"
  198. this.bankList[i].cardColor = "https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/qt.png"
  199. break
  200. }
  201. }
  202. this.$forceUpdate()
  203. } else {
  204. uni.$u.toast(res.message);
  205. }
  206. })
  207. .catch(res => {
  208. uni.$u.toast(res.message);
  209. });
  210. },
  211. addBankCard() {
  212. uni.$u.route('/pages/mine/manageBankCards/addBankCard');
  213. },
  214. edit() {
  215. uni.$u.route('/pages/mine/manageBankCards/editBankCard');
  216. let params = {
  217. type: 'success',
  218. message: "修改成功",
  219. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  220. }
  221. this.$refs.uToast.show({
  222. ...params
  223. })
  224. },
  225. del(val, index) {
  226. this.obj = val
  227. this.index = index
  228. this.isShowAlert = true
  229. }
  230. },
  231. }
  232. </script>
  233. <style lang="scss">
  234. .content {
  235. background: white;
  236. padding: 20rpx;
  237. }
  238. .top-title {
  239. margin: 0 0 20rpx 0;
  240. .left {
  241. .text1 {
  242. font-size: 29rpx;
  243. color: #1F1F1F;
  244. font-weight: 700;
  245. }
  246. .text2 {
  247. font-size: 29rpx;
  248. color: #999999;
  249. }
  250. }
  251. }
  252. .card-list {
  253. padding: 0 20rpx;
  254. .number {
  255. color: white;
  256. }
  257. }
  258. .add-bankcard {
  259. background: #EEF4FF;
  260. color: #F5BA3C;
  261. font-weight: 700;
  262. font-size: 26rpx;
  263. align-items: center;
  264. padding: 4rpx 10rpx 4rpx 20rpx;
  265. border-radius: 30rpx;
  266. }
  267. .card-list-item {
  268. // background: url(https://taohaoliang.oss-cn-beijing.aliyuncs.com/template/zsbg.png) center no-repeat;
  269. background-size: cover;
  270. padding: 60rpx 43rpx 100rpx 43rpx;
  271. border-radius: 20rpx;
  272. margin:10px 0;
  273. .carNumber{
  274. margin-bottom: 20rpx;
  275. }
  276. .img {
  277. width: 80rpx;
  278. height: 80rpx;
  279. margin-right: 20rpx;
  280. }
  281. .right {
  282. .text1 {
  283. font-size: 36rpx;
  284. font-weight: 700;
  285. color: #FFFFFF;
  286. }
  287. .text2 {
  288. // font-size: 24rpx;
  289. color: #FFFFFF;
  290. margin-top: 10rpx;
  291. }
  292. }
  293. }
  294. .row2 {
  295. margin: 20rpx 0;
  296. }
  297. .default-card {
  298. // font-size: 28rpx;
  299. color: #333333;
  300. }
  301. </style>