index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. <image style='width:18px;height:18px;' src="../../../static/images/mine/addcar.png" mode=""></image>
  11. <!-- <u-icon class="icon" name="plus-circle-fill" color="#2979ff" size="24"></u-icon> -->
  12. </view>
  13. </view>
  14. <view class="card-list" v-for="(item,index) in bankList" :key='index'>
  15. <view class="card-list-item" :style='{"background-image":"url("+item.cardColor+")"}'>
  16. <view class="flex flex-end number carNumber">{{item.bankCard}}</view>
  17. <view class="flex align-center">
  18. <!-- @/static/images/mine/bank/gflogo.png -->
  19. <image class="img left" :src="item.imgLogo" 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="$u.throttle(del(item,index), 1000)"></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. confirmClick(){
  67. this.isShowAlert = false
  68. this.$request.baseRequest('post', '/driverPayeeInfo/api/deleteDriverPayee', {
  69. id: this.obj.id
  70. }).then(res => {
  71. if (res.code == '200') {
  72. this.$refs.uToast.show({
  73. type: 'success',
  74. message: "删除成功!",
  75. })
  76. this.bankList.splice(this.index, 1)
  77. }
  78. })
  79. .catch(res => {
  80. uni.$u.toast(res.message);
  81. });
  82. },
  83. cancelClick(){
  84. this.isShowAlert = false
  85. },
  86. radioChange(val) {
  87. for (let i = 0; i < this.bankList.length; i++) {
  88. if (val.id == this.bankList[i].id) {
  89. if(this.bankList[i].defaultFlag == 1){
  90. this.bankList[i].defaultFlag = 0
  91. this.bankList[i].flag = 2 //取消标志
  92. }else{
  93. this.bankList[i].defaultFlag = 1
  94. this.bankList[i].flag = 1 //设置标志
  95. }
  96. this.$request.baseRequest('post', '/driverPayeeInfo/api/setDefault', val).then(res => {
  97. if (res.code == '200') {
  98. if(this.bankList[i].flag == 1){
  99. this.$refs.uToast.show({
  100. type: 'success',
  101. message: "设置成功!",
  102. })
  103. }else{
  104. this.$refs.uToast.show({
  105. type: 'success',
  106. message: "取消成功!",
  107. })
  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?this.userInfo.driverId:uni.getStorageSync("firstAuthentication").id,
  135. // driverId: this.userInfo.driverId,
  136. commonId: this.userInfo.id,
  137. }).then(res => {
  138. if (res.code == '200') {
  139. this.bankList = res.data
  140. for (let i = 0; i < this.bankList.length; i++) {
  141. let _obj = this.bankList[i]
  142. _obj.bankCard = this.number(_obj.bankCard)
  143. switch (_obj.bankDeposit) {
  144. case "建设银行":
  145. this.bankList[i].imgLogo = "../../../static/images/mine/bank/jiansheogo.png"
  146. this.bankList[i].cardColor = "../../../static/images/mine/bank/jh.png"
  147. break
  148. case "招商银行":
  149. this.bankList[i].imgLogo =
  150. "../../../static/images/mine/bank/zhaoshang.png"
  151. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  152. break
  153. case "中国银行":
  154. this.bankList[i].imgLogo = "../../../static/images/mine/bank/zhongyin.png"
  155. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  156. break
  157. case "邮政银行":
  158. this.bankList[i].imgLogo =
  159. "../../../static/images/mine/bank/youzhenglogo.png"
  160. this.bankList[i].cardColor = "../../../static/images/mine/bank/nh.png"
  161. break
  162. case "交通银行":
  163. this.bankList[i].imgLogo =
  164. "../../../static/images/mine/bank/jiaotognlogo.png"
  165. this.bankList[i].cardColor = "../../../static/images/mine/bank/jh.png"
  166. break
  167. case "工商银行":
  168. this.bankList[i].imgLogo = "../../../static/images/mine/bank/gslogo.png"
  169. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  170. break
  171. case "农业银行":
  172. this.bankList[i].imgLogo = "../../../static/images/mine/bank/nongyelogo.png"
  173. this.bankList[i].cardColor = "../../../static/images/mine/bank/nh.png"
  174. break
  175. case "民生银行":
  176. this.bankList[i].imgLogo =
  177. "../../../static/images/mine/bank/minshenglogo.png"
  178. this.bankList[i].cardColor = "../../../static/images/mine/bank/nh.png"
  179. break
  180. case "中信银行":
  181. this.bankList[i].imgLogo =
  182. "../../../static/images/mine/bank/zhongxinlogo.png"
  183. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  184. break
  185. case "广发银行":
  186. this.bankList[i].imgLogo = "../../../static/images/mine/bank/gflogo.png"
  187. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  188. break
  189. case "华夏银行":
  190. this.bankList[i].imgLogo = "../../../static/images/mine/bank/huaxia.png"
  191. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  192. break
  193. case "兴业银行":
  194. this.bankList[i].imgLogo = "../../../static/images/mine/bank/xingye.png"
  195. this.bankList[i].cardColor = "../../../static/images/mine/bank/jh.png"
  196. break
  197. default:
  198. this.bankList[i].imgLogo = "../../../static/images/mine/bank/qitalogo.png"
  199. this.bankList[i].cardColor = "../../../static/images/mine/bank/qt.png"
  200. break
  201. }
  202. }
  203. this.$forceUpdate()
  204. } else {
  205. uni.$u.toast(res.message);
  206. }
  207. })
  208. .catch(res => {
  209. uni.$u.toast(res.message);
  210. });
  211. },
  212. addBankCard() {
  213. uni.$u.route('/pages/mine/manageBankCards/addBankCard');
  214. },
  215. edit() {
  216. uni.$u.route('/pages/mine/manageBankCards/editBankCard');
  217. let params = {
  218. type: 'success',
  219. message: "修改成功",
  220. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  221. }
  222. this.$refs.uToast.show({
  223. ...params
  224. })
  225. },
  226. del(val, index) {
  227. this.obj = val
  228. this.index = index
  229. this.isShowAlert = true
  230. }
  231. },
  232. }
  233. </script>
  234. <style lang="scss">
  235. .content {
  236. background: white;
  237. padding: 20rpx;
  238. }
  239. .top-title {
  240. margin: 0 0 20rpx 0;
  241. .left {
  242. .text1 {
  243. font-size: 29rpx;
  244. color: #1F1F1F;
  245. font-weight: 700;
  246. }
  247. .text2 {
  248. font-size: 29rpx;
  249. color: #999999;
  250. }
  251. }
  252. }
  253. .card-list {
  254. padding: 0 20rpx;
  255. .number {
  256. color: white;
  257. }
  258. }
  259. .add-bankcard {
  260. background: #EEF4FF;
  261. color: #F5BA3C;
  262. font-weight: 700;
  263. font-size: 26rpx;
  264. align-items: center;
  265. padding: 4rpx 10rpx 4rpx 20rpx;
  266. border-radius: 30rpx;
  267. }
  268. .card-list-item {
  269. // background: url(../../../static/images/mine/bank/zsbg.png) center no-repeat;
  270. background-size: cover;
  271. padding: 60rpx 43rpx 100rpx 43rpx;
  272. border-radius: 20rpx;
  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>