多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

548 lines
14 KiB

3 years ago
  1. <!--
  2. * @FileDescription: 商品信息包括活动信息优惠券
  3. * @Author: kahu
  4. * @Date: 2022/11/7
  5. * @LastEditors: kahu
  6. * @LastEditTime: 2022/11/7
  7. -->
  8. <template>
  9. <view>
  10. <!-- 商品详情 -->
  11. <swiper
  12. class="goodsImgswiper-box "
  13. :indicator-dots="true"
  14. :autoplay="true"
  15. >
  16. <swiper-item
  17. v-for="(imgItem, index) in productInfo.images"
  18. :key="index"
  19. >
  20. <image
  21. class="goodsImg default-img u-skeleton-fillet"
  22. :src="imgItem"
  23. ></image>
  24. </swiper-item>
  25. </swiper>
  26. <!-- 分享 -->
  27. <view
  28. class="share-box flex-items-plus"
  29. @click="shareMenuShow"
  30. >
  31. <image
  32. class="share-img"
  33. src="https://ceres.zkthink.com/static/images/shareBut.png"
  34. ></image>
  35. <label class="fs24 mar-left-5">分享</label>
  36. </view>
  37. <view class="goodgDes-box flex-start flex-column">
  38. <view
  39. v-if="skuSelect.activityType === 0"
  40. class="priceBuyNum-box flex-display u-skeleton-fillet flex-sp-between mar-left-30"
  41. >
  42. <view>
  43. <label class="fs36 font-color-C83732">¥</label>
  44. <label class="fs36 fs-bold font-color-C83732 mar-left-10">{{ skuSelect.price || 0 }}</label>
  45. <label class="fs24 font-color-999 discountsPriceLine mar-left-20">¥
  46. {{ skuSelect.originalPrice || 0 }}</label>
  47. </view>
  48. <label class="fs24 font-color-999">{{ productInfo.users || 0 }}人付款</label>
  49. </view>
  50. <view
  51. v-else-if="skuSelect.activityType === 8"
  52. class="sceneMarketingBox"
  53. >
  54. <view class="flex-row-plus flex-items-plus mar-left-30 mar-top-10">
  55. <label class="fs30 font-color-FFF">¥</label>
  56. <label class="fs42 mar-left-5 font-color-FFF">{{ skuSelect.price || 0 }}</label>
  57. <label class="fs28 mar-left-10 discountsPriceLine font-color-CCC">¥
  58. {{ skuSelect.originalPrice || 0 }}</label>
  59. </view>
  60. <view class="sceneNameBox">{{ productInfo.sceneName }}</view>
  61. </view>
  62. <view
  63. v-else
  64. class="seckill-box"
  65. >
  66. <view
  67. class="flex-items flex-sp-between"
  68. v-if="skuSelect.activityType === 9 "
  69. >
  70. <view class="vipImg flex-items">
  71. <image
  72. class="vip-icon"
  73. src="https://ceres.zkthink.com/static/images/vipDetail.png"
  74. mode=""
  75. >
  76. </image>
  77. </view>
  78. <view class="flex-row-plus flex-items-plus mar-left-30 mar-top-10">
  79. <label class="fs30 font-color-FFF">¥</label>
  80. <label class="fs42 mar-left-5 font-color-FFF">{{ skuSelect.price || 0 }}</label>
  81. <label class="fs28 mar-left-10 discountsPriceLine font-color-999">¥
  82. {{ skuSelect.originalPrice || 0 }}
  83. </label>
  84. </view>
  85. </view>
  86. <view
  87. v-else
  88. class="flex-items flex-row flex-sp-between"
  89. >
  90. <view class="flex-column-plus">
  91. <image
  92. v-if="[2,4].includes(skuSelect.activityType)"
  93. class="seckill-icon"
  94. src="https://ceres.zkthink.com/static/images/seckillicon.png"
  95. mode=""
  96. ></image>
  97. <image
  98. v-if="[3,5].includes(skuSelect.activityType)"
  99. class="discount-icon"
  100. src="https://ceres.zkthink.com/static/images/discounticon.png"
  101. mode=""
  102. ></image>
  103. <image
  104. v-if="skuSelect.activityType === 1"
  105. class="spell-icon"
  106. src="https://ceres.zkthink.com/static/images/spellicon.png"
  107. mode=""
  108. ></image>
  109. <view class="flex-row-plus flex-items mar-top-10">
  110. <label class="fs30 font-color-FFF">¥</label>
  111. <label class="fs42 mar-left-5 font-color-FFF">{{ skuSelect.price || 0 }}</label>
  112. <label class="fs28 mar-left-10 discountsPriceLine font-color-999">¥
  113. {{ skuSelect.originalPrice || 0 }}
  114. </label>
  115. </view>
  116. </view>
  117. <view
  118. v-if="[1,2,3,4,5].includes(skuSelect.activityType)"
  119. class="countdown flex-column-plus"
  120. >
  121. <view v-if="timeActiveType">
  122. <label class="fs28">距离结束剩余</label>
  123. <view class="flex-row-plus fs34 flex-items-plus mar-top-10">
  124. <view class="countdown-box flex-items-plus">{{ activeTimeObj.day }}</view>
  125. <view class="font-color-999"></view>
  126. <view class="countdown-box flex-items-plus">{{ activeTimeObj.hour }}</view>
  127. <view class="font-color-999">:</view>
  128. <view class="countdown-box flex-items-plus">{{ activeTimeObj.min }}</view>
  129. <view class="font-color-999">:</view>
  130. <view class="countdown-box flex-items-plus">{{ activeTimeObj.sec }}</view>
  131. </view>
  132. </view>
  133. <view v-else>
  134. <label class="fs28 mar-right-20">即将开始{{ skuSelect.startTime }}</label>
  135. <!-- <view class="fs28 mar-right-20 mar-top-20">{{productInfo.startTime}}</view>-->
  136. </view>
  137. </view>
  138. </view>
  139. </view>
  140. <view class="nameContainer">
  141. <view class="goodsName-box overflowNoDot mar-top-30 mar-left-30 u-skeleton-fillet">
  142. <label class="goodsName fs32 mar-left-20 ">{{ productInfo.productName }}</label>
  143. </view>
  144. <view
  145. class="collectBox "
  146. @click="handleCollect"
  147. >
  148. <image
  149. v-if="productInfo.ifCollect === 1"
  150. class="store-icon "
  151. src="https://ceres.zkthink.com/static/images/shoucangActive1.png"
  152. ></image>
  153. <image
  154. v-else
  155. class="store-icon"
  156. src="https://ceres.zkthink.com/static/images/shoucang2x.png"
  157. >
  158. </image>
  159. <label class="fs22">收藏</label>
  160. </view>
  161. </view>
  162. <view
  163. v-if="markTools.length>0 || shopMarkTools.length>0"
  164. class="activity-box mar-top-10"
  165. @click="couponShowClick"
  166. >
  167. <label class="fs24 font-color-999">优惠</label>
  168. <view class="activity-content mar-left-30 flex-items flex-sp-between flex-row">
  169. <view
  170. class="fs20 overflow"
  171. style="width: 500rpx;"
  172. >
  173. {{ productInfo.couponSplicing }}
  174. </view>
  175. <view class="flex-items">
  176. <label class="fs24 font-color-C5AA7B">领券</label>
  177. <image
  178. class="coupon-arrow"
  179. src="https://ceres.zkthink.com/static/img/user/arrow.png"
  180. ></image>
  181. </view>
  182. </view>
  183. </view>
  184. </view>
  185. <!-- 分享弹出 -->
  186. <u-action-sheet
  187. :list="shareObj.actionList"
  188. v-model="shareObj.actionShow"
  189. @click="handleShareSelect"
  190. ></u-action-sheet>
  191. <shareSpell
  192. ref="shareSpell"
  193. @shareCancel="shareCancel"
  194. :url="shareObj.url"
  195. :img="shareObj.image"
  196. :title="shareObj.title"
  197. >
  198. </shareSpell>
  199. </view>
  200. </template>
  201. <script>
  202. import { TimeFormatting } from "../../../utils/timeUtil";
  203. import NET from "../../../utils/request";
  204. import API from "../../../config/api";
  205. import shareSpell from '../../../component/share.vue'
  206. export default {
  207. name: "GoodActivityDetail",
  208. components: {shareSpell},
  209. data() {
  210. return {
  211. // 活动倒计时
  212. timeDifference: 0,
  213. activeTimeObj: {
  214. day: '00',
  215. hour: '00',
  216. min: '00',
  217. sec: '00'
  218. },
  219. countdownInterval: null,
  220. // 分享
  221. shareObj: {
  222. url: '',
  223. image: '',
  224. title: '好友分享了一个很棒的商品',
  225. actionList: [
  226. {text: '生成分享海报'},
  227. {text: '邀请好友'}
  228. ],
  229. actionShow: false
  230. },
  231. }
  232. },
  233. props: {
  234. // 商品信息
  235. productInfo: {
  236. type: Object,
  237. default: () => ({})
  238. },
  239. // 当前选中的sku
  240. skuSelect: {
  241. type: Object,
  242. default: () => ({})
  243. },
  244. timeActiveType: {
  245. type: Boolean,
  246. default: () => false
  247. },
  248. markTools: {
  249. type: Array,
  250. default: () => ([])
  251. },
  252. shopMarkTools: {
  253. type: Array,
  254. default: () => ([])
  255. }
  256. },
  257. methods: {
  258. /**
  259. * 初始化活动倒计时
  260. * @param endTimestamp
  261. */
  262. handleGetCountDownNumber(endTimestamp) {
  263. endTimestamp = endTimestamp.substring(0, 19).replace(/-/g, '/');
  264. // 与当前时间的时间差(秒)
  265. const timeDifference = (new Date(endTimestamp).getTime() - new Date().getTime()) / 1000;
  266. this.timeDifference = timeDifference
  267. this.activeTimeObj = TimeFormatting(timeDifference)
  268. this.handleCountDown()
  269. },
  270. /**
  271. * 开始倒计时
  272. */
  273. handleCountDown() {
  274. if (this.countdownInterval) {
  275. return
  276. }
  277. this.countdownInterval = setInterval(() => {
  278. if (this.timeDifference <= 0) {
  279. clearInterval(this.countdownInterval)
  280. uni.showToast({
  281. title: "活动结束",
  282. duration: 2000,
  283. icon: 'none'
  284. })
  285. this.$emit('activityEnd', 0)
  286. } else {
  287. this.timeDifference--
  288. this.activeTimeObj = TimeFormatting(this.timeDifference)
  289. }
  290. }, 1000)
  291. },
  292. /**
  293. * 拉起父组件优惠券
  294. */
  295. couponShowClick() {
  296. this.$emit('couponClick')
  297. },
  298. /**
  299. * 收藏
  300. */
  301. handleCollect() {
  302. if (this.productInfo.ifCollect === 0) {
  303. NET.request(API.collect, {
  304. productId: parseInt(this.productInfo.productId)
  305. }, 'POST').then(res => {
  306. this.productInfo.ifCollect = 1
  307. uni.showToast({
  308. title: '收藏成功',
  309. icon: "success"
  310. })
  311. })
  312. } else {
  313. NET.request(API.cancelCollect, {
  314. ids: [this.productInfo.productId]
  315. }, 'PUT').then(res => {
  316. this.productInfo.ifCollect = 0
  317. uni.showToast({
  318. title: '取消收藏成功',
  319. icon: "success"
  320. })
  321. })
  322. }
  323. },
  324. /**
  325. * 海报分享
  326. */
  327. sharePoster() {
  328. let system = undefined
  329. // #ifdef APP-PLUS
  330. system = 1
  331. // #endif
  332. // #ifdef H5
  333. system = 3
  334. // #endif
  335. // #ifdef MP-WEIXIN
  336. system = 2
  337. // #endif
  338. // #ifdef MP-ALIPAY
  339. system = 4
  340. // #endif
  341. uni.showLoading({
  342. mask: true,
  343. title: '请稍候...'
  344. })
  345. NET.request(API.getSharePic, {
  346. productId: this.productInfo.productId,
  347. shopId: this.productInfo.shopId,
  348. skuId: this.skuSelect.skuId,
  349. terminal: system
  350. }, 'GET').then(res => {
  351. uni.hideLoading()
  352. // 推广商品
  353. uni.navigateTo({
  354. url: `/pages_category_page1/distributionModule/shareProduct?shareType=2&productImage=${ this.productInfo.images[0] }&shopId=${ this.productInfo.shopId }&productId=${ this.productInfo.productId }&skuId=${ this.skuSelect.skuId }&productName=${ this.productInfo.productName }&price=${ this.productInfo.price }&headImage=${ res.data.headImage }&shareName=${ res.data.name }&shareImg=${ res.data }`
  355. });
  356. }).catch(res => {
  357. uni.hideLoading()
  358. })
  359. },
  360. shareMenuShow() {
  361. this.shareObj.actionShow = true
  362. },
  363. shareCancel() {
  364. this.$refs.shareSpell.shareShow = false
  365. },
  366. handleShareSelect(index) {
  367. if (index === 0) {
  368. this.sharePoster()
  369. } else {
  370. this.shareObj.url = '/pages_category_page1/goodsModule/goodsDetails?shopId=' + this.productInfo.shopId + '&productId=' + this.productInfo.productId + '&skuId=' + this.skuSelect.skuId
  371. this.shareObj.image = this.productInfo.images[0]
  372. this.shareObj.title = `【cereshop】好友分享了一个好物给您!${ this.productInfo.productName }${ this.productInfo.price } `
  373. this.$refs.shareSpell.shareShow = true
  374. }
  375. },
  376. }
  377. }
  378. </script>
  379. <style
  380. lang="scss"
  381. scoped
  382. >
  383. .goodsImgswiper-box {
  384. width: 750upx;
  385. height: 750upx;
  386. .goodsImg {
  387. width: 750upx;
  388. height: 750upx;
  389. }
  390. }
  391. .share-box {
  392. width: 200upx;
  393. height: 60upx;
  394. background-color: #FFFFFF;
  395. border-radius: 30upx 0 0 30upx;
  396. position: absolute;
  397. top: 30upx;
  398. right: 0;
  399. z-index: 99;
  400. .share-img {
  401. width: 36upx;
  402. height: 36upx;
  403. }
  404. }
  405. .goodgDes-box {
  406. background-color: #FFFFFF;
  407. width: 100%;
  408. padding-bottom: 25upx;
  409. .priceBuyNum-box {
  410. width: 677upx;
  411. margin-top: 30upx;
  412. }
  413. .nameContainer {
  414. display: flex;
  415. .goodsName-box {
  416. width: 677upx;
  417. height: 85upx;
  418. .img618-cion {
  419. width: 70upx;
  420. height: 36upx;
  421. }
  422. }
  423. .collectBox {
  424. width: 80rpx;
  425. margin: 0 30rpx 0 15rpx;
  426. display: flex;
  427. flex-direction: column;
  428. justify-content: center;
  429. align-items: center;
  430. }
  431. .store-icon {
  432. width: 48upx;
  433. height: 48upx;
  434. }
  435. }
  436. .discounts-box {
  437. margin-top: 20upx;
  438. .discounts-text {
  439. margin-left: 10upx;
  440. color: #FF7800;
  441. background-color: #FFE4CC;
  442. padding: 6upx 12upx;
  443. border-radius: 4upx;
  444. }
  445. }
  446. .activity-box {
  447. display: flex;
  448. flex-direction: row;
  449. justify-content: center;
  450. align-items: flex-end;
  451. border-top: 1upx solid #EDEDED;
  452. .activity-content {
  453. width: 614upx;
  454. padding-top: 20upx;
  455. .activity-text {
  456. color: #FF7700;
  457. border: 1upx solid #FF7700;
  458. padding: 6upx 23upx;
  459. }
  460. .coupon-arrow {
  461. width: 16upx;
  462. height: 24upx;
  463. margin-left: 15upx;
  464. }
  465. }
  466. }
  467. }
  468. .seckill-box {
  469. width: 100%;
  470. background: url("https://ceres.zkthink.com/static/images/storeTop_Img.png") no-repeat left top;
  471. padding: 35rpx 30rpx;
  472. .seckill-icon {
  473. width: 187rpx;
  474. height: 41rpx;
  475. background-size: contain;
  476. }
  477. .vip-icon {
  478. width: 187rpx;
  479. height: 41rpx;
  480. background-size: contain;
  481. }
  482. .discount-icon {
  483. width: 187rpx;
  484. height: 41rpx;
  485. background-size: contain;
  486. }
  487. .spell-icon {
  488. width: 182rpx;
  489. height: 37rpx;
  490. background-size: contain;
  491. margin-bottom: 20rpx;
  492. }
  493. .countdown {
  494. text-align: center;
  495. label {
  496. text-align: center;
  497. color: #CCCCCC;
  498. }
  499. }
  500. .countdown-box {
  501. padding: 0 8rpx;
  502. height: 48rpx;
  503. color: #FFEBC4;
  504. background-color: #525252;
  505. margin: 10rpx;
  506. }
  507. }
  508. </style>