detail.vue 14 KB

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