app-account-balance.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view class="app-account-balance dir-left-nowrap cross-center"
  3. :class="[!margin?'no-margin':'', !round?'no-round':'',]" v-if="showBar">
  4. <template v-if="showIntegral">
  5. <view class="box-grow-1 split" :class="[showCount > 1?'':'data-col']">
  6. <app-account-style :show-count="showCount" :icon="userCenter.account_bar.integral.icon"
  7. :text="userCenter.account_bar.integral.text"
  8. :value="userInfo?userInfo.integral:'-'"
  9. :page="userCenter.account_bar.integral.navigate_enabled?'/plugins/integral_mall/index/index':''"></app-account-style>
  10. </view>
  11. </template>
  12. <template v-if="showBalance">
  13. <view class="box-grow-1 split" :class="[showCount > 1?'':'data-col']">
  14. <app-account-style :show-count="showCount" :icon="userCenter.account_bar.balance.icon"
  15. :text="userCenter.account_bar.balance.text"
  16. :value="userInfo?userInfo.balance:'-'"
  17. page="/pages/balance/balance"></app-account-style>
  18. </view>
  19. </template>
  20. <template v-if="showCoupon">
  21. <view class="box-grow-1 split" :class="[showCount > 1?'':'data-col']">
  22. <app-account-style :show-count="showCount" :icon="userCenter.account_bar.coupon.icon"
  23. :text="userCenter.account_bar.coupon.text"
  24. :value="userInfo?userInfo.coupon:'-'"
  25. page="/pages/coupon/index/index"></app-account-style>
  26. </view>
  27. </template>
  28. <template v-if="showCard">
  29. <view class="box-grow-1 split" :class="[showCount > 1?'':'data-col']">
  30. <app-account-style :show-count="showCount" :icon="userCenter.account_bar.card.icon"
  31. :text="userCenter.account_bar.card.text"
  32. :value="userInfo?userInfo.card:'-'"
  33. page="/pages/card/index/index"></app-account-style>
  34. </view>
  35. </template>
  36. </view>
  37. </template>
  38. <script>
  39. import {mapState} from 'vuex';
  40. import appAccountStyle from "./app-account-style.vue";
  41. export default {
  42. name: 'app-account-balance',
  43. components: {
  44. 'app-account-style': appAccountStyle,
  45. },
  46. props: {
  47. margin: {
  48. type: Boolean,
  49. default: false,
  50. },
  51. round: {
  52. type: Boolean,
  53. default: false,
  54. },
  55. inputUserCenter: null,
  56. },
  57. computed: {
  58. ...mapState({
  59. userInfo: state => state.user.info,
  60. storeUserCenter: state => state.mallConfig.user_center,
  61. }),
  62. showBar() {
  63. if (this.userCenter
  64. && this.userCenter.account_bar
  65. && this.userCenter.account_bar.status == 0
  66. ) return false;
  67. return this.showBalance || this.showIntegral;
  68. },
  69. userCenter() {
  70. if (this.inputUserCenter) return this.inputUserCenter;
  71. return this.storeUserCenter;
  72. },
  73. showIntegral() {
  74. if (!this.userCenter) return false;
  75. if (this.userCenter.account_bar && this.userCenter.account_bar.integral.status == 1) return true;
  76. return false;
  77. },
  78. showBalance() {
  79. if (!this.userCenter) return false;
  80. if (this.userCenter.recharge_setting
  81. && this.userCenter.recharge_setting.status == 1
  82. && this.userCenter.account_bar
  83. && this.userCenter.account_bar.balance.status == 1
  84. ) return true;
  85. return false;
  86. },
  87. showCoupon() {
  88. if (!this.userCenter) return false;
  89. if (this.userCenter.account_bar && this.userCenter.account_bar.coupon.status == 1) return true;
  90. return false;
  91. },
  92. showCard() {
  93. if (!this.userCenter) return false;
  94. if (this.userCenter.account_bar && this.userCenter.account_bar.card.status == 1) return true;
  95. return false;
  96. },
  97. showCount() {
  98. let count = 0;
  99. if (this.showIntegral) {
  100. count++;
  101. }
  102. if (this.showBalance) {
  103. count++;
  104. }
  105. if (this.showCoupon) {
  106. count++;
  107. }
  108. if (this.showCard) {
  109. count++;
  110. }
  111. return count;
  112. }
  113. }
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. .app-account-balance.no-margin {
  118. width: 100%;
  119. margin: 0 auto;
  120. box-shadow: none;
  121. }
  122. .app-account-balance.no-round {
  123. border-radius: 0;
  124. }
  125. .app-account-balance {
  126. width: #{702rpx};
  127. height: #{100rpx};
  128. background: #fff;
  129. border-radius: #{16rpx};
  130. margin: #{24rpx} auto;
  131. box-shadow: 0 0 #{8rpx} rgba(0, 0, 0, .05);
  132. }
  133. .data-col {
  134. width: 100%;
  135. padding: 0 #{32rpx};
  136. }
  137. .split {
  138. border-left: #{1rpx #eeeeee solid};
  139. &:first-child {
  140. border: none;
  141. }
  142. }
  143. </style>