templatePrice.vue 4.7 KB

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