您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

bank-card.vue 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <view class="container" @click="choice(item.bankCardId)" v-for="(item,index) in state.bankListArr">
  3. <view class="">
  4. <image class="bg" style="width:100%;height: 260rpx;" :src="`${$imgUrl}bank-bg.png`"></image>
  5. <view class="content">
  6. <view class="flex">
  7. <image style="width:68rpx;height:68rpx;" :src="`${$imgUrl}gongshang.png`">
  8. </image>
  9. <view style="margin-left: 15rpx;" class="">
  10. <view class="bank">工商银行</view>
  11. <view class="card">储蓄卡</view>
  12. </view>
  13. </view>
  14. <view class="button" @click.stop='delCard(item.bankCardId)'>解除绑定</view>
  15. </view>
  16. <view class="value">{{item.bankCardId}}</view>
  17. <!-- <view class='default'>默认</view> -->
  18. </view>
  19. </view>
  20. <!-- <view class="container" @click="navTo('/subpackage/personal-center/setting/bank-card/bank-card-add')">
  21. <view class="">
  22. <image class="bg" style="width:100%;height: 260rpx;" :src="`${$imgUrl}bank-bg.png`"></image>
  23. <view class="content">
  24. <view class="flex">
  25. <image style="width:68rpx;height:68rpx;" :src="`${$imgUrl}gongshang.png`">
  26. </image>
  27. <view style="margin-left: 15rpx;" class="">
  28. <view class="bank">工商银行</view>
  29. <view class="card">储蓄卡</view>
  30. </view>
  31. </view>
  32. <view class="button" @click.stop='delCard()'>解除绑定</view>
  33. </view>
  34. <view class="value">6216 **** **** 8721</view>
  35. <view class='default'>默认</view>
  36. </view>
  37. </view> -->
  38. <view style='margin: 40rpx 30rpx;' @click="navTo('/subpackage/personal-center/setting/bank-card/bank-card-add')">
  39. <submit-button title="+ 添加银行卡"></submit-button>
  40. </view>
  41. </template>
  42. <script lang="ts" setup>
  43. import { reactive } from "vue";
  44. import { request } from "@/utils/network/request.js";
  45. import { queryBankCard, delBankCard } from "@/utils/network/api.js";
  46. import { stringToJson } from "@/utils/network/encryption.js";
  47. import { navTo } from '@/utils/utils';
  48. import { onLoad } from "@dcloudio/uni-app";
  49. const state = reactive({
  50. name: '',
  51. params: {}, //传过来的参数
  52. choiceCard: "",
  53. bankListArr: []
  54. })
  55. onLoad((option : any) => {
  56. if (option.value) {
  57. state.params = JSON.parse(decodeURIComponent(option.value))
  58. state.name = state.params.name;
  59. state.choiceCard = state.params.choiceCard;
  60. }
  61. if (option.name) {
  62. state.name = option.name;
  63. }
  64. console.log("option", state.params)
  65. getBankList();
  66. })
  67. const getBankList = () => {
  68. const options = {
  69. type: 2,
  70. data: {
  71. 'accountId': state.name
  72. },
  73. method: "POST",
  74. showLoading: true,
  75. };
  76. request(queryBankCard, options).then((res) => {
  77. const data = stringToJson(res.bizContent)
  78. state.bankListArr = data.data
  79. console.log("获取银行卡", data)
  80. })
  81. }
  82. const delCard = (cardId) => {
  83. const options = {
  84. type: 2,
  85. data: {
  86. 'accountId': state.name,
  87. 'bankCardId': cardId
  88. },
  89. method: "POST",
  90. showLoading: true,
  91. };
  92. request(delBankCard, options).then((res) => {
  93. const data = stringToJson(res.bizContent)
  94. console.log("删除银行卡", data);
  95. getBankList();
  96. })
  97. }
  98. const choice = (cardNumber) => {
  99. // if (!state.choiceCard) {
  100. // navTo('/subpackage/personal-center/setting/bank-card/bank-card-add')
  101. // } else {
  102. uni.redirectTo({
  103. //关闭当前页面,跳转到应用内的某个页面。
  104. url: `/subpackage/after-sale/account-recharge/recharge?cardNumber=${cardNumber}&value=${encodeURIComponent(JSON.stringify(state.params))}`
  105. });
  106. // navTo(`/subpackage/after-sale/account-recharge/recharge?cardNumber=${cardNumber}`)
  107. // }
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. .container {
  112. padding: 30rpx 30rpx 0 30rpx;
  113. position: relative;
  114. .flex {
  115. display: flex;
  116. align-items: center;
  117. }
  118. .value {
  119. position: absolute;
  120. top: 160rpx;
  121. left: 30rpx;
  122. right: 30rpx;
  123. font-size: 36rpx;
  124. font-family: Microsoft YaHei;
  125. font-weight: 400;
  126. color: #FFFFFF;
  127. text-align: center;
  128. line-height: 36rpx;
  129. }
  130. .default {
  131. position: absolute;
  132. top: 235rpx;
  133. left: 60rpx;
  134. font-size: 29rpx;
  135. font-family: Microsoft YaHei;
  136. font-weight: 400;
  137. color: #FFFFFF;
  138. line-height: 36rpx;
  139. }
  140. .content {
  141. padding: 30rpx;
  142. position: absolute;
  143. top: 30rpx;
  144. left: 30rpx;
  145. right: 30rpx;
  146. display: flex;
  147. justify-content: space-between;
  148. .bank {
  149. font-size: 28rpx;
  150. font-family: Microsoft YaHei;
  151. font-weight: 400;
  152. color: #FFFFFF;
  153. line-height: 28rpx;
  154. }
  155. .card {
  156. font-size: 24rpx;
  157. font-family: Microsoft YaHei;
  158. font-weight: 400;
  159. color: #FFFFFF;
  160. line-height: 24rpx;
  161. margin-top: 5rpx;
  162. }
  163. .button {
  164. height: 48rpx;
  165. line-height: 48rpx;
  166. border: 1px solid #FFFFFF;
  167. border-radius: 20rpx;
  168. color: #ffffff;
  169. font-size: 24rpx;
  170. text-align: center;
  171. padding: 0 20rpx;
  172. }
  173. }
  174. }
  175. </style>