cm-price.vue 18 KB

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