cm-unit-price.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template name="cm-price">
  2. <!-- 商品详情价格判断 -->
  3. <view class="sku-price-main">
  4. <view class="sku-price-viw">
  5. <!-- 价格等级和权限 -->
  6. <template v-if="!hasLogin">
  7. <!-- 游客 -->
  8. <view class="sku-price-text">
  9. <text class="sku-price-l">¥</text>
  10. <uni-grader :grade="Number(skuProduct.priceGrade)"></uni-grader>
  11. </view>
  12. </template>
  13. <template v-else-if="userIdentity == 1">
  14. <!-- 协销 -->
  15. <view
  16. class="sku-price-text"
  17. :class="PromotionsFormat(skuProduct.promotions) || skuProduct.svipProductFlag == 1 ? 'none' : ''"
  18. >
  19. ¥{{
  20. (PromotionsFormat(skuProduct.promotions) || skuProduct.svipProductFlag == 1
  21. ? skuProduct.originalPrice
  22. : skuProduct.price) | NumFormat
  23. }}
  24. </view>
  25. </template>
  26. <template v-else-if="userIdentity == 2 || (userIdentity == 4 && vipFlag == 1)">
  27. <!-- 资质机构 -->
  28. <view class="sku-price-text" v-if="skuProduct.priceFlag == 1">¥未公开价格</view>
  29. <view class="sku-price-text" v-else-if="skuProduct.priceFlag == 3 && firstClubType != 1"
  30. >¥仅医美机构可见</view
  31. >
  32. <view
  33. v-else
  34. class="sku-price-text"
  35. :class="PromotionsFormat(skuProduct.promotions) || skuProduct.svipProductFlag == 1 ? 'none' : ''"
  36. >
  37. ¥{{
  38. (PromotionsFormat(skuProduct.promotions) || skuProduct.svipProductFlag == 1
  39. ? skuProduct.originalPrice
  40. : skuProduct.price) | NumFormat
  41. }}
  42. </view>
  43. </template>
  44. <template v-else-if="userIdentity == 3">
  45. <!-- 供应商 -->
  46. <template v-if="skuProduct.shopId === shopID">
  47. <view class="sku-price-text" v-if="skuProduct.priceFlag == 1">¥未公开价格</view>
  48. <view
  49. v-else
  50. class="sku-price-text"
  51. :class="PromotionsFormat(skuProduct.promotions) || skuProduct.svipProductFlag == 1 ? 'none' : ''"
  52. >
  53. ¥{{
  54. (PromotionsFormat(skuProduct.promotions) || skuProduct.svipProductFlag == 1
  55. ? skuProduct.originalPrice
  56. : skuProduct.price) | NumFormat
  57. }}
  58. </view>
  59. </template>
  60. <template v-else>
  61. <view class="sku-price-text">
  62. <text class="sku-price-l">¥</text>
  63. <uni-grader :grade="Number(skuProduct.priceGrade)"></uni-grader>
  64. </view>
  65. </template>
  66. </template>
  67. <template v-else-if="userIdentity == 4 && vipFlag != 1">
  68. <!-- 普通机构 -->
  69. <text class="sku-price-text" v-if="skuProduct.priceFlag == 1">¥未公开价格</text>
  70. <text class="sku-price-text" v-else-if="skuProduct.priceFlag == 2">¥价格仅会员可见</text>
  71. <text class="sku-price-text" v-else-if="skuProduct.priceFlag == 3">¥仅医美机构可见</text>
  72. <view
  73. v-else
  74. class="sku-price-text"
  75. :class="PromotionsFormat(skuProduct.promotions) || skuProduct.svipProductFlag == 1 ? 'none' : ''"
  76. >
  77. ¥{{
  78. (PromotionsFormat(skuProduct.promotions) || skuProduct.svipProductFlag == 1
  79. ? skuProduct.originalPrice
  80. : skuProduct.price) | NumFormat
  81. }}
  82. </view>
  83. </template>
  84. </view>
  85. <view class="sku-price-vip">
  86. <!-- 优惠券和超级会员标记 -->
  87. <template v-if="!hasLogin">
  88. <!-- 游客 -->
  89. <view class="floor-item-act">
  90. <view class="coupon-tags" v-if="productCoupon.length > 0">优惠券</view>
  91. <template v-if="skuProduct.actStatus == 1">
  92. <view v-if="skuProduct.promotions.type == 1 && skuProduct.promotions.mode == 1" class="floor-tags">
  93. {{ skuProduct.promotions.name }}<text v-if="hasLogin">:¥{{ skuProduct.price | NumFormat }}</text>
  94. </view>
  95. <view v-else class="floor-tags">{{ skuProduct.promotions.name }}</view>
  96. </template>
  97. <template v-if="skuProduct.svipProductFlag == 1">
  98. <view class="svip-tags"> <view class="tags none">SVIP</view> </view>
  99. </template>
  100. </view>
  101. </template>
  102. <template v-else-if="userIdentity == 1">
  103. <!-- 协销 -->
  104. <view class="floor-item-act">
  105. <view class="coupon-tags" v-if="productCoupon.length > 0">优惠券</view>
  106. <template v-if="skuProduct.actStatus == 1">
  107. <view v-if="skuProduct.promotions.type == 1 && skuProduct.promotions.mode == 1" class="floor-tags">
  108. {{ skuProduct.promotions.name
  109. }}<text v-if="hasLogin"
  110. >:¥{{
  111. skuProduct.promotions == null ? '0.00' : skuProduct.price | NumFormat
  112. }}</text
  113. >
  114. </view>
  115. <view v-else class="floor-tags">{{ skuProduct.promotions.name }}</view>
  116. </template>
  117. <template v-if="skuProduct.svipProductFlag == 1">
  118. <view class="svip-tags">
  119. <view class="tags none">SVIP</view> <view class="price">{{ skuProduct.svipPriceTag }}</view>
  120. </view>
  121. </template>
  122. </view>
  123. </template>
  124. <template v-else-if="userIdentity == 2 || (userIdentity == 4 && vipFlag == 1)">
  125. <!-- 资质机构 -->
  126. <view class="floor-item-act">
  127. <view class="coupon-tags" v-if="productCoupon.length > 0">优惠券</view>
  128. <template v-if="skuProduct.actStatus == 1">
  129. <view v-if="skuProduct.promotions.type == 1 && skuProduct.promotions.mode == 1" class="floor-tags">
  130. {{ skuProduct.promotions.name
  131. }}<text v-if="hasLogin && skuProduct.priceFlag != 1"
  132. >:¥{{
  133. skuProduct.promotions == null ? '0.00' : skuProduct.price | NumFormat
  134. }}</text
  135. >
  136. </view>
  137. <view v-else class="floor-tags">{{ skuProduct.promotions.name }}</view>
  138. </template>
  139. <template v-if="skuProduct.svipProductFlag == 1">
  140. <view class="svip-tags">
  141. <view class="tags" :class="{ none: !isShowVipFlag(skuProduct) }">SVIP</view>
  142. <view class="price" v-if="isShowVipFlag(skuProduct)">{{ skuProduct.svipPriceTag }}</view>
  143. </view>
  144. </template>
  145. </view>
  146. </template>
  147. <template v-else-if="userIdentity == 3">
  148. <!-- 供应商 -->
  149. <view class="floor-item-act">
  150. <view class="coupon-tags" v-if="productCoupon.length > 0">优惠券</view>
  151. <template v-if="skuProduct.actStatus == 1">
  152. <view v-if="skuProduct.promotions.type == 1 && skuProduct.promotions.mode == 1" class="floor-tags">
  153. {{ skuProduct.promotions.name
  154. }}<text v-if="hasLogin && skuProduct.priceFlag != 1"
  155. >:¥{{
  156. skuProduct.promotions == null ? '0.00' : skuProduct.price | NumFormat
  157. }}</text
  158. >
  159. </view>
  160. <view v-else class="floor-tags">{{ skuProduct.promotions.name }}</view>
  161. </template>
  162. <template v-if="skuProduct.svipProductFlag == 1">
  163. <view class="svip-tags">
  164. <view class="tags" :class="{ none: vipFlag != 1 }">SVIP</view>
  165. <view class="price" v-if="skuProduct.priceFlag != 1 && vipFlag == 1">{{
  166. skuProduct.svipPriceTag
  167. }}</view>
  168. </view>
  169. </template>
  170. </view>
  171. </template>
  172. <template v-else-if="userIdentity == 4 && vipFlag != 1">
  173. <!-- 普通机构 -->
  174. <view class="floor-item-act">
  175. <view class="coupon-tags" v-if="productCoupon.length > 0">优惠券</view>
  176. <template v-if="skuProduct.actStatus == 1">
  177. <view v-if="PromotionsFormat(skuProduct.promotions)" class="floor-tags">
  178. {{ skuProduct.promotions.name
  179. }}<text v-if="hasLogin && skuProduct.priceFlag != 1"
  180. >:¥{{
  181. skuProduct.promotions == null ? '0.00' : skuProduct.price | NumFormat
  182. }}</text
  183. >
  184. </view>
  185. <view v-else class="floor-tags">{{ skuProduct.promotions.name }}</view>
  186. </template>
  187. <template v-if="skuProduct.svipProductFlag == 1">
  188. <view class="svip-tags">
  189. <view class="tags" :class="{ none: !isShowVipFlag(skuProduct) }">SVIP</view>
  190. <view class="price" v-if="isShowVipFlag(product)">{{ skuProduct.svipPriceTag }}</view>
  191. </view>
  192. </template>
  193. </view>
  194. </template>
  195. </view>
  196. </view>
  197. </template>
  198. <script>
  199. import { mapState, mapMutations } from 'vuex'
  200. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  201. export default {
  202. name: 'cm-unit-price',
  203. components: {
  204. uniGrader
  205. },
  206. props: {
  207. skuProduct: {
  208. type: Object,
  209. default: {}
  210. },
  211. productCoupon: {
  212. type: Array,
  213. default: []
  214. }
  215. },
  216. data() {
  217. return {
  218. vipFlag: 0, // 是否是超级会员 0否 1是
  219. userIdentity: 2,
  220. shopID: 0,
  221. isIphoneX: this.$store.state.isIphoneX,
  222. firstClubType: 0
  223. }
  224. },
  225. filters: {
  226. NumFormat(value) {
  227. //处理金额
  228. return Number(value).toFixed(2)
  229. }
  230. },
  231. created() {
  232. this.initData()
  233. },
  234. computed: {
  235. ...mapState(['hasLogin', 'clubType'])
  236. },
  237. methods: {
  238. async initData(data) {
  239. const userInfo = await this.$api.getStorage()
  240. this.vipFlag = userInfo.vipFlag ? userInfo.vipFlag : 0
  241. this.userIdentity = userInfo.userIdentity ? userInfo.userIdentity : 0
  242. this.shopID = userInfo.shopId ? userInfo.shopId : 0
  243. this.firstClubType = this.clubType
  244. },
  245. PromotionsFormat(promo) {
  246. //促销活动类型数据处理
  247. if (promo != null) {
  248. if (promo.type == 1 && promo.mode == 1) {
  249. return true
  250. } else {
  251. return false
  252. }
  253. }
  254. return false
  255. },
  256. isShowVipFlag(pros) {
  257. /**
  258. *显示SVIP和超级会员价格:
  259. * 个人机构(不是超级会员,但价格所有机构可见),
  260. * 资质机构(不是超级会员,但价格所有机构可见或仅会员可见),
  261. * 超级会员(价格所有机构可见或仅会员可见),超级会员(是医美机构,价格仅医美可见)
  262. *商品价格是否可见:priceFlag 0:所有机构可见 1:未公开价格 2:仅会员可见 3:仅医美机构可见
  263. * 普通机构
  264. * 超级会员 && priceFlag === 0
  265. * 资质机构
  266. * priceFlag !== 1 ||
  267. * 超级会员
  268. * 商品priceFlag === 3 && 是否是医美机构
  269. */
  270. // 未登录 || 非会员
  271. if (!this.hasLogin || !this.vipFlag === 1) return false
  272. // 商品所有机构可见
  273. if (pros.priceFlag === 0) return true
  274. // 商品价格仅资质机构可见
  275. if (pros.priceFlag === 2 && this.userIdentity === 2) return true
  276. // 商品价格仅医美机构可见
  277. if (pros.priceFlag === 3 && this.userIdentity === 2 && this.firstClubType == 1) return true
  278. // 其它
  279. return false
  280. }
  281. }
  282. }
  283. </script>
  284. <style lang="scss">
  285. .sku-price-main {
  286. width: 100%;
  287. height: 100%;
  288. .sku-price-viw {
  289. width: 100%;
  290. height: 40rpx;
  291. margin-bottom: 24rpx;
  292. .sku-price-text {
  293. font-size: 28rpx;
  294. line-height: 40rpx;
  295. color: #f94b4b;
  296. font-weight: bold;
  297. .sku-price-l{
  298. float: left;
  299. font-weight: normal;
  300. }
  301. &.none {
  302. text-decoration: line-through;
  303. color: #999999;
  304. font-weight: normal;
  305. }
  306. }
  307. }
  308. .sku-price-vip {
  309. width: 100%;
  310. height: 40rpx;
  311. }
  312. }
  313. </style>