cm-price.vue 16 KB

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