多租户商城-商户小程序端
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.

549 lines
15 KiB

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