index.vue 8.4 KB

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