bankCard.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <view class="container">
  3. <!-- 内容区域 -->
  4. <scroll-view class="content" scroll-y>
  5. <!-- 有银行卡状态 -->
  6. <view v-if="bankCardData.id" class="card-section">
  7. <view class="bank-card">
  8. <view class="card-header">
  9. <view class="bank-info">
  10. <view class="bank-name">{{ bankCardData.bankName || '' }}</view>
  11. <view class="card-type">{{ bankCardData.cardType || '储蓄卡' }}</view>
  12. </view>
  13. <view class="edit-btn" @click="goEdit">编辑银行卡</view>
  14. </view>
  15. <view class="card-number">{{ formatCardNumber(bankCardData.cardNumber) }}</view>
  16. <image class="w270 h320" src="@/static/image/bg_bankcard.png" mode=""></image>
  17. </view>
  18. <!-- 注意事项 -->
  19. <view class="notes-section">
  20. <view class="notes-title">注意:</view>
  21. <view class="notes-item">1、只能绑定认证用户本人的银行卡;</view>
  22. <view class="notes-item">2、每次更换次数不得超过三次。</view>
  23. </view>
  24. </view>
  25. <!-- 空状态 -->
  26. <view v-else class="empty-section">
  27. <view class="empty-card-illustration">
  28. <image class="w322 h198" src="@/static/image/img_nocard.svg" mode=""></image>
  29. </view>
  30. <view class="empty-text">暂未添加银行卡</view>
  31. <view class="add-btn" @click="goAdd">添加银行卡</view>
  32. </view>
  33. </scroll-view>
  34. </view>
  35. </template>
  36. <script>
  37. import { getBankCardInfo } from '@/api-js/bankCard'
  38. export default {
  39. data() {
  40. return {
  41. bankCardData: {}
  42. }
  43. },
  44. onLoad() {
  45. this.loadBankCardData()
  46. },
  47. onShow() {
  48. // 从编辑/添加页面返回时刷新数据
  49. this.loadBankCardData()
  50. },
  51. methods: {
  52. async loadBankCardData() {
  53. try {
  54. uni.showLoading({ title: '加载中...' })
  55. const res = await getBankCardInfo()
  56. uni.hideLoading()
  57. if (res.code === 200 && res.data) {
  58. this.bankCardData = res.data
  59. } else {
  60. this.bankCardData = {id:1,bankName:'中国工商银行',cardNumber:'**** **** **** 8869'}
  61. }
  62. } catch (e) {
  63. uni.hideLoading()
  64. console.error('加载银行卡信息失败', e)
  65. this.bankCardData = {}
  66. }
  67. },
  68. formatCardNumber(cardNumber) {
  69. if (!cardNumber) return ''
  70. if (cardNumber.length < 4) return cardNumber
  71. // 显示最后4位,其他用*代替
  72. const lastFour = cardNumber.substring(cardNumber.length - 4)
  73. return `**** **** **** ${lastFour}`
  74. },
  75. goBack() {
  76. uni.navigateBack()
  77. },
  78. goAdd() {
  79. uni.navigateTo({
  80. url: '/pages_user/addBankCard'
  81. })
  82. },
  83. goEdit() {
  84. uni.navigateTo({
  85. url: '/pages_user/editBankCard?id=' + this.bankCardData.id
  86. })
  87. }
  88. }
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. .container {
  93. min-height: 100vh;
  94. background: #fff;
  95. display: flex;
  96. flex-direction: column;
  97. }
  98. .navbar {
  99. display: flex;
  100. align-items: center;
  101. justify-content: space-between;
  102. padding: 20rpx 24rpx;
  103. background: #fff;
  104. border-bottom: 1rpx solid #f0f0f0;
  105. position: sticky;
  106. top: 0;
  107. z-index: 100;
  108. .nav-left {
  109. width: 60rpx;
  110. .back-icon {
  111. font-size: 36rpx;
  112. color: #333;
  113. font-weight: bold;
  114. }
  115. }
  116. .nav-title {
  117. flex: 1;
  118. text-align: center;
  119. font-size: 36rpx;
  120. font-weight: bold;
  121. color: #333;
  122. }
  123. .nav-right {
  124. display: flex;
  125. align-items: center;
  126. gap: 24rpx;
  127. width: 60rpx;
  128. justify-content: flex-end;
  129. .more-icon {
  130. font-size: 32rpx;
  131. color: #333;
  132. }
  133. .eye-icon {
  134. font-size: 32rpx;
  135. color: #333;
  136. }
  137. }
  138. }
  139. .content {
  140. flex: 1;
  141. background: #f5f5f5;
  142. }
  143. .card-section {
  144. padding: 24rpx;
  145. .bank-card {
  146. width: 702rpx;
  147. height: 320rpx;
  148. box-sizing: border-box;
  149. background: linear-gradient( 71deg, #388BFF 0%, #0C75FF 100%);
  150. border-radius: 24rpx 24rpx 24rpx 24rpx;
  151. padding: 40rpx;
  152. margin-bottom: 32rpx;
  153. position: relative;
  154. image{
  155. position: absolute;
  156. top:0;
  157. right: 0;
  158. z-index: 0;
  159. }
  160. .card-header {
  161. display: flex;
  162. align-items: flex-start;
  163. justify-content: space-between;
  164. margin-bottom: 60rpx;
  165. position: relative;
  166. z-index: 1;
  167. .bank-info {
  168. .bank-name {
  169. font-family: PingFang SC, PingFang SC;
  170. font-weight: 600;
  171. font-size: 32rpx;
  172. color: #FFFFFF;
  173. margin-bottom: 16rpx;
  174. }
  175. .card-type {
  176. font-family: PingFang SC, PingFang SC;
  177. font-weight: 400;
  178. font-size: 28rpx;
  179. color: #fff;
  180. }
  181. }
  182. .edit-btn {
  183. width: 220rpx;
  184. height: 64rpx;
  185. display: flex;
  186. align-items: center;
  187. justify-content: center;
  188. background: rgba(255,255,255,0.2);
  189. border-radius: 34rpx 34rpx 34rpx 34rpx;
  190. border: 2rpx solid #FFFFFF;
  191. font-family: PingFang SC, PingFang SC;
  192. font-weight: 500;
  193. font-size: 28rpx;
  194. color: #FFFFFF;
  195. }
  196. }
  197. .card-number {
  198. font-family: PingFang SC, PingFang SC;
  199. font-weight: 600;
  200. font-size: 48rpx;
  201. color: #FFFFFF;
  202. }
  203. }
  204. .notes-section {
  205. padding: 32rpx;
  206. .notes-title {
  207. font-family: PingFang SC, PingFang SC;
  208. font-weight: 400;
  209. font-size: 28rpx;
  210. color: #999999;
  211. line-height: 40rpx;
  212. }
  213. .notes-item {
  214. font-family: PingFang SC, PingFang SC;
  215. font-weight: 400;
  216. font-size: 28rpx;
  217. color: #999999;
  218. line-height: 40rpx;
  219. }
  220. }
  221. }
  222. .empty-section {
  223. display: flex;
  224. flex-direction: column;
  225. align-items: center;
  226. justify-content: center;
  227. padding:0 24rpx;
  228. margin-top: 140rpx;
  229. // min-height: 60vh;
  230. .empty-card-illustration {
  231. margin-bottom: 48rpx;
  232. .card-preview {
  233. width: 600rpx;
  234. height: 360rpx;
  235. background: linear-gradient(135deg, #388BFF 0%, #5BA0FF 100%);
  236. border-radius: 24rpx;
  237. position: relative;
  238. padding: 48rpx 32rpx;
  239. .card-chip {
  240. width: 60rpx;
  241. height: 48rpx;
  242. background: #FFC107;
  243. border-radius: 8rpx;
  244. margin-bottom: 32rpx;
  245. }
  246. .card-strip {
  247. width: 200rpx;
  248. height: 40rpx;
  249. background: rgba(255, 255, 255, 0.3);
  250. border-radius: 8rpx;
  251. position: absolute;
  252. top: 32rpx;
  253. right: 32rpx;
  254. }
  255. .card-lines {
  256. margin-top: 32rpx;
  257. .line {
  258. height: 24rpx;
  259. background: rgba(255, 255, 255, 0.6);
  260. border-radius: 4rpx;
  261. margin-bottom: 16rpx;
  262. &.line-1 {
  263. width: 400rpx;
  264. }
  265. &.line-2 {
  266. width: 280rpx;
  267. }
  268. }
  269. }
  270. }
  271. }
  272. .empty-text {
  273. font-size: 28rpx;
  274. color: #999;
  275. margin-bottom: 48rpx;
  276. }
  277. .add-btn {
  278. width: 100%;
  279. max-width: 600rpx;
  280. height: 88rpx;
  281. background: #388BFF;
  282. border-radius: 44rpx;
  283. display: flex;
  284. align-items: center;
  285. justify-content: center;
  286. font-size: 32rpx;
  287. font-weight: bold;
  288. color: #fff;
  289. }
  290. }
  291. </style>