templatePrice.vue 5.5 KB

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