detail.vue 14 KB

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