detail.vue 14 KB

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