cm-price.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  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
  79. v-else
  80. class="p-price tui-skeleton-fillet"
  81. :class="( PromotionsFormat(product.promotions) || product.svipProductFlag == 1 )? 'none' : ''"
  82. >
  83. <text class="txt sm">¥</text>
  84. <text class="txt big">{{
  85. ((PromotionsFormat(product.promotions) || product.svipProductFlag == 1) ? product.originalPrice : product.price) | NumFormat
  86. }}</text>
  87. </view>
  88. <view class="floor-item-act">
  89. <template v-if="product.actStatus == 1" >
  90. <view
  91. v-if="product.promotions.type == 1 && product.promotions.mode == 1"
  92. class="floor-tags"
  93. @click.stop="clickPopupShow(1)"
  94. >
  95. {{ product.promotions.name
  96. }}<text v-if="hasLogin && product.priceFlag != 1"
  97. >:¥{{
  98. product.promotions == null ? '0.00' : product.promotions.touchPrice | NumFormat
  99. }}</text
  100. >
  101. </view>
  102. <view v-else class="floor-tags" @click.stop="clickPopupShow()">{{
  103. product.promotions.name
  104. }}</view>
  105. </template>
  106. <template v-if="product.svipProductFlag == 1">
  107. <view class="svip-tags">
  108. <view class="tags">SVIP</view>
  109. <view class="price" v-if="product.priceFlag != 1">{{ product.svipPriceTag }}</view>
  110. </view>
  111. </template>
  112. </view>
  113. <view v-if="product.actStatus == 0 && product.ladderPriceFlag == 1" class="floor-item-act">
  114. <view class="floor-tags" @click.stop="clickPopupShow()">阶梯价格</view>
  115. </view>
  116. </view>
  117. </template>
  118. <!-- 供应商 -->
  119. <template v-if="userIdentity == 3">
  120. <template v-if="product.shopId === shopID">
  121. <view class="wrap-main-item">
  122. <view v-if="product.priceFlag == 1" class="wrap-main-text">¥未公开价格</view>
  123. <view
  124. v-else
  125. class="p-price tui-skeleton-fillet"
  126. :class="(PromotionsFormat(product.promotions) || product.svipProductFlag == 1)? 'none' : ''"
  127. >
  128. <text class="txt sm">¥</text>
  129. <text class="txt big">{{
  130. ((PromotionsFormat(product.promotions) || product.svipProductFlag == 1 )? product.originalPrice : product.price)
  131. | NumFormat
  132. }}</text>
  133. </view>
  134. <view class="floor-item-act">
  135. <template v-if="product.actStatus == 1" >
  136. <view
  137. v-if="product.promotions.type == 1 && product.promotions.mode == 1"
  138. class="floor-tags"
  139. @click.stop="clickPopupShow(1)"
  140. >
  141. {{ product.promotions.name
  142. }}<text v-if="hasLogin && product.priceFlag != 1"
  143. >:¥{{
  144. product.promotions == null ? '0.00' : product.promotions.touchPrice | NumFormat
  145. }}</text
  146. >
  147. </view>
  148. <view v-else class="floor-tags" @click.stop="clickPopupShow()">{{
  149. product.promotions.name
  150. }}</view>
  151. </template>
  152. <template v-if="product.svipProductFlag == 1">
  153. <view class="svip-tags">
  154. <view class="tags" :class="{ none: vipFlag != 1 }">SVIP</view>
  155. <view class="price" v-if="product.priceFlag != 1 && vipFlag == 1">{{ product.svipPriceTag }}</view>
  156. </view>
  157. </template>
  158. </view>
  159. <view v-if="product.actStatus == 0 && product.ladderPriceFlag == 1" class="floor-item-act">
  160. <view class="floor-tags" @click.stop="clickPopupShow()">阶梯价格</view>
  161. </view>
  162. </view>
  163. </template>
  164. <template v-else>
  165. <view class="p-login grade tui-skeleton-fillet">
  166. <text class="p-no">¥</text>
  167. <uni-grader :grade="Number(product.priceGrade)"></uni-grader>
  168. </view>
  169. </template>
  170. </template>
  171. <!-- 个人机构 -->
  172. <template v-if="userIdentity == 4 && vipFlag !=1">
  173. <template v-if="product.priceFlag == 1">
  174. <text class="wrap-main-text">¥未公开价格</text>
  175. </template>
  176. <template v-if="product.priceFlag == 2">
  177. <text class="wrap-main-text">¥价格仅会员可见</text>
  178. <view class="floor-item-btn">
  179. <view class="btn" @click.stop="goUpgradeApply">升级会员查看价格</view>
  180. </view>
  181. </template>
  182. <template v-if="product.priceFlag == 0">
  183. <view class="wrap-main-item">
  184. <view
  185. class="p-price tui-skeleton-fillet"
  186. :class="(PromotionsFormat(product.promotions) || product.svipProductFlag == 1 )? 'none' : ''"
  187. >
  188. <text class="txt sm">¥</text>
  189. <text class="txt big">{{
  190. ((PromotionsFormat(product.promotions) || product.svipProductFlag == 1) ? product.originalPrice : product.price) | 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" :class="{ none: vipFlag != 1 }">SVIP</view>
  214. <view class="price" v-if="vipFlag == 1">{{ 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' : '34rpx' }">
  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. },
  350. methods: {
  351. async initData(data) {
  352. const userInfo = await this.$api.getStorage()
  353. this.vipFlag = userInfo.vipFlag ? userInfo.vipFlag : 0
  354. },
  355. clickPopupShow(type) {
  356. this.popupShow = true
  357. this.promotionsType = type
  358. },
  359. hidePopup() {
  360. this.popupShow = false
  361. },
  362. PromotionsFormat(promo) {
  363. //促销活动类型数据处理
  364. if (promo != null) {
  365. if (promo.type == 1 && promo.mode == 1) {
  366. return true
  367. } else {
  368. return false
  369. }
  370. }
  371. return false
  372. },
  373. goUpgradeApply() {
  374. // 友盟埋点升级查看价格点击事件
  375. if (process.env.NODE_ENV != 'development') {
  376. this.$uma.trackEvent('Um_Event_ProductUpgrade', {
  377. Um_Key_PageName: '升级查看价格',
  378. Um_Key_SourcePage: '商品详情'
  379. })
  380. }
  381. this.$api.navigateTo('/pages/login/apply')
  382. },
  383. loginClick() {
  384. // 友盟埋点商品详情登录查看价格点击事件
  385. if (process.env.NODE_ENV != 'development') {
  386. this.$uma.trackEvent('Um_Event_ProductLogin', {
  387. Um_Key_PageName: '去登录',
  388. Um_Key_SourcePage: '商品详情登录查看价格'
  389. })
  390. }
  391. this.$api.navigateTo('/pages/login/login')
  392. },
  393. goGoodActiveFn(id) {
  394. this.$parent.popupShow = false
  395. this.$api.navigateTo('/pages/goods/goods-active?id=' + id)
  396. }
  397. }
  398. }
  399. </script>
  400. <style lang="scss">
  401. .tui-flex-1 {
  402. flex: 1;
  403. }
  404. .tui-popup-box {
  405. position: relative;
  406. box-sizing: border-box;
  407. min-height: 220rpx;
  408. padding: 24rpx 24rpx 0 24rpx;
  409. }
  410. .tui-scrollview-box {
  411. width: 100%;
  412. height: auto;
  413. float: left;
  414. box-sizing: border-box;
  415. .ladder-main {
  416. width: 100%;
  417. min-height: 240rpx;
  418. border: 1px solid rgba(225, 86, 22, 0.3);
  419. border-radius: 10rpx;
  420. .ladder-item {
  421. width: 100%;
  422. height: 80rpx;
  423. float: left;
  424. border-bottom: 1px solid rgba(225, 86, 22, 0.3);
  425. &:nth-child(1) {
  426. .ladder-item-td {
  427. color: #333333;
  428. }
  429. }
  430. &:last-child {
  431. border-bottom: none;
  432. }
  433. .ladder-item-td {
  434. width: 50%;
  435. text-align: center;
  436. line-height: 80rpx;
  437. font-size: $font-size-24;
  438. color: $color-system;
  439. box-sizing: border-box;
  440. float: left;
  441. &:nth-child(1) {
  442. border-right: 1px solid rgba(225, 86, 22, 0.3);
  443. }
  444. }
  445. }
  446. }
  447. .box-title {
  448. font-size: $font-size-26;
  449. color: $text-color;
  450. text-align: left;
  451. line-height: 56rpx;
  452. .txt {
  453. color: $color-system;
  454. margin: 0 8rpx;
  455. }
  456. }
  457. .box-text {
  458. font-size: $font-size-26;
  459. color: $text-color;
  460. text-align: left;
  461. line-height: 56rpx;
  462. .txt {
  463. color: $color-system;
  464. }
  465. }
  466. .box-product {
  467. width: 100%;
  468. height: auto;
  469. margin-top: 20rpx;
  470. .title {
  471. font-size: $font-size-24;
  472. color: $text-color;
  473. text-align: left;
  474. line-height: 54rpx;
  475. }
  476. .box-product-main {
  477. width: 100%;
  478. height: 136rpx;
  479. float: left;
  480. margin: 10rpx 0;
  481. .image {
  482. width: 134rpx;
  483. height: 134rpx;
  484. border: 1px solid #ebebeb;
  485. float: left;
  486. image {
  487. width: 100%;
  488. height: 100%;
  489. display: block;
  490. }
  491. }
  492. .info {
  493. width: 540rpx;
  494. height: 134rpx;
  495. float: left;
  496. margin-left: 16rpx;
  497. position: relative;
  498. .name {
  499. width: 100%;
  500. float: left;
  501. line-height: 40rpx;
  502. font-size: $font-size-28;
  503. color: $text-color;
  504. -o-text-overflow: ellipsis;
  505. text-overflow: ellipsis;
  506. display: -webkit-box;
  507. word-break: break-all;
  508. -webkit-box-orient: vertical;
  509. -webkit-line-clamp: 2;
  510. overflow: hidden;
  511. }
  512. .num {
  513. width: 100%;
  514. height: 44rpx;
  515. font-size: $font-size-24;
  516. color: $text-color;
  517. text-align: left;
  518. line-height: 44rpx;
  519. position: absolute;
  520. bottom: 0;
  521. left: 0;
  522. }
  523. }
  524. }
  525. }
  526. }
  527. .tui-popup-btn {
  528. width: 100%;
  529. height: auto;
  530. float: left;
  531. margin-top: 24rpx;
  532. .tui-button {
  533. width: 100%;
  534. height: 88rpx;
  535. background: $btn-confirm;
  536. line-height: 88rpx;
  537. text-align: center;
  538. color: #ffffff;
  539. font-size: $font-size-28;
  540. border-radius: 44rpx;
  541. }
  542. }
  543. </style>