index.vue 10 KB

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