detail.vue 14 KB

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