index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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 v-if='bankList.length==0' @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 v-else><image style='width:17px;height:17px;' @click="del()" src="../../../static/mine/sanchu.png" mode=""></image></view>
  13. </view>
  14. <!-- <image src="../../../static/images/mine/bank/nongyelogo.png" mode=""></image> -->
  15. <view class="card-list" v-for="(item,index) in bankList" :key='index'>
  16. <view class="card-list-item" :style='{"background-image":"url("+item.cardColor+")"}'>
  17. <view class="flex flex-end number carNumber">{{item.bankCard}}</view>
  18. <view class="flex align-center">
  19. <!-- @/static/images/mine/bank/gflogo.png -->
  20. <image class="img left" :src="item.imgLogo" mode='widthFix'>
  21. </image>
  22. <view class="right">
  23. <view class="text1">{{item.bankDeposit}}</view>
  24. <view class="text2">收款人:{{item.cardholderName}}</view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="flex flex-space-between row2 align-center">
  29. <view class="flex align-center">
  30. <!-- <radio :checked="item.defaultFlag==1" @click='radioChange(item)' />
  31. <view class="default-card">设为默认收款账户</view> -->
  32. </view>
  33. <view>
  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. onShow() {
  66. this.init();
  67. },
  68. methods: {
  69. confirmClick(){
  70. this.isShowAlert = false
  71. this.$request.baseRequest('post', '/hyCargoOwnerPayeeInfo/api/deletePayee', {
  72. id: this.obj.id
  73. }).then(res => {
  74. if (res.code == '200') {
  75. this.$refs.uToast.show({
  76. type: 'success',
  77. message: "删除成功!",
  78. })
  79. this.bankList.splice(this.index, 1)
  80. }
  81. })
  82. .catch(res => {
  83. uni.$u.toast(res.message);
  84. });
  85. },
  86. cancelClick(){
  87. this.isShowAlert = false
  88. },
  89. radioChange(val) {
  90. for (let i = 0; i < this.bankList.length; i++) {
  91. if (val.id == this.bankList[i].id) {
  92. if(this.bankList[i].defaultFlag == 1){
  93. this.bankList[i].defaultFlag = 0
  94. this.bankList[i].flag = 2 //取消标志
  95. }else{
  96. this.bankList[i].defaultFlag = 1
  97. this.bankList[i].flag = 1 //设置标志
  98. }
  99. this.$request.baseRequest('post', '/hyCargoOwnerPayeeInfo/api/setDefault', val).then(res => {
  100. if (res.code == '200') {
  101. if(this.bankList[i].flag == 1){
  102. this.$refs.uToast.show({
  103. type: 'success',
  104. message: "设置成功!",
  105. })
  106. }else{
  107. this.$refs.uToast.show({
  108. type: 'success',
  109. message: "取消成功!",
  110. })
  111. }
  112. } else {
  113. uni.$u.toast(res.message);
  114. }
  115. })
  116. .catch(res => {
  117. uni.$u.toast(res.message);
  118. });
  119. } else {
  120. this.bankList[i].defaultFlag = 0
  121. }
  122. }
  123. },
  124. number(value){
  125. if(value&&value.length>8) {
  126. let reg = /^(\d{4})(\d*)(\d{4})$/;
  127. let str = value.replace(reg, (a, b, c, d)=> {
  128. return b + c.replace(/\d/g, "*") + d;
  129. });
  130. return str
  131. }else {
  132. return value
  133. }
  134. },
  135. init() {
  136. this.$request.baseRequest('get', '/hyCargoOwnerPayeeInfo/selectPayee', {
  137. commonId: this.userInfo.id,
  138. pageSize: 10,
  139. currentPage: 1,
  140. }).then(res => {
  141. if (res.code == '200') {
  142. this.bankList = res.data.records
  143. for (let i = 0; i < this.bankList.length; i++) {
  144. let _obj = this.bankList[i]
  145. _obj.bankCard = this.number(_obj.bankCard)
  146. switch (_obj.bankDeposit) {
  147. case "建设银行":
  148. this.bankList[i].imgLogo = "../../../static/images/mine/bank/jiansheogo.png"
  149. this.bankList[i].cardColor = "../../../static/images/mine/bank/jh.png"
  150. break
  151. case "招商银行":
  152. this.bankList[i].imgLogo =
  153. "../../../static/images/mine/bank/zhaoshang.png"
  154. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  155. break
  156. case "中国银行":
  157. this.bankList[i].imgLogo = "../../../static/images/mine/bank/zhongyin.png"
  158. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  159. break
  160. case "邮政银行":
  161. this.bankList[i].imgLogo =
  162. "../../../static/images/mine/bank/youzhenglogo.png"
  163. this.bankList[i].cardColor = "../../../static/images/mine/bank/nh.png"
  164. break
  165. case "交通银行":
  166. this.bankList[i].imgLogo =
  167. "../../../static/images/mine/bank/jiaotognlogo.png"
  168. this.bankList[i].cardColor = "../../../static/images/mine/bank/jh.png"
  169. break
  170. case "工商银行":
  171. this.bankList[i].imgLogo = "../../../static/images/mine/bank/gslogo.png"
  172. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  173. break
  174. case "农业银行":
  175. this.bankList[i].imgLogo = "../../../static/images/mine/bank/nongyelogo.png"
  176. this.bankList[i].cardColor = "../../../static/images/mine/bank/nh.png"
  177. break
  178. case "民生银行":
  179. this.bankList[i].imgLogo =
  180. "../../../static/images/mine/bank/minshenglogo.png"
  181. this.bankList[i].cardColor = "../../../static/images/mine/bank/nh.png"
  182. break
  183. case "中信银行":
  184. this.bankList[i].imgLogo =
  185. "../../../static/images/mine/bank/zhongxinlogo.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/gflogo.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/huaxia.png"
  194. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  195. break
  196. case "兴业银行":
  197. this.bankList[i].imgLogo = "../../../static/images/mine/bank/xingye.png"
  198. this.bankList[i].cardColor = "../../../static/images/mine/bank/jh.png"
  199. break
  200. default:
  201. this.bankList[i].imgLogo = "../../../static/images/mine/bank/qitalogo.png"
  202. this.bankList[i].cardColor = "../../../static/images/mine/bank/qt.png"
  203. break
  204. }
  205. }
  206. this.$forceUpdate()
  207. } else {
  208. uni.$u.toast(res.message);
  209. }
  210. })
  211. .catch(res => {
  212. uni.$u.toast(res.message);
  213. });
  214. },
  215. addBankCard() {
  216. var _this = this;
  217. // this.dataDetails.driverId = this.userInfo.driverId
  218. _this.$request.baseRequest('get', '/cargoOwnerInfo/firstAuthentication', { //查身份证号
  219. phone: uni.getStorageSync("userInfo").phone
  220. }).then(res => {
  221. if(res.data.authenticationStatus=='已认证'){
  222. uni.$u.route('/pages/mine/manageBankCards/addBankCard');
  223. }else{
  224. this.$refs.uToast.show({
  225. type: 'error',
  226. message: "请先进行身份认证!",
  227. })
  228. }
  229. })
  230. },
  231. edit() {
  232. uni.$u.route('/pages/mine/manageBankCards/editBankCard');
  233. let params = {
  234. type: 'success',
  235. message: "修改成功",
  236. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  237. }
  238. this.$refs.uToast.show({
  239. ...params
  240. })
  241. },
  242. del(val, index) {
  243. this.obj = this.bankList[0]
  244. this.index = 0
  245. this.isShowAlert = true
  246. }
  247. },
  248. }
  249. </script>
  250. <style lang="scss">
  251. .content {
  252. background: white;
  253. padding: 20rpx;
  254. }
  255. .top-title {
  256. margin: 0 0 20rpx 0;
  257. .left {
  258. .text1 {
  259. font-size: 29rpx;
  260. color: #1F1F1F;
  261. font-weight: 700;
  262. }
  263. .text2 {
  264. font-size: 29rpx;
  265. color: #999999;
  266. }
  267. }
  268. }
  269. .card-list {
  270. padding: 0 20rpx;
  271. .number {
  272. color: white;
  273. }
  274. }
  275. .add-bankcard {
  276. background: #EEF4FF;
  277. color: #2772FB;
  278. font-weight: 700;
  279. font-size: 26rpx;
  280. align-items: center;
  281. padding: 4rpx 10rpx 4rpx 20rpx;
  282. border-radius: 30rpx;
  283. }
  284. .card-list-item {
  285. // background: url(../../../static/images/mine/bank/zsbg.png) center no-repeat;
  286. background-size: cover;
  287. padding: 60rpx 43rpx 100rpx 43rpx;
  288. border-radius: 20rpx;
  289. .carNumber{
  290. margin-bottom: 20rpx;
  291. }
  292. .img {
  293. width: 80rpx;
  294. height: 80rpx;
  295. margin-right: 20rpx;
  296. }
  297. .right {
  298. .text1 {
  299. font-size: 36rpx;
  300. font-weight: 700;
  301. color: #FFFFFF;
  302. }
  303. .text2 {
  304. // font-size: 24rpx;
  305. color: #FFFFFF;
  306. margin-top: 10rpx;
  307. }
  308. }
  309. }
  310. .row2 {
  311. margin: 20rpx 0;
  312. }
  313. .default-card {
  314. // font-size: 28rpx;
  315. color: #333333;
  316. }
  317. </style>