detail.vue 14 KB

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