app-vip-card.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view v-if="vip_card.permission == 1" v-bind:style="vipBoxStyle">
  3. <view v-if="!userInfo.is_vip_card_user" class="app-vip-card cross-center dir-left-nowrap" v-bind:style="noVipStyle">
  4. <image class="app-vip-logo" v-bind:src="svipImg.logo"></image>
  5. <view>
  6. <view class="buy-big-text" v-bind:style="[{'color': `${vip_card.setting.form.buy_big_color}`}]">{{vip_card.setting.form.buy_big}}</view>
  7. <view class="buy-small-text" v-bind:style="[{'color': `${vip_card.setting.form.buy_small_color}`}]">{{vip_card.setting.form.buy_small}}</view>
  8. </view>
  9. <view @click="router" class="app-vip-btn" v-bind:style="[{'color': `${vip_card.setting.form.buy_btn_color}`,'background':`${vip_card.setting.form.buy_btn_bg_color}`}]">{{vip_card.setting.form.buy_btn_text}}</view>
  10. </view>
  11. <view v-else-if="userInfo.is_vip_card_user" class="app-vip-card cross-center dir-left-nowrap" v-bind:style="isVipStyle">
  12. <image class="app-vip-logo" v-bind:src="svipImg.logo"></image>
  13. <view>
  14. <view class="buy-big-text" v-bind:style="[{'color': `${vip_card.setting.form.renew_text_color}`}]">{{vip_card.setting.form.renew_text}}</view>
  15. </view>
  16. <view @click="router" class="app-vip-btn app-renew-btn cross-center main-center" v-bind:style="[{'background':`${vip_card.setting.form.renew_btn_bg_color}`}]">
  17. <text>详情</text>
  18. <image class="right-icon" src="/static/image/icon/right.png"></image>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import { mapState } from 'vuex';
  25. export default {
  26. name: 'app-vip-card',
  27. data() {
  28. return {
  29. vip_card: {
  30. setting: {
  31. form: {}
  32. }
  33. }
  34. }
  35. },
  36. props: {
  37. background: {
  38. type: String,
  39. default() {
  40. return `#f7f7f7`;
  41. }
  42. },
  43. top: {
  44. type: String,
  45. default() {
  46. return `20rpx`;
  47. }
  48. },
  49. value: {
  50. type: Object
  51. }
  52. },
  53. computed: {
  54. ...mapState({
  55. userInfo: function(state) {
  56. return state.user.info;
  57. },
  58. svipImg: function(state) {
  59. return state.mallConfig.__wxapp_img.vip_card
  60. }
  61. }),
  62. vipBoxStyle: function() {
  63. return this.value ? `background-color: ${this.vip_card.setting.form.background};
  64. height:${this.vip_card.setting.form.top_bottom_padding*2 + 120 + 'rpx'};
  65. padding: ${this.vip_card.setting.form.top_bottom_padding + 'rpx 0'}` : '';
  66. },
  67. noVipStyle: function() {
  68. let buy_bg = this.vip_card.setting.form.buy_bg;
  69. return `background-image: url(${buy_bg !== 'statics/img/app/vip_card/buy_bg.png' ? buy_bg : this.svipImg.buy_bg});
  70. background-color: ${this.background};
  71. margin-top: ${this.top}`;
  72. },
  73. isVipStyle: function() {
  74. let renew_bg = this.vip_card.setting.form.renew_bg;
  75. return `background-image: url(${ renew_bg !== 'statics/img/app/vip_card/buy_bg.png' ? renew_bg : this.svipImg.buy_bg});
  76. background-color: ${this.background};
  77. margin-top: ${this.top}`;
  78. }
  79. },
  80. created() {
  81. this.getConfig();
  82. },
  83. methods: {
  84. router() {
  85. uni.navigateTo({
  86. url: '/plugins/vip_card/index/index'
  87. });
  88. },
  89. async getConfig() {
  90. const res = await this.$request({
  91. url: this.$api.index.config
  92. });
  93. if (res.code === 0) {
  94. this.vip_card = Object.assign(this.vip_card,res.data.plugin.vip_card);
  95. if(this.value) {
  96. this.vip_card.setting.form = this.value;
  97. }
  98. } else {
  99. uni.showToast({
  100. title: res.msg,
  101. icon: 'none'
  102. })
  103. }
  104. }
  105. }
  106. }
  107. </script>
  108. <style scoped lang="scss">
  109. .app-vip-card {
  110. height: #{120rpx};
  111. width: 100%;
  112. position: relative;
  113. background-size: 100% 100%;
  114. background-repeat:no-repeat;
  115. background-position: center bottom;
  116. }
  117. .app-vip-btn.app-renew-btn {
  118. width: #{89rpx};
  119. height: #{35rpx};
  120. line-height: #{35rpx};
  121. border-radius: #{18rpx};
  122. top: #{42.5rpx};
  123. }
  124. .app-vip-logo {
  125. height: #{54rpx};
  126. width: #{60rpx};
  127. margin: 0 #{30rpx} 0 #{25rpx};
  128. }
  129. .buy-big-text {
  130. font-size: #{28rpx};
  131. margin-bottom: #{4rpx};
  132. }
  133. .buy-small-text {
  134. font-size: #{22rpx};
  135. }
  136. .app-vip-btn {
  137. position: absolute;
  138. right: #{45rpx};
  139. top: #{36rpx};
  140. font-size: #{25rpx};
  141. width: #{140rpx};
  142. height: #{48rpx};
  143. line-height: #{48rpx};
  144. text-align: center;
  145. border-radius: #{24rpx};
  146. background: -webkit-linear-gradient(left, #fbdec7, #f3bf95);
  147. background: -o-linear-gradient(left, #fbdec7, #f3bf95);
  148. background: linear-gradient(to right, #fbdec7, #f3bf95);
  149. }
  150. .right-icon {
  151. height: #{22rpx};
  152. width: #{12rpx};
  153. margin-left: #{8rpx};
  154. }
  155. </style>