index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. <!-- <image src="../../../static/images/mine/bank/nongyelogo.png" mode=""></image> -->
  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.cardholderName}}</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='#2772FB' @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', '/hyCargoOwnerPayeeInfo/api/deletePayee', {
  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. this.bankList[i].defaultFlag = 1
  90. this.$request.baseRequest('post', '/hyCargoOwnerPayeeInfo/api/setDefault', val).then(res => {
  91. if (res.code == '200') {
  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('get', '/hyCargoOwnerPayeeInfo/selectPayee', {
  121. commonId: this.userInfo.id,
  122. pageSize: 10,
  123. currentPage: 1,
  124. }).then(res => {
  125. if (res.code == '200') {
  126. this.bankList = res.data.records
  127. for (let i = 0; i < this.bankList.length; i++) {
  128. let _obj = this.bankList[i]
  129. _obj.bankCard = this.number(_obj.bankCard)
  130. switch (_obj.bankDeposit) {
  131. case "建设银行":
  132. this.bankList[i].imgLogo = "../../../static/images/mine/bank/jiansheogo.png"
  133. this.bankList[i].cardColor = "../../../static/images/mine/bank/jh.png"
  134. break
  135. case "招商银行":
  136. this.bankList[i].imgLogo =
  137. "../../../static/images/mine/bank/zhaoshang.png"
  138. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  139. break
  140. case "中国银行":
  141. this.bankList[i].imgLogo = "../../../static/images/mine/bank/zhongyin.png"
  142. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  143. break
  144. case "邮政银行":
  145. this.bankList[i].imgLogo =
  146. "../../../static/images/mine/bank/youzhenglogo.png"
  147. this.bankList[i].cardColor = "../../../static/images/mine/bank/nh.png"
  148. break
  149. case "交通银行":
  150. this.bankList[i].imgLogo =
  151. "../../../static/images/mine/bank/jiaotognlogo.png"
  152. this.bankList[i].cardColor = "../../../static/images/mine/bank/jh.png"
  153. break
  154. case "工商银行":
  155. this.bankList[i].imgLogo = "../../../static/images/mine/bank/gslogo.png"
  156. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  157. break
  158. case "农业银行":
  159. this.bankList[i].imgLogo = "../../../static/images/mine/bank/nongyelogo.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/minshenglogo.png"
  165. this.bankList[i].cardColor = "../../../static/images/mine/bank/nh.png"
  166. break
  167. case "中信银行":
  168. this.bankList[i].imgLogo =
  169. "../../../static/images/mine/bank/zhongxinlogo.png"
  170. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  171. break
  172. case "广发银行":
  173. this.bankList[i].imgLogo = "../../../static/images/mine/bank/gflogo.png"
  174. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  175. break
  176. case "华夏银行":
  177. this.bankList[i].imgLogo = "../../../static/images/mine/bank/huaxia.png"
  178. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  179. break
  180. case "兴业银行":
  181. this.bankList[i].imgLogo = "../../../static/images/mine/bank/xingye.png"
  182. this.bankList[i].cardColor = "../../../static/images/mine/bank/jh.png"
  183. break
  184. default:
  185. this.bankList[i].imgLogo = "../../../static/images/mine/bank/qitalogo.png"
  186. this.bankList[i].cardColor = "../../../static/images/mine/bank/qt.png"
  187. break
  188. }
  189. }
  190. this.$forceUpdate()
  191. } else {
  192. uni.$u.toast(res.message);
  193. }
  194. })
  195. .catch(res => {
  196. uni.$u.toast(res.message);
  197. });
  198. },
  199. addBankCard() {
  200. uni.$u.route('/pages/mine/manageBankCards/addBankCard');
  201. },
  202. edit() {
  203. uni.$u.route('/pages/mine/manageBankCards/editBankCard');
  204. let params = {
  205. type: 'success',
  206. message: "修改成功",
  207. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  208. }
  209. this.$refs.uToast.show({
  210. ...params
  211. })
  212. },
  213. del(val, index) {
  214. this.obj = val
  215. this.index = index
  216. this.isShowAlert = true
  217. }
  218. },
  219. }
  220. </script>
  221. <style lang="scss">
  222. .content {
  223. background: white;
  224. padding: 20rpx;
  225. }
  226. .top-title {
  227. margin: 0 0 20rpx 0;
  228. .left {
  229. .text1 {
  230. font-size: 29rpx;
  231. color: #1F1F1F;
  232. font-weight: 700;
  233. }
  234. .text2 {
  235. font-size: 29rpx;
  236. color: #999999;
  237. }
  238. }
  239. }
  240. .card-list {
  241. padding: 0 20rpx;
  242. .number {
  243. color: white;
  244. }
  245. }
  246. .add-bankcard {
  247. background: #EEF4FF;
  248. color: #2772FB;
  249. font-weight: 700;
  250. font-size: 26rpx;
  251. align-items: center;
  252. padding: 4rpx 10rpx 4rpx 20rpx;
  253. border-radius: 30rpx;
  254. }
  255. .card-list-item {
  256. // background: url(../../../static/images/mine/bank/zsbg.png) center no-repeat;
  257. background-size: cover;
  258. padding: 60rpx 43rpx 100rpx 43rpx;
  259. border-radius: 20rpx;
  260. .carNumber{
  261. margin-bottom: 20rpx;
  262. }
  263. .img {
  264. width: 80rpx;
  265. height: 80rpx;
  266. margin-right: 20rpx;
  267. }
  268. .right {
  269. .text1 {
  270. font-size: 36rpx;
  271. font-weight: 700;
  272. color: #FFFFFF;
  273. }
  274. .text2 {
  275. // font-size: 24rpx;
  276. color: #FFFFFF;
  277. margin-top: 10rpx;
  278. }
  279. }
  280. }
  281. .row2 {
  282. margin: 20rpx 0;
  283. }
  284. .default-card {
  285. // font-size: 28rpx;
  286. color: #333333;
  287. }
  288. </style>