cm-price.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. <template name="cm-price">
  2. <!-- 商品详情价格判断 -->
  3. <view class="wrap-main">
  4. <template v-if="!hasLogin">
  5. <view class="p-login grade tui-skeleton-fillet">
  6. <text class="p-no">¥</text>
  7. <uni-grader :grade="Number(product.priceGrade)"></uni-grader>
  8. <view class="floor-item-act">
  9. <template v-if="product.actStatus == 1" >
  10. <view
  11. v-if="product.promotions.type == 1 && product.promotions.mode == 1"
  12. class="floor-tags"
  13. @click.stop="clickPopupShow()"
  14. >
  15. {{ product.promotions.name }}<text v-if="hasLogin">:¥{{ product.price | NumFormat }}</text>
  16. </view>
  17. <view v-else class="floor-tags" @click.stop="clickPopupShow()">{{ product.promotions.name }}</view>
  18. </template>
  19. <template v-if="product.svipProductFlag == 1">
  20. <view class="svip-tags">
  21. <view class="tags none">SVIP</view>
  22. </view>
  23. </template>
  24. </view>
  25. <view class="floor-item-btn"> <view class="btn" @click.stop="loginClick">登录查看价格</view> </view>
  26. </view>
  27. </template>
  28. <template v-else>
  29. <!-- 协销 -->
  30. <template v-if="userIdentity == 1">
  31. <view class="wrap-main-item">
  32. <view
  33. class="p-price tui-skeleton-fillet"
  34. :class="(PromotionsFormat(product.promotions) || product.svipProductFlag == 1) ? 'none' : ''"
  35. >
  36. <text class="txt sm">¥</text>
  37. <text class="txt big">{{
  38. ((PromotionsFormat(product.promotions) || product.svipProductFlag == 1) ? product.originalPrice : product.price) | NumFormat
  39. }}</text>
  40. </view>
  41. <view class="floor-item-act">
  42. <template v-if="product.actStatus == 1" >
  43. <view
  44. v-if="product.promotions.type == 1 && product.promotions.mode == 1"
  45. class="floor-tags"
  46. @click.stop="clickPopupShow(1)"
  47. >
  48. {{ product.promotions.name
  49. }}<text v-if="hasLogin"
  50. >:¥{{
  51. product.promotions == null ? '0.00' : product.promotions.touchPrice | NumFormat
  52. }}</text
  53. >
  54. </view>
  55. <view v-else class="floor-tags" @click.stop="clickPopupShow()">{{
  56. product.promotions.name
  57. }}</view>
  58. </template>
  59. <template v-if="product.svipProductFlag == 1">
  60. <view class="svip-tags">
  61. <view class="tags none">SVIP</view>
  62. <view class="price">{{ product.svipPriceTag }}</view>
  63. </view>
  64. </template>
  65. </view>
  66. </view>
  67. </template>
  68. <!-- 资质机构 -->
  69. <template v-if="userIdentity == 2 || (userIdentity == 4 && vipFlag == 1)">
  70. <view class="wrap-main-item">
  71. <view v-if="product.priceFlag == 1" class="wrap-main-text">¥未公开价格</view>
  72. <view v-else-if="product.priceFlag == 3 && (firstClubType!=1)" class="wrap-main-text">¥仅医美机构可见</view>
  73. <view
  74. v-else
  75. class="p-price tui-skeleton-fillet"
  76. :class="( PromotionsFormat(product.promotions) || product.svipProductFlag == 1 )? 'none' : ''"
  77. >
  78. <text class="txt sm">¥</text>
  79. <text class="txt big">{{
  80. ((PromotionsFormat(product.promotions) || product.svipProductFlag == 1) ? product.originalPrice : product.price) | NumFormat
  81. }}</text>
  82. </view>
  83. <view class="floor-item-act">
  84. <template v-if="product.actStatus == 1" >
  85. <view
  86. v-if="product.promotions.type == 1 && product.promotions.mode == 1"
  87. class="floor-tags"
  88. @click.stop="clickPopupShow(1)"
  89. >
  90. {{ product.promotions.name
  91. }}<text v-if="hasLogin && product.priceFlag != 1"
  92. >:¥{{
  93. product.promotions == null ? '0.00' : product.promotions.touchPrice | NumFormat
  94. }}</text
  95. >
  96. </view>
  97. <view v-else class="floor-tags" @click.stop="clickPopupShow()">{{
  98. product.promotions.name
  99. }}</view>
  100. </template>
  101. <template v-if="product.svipProductFlag == 1">
  102. <view class="svip-tags">
  103. <view class="tags" :class="{ none: !isShowVipFlag(product) }">SVIP</view>
  104. <view class="price" v-if="isShowVipFlag(product)">{{ product.svipPriceTag }}</view>
  105. </view>
  106. </template>
  107. </view>
  108. </view>
  109. </template>
  110. <!-- 供应商 -->
  111. <template v-if="userIdentity == 3">
  112. <template v-if="product.shopId === shopID">
  113. <view class="wrap-main-item">
  114. <view v-if="product.priceFlag == 1" class="wrap-main-text">¥未公开价格</view>
  115. <view
  116. v-else
  117. class="p-price tui-skeleton-fillet"
  118. :class="(PromotionsFormat(product.promotions) || product.svipProductFlag == 1)? 'none' : ''"
  119. >
  120. <text class="txt sm">¥</text>
  121. <text class="txt big">{{
  122. ((PromotionsFormat(product.promotions) || product.svipProductFlag == 1 )? product.originalPrice : product.price)
  123. | NumFormat
  124. }}</text>
  125. </view>
  126. <view class="floor-item-act">
  127. <template v-if="product.actStatus == 1" >
  128. <view
  129. v-if="product.promotions.type == 1 && product.promotions.mode == 1"
  130. class="floor-tags"
  131. @click.stop="clickPopupShow(1)"
  132. >
  133. {{ product.promotions.name
  134. }}<text v-if="hasLogin && product.priceFlag != 1"
  135. >:¥{{
  136. product.promotions == null ? '0.00' : product.promotions.touchPrice | NumFormat
  137. }}</text
  138. >
  139. </view>
  140. <view v-else class="floor-tags" @click.stop="clickPopupShow()">{{
  141. product.promotions.name
  142. }}</view>
  143. </template>
  144. <template v-if="product.svipProductFlag == 1">
  145. <view class="svip-tags">
  146. <view class="tags" :class="{ none: vipFlag != 1 }">SVIP</view>
  147. <view class="price" v-if="product.priceFlag != 1 && vipFlag == 1">{{ product.svipPriceTag }}</view>
  148. </view>
  149. </template>
  150. </view>
  151. </view>
  152. </template>
  153. <template v-else>
  154. <view class="p-login grade tui-skeleton-fillet">
  155. <text class="p-no">¥</text>
  156. <uni-grader :grade="Number(product.priceGrade)"></uni-grader>
  157. </view>
  158. </template>
  159. </template>
  160. <!-- 个人机构 -->
  161. <template v-if="userIdentity == 4 && vipFlag !=1">
  162. <template v-if="product.priceFlag == 1">
  163. <text class="wrap-main-text">¥未公开价格</text>
  164. </template>
  165. <template v-else-if="product.priceFlag == 2">
  166. <text class="wrap-main-text">¥价格仅会员可见</text>
  167. <view class="floor-item-btn">
  168. <view class="btn" @click.stop="goUpgradeApply">升级会员查看价格</view>
  169. </view>
  170. </template>
  171. <template v-else-if="product.priceFlag == 3">
  172. <text class="wrap-main-text">¥仅医美机构可见</text>
  173. <view class="floor-item-btn">
  174. <view class="btn" @click.stop="goUpgradeApply">成为医美机构查看价格</view>
  175. </view>
  176. </template>
  177. <template v-else>
  178. <view class="wrap-main-item">
  179. <view
  180. class="p-price tui-skeleton-fillet"
  181. :class="(PromotionsFormat(product.promotions) || product.svipProductFlag == 1 )? 'none' : ''"
  182. >
  183. <text class="txt sm">¥</text>
  184. <text class="txt big">{{
  185. ((PromotionsFormat(product.promotions) || product.svipProductFlag == 1) ? product.originalPrice : product.price) | NumFormat
  186. }}</text>
  187. </view>
  188. <view class="floor-item-act">
  189. <template v-if="product.actStatus == 1" >
  190. <view
  191. v-if="PromotionsFormat(product.promotions)"
  192. class="floor-tags"
  193. @click.stop="clickPopupShow(1)"
  194. >
  195. {{ product.promotions.name
  196. }}<text v-if="hasLogin && product.priceFlag != 1"
  197. >:¥{{
  198. product.promotions == null ? '0.00' : product.promotions.touchPrice | NumFormat
  199. }}</text
  200. >
  201. </view>
  202. <view v-else class="floor-tags" @click.stop="clickPopupShow()">{{
  203. product.promotions.name
  204. }}</view>
  205. </template>
  206. <template v-if="product.svipProductFlag == 1">
  207. <view class="svip-tags">
  208. <view class="tags" :class="{ none: !isShowVipFlag(product) }">SVIP</view>
  209. <view class="price" v-if="isShowVipFlag(product)">{{ product.svipPriceTag }}</view>
  210. </view>
  211. </template>
  212. </view>
  213. </view>
  214. </template>
  215. </template>
  216. <!--促销活动弹窗提示-->
  217. <tui-bottom-popup :radius="true" :show="popupShow" @close="hidePopup()">
  218. <view class="tui-popup-box clearfix">
  219. <template v-if="product.actStatus == 0 && product.ladderPriceFlag == 1">
  220. <view class="tui-scrollview-box">
  221. <view class="ladder-main clearfix">
  222. <view class="ladder-item">
  223. <view class="ladder-item-td">起订量</view> <view class="ladder-item-td">价格</view>
  224. </view>
  225. <view class="ladder-item" v-for="(ladd, index) in product.ladderPriceList" :key="index">
  226. <view class="ladder-item-td">{{ ladd.numRange }}</view>
  227. <view class="ladder-item-td">{{ ladd.buyPrice | NumFormat }}</view>
  228. </view>
  229. </view>
  230. </view>
  231. </template>
  232. <template v-else>
  233. <view class="tui-scrollview-box">
  234. <view class="box-text">
  235. <text>促销时间:</text>
  236. <text class="txt" v-if="product.promotions.status == 1">不限时</text>
  237. <text class="txt" v-else
  238. >{{ product.promotions.beginTime }} ~ {{ product.promotions.endTime }}</text
  239. >
  240. </view>
  241. <view class="box-title" v-show="product.promotions.mode == 2">
  242. <text>购买{{ product.promotions.name }}商品,满</text>
  243. <text class="txt"
  244. >¥{{
  245. product.promotions == null ? '0.00' : product.promotions.touchPrice | NumFormat
  246. }}</text
  247. >减
  248. <text class="txt"
  249. >¥{{
  250. product.promotions == null
  251. ? '0.00'
  252. : product.promotions.reducedPrice | NumFormat
  253. }}</text
  254. >
  255. </view>
  256. <view class="box-title" v-show="product.promotions.mode == 3">
  257. <text>购买{{ product.promotions.name }}商品,满</text>
  258. <text class="txt"
  259. >¥{{
  260. product.promotions == null ? '0.00' : product.promotions.touchPrice | NumFormat
  261. }}</text
  262. >赠送商品
  263. </view>
  264. <view class="box-product" v-show="product.promotions.mode == 3">
  265. <view
  266. class="box-product-main"
  267. v-for="(item, index) in product.promotions.giftList"
  268. :key="index"
  269. >
  270. <view class="image"><image :src="item.image" mode=""></image></view>
  271. <view class="info">
  272. <view class="name">{{ item.name }}</view>
  273. <view class="num">X{{ item.number }}</view>
  274. </view>
  275. </view>
  276. </view>
  277. </view>
  278. </template>
  279. <view class="tui-right-flex tui-popup-btn" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
  280. <view class="tui-flex-1">
  281. <view
  282. class="tui-button"
  283. v-if="product.promotions.type == 2"
  284. @click="goGoodActiveFn(product.promotions.id)"
  285. >更多凑单商品</view
  286. >
  287. <view class="tui-button" v-else @click="hidePopup()">了解</view>
  288. </view>
  289. </view>
  290. </view>
  291. </tui-bottom-popup>
  292. </template>
  293. </view>
  294. </template>
  295. <script>
  296. import { mapState, mapMutations } from 'vuex'
  297. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  298. export default {
  299. name: 'cm-price',
  300. components: {
  301. uniGrader
  302. },
  303. props: {
  304. product: {
  305. type: Object
  306. },
  307. userIdentity: {
  308. type: Number,
  309. default: 2
  310. },
  311. shopID: {
  312. type: Number,
  313. default: 2
  314. },
  315. ladderPriceList: {
  316. type: Array
  317. },
  318. promotions: {
  319. type: Object
  320. }
  321. },
  322. data() {
  323. return {
  324. vipFlag: 0, // 是否是超级会员 0否 1是
  325. popupShow: false,
  326. promotionsType: 0,
  327. isIphoneX: this.$store.state.isIphoneX,
  328. firstClubType:0
  329. }
  330. },
  331. filters: {
  332. NumFormat: function(text) {
  333. //处理金额
  334. return Number(text).toFixed(2)
  335. }
  336. },
  337. created() {
  338. this.initData()
  339. },
  340. computed: {
  341. ...mapState(['hasLogin', 'clubType']),
  342. },
  343. methods: {
  344. async initData(data) {
  345. const userInfo = await this.$api.getStorage()
  346. this.vipFlag = userInfo.vipFlag ? userInfo.vipFlag : 0
  347. this.firstClubType = this.clubType
  348. },
  349. clickPopupShow(type) {
  350. this.popupShow = true
  351. this.promotionsType = type
  352. },
  353. hidePopup() {
  354. this.popupShow = false
  355. },
  356. PromotionsFormat(promo) {
  357. //促销活动类型数据处理
  358. if (promo != null) {
  359. if (promo.type == 1 && promo.mode == 1) {
  360. return true
  361. } else {
  362. return false
  363. }
  364. }
  365. return false
  366. },
  367. isShowVipFlag(pros) {
  368. /**
  369. *显示SVIP和超级会员价格:
  370. * 个人机构(不是超级会员,但价格所有机构可见),
  371. * 资质机构(不是超级会员,但价格所有机构可见或仅会员可见),
  372. * 超级会员(价格所有机构可见或仅会员可见),超级会员(是医美机构,价格仅医美可见)
  373. *商品价格是否可见:priceFlag 0:所有机构可见 1:未公开价格 2:仅会员可见 3:仅医美机构可见
  374. * 普通机构
  375. * 超级会员 && priceFlag === 0
  376. * 资质机构
  377. * priceFlag !== 1 ||
  378. * 超级会员
  379. * 商品priceFlag === 3 && 是否是医美机构
  380. */
  381. // 未登录 || 非会员
  382. if(!this.hasLogin || !this.vipFlag === 1) return false
  383. // 商品所有机构可见
  384. if(pros.priceFlag === 0 ) return true
  385. // 商品价格仅资质机构可见
  386. if(pros.priceFlag === 2 && this.userIdentity === 2) return true
  387. // 商品价格仅医美机构可见
  388. if(pros.priceFlag === 3 && this.userIdentity === 2 && this.firstClubType == 1) return true
  389. // 其它
  390. return false
  391. },
  392. goUpgradeApply() {
  393. // 友盟埋点升级查看价格点击事件
  394. if (process.env.NODE_ENV != 'development') {
  395. this.$uma.trackEvent('Um_Event_ProductUpgrade', {
  396. Um_Key_PageName: '升级查看价格',
  397. Um_Key_SourcePage: '商品详情'
  398. })
  399. }
  400. this.$api.navigateTo('/pages/login/apply')
  401. },
  402. loginClick() {
  403. // 友盟埋点商品详情登录查看价格点击事件
  404. if (process.env.NODE_ENV != 'development') {
  405. this.$uma.trackEvent('Um_Event_ProductLogin', {
  406. Um_Key_PageName: '去登录',
  407. Um_Key_SourcePage: '商品详情登录查看价格'
  408. })
  409. }
  410. this.$api.navigateTo('/pages/login/login')
  411. },
  412. goGoodActiveFn(id) {
  413. this.$parent.popupShow = false
  414. this.$api.navigateTo('/pages/goods/goods-active?id=' + id)
  415. }
  416. }
  417. }
  418. </script>
  419. <style lang="scss">
  420. .tui-flex-1 {
  421. flex: 1;
  422. }
  423. .tui-popup-box {
  424. position: relative;
  425. box-sizing: border-box;
  426. min-height: 220rpx;
  427. padding: 24rpx 24rpx 0 24rpx;
  428. }
  429. .tui-scrollview-box {
  430. width: 100%;
  431. height: auto;
  432. float: left;
  433. box-sizing: border-box;
  434. .ladder-main {
  435. width: 100%;
  436. min-height: 240rpx;
  437. border: 1px solid rgba(225, 86, 22, 0.3);
  438. border-radius: 10rpx;
  439. .ladder-item {
  440. width: 100%;
  441. height: 80rpx;
  442. float: left;
  443. border-bottom: 1px solid rgba(225, 86, 22, 0.3);
  444. &:nth-child(1) {
  445. .ladder-item-td {
  446. color: #333333;
  447. }
  448. }
  449. &:last-child {
  450. border-bottom: none;
  451. }
  452. .ladder-item-td {
  453. width: 50%;
  454. text-align: center;
  455. line-height: 80rpx;
  456. font-size: $font-size-24;
  457. color: $color-system;
  458. box-sizing: border-box;
  459. float: left;
  460. &:nth-child(1) {
  461. border-right: 1px solid rgba(225, 86, 22, 0.3);
  462. }
  463. }
  464. }
  465. }
  466. .box-title {
  467. font-size: $font-size-26;
  468. color: $text-color;
  469. text-align: left;
  470. line-height: 56rpx;
  471. .txt {
  472. color: $color-system;
  473. margin: 0 8rpx;
  474. }
  475. }
  476. .box-text {
  477. font-size: $font-size-26;
  478. color: $text-color;
  479. text-align: left;
  480. line-height: 56rpx;
  481. .txt {
  482. color: $color-system;
  483. }
  484. }
  485. .box-product {
  486. width: 100%;
  487. height: auto;
  488. margin-top: 20rpx;
  489. .title {
  490. font-size: $font-size-24;
  491. color: $text-color;
  492. text-align: left;
  493. line-height: 54rpx;
  494. }
  495. .box-product-main {
  496. width: 100%;
  497. height: 136rpx;
  498. float: left;
  499. margin: 10rpx 0;
  500. .image {
  501. width: 134rpx;
  502. height: 134rpx;
  503. border: 1px solid #ebebeb;
  504. float: left;
  505. image {
  506. width: 100%;
  507. height: 100%;
  508. display: block;
  509. }
  510. }
  511. .info {
  512. width: 540rpx;
  513. height: 134rpx;
  514. float: left;
  515. margin-left: 16rpx;
  516. position: relative;
  517. .name {
  518. width: 100%;
  519. float: left;
  520. line-height: 40rpx;
  521. font-size: $font-size-28;
  522. color: $text-color;
  523. -o-text-overflow: ellipsis;
  524. text-overflow: ellipsis;
  525. display: -webkit-box;
  526. word-break: break-all;
  527. -webkit-box-orient: vertical;
  528. -webkit-line-clamp: 2;
  529. overflow: hidden;
  530. }
  531. .num {
  532. width: 100%;
  533. height: 44rpx;
  534. font-size: $font-size-24;
  535. color: $text-color;
  536. text-align: left;
  537. line-height: 44rpx;
  538. position: absolute;
  539. bottom: 0;
  540. left: 0;
  541. }
  542. }
  543. }
  544. }
  545. }
  546. .tui-popup-btn {
  547. width: 100%;
  548. height: auto;
  549. float: left;
  550. margin-top: 24rpx;
  551. .tui-button {
  552. width: 100%;
  553. height: 88rpx;
  554. background: $btn-confirm;
  555. line-height: 88rpx;
  556. text-align: center;
  557. color: #ffffff;
  558. font-size: $font-size-28;
  559. border-radius: 44rpx;
  560. }
  561. }
  562. </style>