bankList.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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" @click="bankCheng(item)">
  15. <view class="card-list-item" :style='{"background-image":"url("+item.cardColor+")"}'>
  16. <image style='width:17px;height:17px;position: absolute;z-index: 9999;right: 20rpx;top: 20rpx;' @click.stop="del(item,index)" src="../../../static/mine/sanchu.png" mode=""></image>
  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>
  29. <!-- <view @click="addBankCard">添加银行卡</view> -->
  30. <u-modal :show="isShowAlert" :title="alertTitle" :closeOnClickOverlay='true' :showCancelButton='true' confirmColor='#2772FB' @confirm="$u.throttle(confirmClick(), 1000)" @close="cancelClick" @cancel="cancelClick"></u-modal>
  31. <u-toast ref="uToast"></u-toast>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. mapState
  37. } from 'vuex';
  38. export default {
  39. data() {
  40. return {
  41. bankList: [],
  42. obj:{},
  43. index:null,
  44. isShowAlert:false,
  45. alertTitle:'确认删除该银行卡?',
  46. enterprise:"",//判断是否有值(有则是我的公司页面进来的 没有则是首页进来的)
  47. };
  48. },
  49. computed: {
  50. ...mapState(['hasLogin', 'userInfo']),
  51. },
  52. onLoad(options) {
  53. if(options && options.enterprise){
  54. this.enterprise = options.enterprise
  55. }
  56. if (!this.hasLogin) {
  57. uni.$u.route('/pages/public/login');
  58. }
  59. this.init();
  60. },
  61. onShow() {
  62. this.init();
  63. },
  64. methods: {
  65. bankCheng(item){
  66. uni.setStorageSync("bankInfo",item)
  67. uni.navigateBack({
  68. delta:1
  69. })
  70. },
  71. confirmClick(){
  72. this.isShowAlert = false
  73. this.$request.baseRequest('post', '/hyCargoOwnerPayeeInfo/api/deletePayee', {
  74. id: this.obj.id
  75. }).then(res => {
  76. if (res.code == '200') {
  77. this.$refs.uToast.show({
  78. type: 'success',
  79. message: "删除成功!",
  80. })
  81. this.bankList.splice(this.index, 1)
  82. }
  83. })
  84. .catch(res => {
  85. uni.$u.toast(res.message);
  86. });
  87. },
  88. cancelClick(){
  89. this.isShowAlert = false
  90. },
  91. radioChange(val) {
  92. for (let i = 0; i < this.bankList.length; i++) {
  93. if (val.id == this.bankList[i].id) {
  94. this.bankList[i].defaultFlag = 1
  95. this.$request.baseRequest('post', '/hyCargoOwnerPayeeInfo/api/setDefault', val).then(res => {
  96. if (res.code == '200') {
  97. this.$refs.uToast.show({
  98. type: 'success',
  99. message: "设置成功!",
  100. })
  101. } else {
  102. uni.$u.toast(res.message);
  103. }
  104. })
  105. .catch(res => {
  106. uni.$u.toast(res.message);
  107. });
  108. } else {
  109. this.bankList[i].defaultFlag = 0
  110. }
  111. }
  112. },
  113. number(value){
  114. if(value&&value.length>8) {
  115. let reg = /^(\d{4})(\d*)(\d{4})$/;
  116. let str = value.replace(reg, (a, b, c, d)=> {
  117. return b + c.replace(/\d/g, "*") + d;
  118. });
  119. return str
  120. }else {
  121. return value
  122. }
  123. },
  124. init() {
  125. this.$request.baseRequest('get', '/hyCargoOwnerPayeeInfo/selectPayee', {
  126. commonId: this.userInfo.id,
  127. pageSize: 10,
  128. currentPage: 1,
  129. }).then(res => {
  130. if (res.code == '200') {
  131. this.bankList = res.data.records
  132. for (let i = 0; i < this.bankList.length; i++) {
  133. let _obj = this.bankList[i]
  134. _obj.bankCard = this.number(_obj.bankCard)
  135. switch (_obj.bankDeposit) {
  136. case "建设银行":
  137. this.bankList[i].imgLogo = "../../../static/images/mine/bank/jiansheogo.png"
  138. this.bankList[i].cardColor = "../../../static/images/mine/bank/jh.png"
  139. break
  140. case "招商银行":
  141. this.bankList[i].imgLogo =
  142. "../../../static/images/mine/bank/zhaoshang.png"
  143. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  144. break
  145. case "中国银行":
  146. this.bankList[i].imgLogo = "../../../static/images/mine/bank/zhongyin.png"
  147. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  148. break
  149. case "邮政银行":
  150. this.bankList[i].imgLogo =
  151. "../../../static/images/mine/bank/youzhenglogo.png"
  152. this.bankList[i].cardColor = "../../../static/images/mine/bank/nh.png"
  153. break
  154. case "交通银行":
  155. this.bankList[i].imgLogo =
  156. "../../../static/images/mine/bank/jiaotognlogo.png"
  157. this.bankList[i].cardColor = "../../../static/images/mine/bank/jh.png"
  158. break
  159. case "工商银行":
  160. this.bankList[i].imgLogo = "../../../static/images/mine/bank/gslogo.png"
  161. this.bankList[i].cardColor = "../../../static/images/mine/bank/zsbg.png"
  162. break
  163. case "农业银行":
  164. this.bankList[i].imgLogo = "../../../static/images/mine/bank/nongyelogo.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/minshenglogo.png"
  170. this.bankList[i].cardColor = "../../../static/images/mine/bank/nh.png"
  171. break
  172. case "中信银行":
  173. this.bankList[i].imgLogo =
  174. "../../../static/images/mine/bank/zhongxinlogo.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/gflogo.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/huaxia.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/xingye.png"
  187. this.bankList[i].cardColor = "../../../static/images/mine/bank/jh.png"
  188. break
  189. default:
  190. this.bankList[i].imgLogo = "../../../static/images/mine/bank/qitalogo.png"
  191. this.bankList[i].cardColor = "../../../static/images/mine/bank/qt.png"
  192. break
  193. }
  194. }
  195. this.$forceUpdate()
  196. } else {
  197. uni.$u.toast(res.message);
  198. }
  199. })
  200. .catch(res => {
  201. uni.$u.toast(res.message);
  202. });
  203. },
  204. addBankCard() {
  205. var _this = this;
  206. // this.dataDetails.driverId = this.userInfo.driverId
  207. _this.$request.baseRequest('get', '/cargoOwnerInfo/firstAuthentication', { //查身份证号
  208. phone: uni.getStorageSync("userInfo").phone
  209. }).then(res => {
  210. if(res.data.authenticationStatus=='已认证'){
  211. if(this.enterprise){
  212. uni.$u.route('/pages/mine/manageBankCards/addBankCard?enterprise='+this.enterprise);//企业添加银行卡标识
  213. }else{
  214. uni.$u.route('/pages/mine/manageBankCards/addBankCard');
  215. }
  216. }else{
  217. this.$refs.uToast.show({
  218. type: 'error',
  219. message: "请先进行身份认证!",
  220. })
  221. }
  222. })
  223. },
  224. edit() {
  225. uni.$u.route('/pages/mine/manageBankCards/editBankCard');
  226. let params = {
  227. type: 'success',
  228. message: "修改成功",
  229. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  230. }
  231. this.$refs.uToast.show({
  232. ...params
  233. })
  234. },
  235. del(val,index) {
  236. this.obj = val
  237. this.index = index
  238. this.isShowAlert = true
  239. }
  240. },
  241. }
  242. </script>
  243. <style lang="scss">
  244. .content {
  245. background: white;
  246. padding: 20rpx;
  247. }
  248. .top-title {
  249. margin: 0 0 20rpx 0;
  250. .left {
  251. .text1 {
  252. font-size: 29rpx;
  253. color: #1F1F1F;
  254. font-weight: 700;
  255. }
  256. .text2 {
  257. font-size: 29rpx;
  258. color: #999999;
  259. }
  260. }
  261. }
  262. .card-list {
  263. padding: 0 20rpx;
  264. margin-top: 20rpx;
  265. .number {
  266. color: white;
  267. }
  268. }
  269. .add-bankcard {
  270. background: #EEF4FF;
  271. color: #2772FB;
  272. font-weight: 700;
  273. font-size: 26rpx;
  274. align-items: center;
  275. padding: 4rpx 10rpx 4rpx 20rpx;
  276. border-radius: 30rpx;
  277. }
  278. .card-list-item {
  279. // background: url(../../../static/images/mine/bank/zsbg.png) center no-repeat;
  280. background-size: cover;
  281. padding: 60rpx 43rpx 100rpx 43rpx;
  282. border-radius: 20rpx;
  283. position: relative;
  284. .carNumber{
  285. margin-bottom: 20rpx;
  286. }
  287. .img {
  288. width: 80rpx;
  289. height: 80rpx;
  290. margin-right: 20rpx;
  291. }
  292. .right {
  293. .text1 {
  294. font-size: 36rpx;
  295. font-weight: 700;
  296. color: #FFFFFF;
  297. }
  298. .text2 {
  299. // font-size: 24rpx;
  300. color: #FFFFFF;
  301. margin-top: 10rpx;
  302. }
  303. }
  304. }
  305. .row2 {
  306. margin: 20rpx 0;
  307. }
  308. .default-card {
  309. // font-size: 28rpx;
  310. color: #333333;
  311. }
  312. </style>