detail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. <!-- 拼团订单的详情 -->
  2. <template>
  3. <s-layout
  4. title="拼团详情"
  5. class="detail-wrap"
  6. :navbar="state.data && !state.loading ? 'inner' : 'normal'"
  7. :onShareAppMessage="shareInfo"
  8. >
  9. <view v-if="state.loading"></view>
  10. <view v-if="state.data && !state.loading">
  11. <!-- 团长信息 + 活动信息 -->
  12. <view
  13. class="recharge-box"
  14. v-if="state.data.headRecord"
  15. :style="[
  16. {
  17. marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
  18. paddingTop: Number(statusBarHeight + 108) + 'rpx',
  19. },
  20. ]"
  21. >
  22. <s-goods-item
  23. class="goods-box"
  24. :img="state.data.headRecord.picUrl"
  25. :title="state.data.headRecord.spuName"
  26. :price="state.data.headRecord.combinationPrice"
  27. priceColor="#E1212B"
  28. @tap="
  29. sheep.$router.go('/pages/goods/groupon', {
  30. id: state.data.headRecord.activityId,
  31. })
  32. "
  33. :style="[{ top: Number(statusBarHeight + 108) + 'rpx' }]"
  34. >
  35. <template #groupon>
  36. <view class="ss-flex">
  37. <view class="sales-title">{{ state.data.headRecord.userSize }}人团</view>
  38. <view class="num-title ss-m-l-20">已拼{{ state.data.headRecord.userCount }}件</view>
  39. </view>
  40. </template>
  41. </s-goods-item>
  42. </view>
  43. <view class="countdown-box detail-card ss-p-t-44 ss-flex-col ss-col-center">
  44. <!-- 情况一:拼团成功 -->
  45. <view v-if="state.data.headRecord.status === 1">
  46. <view v-if="state.data.orderId">
  47. <view class="countdown-title ss-flex">
  48. <text class="cicon-check-round" />
  49. 恭喜您~拼团成功
  50. </view>
  51. </view>
  52. <view v-else>
  53. <view class="countdown-title ss-flex">
  54. <text class="cicon-info" />
  55. 抱歉~该团已满员
  56. </view>
  57. </view>
  58. </view>
  59. <!-- 情况二:拼团失败 -->
  60. <view v-if="state.data.headRecord.status === 2">
  61. <view class="countdown-title ss-flex">
  62. <text class="cicon-info"></text>
  63. {{ state.data.orderId ? '拼团超时,已自动退款' : '该团已解散' }}
  64. </view>
  65. </view>
  66. <!-- 情况三:拼团进行中 -->
  67. <view v-if="state.data.headRecord.status === 0">
  68. <view v-if="state.data.headRecord.expireTime <= new Date().getTime()">
  69. <view class="countdown-title ss-flex">
  70. <text class="cicon-info"></text>
  71. 拼团已结束,请关注下次活动
  72. </view>
  73. </view>
  74. <view class="countdown-title ss-flex" v-else>
  75. 还差
  76. <view class="num"
  77. >{{ state.data.headRecord.userSize - state.data.headRecord.userCount }}人</view
  78. >
  79. 拼团成功
  80. <view class="ss-flex countdown-time">
  81. <view class="countdown-h ss-flex ss-row-center">{{ endTime.h }}</view>
  82. <view class="ss-m-x-4">:</view>
  83. <view class="countdown-num ss-flex ss-row-center">
  84. {{ endTime.m }}
  85. </view>
  86. <view class="ss-m-x-4">:</view>
  87. <view class="countdown-num ss-flex ss-row-center">
  88. {{ endTime.s }}
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. <!-- 拼团的记录列表,展示每个参团人 -->
  94. <view class="ss-m-t-60 ss-flex ss-flex-wrap ss-row-center">
  95. <!-- 团长 -->
  96. <view class="header-avatar ss-m-r-24 ss-m-b-20">
  97. <image :src="sheep.$url.cdn(state.data.headRecord.avatar) || sheep.$url.static('/static/img/shop/default_avatar.png')" class="avatar-img"></image>
  98. <view class="header-tag ss-flex ss-col-center ss-row-center">团长</view>
  99. </view>
  100. <!-- 团员 -->
  101. <view
  102. class="header-avatar ss-m-r-24 ss-m-b-20"
  103. v-for="item in state.data.memberRecords"
  104. :key="item.id"
  105. >
  106. <image :src="sheep.$url.cdn(item.avatar) || sheep.$url.static('/static/img/shop/default_avatar.png')" class="avatar-img"></image>
  107. <view
  108. class="header-tag ss-flex ss-col-center ss-row-center"
  109. v-if="item.is_leader == '1'"
  110. >
  111. 团长
  112. </view>
  113. </view>
  114. <!-- 还有几个坑位 -->
  115. <view
  116. class="default-avatar ss-m-r-24 ss-m-b-20"
  117. v-for="item in state.remainNumber"
  118. :key="item"
  119. >
  120. <image
  121. :src="sheep.$url.static('/static/img/shop/avatar/unknown.png')"
  122. class="avatar-img"
  123. ></image>
  124. </view>
  125. </view>
  126. </view>
  127. <!-- 情况一:拼团成功;情况二:拼团失败 -->
  128. <view
  129. v-if="state.data.headRecord.status === 1 || state.data.headRecord.status === 2"
  130. class="ss-m-t-40 ss-flex ss-row-center"
  131. >
  132. <button
  133. class="ss-reset-button order-btn"
  134. v-if="state.data.orderId"
  135. @tap="onDetail(state.data.orderId)"
  136. >
  137. 查看订单
  138. </button>
  139. <button class="ss-reset-button join-btn" v-else @tap="onCreateGroupon"> 我要开团 </button>
  140. </view>
  141. <!-- 情况三:拼团进行中,查看订单或参加或邀请好友或参加 -->
  142. <view v-if="state.data.headRecord.status === 0" class="ss-m-t-40 ss-flex ss-row-center">
  143. <view v-if="state.data.headRecord.expireTime <= new Date().getTime()">
  144. <button
  145. class="ss-reset-button join-btn"
  146. v-if="state.data.orderId"
  147. @tap="onDetail(state.data.orderId)"
  148. >
  149. 查看订单
  150. </button>
  151. <button
  152. class="ss-reset-button disabled-btn"
  153. v-else
  154. disabled
  155. @tap="onDetail(state.data.orderId)"
  156. >
  157. 去参团
  158. </button>
  159. </view>
  160. <view v-else class="ss-flex ss-row-center">
  161. <view v-if="state.data.orderId">
  162. <button class="ss-reset-button join-btn" :disabled="endTime.ms <= 0" @tap="onShare">
  163. 邀请好友来拼团
  164. </button>
  165. </view>
  166. <view v-else>
  167. <button
  168. class="ss-reset-button join-btn"
  169. :disabled="endTime.ms <= 0"
  170. @tap="onJoinGroupon()"
  171. >
  172. 立即参团
  173. </button>
  174. </view>
  175. </view>
  176. </view>
  177. <view v-if="!isEmpty(state.goodsInfo)">
  178. <!-- 规格与数量弹框 -->
  179. <s-select-groupon-sku
  180. :show="state.showSelectSku"
  181. :goodsInfo="state.goodsInfo"
  182. :grouponAction="state.grouponAction"
  183. :grouponNum="state.grouponNum"
  184. @buy="onBuy"
  185. @change="onSkuChange"
  186. @close="state.showSelectSku = false"
  187. />
  188. </view>
  189. </view>
  190. <s-empty v-if="!state.data && !state.loading" icon="/static/goods-empty.png" />
  191. </s-layout>
  192. </template>
  193. <script setup>
  194. import { computed, reactive } from 'vue';
  195. import sheep from '@/sheep';
  196. import { onLoad } from '@dcloudio/uni-app';
  197. import { fen2yuan, useDurationTime } from '@/sheep/hooks/useGoods';
  198. import { showShareModal } from '@/sheep/hooks/useModal';
  199. import { isEmpty } from 'lodash-es';
  200. import CombinationApi from '@/sheep/api/promotion/combination';
  201. import SpuApi from '@/sheep/api/product/spu';
  202. import { SharePageEnum } from '@/sheep/helper/const';
  203. const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
  204. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  205. const state = reactive({
  206. data: {}, // 拼团详情
  207. goodsId: 0, // 商品ID
  208. goodsInfo: {}, // 商品信息
  209. showSelectSku: false, // 显示规格弹框
  210. selectedSkuPrice: {}, // 选中的规格价格
  211. activity: {}, // 团购活动
  212. grouponId: 0, // 团购ID
  213. grouponNum: 0, // 团购人数
  214. grouponAction: 'create', // 团购操作
  215. combinationHeadId: null, // 拼团团长编号
  216. loading: true,
  217. });
  218. const shareInfo = computed(() => {
  219. if (isEmpty(state.data)) return {};
  220. return sheep.$platform.share.getShareInfo(
  221. {
  222. title: state.data.headRecord.spuName,
  223. image: sheep.$url.cdn(state.data.headRecord.picUrl),
  224. desc: state.data.goods?.subtitle,
  225. params: {
  226. page: SharePageEnum.GROUPON_DETAIL.value,
  227. query: state.data.headRecord.id,
  228. },
  229. },
  230. {
  231. type: 'groupon', // 邀请拼团海报
  232. title: state.data.headRecord.spuName, // 商品标题
  233. image: sheep.$url.cdn(state.data.headRecord.picUrl), // 商品主图
  234. price: fen2yuan(state.data.headRecord.combinationPrice), // 商品价格
  235. grouponNum: state.data.headRecord.userSize, // 拼团人数
  236. },
  237. );
  238. });
  239. // 订单详情
  240. function onDetail(orderId) {
  241. sheep.$router.go('/pages/order/detail', {
  242. id: orderId,
  243. });
  244. }
  245. // 去开团
  246. function onCreateGroupon() {
  247. state.grouponAction = 'create';
  248. state.grouponId = 0;
  249. state.showSelectSku = true;
  250. }
  251. // 规格变更
  252. function onSkuChange(e) {
  253. state.selectedSkuPrice = e;
  254. }
  255. // 立即参团
  256. function onJoinGroupon() {
  257. state.grouponAction = 'join';
  258. state.grouponId = state.data.headRecord.activityId;
  259. state.combinationHeadId = state.data.headRecord.id;
  260. state.grouponNum = state.data.headRecord.userSize;
  261. state.showSelectSku = true;
  262. }
  263. // 立即购买
  264. function onBuy(sku) {
  265. sheep.$router.go('/pages/order/confirm', {
  266. data: JSON.stringify({
  267. order_type: 'goods',
  268. combinationActivityId: state.activity.id,
  269. combinationHeadId: state.combinationHeadId,
  270. items: [
  271. {
  272. skuId: sku.id,
  273. count: sku.count,
  274. },
  275. ],
  276. }),
  277. });
  278. }
  279. const endTime = computed(() => {
  280. return useDurationTime(state.data.headRecord.expireTime);
  281. });
  282. // 获取拼团团队详情
  283. async function getGrouponDetail(id) {
  284. const { code, data } = await CombinationApi.getCombinationRecordDetail(id);
  285. if (code === 0) {
  286. state.data = data;
  287. const remainNumber = Number(state.data.headRecord.userSize - state.data.headRecord.userCount);
  288. state.remainNumber = remainNumber > 0 ? remainNumber : 0;
  289. // 获取活动信息
  290. const { data: activity } = await CombinationApi.getCombinationActivity(
  291. data.headRecord.activityId,
  292. );
  293. state.activity = activity;
  294. state.grouponNum = activity.userSize;
  295. // 加载商品信息
  296. const { data: spu } = await SpuApi.getSpuDetail(activity.spuId);
  297. state.goodsId = spu.id;
  298. // 默认显示最低价
  299. activity.products.forEach((product) => {
  300. spu.price = Math.min(spu.price, product.combinationPrice); // 设置 SPU 的最低价格
  301. });
  302. state.goodsInfo = spu;
  303. // 价格、库存使用活动的
  304. spu.skus.forEach((sku) => {
  305. const product = activity.products.find((product) => product.skuId === sku.id);
  306. if (product) {
  307. sku.price = product.combinationPrice;
  308. } else {
  309. // 找不到可能是没配置,则不能发起秒杀
  310. sku.stock = 0;
  311. }
  312. });
  313. } else {
  314. state.data = null;
  315. }
  316. state.loading = false;
  317. }
  318. function onShare() {
  319. showShareModal();
  320. }
  321. onLoad((options) => {
  322. getGrouponDetail(options.id);
  323. });
  324. </script>
  325. <style lang="scss" scoped>
  326. .recharge-box {
  327. position: relative;
  328. margin-bottom: 120rpx;
  329. background: v-bind(headerBg) center/750rpx 100% no-repeat,
  330. linear-gradient(115deg, #f44739 0%, #ff6600 100%);
  331. border-radius: 0 0 5% 5%;
  332. height: 100rpx;
  333. .goods-box {
  334. width: 710rpx;
  335. border-radius: 20rpx;
  336. position: absolute;
  337. left: 20rpx;
  338. box-sizing: border-box;
  339. }
  340. .sales-title {
  341. height: 32rpx;
  342. background: rgba(#ffe0e2, 0.29);
  343. border-radius: 16rpx;
  344. font-size: 24rpx;
  345. font-weight: 400;
  346. padding: 6rpx 20rpx;
  347. color: #f7979c;
  348. }
  349. .num-title {
  350. font-size: 24rpx;
  351. font-weight: 400;
  352. color: #999999;
  353. }
  354. }
  355. .countdown-time {
  356. font-size: 26rpx;
  357. font-weight: 500;
  358. color: #383a46;
  359. .countdown-h {
  360. font-size: 24rpx;
  361. font-family: OPPOSANS;
  362. font-weight: 500;
  363. color: #ffffff;
  364. padding: 0 4rpx;
  365. margin-left: 16rpx;
  366. height: 40rpx;
  367. background: linear-gradient(90deg, #ff6000 0%, #fe832a 100%);
  368. border-radius: 6rpx;
  369. }
  370. .countdown-num {
  371. font-size: 24rpx;
  372. font-family: OPPOSANS;
  373. font-weight: 500;
  374. color: #ffffff;
  375. width: 40rpx;
  376. height: 40rpx;
  377. background: linear-gradient(90deg, #ff6000 0%, #fe832a 100%);
  378. border-radius: 6rpx;
  379. }
  380. }
  381. .countdown-box {
  382. // height: 364rpx;
  383. background: #ffffff;
  384. border-radius: 10rpx;
  385. box-sizing: border-box;
  386. .countdown-title {
  387. font-size: 28rpx;
  388. font-weight: 500;
  389. color: #333333;
  390. .cicon-check-round {
  391. color: #42b111;
  392. margin-right: 24rpx;
  393. }
  394. .cicon-info {
  395. color: #d71e08;
  396. margin-right: 24rpx;
  397. }
  398. .num {
  399. color: #ff6000;
  400. }
  401. }
  402. .header-avatar {
  403. width: 86rpx;
  404. height: 86rpx;
  405. background: #ececec;
  406. border-radius: 50%;
  407. border: 4rpx solid #edc36c;
  408. position: relative;
  409. box-sizing: border-box;
  410. .avatar-img {
  411. width: 100%;
  412. height: 100%;
  413. border-radius: 50%;
  414. }
  415. .header-tag {
  416. width: 72rpx;
  417. height: 36rpx;
  418. font-size: 24rpx;
  419. line-height: nor;
  420. background: linear-gradient(132deg, #f3dfb1, #f3dfb1, #ecbe60);
  421. border-radius: 16rpx;
  422. position: absolute;
  423. left: 4rpx;
  424. top: -36rpx;
  425. }
  426. }
  427. .default-avatar {
  428. width: 86rpx;
  429. height: 86rpx;
  430. background: #ececec;
  431. border-radius: 50%;
  432. .avatar-img {
  433. width: 100%;
  434. height: 100%;
  435. border-radius: 50%;
  436. }
  437. }
  438. .user-avatar {
  439. width: 86rpx;
  440. height: 86rpx;
  441. background: #ececec;
  442. border-radius: 50%;
  443. }
  444. }
  445. .order-btn {
  446. width: 668rpx;
  447. height: 70rpx;
  448. border: 2rpx solid #dfdfdf;
  449. border-radius: 35rpx;
  450. color: #999999;
  451. font-weight: 500;
  452. font-size: 26rpx;
  453. line-height: normal;
  454. }
  455. .disabled-btn {
  456. width: 668rpx;
  457. height: 70rpx;
  458. background: #dddddd;
  459. border-radius: 35rpx;
  460. color: #999999;
  461. font-weight: 500;
  462. font-size: 28rpx;
  463. line-height: normal;
  464. }
  465. .join-btn {
  466. width: 668rpx;
  467. height: 70rpx;
  468. background: linear-gradient(90deg, #ff6000 0%, #fe832a 100%);
  469. box-shadow: 0px 8rpx 6rpx 0px rgba(255, 104, 4, 0.22);
  470. border-radius: 35rpx;
  471. color: #fff;
  472. font-weight: 500;
  473. font-size: 28rpx;
  474. line-height: normal;
  475. }
  476. .detail-cell-wrap {
  477. width: 100%;
  478. padding: 10rpx 20rpx;
  479. box-sizing: border-box;
  480. border-top: 2rpx solid #dfdfdf;
  481. background-color: #fff;
  482. // min-height: 60rpx;
  483. .label-text {
  484. font-size: 28rpx;
  485. font-weight: 400;
  486. }
  487. .cell-content {
  488. font-size: 28rpx;
  489. font-weight: 500;
  490. color: $dark-6;
  491. }
  492. .right-forwrad-icon {
  493. font-size: 28rpx;
  494. font-weight: 500;
  495. color: $dark-9;
  496. }
  497. }
  498. </style>