detail.vue 14 KB

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