index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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. if(this.bankList[i].defaultFlag == 1){
  89. this.bankList[i].defaultFlag = 0
  90. this.bankList[i].flag = 2 //取消标志
  91. }else{
  92. this.bankList[i].defaultFlag = 1
  93. this.bankList[i].flag = 1 //设置标志
  94. }
  95. this.$request.baseRequest('post', '/driverPayeeInfo/api/setDefault', val).then(res => {
  96. if (res.code == '200') {
  97. if(this.bankList[i].flag == 1){
  98. this.$refs.uToast.show({
  99. type: 'success',
  100. message: "设置成功!",
  101. })
  102. }else{
  103. this.$refs.uToast.show({
  104. type: 'success',
  105. message: "取消成功!",
  106. })
  107. }
  108. } else {
  109. uni.$u.toast(res.message);
  110. }
  111. })
  112. .catch(res => {
  113. uni.$u.toast(res.message);
  114. });
  115. } else {
  116. this.bankList[i].defaultFlag = 0
  117. }
  118. }
  119. },
  120. number(value){
  121. if(value&&value.length>8) {
  122. let reg = /^(\d{4})(\d*)(\d{4})$/;
  123. let str = value.replace(reg, (a, b, c, d)=> {
  124. return b + c.replace(/\d/g, "*") + d;
  125. });
  126. return str
  127. }else {
  128. return value
  129. }
  130. },
  131. init() {
  132. this.$request.baseRequest('post', '/driverPayeeInfo/selectDriverPayee', {
  133. driverId: this.userInfo.driverId?this.userInfo.driverId:uni.getStorageSync("firstAuthentication").id,
  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.bankCard = this.number(_obj.bankCard)
  142. switch (_obj.bankDeposit) {
  143. case "建设银行":
  144. this.bankList[i].imgLogo = "../../../static/images/mine/bank/jiansheogo.png"
  145. this.bankList[i].cardColor = "../../../static/images/mine/bank/jh.png"
  146. break
  147. case "招商银行":
  148. this.bankList[i].imgLogo =
  149. "../../../static/images/mine/bank/zhaoshang.png"
  150. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  151. break
  152. case "中国银行":
  153. this.bankList[i].imgLogo = "../../../static/images/mine/bank/zhongyin.png"
  154. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  155. break
  156. case "邮政银行":
  157. this.bankList[i].imgLogo =
  158. "../../../static/images/mine/bank/youzhenglogo.png"
  159. this.bankList[i].cardColor = "../../../static/images/mine/bank/nh.png"
  160. break
  161. case "交通银行":
  162. this.bankList[i].imgLogo =
  163. "../../../static/images/mine/bank/jiaotognlogo.png"
  164. this.bankList[i].cardColor = "../../../static/images/mine/bank/jh.png"
  165. break
  166. case "工商银行":
  167. this.bankList[i].imgLogo = "../../../static/images/mine/bank/gslogo.png"
  168. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  169. break
  170. case "农业银行":
  171. this.bankList[i].imgLogo = "../../../static/images/mine/bank/nongyelogo.png"
  172. this.bankList[i].cardColor = "../../../static/images/mine/bank/nh.png"
  173. break
  174. case "民生银行":
  175. this.bankList[i].imgLogo =
  176. "../../../static/images/mine/bank/minshenglogo.png"
  177. this.bankList[i].cardColor = "../../../static/images/mine/bank/nh.png"
  178. break
  179. case "中信银行":
  180. this.bankList[i].imgLogo =
  181. "../../../static/images/mine/bank/zhongxinlogo.png"
  182. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  183. break
  184. case "广发银行":
  185. this.bankList[i].imgLogo = "../../../static/images/mine/bank/gflogo.png"
  186. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  187. break
  188. case "华夏银行":
  189. this.bankList[i].imgLogo = "../../../static/images/mine/bank/huaxia.png"
  190. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  191. break
  192. case "兴业银行":
  193. this.bankList[i].imgLogo = "../../../static/images/mine/bank/xingye.png"
  194. this.bankList[i].cardColor = "../../../static/images/mine/bank/jh.png"
  195. break
  196. default:
  197. this.bankList[i].imgLogo = "../../../static/images/mine/bank/qitalogo.png"
  198. this.bankList[i].cardColor = "../../../static/images/mine/bank/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: #2772FB;
  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(../../../static/images/mine/bank/zsbg.png) center no-repeat;
  269. background-size: cover;
  270. padding: 60rpx 43rpx 100rpx 43rpx;
  271. border-radius: 20rpx;
  272. .carNumber{
  273. margin-bottom: 20rpx;
  274. }
  275. .img {
  276. width: 80rpx;
  277. height: 80rpx;
  278. margin-right: 20rpx;
  279. }
  280. .right {
  281. .text1 {
  282. font-size: 36rpx;
  283. font-weight: 700;
  284. color: #FFFFFF;
  285. }
  286. .text2 {
  287. // font-size: 24rpx;
  288. color: #FFFFFF;
  289. margin-top: 10rpx;
  290. }
  291. }
  292. }
  293. .row2 {
  294. margin: 20rpx 0;
  295. }
  296. .default-card {
  297. // font-size: 28rpx;
  298. color: #333333;
  299. }
  300. </style>