templatePrice.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template name="cm-acttags">
  2. <!-- 楼层价格显示公共组件 -->
  3. <view>
  4. <template v-if="vipFlag == 1">
  5. <view class="title-none" v-if="goods.priceFlag === 1"> <text class="p big">¥未公开价格</text> </view>
  6. <view
  7. class="price tui-skeleton-rect"
  8. v-else
  9. :class="PromotionsFormat(goods.promotions) || goods.svipProductFlag == 1 ? 'none' : ''"
  10. >
  11. <text class="p sm">¥</text>
  12. <text class="p big">{{
  13. (PromotionsFormat(goods.promotions) ? goods.originalPrice : goods.price) | NumFormat
  14. }}</text>
  15. </view>
  16. </template>
  17. <template v-else>
  18. <!-- 供应商查看商品价格 -->
  19. <template v-if="userIdentity == 3">
  20. <template v-if="goods.shopId == shopId">
  21. <view class="title-none" v-if="goods.priceFlag === 1">
  22. <text class="p big">¥未公开价格</text>
  23. </view>
  24. <view
  25. class="price tui-skeleton-rect"
  26. v-else
  27. :class="PromotionsFormat(goods.promotions) || goods.svipProductFlag == 1 ? 'none' : ''"
  28. >
  29. <text class="p sm">¥</text>
  30. <text class="p big">{{
  31. (PromotionsFormat(goods.promotions) ? goods.originalPrice : goods.price) | NumFormat
  32. }}</text>
  33. </view>
  34. </template>
  35. <template v-else>
  36. <view class="no-price">
  37. <view class="p-stars">
  38. <text class="p-no">¥</text>
  39. <uni-grader :grade="Number(goods.priceGrade)" :margin="14"></uni-grader>
  40. </view>
  41. </view>
  42. </template>
  43. </template>
  44. <!-- 个人机构查看价格 -->
  45. <template v-else-if="userIdentity === 4">
  46. <view class="title-none" v-if="goods.priceFlag === 1"> <text class="p big">¥未公开价格</text> </view>
  47. <view class="title-none" v-if="goods.priceFlag === 2">
  48. <text class="p big">¥价格仅会员可见</text>
  49. </view>
  50. <view
  51. class="price tui-skeleton-rect"
  52. v-if="goods.priceFlag === 0"
  53. :class="PromotionsFormat(goods.promotions) || goods.svipProductFlag == 1 ? 'none' : ''"
  54. >
  55. <text class="p sm">¥</text>
  56. <text class="p big">{{
  57. (PromotionsFormat(goods.promotions) ? goods.originalPrice : goods.price) | NumFormat
  58. }}</text>
  59. </view>
  60. </template>
  61. <!-- 协销和会员机构查看价格 -->
  62. <template v-else>
  63. <view class="title-none" v-if="goods.priceFlag === 1"> <text class="p big">¥未公开价格</text> </view>
  64. <view
  65. class="price tui-skeleton-rect"
  66. v-else
  67. :class="PromotionsFormat(goods.promotions) || goods.svipProductFlag == 1 ? 'none' : ''"
  68. >
  69. <text class="p sm">¥</text>
  70. <text class="p big">{{
  71. (PromotionsFormat(goods.promotions) ? goods.originalPrice : goods.price) | NumFormat
  72. }}</text>
  73. </view>
  74. </template>
  75. </template>
  76. </view>
  77. </template>
  78. <script>
  79. import { mapState, mapMutations } from 'vuex'
  80. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  81. export default {
  82. name: 'cm-price',
  83. components: {
  84. uniGrader
  85. },
  86. props: {
  87. product: {
  88. type: Object
  89. }
  90. },
  91. data() {
  92. return {
  93. vipFlag: 0, // 是否是超级会员 0否 1是
  94. shopId: 0, // 是否是供应商
  95. userIdentity: 0, // 用户类型
  96. goods: {}
  97. }
  98. },
  99. filters: {
  100. NumFormat: function(text) {
  101. //处理金额
  102. return Number(text).toFixed(2)
  103. }
  104. },
  105. created() {
  106. this.initData(this.product)
  107. },
  108. computed: {
  109. ...mapState(['hasLogin', 'isWxAuthorize'])
  110. },
  111. watch: {
  112. pageData: {
  113. handler: function(el) {
  114. //监听对象的变换使用 function,箭头函数容易出现this指向不正确
  115. this.product = el
  116. this.initData(this.product)
  117. },
  118. deep: true
  119. }
  120. },
  121. methods: {
  122. async initData(data) {
  123. const userInfo = await this.$api.getStorage()
  124. this.shopId = userInfo.shopId ? userInfo.shopId : 0
  125. this.userIdentity = userInfo.userIdentity ? userInfo.userIdentity : 0
  126. this.vipFlag = userInfo.vipFlag ? userInfo.vipFlag : 0
  127. this.goods = data
  128. },
  129. isShowVipFlag(pros) {
  130. if (pros.priceFlag != 1) {
  131. if (this.userIdentity == 4 && this.vipFlag == 1) {
  132. return true
  133. } else if (this.userIdentity == 2) {
  134. return true
  135. }
  136. }
  137. },
  138. PromotionsFormat(promo) {
  139. //促销活动类型数据处理
  140. if (promo != null) {
  141. if (promo.type == 1 && promo.mode == 1) {
  142. return true
  143. } else {
  144. return false
  145. }
  146. }
  147. return false
  148. }
  149. }
  150. }
  151. </script>
  152. <style lang="scss">
  153. .price {
  154. color: #ff2a2a;
  155. line-height: 54rpx;
  156. &.none {
  157. text-decoration: line-through;
  158. color: #999999;
  159. }
  160. .sm {
  161. font-size: $font-size-24;
  162. }
  163. .big {
  164. font-size: $font-size-28;
  165. }
  166. }
  167. .title-none {
  168. font-size: $font-size-26;
  169. color: #ff2a2a;
  170. line-height: 54rpx;
  171. }
  172. </style>