detail.vue 15 KB

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