bankCard.vue 6.2 KB

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