detail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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)" 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)" 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/util/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. },
  236. );
  237. });
  238. // 订单详情
  239. function onDetail(orderId) {
  240. sheep.$router.go('/pages/order/detail', {
  241. id: orderId,
  242. });
  243. }
  244. // 去开团
  245. function onCreateGroupon() {
  246. state.grouponAction = 'create';
  247. state.grouponId = 0;
  248. state.showSelectSku = true;
  249. }
  250. // 规格变更
  251. function onSkuChange(e) {
  252. state.selectedSkuPrice = e;
  253. }
  254. // 立即参团
  255. function onJoinGroupon() {
  256. state.grouponAction = 'join';
  257. state.grouponId = state.data.headRecord.activityId;
  258. state.combinationHeadId = state.data.headRecord.id;
  259. state.grouponNum = state.data.headRecord.userSize;
  260. state.showSelectSku = true;
  261. }
  262. // 立即购买
  263. function onBuy(sku) {
  264. sheep.$router.go('/pages/order/confirm', {
  265. data: JSON.stringify({
  266. order_type: 'goods',
  267. combinationActivityId: state.activity.id,
  268. combinationHeadId: state.combinationHeadId,
  269. items: [
  270. {
  271. skuId: sku.id,
  272. count: sku.count,
  273. },
  274. ],
  275. }),
  276. });
  277. }
  278. const endTime = computed(() => {
  279. return useDurationTime(state.data.headRecord.expireTime);
  280. });
  281. // 获取拼团团队详情
  282. async function getGrouponDetail(id) {
  283. const { code, data } = await CombinationApi.getCombinationRecordDetail(id);
  284. if (code === 0) {
  285. state.data = data;
  286. const remainNumber = Number(state.data.headRecord.userSize - state.data.headRecord.userCount);
  287. state.remainNumber = remainNumber > 0 ? remainNumber : 0;
  288. // 获取活动信息
  289. const { data: activity } = await CombinationApi.getCombinationActivity(
  290. data.headRecord.activityId,
  291. );
  292. state.activity = activity;
  293. state.grouponNum = activity.userSize;
  294. // 加载产品信息
  295. const { data: spu } = await SpuApi.getSpuDetail(activity.spuId);
  296. state.goodsId = spu.id;
  297. // 默认显示最低价
  298. activity.products.forEach((product) => {
  299. spu.price = Math.min(spu.price, product.combinationPrice); // 设置 SPU 的最低价格
  300. });
  301. state.goodsInfo = spu;
  302. // 价格、库存使用活动的
  303. spu.skus.forEach((sku) => {
  304. const product = activity.products.find((product) => product.skuId === sku.id);
  305. if (product) {
  306. sku.price = product.combinationPrice;
  307. } else {
  308. // 找不到可能是没配置,则不能发起秒杀
  309. sku.stock = 0;
  310. }
  311. });
  312. } else {
  313. state.data = null;
  314. }
  315. state.loading = false;
  316. }
  317. function onShare() {
  318. showShareModal();
  319. }
  320. onLoad((options) => {
  321. getGrouponDetail(options.id);
  322. });
  323. </script>
  324. <style lang="scss" scoped>
  325. .recharge-box {
  326. position: relative;
  327. margin-bottom: 120rpx;
  328. background: v-bind(headerBg) center/750rpx 100% no-repeat,
  329. linear-gradient(115deg, #f44739 0%, #ff6600 100%);
  330. border-radius: 0 0 5% 5%;
  331. height: 100rpx;
  332. .goods-box {
  333. width: 710rpx;
  334. border-radius: 20rpx;
  335. position: absolute;
  336. left: 20rpx;
  337. box-sizing: border-box;
  338. }
  339. .sales-title {
  340. height: 32rpx;
  341. background: rgba(#ffe0e2, 0.29);
  342. border-radius: 16rpx;
  343. font-size: 24rpx;
  344. font-weight: 400;
  345. padding: 6rpx 20rpx;
  346. color: #f7979c;
  347. }
  348. .num-title {
  349. font-size: 24rpx;
  350. font-weight: 400;
  351. color: #999999;
  352. }
  353. }
  354. .countdown-time {
  355. font-size: 26rpx;
  356. font-weight: 500;
  357. color: #383a46;
  358. .countdown-h {
  359. font-size: 24rpx;
  360. font-family: OPPOSANS;
  361. font-weight: 500;
  362. color: #ffffff;
  363. padding: 0 4rpx;
  364. margin-left: 16rpx;
  365. height: 40rpx;
  366. background: linear-gradient(90deg, #ff6000 0%, #fe832a 100%);
  367. border-radius: 6rpx;
  368. }
  369. .countdown-num {
  370. font-size: 24rpx;
  371. font-family: OPPOSANS;
  372. font-weight: 500;
  373. color: #ffffff;
  374. width: 40rpx;
  375. height: 40rpx;
  376. background: linear-gradient(90deg, #ff6000 0%, #fe832a 100%);
  377. border-radius: 6rpx;
  378. }
  379. }
  380. .countdown-box {
  381. // height: 364rpx;
  382. background: #ffffff;
  383. border-radius: 10rpx;
  384. box-sizing: border-box;
  385. .countdown-title {
  386. font-size: 28rpx;
  387. font-weight: 500;
  388. color: #333333;
  389. .cicon-check-round {
  390. color: #42b111;
  391. margin-right: 24rpx;
  392. }
  393. .cicon-info {
  394. color: #d71e08;
  395. margin-right: 24rpx;
  396. }
  397. .num {
  398. color: #ff6000;
  399. }
  400. }
  401. .header-avatar {
  402. width: 86rpx;
  403. height: 86rpx;
  404. background: #ececec;
  405. border-radius: 50%;
  406. border: 4rpx solid #edc36c;
  407. position: relative;
  408. box-sizing: border-box;
  409. .avatar-img {
  410. width: 100%;
  411. height: 100%;
  412. border-radius: 50%;
  413. }
  414. .header-tag {
  415. width: 72rpx;
  416. height: 36rpx;
  417. font-size: 24rpx;
  418. line-height: nor;
  419. background: linear-gradient(132deg, #f3dfb1, #f3dfb1, #ecbe60);
  420. border-radius: 16rpx;
  421. position: absolute;
  422. left: 4rpx;
  423. top: -36rpx;
  424. }
  425. }
  426. .default-avatar {
  427. width: 86rpx;
  428. height: 86rpx;
  429. background: #ececec;
  430. border-radius: 50%;
  431. .avatar-img {
  432. width: 100%;
  433. height: 100%;
  434. border-radius: 50%;
  435. }
  436. }
  437. .user-avatar {
  438. width: 86rpx;
  439. height: 86rpx;
  440. background: #ececec;
  441. border-radius: 50%;
  442. }
  443. }
  444. .order-btn {
  445. width: 668rpx;
  446. height: 70rpx;
  447. border: 2rpx solid #dfdfdf;
  448. border-radius: 35rpx;
  449. color: #999999;
  450. font-weight: 500;
  451. font-size: 26rpx;
  452. line-height: normal;
  453. }
  454. .disabled-btn {
  455. width: 668rpx;
  456. height: 70rpx;
  457. background: #dddddd;
  458. border-radius: 35rpx;
  459. color: #999999;
  460. font-weight: 500;
  461. font-size: 28rpx;
  462. line-height: normal;
  463. }
  464. .join-btn {
  465. width: 668rpx;
  466. height: 70rpx;
  467. background: linear-gradient(90deg, #ff6000 0%, #fe832a 100%);
  468. box-shadow: 0px 8rpx 6rpx 0px rgba(255, 104, 4, 0.22);
  469. border-radius: 35rpx;
  470. color: #fff;
  471. font-weight: 500;
  472. font-size: 28rpx;
  473. line-height: normal;
  474. }
  475. .detail-cell-wrap {
  476. width: 100%;
  477. padding: 10rpx 20rpx;
  478. box-sizing: border-box;
  479. border-top: 2rpx solid #dfdfdf;
  480. background-color: #fff;
  481. // min-height: 60rpx;
  482. .label-text {
  483. font-size: 28rpx;
  484. font-weight: 400;
  485. }
  486. .cell-content {
  487. font-size: 28rpx;
  488. font-weight: 500;
  489. color: $dark-6;
  490. }
  491. .right-forwrad-icon {
  492. font-size: 28rpx;
  493. font-weight: 500;
  494. color: $dark-9;
  495. }
  496. }
  497. </style>