templatePrice.vue 4.6 KB

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