detail.vue 14 KB

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