card-list.vue 7.4 KB

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