card-list.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <view class="container card clearfix">
  3. <tui-skeleton
  4. v-if="skeletonShow"
  5. backgroundColor="#fafafa"
  6. borderRadius="10rpx"
  7. :isLoading="true"
  8. :loadingType="5"
  9. ></tui-skeleton>
  10. <template v-else>
  11. <view class="card-title">我的银行卡 <text>{{ list.length }}张</text></view>
  12. <view class="card-content">
  13. <template v-if="list.length > 0">
  14. <view class="list" v-for="(card, index) in list" :key="index" :style="{ backgroundImage: handleStyle(card.bankCode) }">
  15. <view class="list-logo">
  16. <view class="logo"><image :src="'https://static.caimei365.com/app/img/pay/icon_'+ card.bankCode+'_@2x.png'"></image></view>
  17. </view>
  18. <view class="list-main">
  19. <view class="list-main-name">{{ card.bankName }}</view>
  20. <view class="list-main-tag"> <text class="tag"> {{ card.bankType === 1 ? '借记卡' : '贷记卡' }} </text> </view>
  21. <view class="list-main-code">
  22. {{ card.quickPayBankNumber | cardsFormat }}
  23. </view>
  24. </view>
  25. <view class="list-btn" @click="handleUnbind(card)">解绑</view>
  26. </view>
  27. </template>
  28. <view class="list-none" v-else>
  29. <text>暂无银行卡~</text>
  30. </view>
  31. </view>
  32. </template>
  33. <!-- 取消收藏操作 -->
  34. <tui-bottom-popup :radius="false" :mask="false" :show="popupShow">
  35. <view class="tui-popup-box clearfix">
  36. <view class="tui-right-flex tui-popup-btn" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
  37. <view class="tui-flex-1">
  38. <view class="tui-button" @click="handleAddCard(1)">添加银行卡</view>
  39. </view>
  40. </view>
  41. </view>
  42. </tui-bottom-popup>
  43. <!-- 弹窗提示 -->
  44. <tui-modal
  45. :show="modal"
  46. @click="handleClick"
  47. @cancel="hideMobel"
  48. :content="contentModalText"
  49. :button="modalButton"
  50. color="#333"
  51. :size="32"
  52. shape="circle"
  53. :maskClosable="false"
  54. >
  55. </tui-modal>
  56. </view>
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. isIphoneX:this.$store.state.isIphoneX,
  63. skeletonShow:true,
  64. popupShow:true,
  65. contentModalText: '', //操作文字提示语句
  66. modal: false,
  67. modalButton: [
  68. {
  69. text: '保持绑定',
  70. type: 'gray',
  71. plain: true //是否空心
  72. },
  73. {
  74. text: '继续解绑',
  75. customStyle: {
  76. color: '#fff',
  77. bgColor: 'linear-gradient(90deg, #F28F31 0%, #F3B574 100%)'
  78. },
  79. plain: false
  80. }
  81. ],
  82. list: []
  83. }
  84. },
  85. onLoad() {
  86. this.GetUserClubBanks()
  87. },
  88. filters: {
  89. cardsFormat(valus) {
  90. // 银行卡只显示最后四位数 ,隐藏信息用*代替
  91. return valus.replace(/^(\d{4})\d+(\d{4})$/,"$1****$2")
  92. },
  93. },
  94. methods: {
  95. async GetUserClubBanks() {
  96. //获取列表
  97. try {
  98. const user = await this.$api.getStorage()
  99. const res = await this.UserService.userClubBanks({ userId:user.userId })
  100. this.list = res.data
  101. this.skeletonShow = false
  102. } catch (error) {
  103. console.log(error)
  104. }
  105. },
  106. handleAddCard(index){
  107. // 跳转添加银行卡页面
  108. this.$api.navigateTo(`/pages/user/pay/card-comfirm?type=${index}`)
  109. },
  110. handleUnbind(card){
  111. //点击解绑
  112. this.handleCardId = card.id
  113. this.modal = true
  114. this.contentModalText = '解绑后此卡需要重新绑定才能继续使用'
  115. },
  116. handleClick(e) {
  117. //确认解绑
  118. if (e.index == 1) {
  119. this.orderPayUnboundCard()
  120. }
  121. this.modal = false
  122. },
  123. async orderPayUnboundCard(){
  124. //请求
  125. try {
  126. const res = await this.PayService.orderPayUnboundCard({ cardId : this.handleCardId })
  127. console.log('res', res.data)
  128. this.$util.msg('解绑成功',2000,true,'success')
  129. this.GetUserClubBanks()
  130. } catch (error) {
  131. this.$util.msg(error.msg, 2000)
  132. }
  133. },
  134. hideMobel(){
  135. // 取消解绑
  136. this.modal = false
  137. },
  138. handleStyle(type) {
  139. // 设置各个银行卡配色
  140. const styleMap = {
  141. 'ABC':'linear-gradient(90deg, #19B8B2 0%, #009C96 100%);',
  142. 'BCCB':'linear-gradient(90deg, #4D8CD8 0%, #3C66C9 100%);',
  143. 'BOC':'linear-gradient(90deg, #FB6965 0%, #CE4343 100%);',
  144. 'BOCO':'linear-gradient(90deg, #7275BE 0%, #434492 100%);',
  145. 'CCB':'linear-gradient(90deg, #4D8CD8 0%, #3C66C9 100%);',
  146. 'CEB':'linear-gradient(90deg, #B673CB 0%, #843C9A 100%);',
  147. 'CGB':'linear-gradient(90deg, #FB6965 0%, #CE4343 100%);',
  148. 'CIB':'linear-gradient(90deg, #457EBC 0%, #1B518A 100%);',
  149. 'CMBC':'linear-gradient(90deg, #3C9EC2 0%, #0584B4 100%);',
  150. 'CMBCHINA':'linear-gradient(90deg, #FB6965 0%, #CE4343 100%);',
  151. 'ECITIC':'linear-gradient(90deg, #ED796B 0%, #EF585E 100%);',
  152. 'HXB':'linear-gradient(90deg, #ED796B 0%, #EF585E 100%);',
  153. 'ICBC':'linear-gradient(90deg, #ED796B 0%, #EF585E 100%);',
  154. 'PINGAN':'linear-gradient(90deg, #F5A15A 0%, #E47F29 100%);',
  155. 'POST':'linear-gradient(90deg, #3EB97B 0%, #11874B 100%);',
  156. 'SHB':'linear-gradient(90deg, #6479C8 0%, #314693 100%);',
  157. 'SPDB':'linear-gradient(90deg, #4D8CD8 0%, #3C66C9 100%);',
  158. }
  159. return styleMap[type]
  160. },
  161. },
  162. onPullDownRefresh() {
  163. //下拉刷新
  164. this.GetUserClubBanks()
  165. uni.stopPullDownRefresh()
  166. },
  167. onShow() {
  168. }
  169. }
  170. </script>
  171. <style lang="scss">
  172. page,
  173. .container {
  174. background: #ffffff;
  175. height: 100%;
  176. }
  177. .card-title {
  178. width: 100%;
  179. height: 100rpx;
  180. line-height: 100rpx;
  181. font-size: $font-size-32;
  182. color: #333;
  183. font-weight: bold;
  184. box-sizing: border-box;
  185. padding: 0 24rpx;
  186. text {
  187. font-size: $font-size-28;
  188. color: #999;
  189. font-weight: normal;
  190. margin-left: 10rpx;
  191. }
  192. }
  193. .card-content {
  194. width: 100%;
  195. height: auto;
  196. box-sizing: border-box;
  197. padding: 0 40rpx;
  198. .list-none{
  199. width: 100%;
  200. height: 900rpx;
  201. line-height: 900rpx;
  202. font-size: $font-size-28;
  203. text-align: center;
  204. color: #999;
  205. }
  206. .list {
  207. width: 100%;
  208. height: 240rpx;
  209. border-radius: 16rpx;
  210. box-sizing: border-box;
  211. padding: 32rpx;
  212. position: relative;
  213. margin-bottom: 32rpx;
  214. background: url(https://static.caimei365.com/app/img/pay/icon_bg_cards@2x.png);
  215. background-size: cover;
  216. &:last-child{
  217. margin-bottom: 0;
  218. }
  219. .list-logo{
  220. width: 80rpx;
  221. height: 100%;
  222. float: left;
  223. .logo{
  224. width: 80rpx;
  225. height: 80rpx;
  226. border-radius: 50%;
  227. box-sizing: border-box;
  228. float: left;
  229. image{
  230. width: 80rpx;
  231. height: 80rpx;
  232. border-radius: 50%;
  233. display: block;
  234. }
  235. }
  236. }
  237. .list-main{
  238. width: 452rpx;
  239. float: left;
  240. margin-left: 32rpx;
  241. .list-main-name{
  242. width: 100%;
  243. height: 50rpx;
  244. line-height: 50rpx;
  245. font-size: $font-size-34;
  246. color: #ffffff;
  247. }
  248. .list-main-tag{
  249. width: 100%;
  250. height: 37rpx;
  251. margin: 8rpx 0 36rpx 0;
  252. .tag{
  253. display: inline-block;
  254. line-height: 37rpx;
  255. padding: 0 12rpx;
  256. border-radius: 19rpx;
  257. font-size: $font-size-24;
  258. color: #ffffff;
  259. background: rgba(255, 255, 255, 0.2);
  260. float: left;
  261. }
  262. }
  263. .list-main-code{
  264. width: 100%;
  265. height: 50rpx;
  266. line-height: 50rpx;
  267. font-size: $font-size-34;
  268. color: #ffffff;
  269. }
  270. }
  271. .list-btn{
  272. font-size: $font-size-24;
  273. color: #ffffff;
  274. height: 30rpx;
  275. line-height: 30rpx;
  276. position: absolute;
  277. right: 32rpx;
  278. top: 32rpx;
  279. }
  280. }
  281. }
  282. .tui-popup-box {
  283. position: relative;
  284. box-sizing: border-box;
  285. min-height: 100rpx;
  286. padding: 6rpx 24rpx;
  287. .tui-popup-content {
  288. padding-top: 30rpx;
  289. }
  290. }
  291. .tui-popup-btn {
  292. width: 100%;
  293. height: auto;
  294. float: left;
  295. box-sizing: border-box;
  296. margin-top: 30rpx;
  297. .tui-button {
  298. width: 600rpx;
  299. height: 88rpx;
  300. background: $btn-confirm;
  301. line-height: 88rpx;
  302. text-align: center;
  303. color: #ffffff;
  304. font-size: $font-size-28;
  305. border-radius: 44rpx;
  306. margin: 0 auto;
  307. }
  308. }
  309. </style>