GoodActivityDetail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <template>
  2. <view class="good-activity-detail-container">
  3. <!-- 商品详情 -->
  4. <swiper class="goodsImgswiper-box " :indicator-dots="true" :autoplay="true">
  5. <swiper-item v-for="(imgItem, index) in goodsDetail.images" :key="index">
  6. <image
  7. v-if="!isVideoSource(imgItem)" mode="aspectFit" class="goodsImg default-img"
  8. :src="common.seamingImgUrl(imgItem)"
  9. ></image>
  10. <video v-else style="width: 750upx; height: 750upx;" :src="common.seamingImgUrl(imgItem)"></video>
  11. </swiper-item>
  12. </swiper>
  13. <!-- 分享 -->
  14. <view class="share-box flex-items-plus" @click="shareObj.actionShow = true">
  15. <tui-icon :size="18" color="#141414" name="share-fill"></tui-icon>
  16. <label class="fs24 mar-left-5">分享</label>
  17. </view>
  18. <view class="goodgDes-box flex-start flex-column">
  19. <view v-if="skuSelect.activityType === 0" class="flex-items flex-sp-between">
  20. <view class="flex-items">
  21. <label class="fs36 font-color-C83732">¥</label>
  22. <label class="fs36 fs-bold font-color-C83732 mar-left-10">{{ skuSelect.price || 0 }}</label>
  23. <view class="flex-column-plus mar-left-20">
  24. <label
  25. v-if="skuSelect.price !== skuSelect.originalPrice"
  26. class="fs24 font-color-999 discountsPriceLine mar-left-20"
  27. >
  28. ¥ {{ skuSelect.originalPrice || 0 }}
  29. </label>
  30. </view>
  31. </view>
  32. <label class="fs24 font-color-999">{{ goodsDetail.users || 0 }}人付款</label>
  33. </view>
  34. <view v-else-if="skuSelect.activityType === 8">
  35. <view class="flex-row-plus flex-items-plus">
  36. <label class="fs30 font-color-FFF">¥</label>
  37. <label class="fs42 mar-left-5 font-color-FFF">{{ skuSelect.price || 0 }}</label>
  38. <label class="fs28 mar-left-10 discountsPriceLine font-color-CCC">
  39. ¥
  40. {{ skuSelect.originalPrice || 0 }}
  41. </label>
  42. </view>
  43. <view class="sceneNameBox">{{ goodsDetail.sceneName }}</view>
  44. </view>
  45. <view v-else class="seckill-box">
  46. <view v-if="skuSelect.activityType === 9" class="flex-items flex-sp-between">
  47. <view class="vipImg flex-items">
  48. <image class="vip-icon" src="../../../../static/images/new-business/shop/vipDetail.png" mode="">
  49. </image>
  50. </view>
  51. <view class="flex-row-plus flex-items-plus mar-left-30 mar-top-10">
  52. <label class="fs30 font-color-FFF">¥</label>
  53. <label class="fs42 mar-left-5 font-color-FFF">{{ skuSelect.price || 0 }}</label>
  54. <label class="fs28 mar-left-10 discountsPriceLine font-color-999">
  55. ¥
  56. {{ skuSelect.originalPrice || 0 }}
  57. </label>
  58. </view>
  59. </view>
  60. <view v-else class="flex-items flex-row flex-sp-between">
  61. <view class="flex-column-plus">
  62. <image
  63. v-if="[2, 4].includes(skuSelect.activityType)" class="seckill-icon"
  64. src="../../../../static/images/new-business/shop/seckillicon.png" mode=""
  65. ></image>
  66. <image
  67. v-if="[3, 5].includes(skuSelect.activityType)" class="discount-icon"
  68. src="../../../../static/images/new-business/shop/discounticon.png" mode=""
  69. ></image>
  70. <image
  71. v-if="skuSelect.activityType === 1" class="spell-icon"
  72. src="../../../../static/images/new-business/shop/spellicon.png" mode=""
  73. ></image>
  74. <view class="flex-row-plus flex-items mar-top-10">
  75. <label class="fs30 font-color-FFF">¥</label>
  76. <label class="fs42 mar-left-5 font-color-FFF">{{ skuSelect.price || 0 }}</label>
  77. <label class="fs28 mar-left-10 discountsPriceLine font-color-999">
  78. ¥
  79. {{ skuSelect.originalPrice || 0 }}
  80. </label>
  81. </view>
  82. </view>
  83. <view v-if="[1, 2, 3, 4, 5].includes(skuSelect.activityType)" class="countdown flex-column-plus">
  84. <view v-if="skuSelect.ifEnable === 0">
  85. <label class="fs28">距离结束剩余</label>
  86. <view class="flex-row-plus fs34 flex-items-plus mar-top-10">
  87. <view class="countdown-box flex-items-plus">{{ activeTimeObj.day }}</view>
  88. <view class="font-color-999">天</view>
  89. <view class="countdown-box flex-items-plus">{{ activeTimeObj.hour }}</view>
  90. <view class="font-color-999">:</view>
  91. <view class="countdown-box flex-items-plus">{{ activeTimeObj.min }}</view>
  92. <view class="font-color-999">:</view>
  93. <view class="countdown-box flex-items-plus">{{ activeTimeObj.sec }}</view>
  94. </view>
  95. </view>
  96. <view v-else>
  97. <label class="fs28 mar-right-20">即将开始:{{ skuSelect.startTime }}</label>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. <view style="display: flex;align-items: center;flex-wrap: wrap;">
  103. <text
  104. v-if="skuSelect.voucherId"
  105. style="padding: 6upx 12upx;background-color: #f0f0f0;font-size: 28upx;color: #fa5151;border-radius: 22upx;"
  106. >
  107. 可使用{{ skuSelect.voucherPrice }}代金券抵扣
  108. </text>
  109. <text
  110. v-if="skuSelect.presenterVoucher"
  111. style="margin-left: 12upx;padding: 6upx 12upx;background-color: #f0f0f0;font-size: 28upx;color: #fa5151;border-radius: 22upx;"
  112. >
  113. 赠送 {{ skuSelect.presenterVoucher }} 代金券
  114. </text>
  115. </view>
  116. <view class="nameContainer">
  117. <view class="goodsName-box overflowNoDot mar-top-30 mar-left-30">
  118. <label class="goodsName fs32 mar-left-20 ">{{ goodsDetail.productName }}</label>
  119. </view>
  120. <view class="collectBox " @click="handleCollect">
  121. <tui-icon v-if="goodsDetail.ifCollect === 1" :size="24" color="#c5aa7b" name="star-fill"></tui-icon>
  122. <tui-icon v-else :size="24" color="#333333" name="star"></tui-icon>
  123. <label class="fs22">收藏</label>
  124. </view>
  125. </view>
  126. <view
  127. v-if="goodsDetail.markTools.length > 0 || goodsDetail.shopMarkTools.length > 0"
  128. class="activity-box mar-top-10" @click="$refs.refCouponPopup && ($refs.refCouponPopup.showActivity = true)"
  129. >
  130. <label class="fs24 font-color-999">优惠</label>
  131. <view class="activity-content mar-left-30 flex-items flex-sp-between flex-row">
  132. <view class="fs20 overflow" style="width: 500rpx;">
  133. {{ goodsDetail.couponSplicing }}
  134. </view>
  135. <view class="flex-items">
  136. <label class="fs24 font-color-C5AA7B">领券</label>
  137. <tui-icon :size="24" color="#baa174" name="arrowright" margin="0 0 0 10upx"></tui-icon>
  138. </view>
  139. </view>
  140. </view>
  141. </view>
  142. <!-- 分享弹出 -->
  143. <tui-actionsheet
  144. :show="shareObj.actionShow" :item-list="shareObj.actionList.map(i => ({ ...i, color: '#000000' }))"
  145. @click="handleShareSelect" @cancel="shareObj.actionShow = false"
  146. >
  147. </tui-actionsheet>
  148. <ShareSpell
  149. ref="shareSpell" :url="shareObj.url" :img="shareObj.image" :title="shareObj.title"
  150. @shareCancel="shareCancel"
  151. >
  152. </ShareSpell>
  153. <!-- 优惠券选择器 -->
  154. <CouponPopup
  155. ref="refCouponPopup" :platform-mark-tools="goodsDetail.shopMarkTools"
  156. :shop-mark-tools="goodsDetail.shopMarkTools"
  157. ></CouponPopup>
  158. </view>
  159. </template>
  160. <script>
  161. import CouponPopup from './CouponPopup'
  162. import { timeFormatting, isVideoSource } from '../../../../utils'
  163. import { getProductSharePicApi, updateCollectCancelPUTApi, updateCollectToCollectApi } from '../../../../api/anotherTFInterface'
  164. export default {
  165. name: 'GoodActivityDetail',
  166. components: {
  167. CouponPopup
  168. },
  169. props: {
  170. // 商品信息
  171. goodsDetail: {
  172. type: Object,
  173. default: () => ({})
  174. },
  175. // 当前选中的sku
  176. skuSelect: {
  177. type: Object,
  178. default: () => ({})
  179. }
  180. },
  181. data() {
  182. return {
  183. // 活动倒计时
  184. timeDifference: 0,
  185. activeTimeObj: {
  186. day: '00',
  187. hour: '00',
  188. min: '00',
  189. sec: '00'
  190. },
  191. countdownInterval: null,
  192. // 分享
  193. shareObj: {
  194. url: '',
  195. image: '',
  196. title: '好友分享了一个很棒的商品',
  197. actionList: [
  198. { text: '生成分享海报' },
  199. { text: '邀请好友' }
  200. ],
  201. actionShow: false
  202. }
  203. }
  204. },
  205. watch: {
  206. skuSelect: {
  207. handler(newVal) {
  208. if ([1, 2, 3, 4, 5].includes(newVal.activityType) && (newVal.ifEnable === 0)) {
  209. this.$refs.goodActivityDetail.handleGetCountDownNumber(newVal.endTime)
  210. }
  211. },
  212. immediate: false,
  213. deep: true
  214. }
  215. },
  216. methods: {
  217. isVideoSource,
  218. /**
  219. * 初始化活动倒计时
  220. * @param endTimestamp
  221. */
  222. handleGetCountDownNumber(endTimestamp) {
  223. // 与当前时间的时间差(秒)
  224. this.timeDifference = (new Date(endTimestamp.substring(0, 19).replace(/-/g, '/')).getTime() - new Date().getTime()) / 1000
  225. this.activeTimeObj = timeFormatting(this.timeDifference)
  226. this.handleCountDown()
  227. },
  228. /**
  229. * 开始倒计时
  230. */
  231. handleCountDown() {
  232. if (this.countdownInterval) {
  233. return
  234. }
  235. this.countdownInterval = setInterval(() => {
  236. if (this.timeDifference <= 0) {
  237. clearInterval(this.countdownInterval)
  238. uni.showToast({
  239. title: '活动结束',
  240. duration: 2000,
  241. icon: 'none'
  242. })
  243. this.$emit('activityEnd')
  244. } else {
  245. this.timeDifference--
  246. this.activeTimeObj = timeFormatting(this.timeDifference)
  247. }
  248. }, 1000)
  249. },
  250. /**
  251. * 收藏
  252. */
  253. handleCollect() {
  254. if (this.goodsDetail.ifCollect === 0) {
  255. updateCollectToCollectApi({
  256. productId: parseInt(this.goodsDetail.productId)
  257. }).then((res) => {
  258. this.goodsDetail.ifCollect = 1
  259. uni.showToast({
  260. title: '收藏成功',
  261. icon: 'success'
  262. })
  263. })
  264. } else {
  265. updateCollectCancelPUTApi({
  266. ids: [ this.goodsDetail.productId ]
  267. }).then((res) => {
  268. this.goodsDetail.ifCollect = 0
  269. uni.showToast({
  270. title: '取消收藏成功',
  271. icon: 'success'
  272. })
  273. })
  274. }
  275. },
  276. /**
  277. * 海报分享
  278. */
  279. sharePoster() {
  280. let system
  281. // #ifdef APP
  282. system = 1
  283. // #endif
  284. // #ifdef H5
  285. system = 3
  286. // #endif
  287. // #ifdef MP-WEIXIN
  288. system = 2
  289. // #endif
  290. // #ifdef MP-ALIPAY
  291. system = 4
  292. // #endif
  293. uni.showLoading()
  294. getProductSharePicApi({
  295. productId: this.goodsDetail.productId,
  296. shopId: this.goodsDetail.shopId,
  297. skuId: this.skuSelect.skuId,
  298. terminal: system
  299. }).then((res) => {
  300. uni.hideLoading()
  301. // 推广商品
  302. uni.navigateTo({
  303. url: `/another-tf/another-serve/shareProduct/index?shareType=2&shopId=${this.goodsDetail.shopId}&productId=${this.goodsDetail.productId}&skuId=${this.skuSelect.skuId}&shareImg=${res.data}`
  304. })
  305. })
  306. .catch((e) => {
  307. uni.hideLoading()
  308. })
  309. },
  310. shareCancel() {
  311. this.$refs.shareSpell.shareShow = false
  312. },
  313. handleShareSelect(e) {
  314. if (e.index === 0) {
  315. this.sharePoster()
  316. } else {
  317. this.shareObj.url = '/another-tf/another-serve/goodsDetails/index?shopId=' + this.goodsDetail.shopId + '&productId=' + this.goodsDetail.productId + '&skuId=' + this.skuSelect.skuId
  318. this.shareObj.image = this.goodsDetail.images[0]
  319. this.shareObj.title = `【shop】好友分享了一个好物给您!${this.goodsDetail.productName} ¥${this.goodsDetail.price} `
  320. this.$refs.shareSpell.shareShow = true
  321. }
  322. }
  323. }
  324. }
  325. </script>
  326. <style lang="less" scoped>
  327. .good-activity-detail-container {
  328. box-sizing: border-box;
  329. .goodsImgswiper-box {
  330. width: 750upx;
  331. height: 750upx;
  332. .goodsImg {
  333. width: 750upx;
  334. height: 750upx;
  335. }
  336. }
  337. .share-box {
  338. width: 200upx;
  339. height: 60upx;
  340. background-color: #FFFFFF;
  341. border-radius: 30upx 0 0 30upx;
  342. position: absolute;
  343. top: 110upx;
  344. right: 0;
  345. z-index: 99;
  346. }
  347. .goodgDes-box {
  348. background-color: #FFFFFF;
  349. padding: 30upx 25upx 25upx;
  350. .nameContainer {
  351. display: flex;
  352. .goodsName-box {
  353. width: 677upx;
  354. }
  355. .collectBox {
  356. width: 80rpx;
  357. margin: 0 30rpx 0 15rpx;
  358. display: flex;
  359. flex-direction: column;
  360. justify-content: center;
  361. align-items: center;
  362. }
  363. }
  364. .activity-box {
  365. display: flex;
  366. flex-direction: row;
  367. justify-content: center;
  368. align-items: flex-end;
  369. border-top: 1upx solid #EDEDED;
  370. .activity-content {
  371. width: 614upx;
  372. padding-top: 20upx;
  373. }
  374. }
  375. }
  376. .seckill-box {
  377. width: 100%;
  378. background: url("../../../../static/images/new-business/shop/storeTop_Img.png") no-repeat left top;
  379. .seckill-icon {
  380. width: 187rpx;
  381. height: 41rpx;
  382. background-size: contain;
  383. }
  384. .vip-icon {
  385. width: 187rpx;
  386. height: 41rpx;
  387. background-size: contain;
  388. }
  389. .discount-icon {
  390. width: 187rpx;
  391. height: 41rpx;
  392. background-size: contain;
  393. }
  394. .spell-icon {
  395. width: 182rpx;
  396. height: 37rpx;
  397. background-size: contain;
  398. margin-bottom: 20rpx;
  399. }
  400. .countdown {
  401. text-align: center;
  402. label {
  403. text-align: center;
  404. color: #CCCCCC;
  405. }
  406. }
  407. .countdown-box {
  408. padding: 0 8rpx;
  409. height: 48rpx;
  410. color: #FFEBC4;
  411. background-color: #525252;
  412. margin: 10rpx;
  413. }
  414. }
  415. }
  416. </style>