bankCardList.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view class="container">
  3. <navbar :config="config" backColor="#666666"></navbar>
  4. <view class="u-plr30">
  5. <view class="bank-list" v-if="bankCardList.length > 0">
  6. <view class="item u-flex-center-sb" v-for="(item,index) in bankCardList" :key="item.id">
  7. <view class="bank u-flex" @click="cardLink(item)">
  8. <image :src="item.icon"></image>
  9. <view class="ml90 u-font28">
  10. <view class="u-1A1A1A">{{item.bank_name}}</view>
  11. <view class="u-999 u-mt5 u-flex">尾号<rich-text :nodes="$mUtil.cutOut(item.card_num)" ></rich-text>储蓄卡</view>
  12. </view>
  13. </view>
  14. <view class="unbind u-EC6044 u-font24" @click="del(item.id)">解绑</view>
  15. <view class="addcommodity" v-if="item.is_default" @click="onFlag(item)">
  16. <icon type="success" color="#ff0000" size="17"></icon>
  17. </view>
  18. <view class="addcommodity" @click="onFlag(item)" v-else style=" width: 30rpx; height: 30rpx; border-radius: 50%;border: 1rpx solid #333;">
  19. </view>
  20. </view>
  21. </view>
  22. <!-- 没有数据 -->
  23. <view class="nogoods u-mt30 u-flex-column-center" v-if="bankCardList.length==0">
  24. <nodata :config="{top:5,content:'您还没有添加银行卡~'}"></nodata>
  25. </view>
  26. <view class="mt212" @click="goAddBankCard">
  27. <button class="u-btn">添加银行卡</button>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. config: {
  37. back: true, //false是tolbar页面 是则不写
  38. title: '银行卡',
  39. color: '#1A1A1A',
  40. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  41. backgroundColor: [1, "#FFFFFF"],
  42. statusBarFontColor: '#1A1A1A'
  43. },
  44. bankCardList:[],//银行卡列表
  45. flag:false
  46. }
  47. },
  48. onLoad() {
  49. },
  50. onShow() {
  51. let that = this;
  52. that.getBankCardList()
  53. },
  54. methods: {
  55. // 协议
  56. cardLink(item){
  57. var item = JSON.stringify(item);
  58. uni.navigateTo({
  59. url:`addBankCard?item=${encodeURIComponent(item)}`
  60. })
  61. },
  62. //获取银行卡列表
  63. async getBankCardList(){
  64. let that = this
  65. this.$http.get('/member/bankcard/bankCardList',{}).then(async res => {
  66. if(res.code ==200){
  67. that.bankCardList = res.list
  68. }
  69. })
  70. },
  71. //添加银行卡
  72. goAddBankCard(){
  73. uni.navigateTo({
  74. url:"addBankCard"
  75. })
  76. },
  77. // 协议
  78. onFlag(item){
  79. let that = this
  80. uni.showModal({
  81. title:"是否选择为默认银行卡",
  82. success:function(res){
  83. if(res.confirm){
  84. that.$http.post("/member/bankcard/setDefaultBankCard/"+item.id,).then(res=>{
  85. if(res&&res.code==200){
  86. that.getBankCardList()
  87. that.$mUtil.toast("更换成功")
  88. }
  89. })
  90. }else if(res.cancel){
  91. that.$mUtil.toast("取消成功")
  92. }
  93. }
  94. })
  95. },
  96. //删除
  97. del(id){
  98. let that = this
  99. uni.showModal({
  100. title: '是否解绑该银行卡',
  101. success: function (res) {
  102. if (res.confirm) {
  103. that.$http.delete('/member/bankcard/delete/'+id,)
  104. .then(async res => {
  105. if(res.code==200){
  106. uni.showToast({
  107. title:"解绑成功",
  108. icon:"none",
  109. duration:3000,
  110. success() {
  111. that.getBankCardList()
  112. }
  113. })
  114. }
  115. })
  116. } else if (res.cancel) {
  117. }
  118. }
  119. });
  120. },
  121. }
  122. }
  123. </script>
  124. <style lang="scss">
  125. page{
  126. background-color: #F5F5F5;
  127. }
  128. .item{
  129. background-color: #FFFFFF;
  130. border-radius: 18rpx;
  131. padding: 46rpx 38rpx 48rpx;
  132. margin-top: 30rpx;
  133. .bank{
  134. image{
  135. width: 72rpx;
  136. height: 72rpx;
  137. }
  138. }
  139. .unbind{
  140. border: 1rpx solid #D65A5A;
  141. padding: 5rpx 16rpx;
  142. border-radius: 20rpx;
  143. }
  144. }
  145. .mt212{
  146. margin: 0 auto;
  147. margin-top: 212rpx;
  148. padding-bottom: 40rpx;
  149. display: flex;
  150. justify-content: center;
  151. }
  152. .ml90{
  153. margin-left: 90rpx;
  154. }
  155. </style>