cm-unit-price.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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(product.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(product.promotions) || product.svipProductFlag == 1 ? 'none' : ''"
  18. >
  19. ¥{{
  20. (PromotionsFormat(product.promotions) || product.svipProductFlag == 1
  21. ? product.originalPrice
  22. : product.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="product.priceFlag == 1">¥未公开价格</view>
  29. <view class="sku-price-text" v-else-if="product.priceFlag == 3 && firstClubType != 1"
  30. >¥仅医美机构可见</view
  31. >
  32. <view
  33. v-else
  34. class="sku-price-text"
  35. :class="PromotionsFormat(product.promotions) || product.svipProductFlag == 1 ? 'none' : ''"
  36. >
  37. ¥{{
  38. (PromotionsFormat(product.promotions) || product.svipProductFlag == 1
  39. ? product.originalPrice
  40. : product.price) | NumFormat
  41. }}
  42. </view>
  43. </template>
  44. <template v-else-if="userIdentity == 3">
  45. <!-- 供应商 -->
  46. <template v-if="product.shopId === shopID">
  47. <view class="sku-price-text" v-if="product.priceFlag == 1">¥未公开价格</view>
  48. <view
  49. v-else
  50. class="sku-price-text"
  51. :class="PromotionsFormat(product.promotions) || product.svipProductFlag == 1 ? 'none' : ''"
  52. >
  53. ¥{{
  54. (PromotionsFormat(product.promotions) || product.svipProductFlag == 1
  55. ? product.originalPrice
  56. : product.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(product.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="product.priceFlag == 1">¥未公开价格</text>
  70. <text class="sku-price-text" v-else-if="product.priceFlag == 2">¥价格仅会员可见</text>
  71. <text class="sku-price-text" v-else-if="product.priceFlag == 3">¥仅医美机构可见</text>
  72. <view
  73. v-else
  74. class="sku-price-text"
  75. :class="PromotionsFormat(product.promotions) || product.svipProductFlag == 1 ? 'none' : ''"
  76. >
  77. ¥{{
  78. (PromotionsFormat(product.promotions) || product.svipProductFlag == 1
  79. ? product.originalPrice
  80. : product.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="this.$parent.productCoupon.length > 0">优惠券</view>
  91. <template v-if="product.actStatus == 1">
  92. <view v-if="product.promotions.type == 1 && product.promotions.mode == 1" class="floor-tags">
  93. {{ product.promotions.name }}<text v-if="hasLogin">:¥{{ product.price | NumFormat }}</text>
  94. </view>
  95. <view v-else class="floor-tags">{{ product.promotions.name }}</view>
  96. </template>
  97. <template v-if="product.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="this.$parent.productCoupon.length > 0">优惠券</view>
  106. <template v-if="product.actStatus == 1">
  107. <view v-if="product.promotions.type == 1 && product.promotions.mode == 1" class="floor-tags">
  108. {{ product.promotions.name
  109. }}<text v-if="hasLogin"
  110. >:¥{{
  111. product.promotions == null ? '0.00' : product.promotions.touchPrice | NumFormat
  112. }}</text
  113. >
  114. </view>
  115. <view v-else class="floor-tags">{{ product.promotions.name }}</view>
  116. </template>
  117. <template v-if="product.svipProductFlag == 1">
  118. <view class="svip-tags">
  119. <view class="tags none">SVIP</view> <view class="price">{{ product.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="this.$parent.productCoupon.length > 0">优惠券</view>
  128. <template v-if="product.actStatus == 1">
  129. <view v-if="product.promotions.type == 1 && product.promotions.mode == 1" class="floor-tags">
  130. {{ product.promotions.name
  131. }}<text v-if="hasLogin && product.priceFlag != 1"
  132. >:¥{{
  133. product.promotions == null ? '0.00' : product.promotions.touchPrice | NumFormat
  134. }}</text
  135. >
  136. </view>
  137. <view v-else class="floor-tags">{{ product.promotions.name }}</view>
  138. </template>
  139. <template v-if="product.svipProductFlag == 1">
  140. <view class="svip-tags">
  141. <view class="tags" :class="{ none: !isShowVipFlag(product) }">SVIP</view>
  142. <view class="price" v-if="isShowVipFlag(product)">{{ product.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="this.$parent.productCoupon.length > 0">优惠券</view>
  151. <template v-if="product.actStatus == 1">
  152. <view v-if="product.promotions.type == 1 && product.promotions.mode == 1" class="floor-tags">
  153. {{ product.promotions.name
  154. }}<text v-if="hasLogin && product.priceFlag != 1"
  155. >:¥{{
  156. product.promotions == null ? '0.00' : product.promotions.touchPrice | NumFormat
  157. }}</text
  158. >
  159. </view>
  160. <view v-else class="floor-tags">{{ product.promotions.name }}</view>
  161. </template>
  162. <template v-if="product.svipProductFlag == 1">
  163. <view class="svip-tags">
  164. <view class="tags" :class="{ none: vipFlag != 1 }">SVIP</view>
  165. <view class="price" v-if="product.priceFlag != 1 && vipFlag == 1">{{
  166. product.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="this.$parent.productCoupon.length > 0">优惠券</view>
  176. <template v-if="product.actStatus == 1">
  177. <view v-if="PromotionsFormat(product.promotions)" class="floor-tags">
  178. {{ product.promotions.name
  179. }}<text v-if="hasLogin && product.priceFlag != 1"
  180. >:¥{{
  181. product.promotions == null ? '0.00' : product.promotions.touchPrice | NumFormat
  182. }}</text
  183. >
  184. </view>
  185. <view v-else class="floor-tags">{{ product.promotions.name }}</view>
  186. </template>
  187. <template v-if="product.svipProductFlag == 1">
  188. <view class="svip-tags">
  189. <view class="tags" :class="{ none: !isShowVipFlag(product) }">SVIP</view>
  190. <view class="price" v-if="isShowVipFlag(product)">{{ product.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. product: {
  208. type: Object
  209. }
  210. },
  211. data() {
  212. return {
  213. vipFlag: 0, // 是否是超级会员 0否 1是
  214. userIdentity: 2,
  215. shopID: 0,
  216. isIphoneX: this.$store.state.isIphoneX,
  217. firstClubType: 0
  218. }
  219. },
  220. filters: {
  221. NumFormat(value) {
  222. //处理金额
  223. return Number(value).toFixed(2)
  224. }
  225. },
  226. created() {
  227. this.initData()
  228. },
  229. computed: {
  230. ...mapState(['hasLogin', 'clubType'])
  231. },
  232. methods: {
  233. async initData(data) {
  234. const userInfo = await this.$api.getStorage()
  235. this.vipFlag = userInfo.vipFlag ? userInfo.vipFlag : 0
  236. this.userIdentity = userInfo.userIdentity ? userInfo.userIdentity : 0
  237. this.shopID = userInfo.shopId ? userInfo.shopId : 0
  238. this.firstClubType = this.clubType
  239. },
  240. PromotionsFormat(promo) {
  241. //促销活动类型数据处理
  242. if (promo != null) {
  243. if (promo.type == 1 && promo.mode == 1) {
  244. return true
  245. } else {
  246. return false
  247. }
  248. }
  249. return false
  250. },
  251. isShowVipFlag(pros) {
  252. /**
  253. *显示SVIP和超级会员价格:
  254. * 个人机构(不是超级会员,但价格所有机构可见),
  255. * 资质机构(不是超级会员,但价格所有机构可见或仅会员可见),
  256. * 超级会员(价格所有机构可见或仅会员可见),超级会员(是医美机构,价格仅医美可见)
  257. *商品价格是否可见:priceFlag 0:所有机构可见 1:未公开价格 2:仅会员可见 3:仅医美机构可见
  258. * 普通机构
  259. * 超级会员 && priceFlag === 0
  260. * 资质机构
  261. * priceFlag !== 1 ||
  262. * 超级会员
  263. * 商品priceFlag === 3 && 是否是医美机构
  264. */
  265. // 未登录 || 非会员
  266. if (!this.hasLogin || !this.vipFlag === 1) return false
  267. // 商品所有机构可见
  268. if (pros.priceFlag === 0) return true
  269. // 商品价格仅资质机构可见
  270. if (pros.priceFlag === 2 && this.userIdentity === 2) return true
  271. // 商品价格仅医美机构可见
  272. if (pros.priceFlag === 3 && this.userIdentity === 2 && this.firstClubType == 1) return true
  273. // 其它
  274. return false
  275. }
  276. }
  277. }
  278. </script>
  279. <style lang="scss">
  280. .sku-price-main {
  281. width: 100%;
  282. height: 100%;
  283. .sku-price-viw {
  284. width: 100%;
  285. height: 40rpx;
  286. margin-bottom: 24rpx;
  287. .sku-price-text {
  288. font-size: 28rpx;
  289. line-height: 40rpx;
  290. color: #f94b4b;
  291. font-weight: bold;
  292. .sku-price-l{
  293. float: left;
  294. font-weight: normal;
  295. }
  296. &.none {
  297. text-decoration: line-through;
  298. color: #999999;
  299. font-weight: normal;
  300. }
  301. }
  302. }
  303. .sku-price-vip {
  304. width: 100%;
  305. height: 40rpx;
  306. }
  307. }
  308. </style>