group-goods-info.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. <template>
  2. <view class="flex-common-css iPhone-bottom box-border-box">
  3. <Nav :title="shop_name" :bgckgroundBox='"transparent"' leftColor="#fff" titleColor="#fff"></Nav>
  4. <image src="https://sjz-school.oss-cn-chengdu.aliyuncs.com/webImages/bg-2.png" mode="" class="bg-img"></image>
  5. <uni-popup ref="popup" type="top" border-radius="0 0 10px 10px">
  6. <view class="pop-box bgc-f" :style="[{'padding-top': popTop + 'px'}]">
  7. <view class="p-24 box-border-box">
  8. <view class="fs-32 fc-3 mb-20">
  9. 全部团购
  10. </view>
  11. <view class="align-items-center flex-wrap-wrap">
  12. <view class="w-50 p-24 box-border-box text-overflow-ellipsis-one"
  13. v-for="(item,index) in sift_data" :key="index" :class="{'active':isActive==index}"
  14. @click="popChenked(index)">
  15. {{item.title}}
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </uni-popup>
  21. <view class="sift-box p-12-24 box-border-box align-items-center">
  22. <scroll-view scroll-x="true" scroll-with-animation :scroll-left="scrollLeft" class="flex-1 tab-scroll">
  23. <view class="max-w-200 text-overflow-ellipsis-one tab-scroll_item" v-for="(item,index) in sift_data"
  24. :key="index" @click="chenked(index)">
  25. <view class="text-overflow-ellipsis-one fs-28 fc-f mb-16">
  26. {{item.title}}
  27. </view>
  28. <view v-if="isActive==index" class="title-hr bgc-f"></view>
  29. </view>
  30. </scroll-view>
  31. <!-- <uni-icons @click="openPop" class="flex-shrink0 ml-16 z-2" type="bars" size="22"></uni-icons> -->
  32. </view>
  33. <swiper @change="change" :current="isActive" class="swiper-content common-view-css">
  34. <swiper-item class="swiperitem-content w-h-100" v-for="(item,index) in swiper_data" :key="index">
  35. <view class="w-h-100 flex-direction">
  36. <scroll-view v-if="item!==''" :scroll-y="true" class="scroll-view-css p-12-24 box-border-box">
  37. <swiper class="swiper-goods mb-30">
  38. <swiper-item class="swiper-item-goods" v-for="(goods_item, goods_index) in item.image"
  39. :key="goods_index">
  40. <image class="goods-img" :src="goods_item" mode="aspectFill"></image>
  41. </swiper-item>
  42. </swiper>
  43. <view class="item-goods-box b-rad-20 bgc-f p-24 box-border-box mb-32">
  44. <view class="align-items-center flex-justify-space mb-30">
  45. <view class="fs-32 fw-b fc-0 letter-spacing-3">
  46. {{item.title}}
  47. </view>
  48. <view class="xl-box">
  49. <image src="/pages-buy/static/xl.png" mode="" class="xl-img"></image>
  50. <view class="fc-F7663A fs-24 text-align-center z-2">
  51. 已拼{{item.sales}}+
  52. </view>
  53. </view>
  54. </view>
  55. <view class="align-items-center flex-justify-space mb-60 fg-box">
  56. <view class="by-box"></view>
  57. <view class="fg-hr"></view>
  58. <view class="by-box-two"></view>
  59. </view>
  60. <view class="align-items-flex-start mb-16" v-show="item.is_quota == 1">
  61. <view class="mr-24 fs-28 fw-b fc-0">
  62. 使用限制
  63. </view>
  64. <view class="align-items-center">
  65. <view class="mr-8 fs-28 fc-0">
  66. 每人限购{{item.quota_num}}张,
  67. </view>
  68. </view>
  69. </view>
  70. <view class="align-items-flex-start mb-16">
  71. <view class="mr-24 fs-28 fw-b fc-0">
  72. 使用限制
  73. </view>
  74. <view class="align-items-center">
  75. <view class="fs-28 fc-0" v-show="item.restricted === 1">
  76. 不限用
  77. </view>
  78. <view class="fs-28 fc-0" v-show="item.restricted === 2">
  79. 每张卷限{{item.restricted_num}}人使用
  80. </view>
  81. <view class="fs-28 fc-0" v-show="item.restricted === 3">
  82. 每桌限用{{item.restricted_num}}张
  83. </view>
  84. </view>
  85. </view>
  86. <view class="align-items-flex-start mb-16">
  87. <view class="mr-24 fs-28 fw-b fc-0">
  88. 消费须知
  89. </view>
  90. <view class="fs-28 fc-0" v-show="item.usable_time == 1">
  91. 24小时可用
  92. </view>
  93. <view class="fs-28 fc-0" v-show="item.usable_time == 2">
  94. {{item.timeData}}
  95. </view>
  96. </view>
  97. <view class="align-items-flex-start">
  98. <view class="mr-24 fs-28 fw-b fc-0">
  99. 服务保障
  100. </view>
  101. <view class="fs-28 fc-0">
  102. 随时退,过期自动退
  103. </view>
  104. </view>
  105. </view>
  106. <view class="align-items-center flex-justify-center mb-32">
  107. <view class="tm-hr"></view>
  108. <view class="fs-28 fc-0 plr-12">
  109. 团购详情
  110. </view>
  111. <view class="tm-hr"></view>
  112. </view>
  113. <view class="item-goods-box b-rad-20 bgc-f p-24 box-border-box mb-32">
  114. <view class="item-info" v-for="(item_item,item_index) in item.item" :key="item_index">
  115. <view class="align-items-center mb-10">
  116. <view class="d"></view>
  117. <view class="fs-28 fw-b">
  118. {{item_item.name}}
  119. </view>
  120. </view>
  121. <view class="align-items-center flex-justify-space goods-info"
  122. v-for="(goods_item,goods_index) in item_item.goods" :key="goods_index">
  123. <div class="align-items-center">
  124. <view class="d d-c"></view>
  125. <view class="fs-24">
  126. {{goods_item.name}}
  127. </view>
  128. </div>
  129. <view class="align-items-center">
  130. <view class="fc-a mr-18 fs-24">
  131. ({{goods_item.number}}{{goods_item.unit}})
  132. </view>
  133. <view class="w-100 text-align-right fs-24">
  134. ¥{{goods_item.price}}
  135. </view>
  136. </view>
  137. </view>
  138. </view>
  139. <view class="item-info">
  140. <view class="align-items-center mb-10">
  141. <view class="d"></view>
  142. <view class="fs-28 fw-b">
  143. 备注
  144. </view>
  145. </view>
  146. <view class="fs-24">
  147. 温馨提示:套餐使用前请提前验券
  148. </view>
  149. </view>
  150. </view>
  151. <!-- <view class="fs-34 fc-3 mb-18">
  152. 购买须知
  153. </view> -->
  154. <view class="item-goods-box b-rad-20 bgc-f p-38-20-24 box-border-box mb-32">
  155. <view class="align-items-center pb-36 mb-24 b-b-EAEAEC">
  156. <image src="/pages-buy/static/gmxz.png" mode="" class="gmxz-img mr-10"></image>
  157. <view class="fs-28 fc-F7663A">
  158. 购买须知
  159. </view>
  160. </view>
  161. <view class="align-items-center mb-24">
  162. <view class="d"></view>
  163. <view class="fs-28 fw-600 fc-3">
  164. 有效期
  165. </view>
  166. </view>
  167. <view class="align-items-center mb-40">
  168. <view class="d d-c"></view>
  169. <view class="fs-24" v-if="item.time_type === 1">
  170. {{item.start_time}} 至 {{item.end_time}}
  171. </view>
  172. <view class="fs-24" v-else>
  173. 购买后{{item.valid_day}}天
  174. </view>
  175. </view>
  176. <view class="align-items-center mb-24">
  177. <view class="d"></view>
  178. <view class="fs-28 fw-600 fc-3">
  179. 使用时间
  180. </view>
  181. </view>
  182. <view class="align-items-center mb-40">
  183. <view class="d d-c"></view>
  184. <view class="fs-24">
  185. {{item.usable_time == 1?'24小时可用':item.timeData}}
  186. </view>
  187. </view>
  188. <view class="align-items-center mb-24">
  189. <view class="d"></view>
  190. <view class="fs-28 fw-600 fc-3">
  191. 使用规则
  192. </view>
  193. </view>
  194. <view class="align-items-center mb-30"
  195. v-for="(use_message_item,use_message_index) in item.use_message"
  196. :key="use_message_index">
  197. <view class="d d-c"></view>
  198. <image src="/pages-buy/static/right.png" mode="" class="right-icon"></image>
  199. <view class="fs-24">
  200. {{use_message_item.notice}}
  201. </view>
  202. </view>
  203. </view>
  204. </scroll-view>
  205. <view class="but-box box-border-box">
  206. <view class="but align-items-center flex-justify-space">
  207. <view class="align-items-baseline pl-42 box-border-box">
  208. <view class="fs-24 fc-f">
  209. 折后 ¥
  210. </view>
  211. <view class="fs-40 fc-f fw-b mr-12">
  212. {{item.price}}
  213. </view>
  214. <view class="zk-box text-align-center">
  215. <image src="/pages-buy/static/zk.png" mode="" class="zk-img"></image>
  216. <view class="fs-24 fc-F7663A z-2">
  217. {{toFixedOne(item.price,item.line_price)}}折
  218. </view>
  219. </view>
  220. </view>
  221. <view class="ljtg-box text-align-center" @click="goToUrl">
  222. <image src="/pages-buy/static/ljtg.png" mode="" class="ljtg-bg"></image>
  223. <view class="fc-F6531E fs-32 fw-b z-2">
  224. 立即团购
  225. </view>
  226. </view>
  227. </view>
  228. </view>
  229. </view>
  230. </swiper-item>
  231. </swiper>
  232. </view>
  233. </template>
  234. <script>
  235. import {
  236. groupInfo,
  237. groupIndexGoods
  238. } from '@/api/group.js'
  239. export default {
  240. components: {},
  241. data() {
  242. return {
  243. shop_id: '',
  244. goods_id: '',
  245. shop_name: '',
  246. sift_data: [],
  247. sift_id: 0,
  248. currentindex: 0,
  249. contentScrollW: 0, // 导航区宽度
  250. scrollLeft: 0, // 横向滚动条位置
  251. isActive: 0,
  252. swiper_data: [],
  253. goodsList: [],
  254. popTop: 0
  255. };
  256. },
  257. onLoad(data) {
  258. if (data) {
  259. this.shop_id = data.shop_id
  260. this.goods_id = data.goods_id
  261. this.shop_name = data.shop_name
  262. // this.groupInfo()
  263. this.groupIndexGoods()
  264. }
  265. // console.log(data);
  266. },
  267. watch: {
  268. // swiper与上面选项卡联动
  269. currentindex(newval) {
  270. this.isActive = newval;
  271. this.scrollLeft = 0;
  272. // 滑动swiper后,每个选项距离其父元素最左侧的距离
  273. console.log(newval);
  274. if (newval === 0) {
  275. this.scrollLeft = this.sift_data[newval].left - 60
  276. } else {
  277. this.scrollLeft = (this.sift_data[newval].left - ((this.sift_data[(newval - 1)].width) / 2)) - 60
  278. }
  279. // for (let i = 0; i < newval - 1; i++) {
  280. // this.scrollLeft += (this.sift_data[i].width + (this.sift_data[i].left))
  281. console.log(this.scrollLeft);
  282. // };
  283. },
  284. },
  285. mounted() {
  286. this.$nextTick(() => {
  287. setTimeout(() => {
  288. this.getScrollW()
  289. }, 500)
  290. uni.getSystemInfo({
  291. success: (e) => {
  292. let statusBarH = e.statusBarHeight + 10
  293. let custom = 0;
  294. custom = wx.getMenuButtonBoundingClientRect()
  295. let customBarH = custom.height;
  296. this.popTop = statusBarH + customBarH;
  297. }
  298. })
  299. })
  300. },
  301. methods: {
  302. toFixedOne(price, line_price) {
  303. let num = (Number(price) / Number(line_price) * 10).toFixed(1)
  304. // 转换为字符串,以便进行操作
  305. var numStr = num.toString();
  306. // 检查是否有小数部分
  307. if (numStr.indexOf('.') !== -1) {
  308. // 有小数部分,则移除多余的零
  309. numStr = numStr.replace(/0+$/, '').replace(/\.$/, '');
  310. }
  311. // 返回处理后的数字或整数
  312. return parseFloat(numStr);
  313. },
  314. goToUrl() {
  315. uni.navigateTo({
  316. url: '/pages-buy/group-pay?shop_id=' + this.sift_data[this.isActive].shop_id + '&goods_id=' +
  317. this.sift_data[this.isActive].id
  318. });
  319. },
  320. openPop() {
  321. this.$refs.popup.open()
  322. },
  323. setTimeData(timeData) {
  324. let time = ''
  325. let array = ''
  326. timeData.forEach((v, k) => {
  327. v.forEach((i, j) => {
  328. let timeTwo = ''
  329. if (j == 0 || j == 3) {
  330. timeTwo = i + '-'
  331. } else {
  332. timeTwo = i
  333. }
  334. array = array + timeTwo
  335. })
  336. if (timeData.length === k + 1) {
  337. time = time + array + '可用'
  338. } else {
  339. time = time + array + '可用' + ','
  340. }
  341. array = ''
  342. })
  343. console.log(time);
  344. return time
  345. },
  346. change(e) {
  347. const {
  348. current
  349. } = e.detail;
  350. console.log(current);
  351. this.currentindex = current;
  352. },
  353. getScrollW() {
  354. const query = uni.createSelectorQuery().in(this);
  355. query.select('.tab-scroll').boundingClientRect(data => {
  356. // 拿到 scroll-view 组件宽度
  357. this.contentScrollW = data.width
  358. // console.log(data, '00000000000000');
  359. }).exec();
  360. query.selectAll('.tab-scroll_item').boundingClientRect(data => {
  361. let dataLen = data.length;
  362. // console.log(data, '11111111111111111111');
  363. for (let i = 0; i < dataLen; i++) {
  364. // scroll-view 子元素组件距离左边栏的距离
  365. this.sift_data[i].left = data[i].left;
  366. // scroll-view 子元素组件宽度
  367. this.sift_data[i].width = data[i].width
  368. // console.log(this.sift_data);
  369. }
  370. }).exec()
  371. },
  372. popChenked(index) {
  373. this.chenked(index)
  374. this.$refs.popup.close()
  375. },
  376. chenked(index) {
  377. this.isActive = index;
  378. this.scrollLeft = 0;
  379. console.log(this.scrollLeft);
  380. for (let i = 0; i < index - 1; i++) {
  381. this.scrollLeft += this.sift_data[i].width + (this.sift_data[i].width / 2)
  382. console.log(this.scrollLeft);
  383. };
  384. },
  385. groupIndexGoods() {
  386. groupIndexGoods({
  387. goods_id: this.goods_id,
  388. shop_id: this.shop_id
  389. }).then((res) => {
  390. if (res.code === 1) {
  391. this.sift_data = res.data
  392. this.swiper_data = []
  393. this.processGroupInfo(0);
  394. }
  395. })
  396. },
  397. processGroupInfo(index) {
  398. if (index < this.sift_data.length) {
  399. const v = this.sift_data[index];
  400. this.groupInfo(v.id).then(() => {
  401. this.processGroupInfo(index + 1);
  402. });
  403. }
  404. },
  405. groupInfo(goodsId) {
  406. return new Promise((resolve) => {
  407. groupInfo({
  408. id: goodsId,
  409. shop_id: this.shop_id
  410. }).then((res) => {
  411. if (res.code === 1) {
  412. if (res.data.usable_time === 2) {
  413. res.data.timeData = this.setTimeData(res.data.usable_time_arr)
  414. }
  415. this.swiper_data.push(res.data);
  416. }
  417. resolve();
  418. });
  419. });
  420. }
  421. },
  422. }
  423. </script>
  424. <style lang="scss" scoped>
  425. .ljtg-box {
  426. width: 247rpx;
  427. height: 100rpx;
  428. line-height: 100rpx;
  429. position: relative;
  430. }
  431. .ljtg-bg {
  432. position: absolute;
  433. right: 0;
  434. top: 0;
  435. width: 247rpx;
  436. height: 100rpx;
  437. }
  438. .zk-box {
  439. width: 83rpx;
  440. height: 32rpx;
  441. line-height: 32rpx;
  442. position: relative;
  443. }
  444. .zk-img {
  445. position: absolute;
  446. left: 0;
  447. top: 0;
  448. width: 83rpx;
  449. height: 32rpx;
  450. }
  451. .gmxz-img {
  452. width: 27rpx;
  453. height: 27rpx;
  454. }
  455. .fg-box {
  456. position: relative;
  457. }
  458. .by-box {
  459. width: 48rpx;
  460. height: 48rpx;
  461. border-radius: 50%;
  462. background: #F5F5F5;
  463. position: absolute;
  464. left: -48rpx;
  465. top: 0;
  466. }
  467. .fg-hr {
  468. width: 100%;
  469. height: 1rpx;
  470. background: #EAEAEC;
  471. position: relative;
  472. top: 24rpx;
  473. }
  474. .by-box-two {
  475. width: 48rpx;
  476. height: 48rpx;
  477. border-radius: 50%;
  478. background: #F5F5F5;
  479. position: absolute;
  480. right: -48rpx;
  481. top: 0;
  482. }
  483. .tm-hr {
  484. width: 55rpx;
  485. height: 1rpx;
  486. background: #000;
  487. }
  488. .xl-box {
  489. width: 126rpx;
  490. height: 60rpx;
  491. position: absolute;
  492. right: -3rpx;
  493. top: 16rpx;
  494. padding-top: 12rpx;
  495. }
  496. .xl-img {
  497. width: 126rpx;
  498. height: 60rpx;
  499. position: absolute;
  500. top: 0;
  501. right: 0;
  502. z-index: 1;
  503. }
  504. .item-goods-box {
  505. position: relative;
  506. }
  507. .title-hr {
  508. width: 48rpx;
  509. height: 6rpx;
  510. border-radius: 10rpx;
  511. position: relative;
  512. left: calc(50% - 24rpx);
  513. // position: absolute;
  514. // left: 0;
  515. bottom: 0;
  516. }
  517. .bg-img {
  518. position: fixed;
  519. left: 0;
  520. top: 0;
  521. width: 100%;
  522. height: 427rpx;
  523. }
  524. .w-100 {
  525. min-width: 100rpx;
  526. }
  527. .w-h-100 {
  528. width: 100%;
  529. height: 100%;
  530. }
  531. .overflow-auto {
  532. overflow: auto;
  533. }
  534. .but-box {
  535. padding: 0 30rpx 0;
  536. width: 100%;
  537. }
  538. .but {
  539. width: 100%;
  540. height: 100rpx;
  541. line-height: 100rpx;
  542. border-radius: 50rpx;
  543. position: relative;
  544. background: linear-gradient(-90deg, #FF7D2D, #F54F1D);
  545. box-shadow: 0rpx 3rpx 8rpx 0rpx rgba(246, 83, 30, 0.32);
  546. }
  547. .w-50 {
  548. width: 50%;
  549. }
  550. .pop-box {
  551. width: 100%;
  552. max-height: 40vh;
  553. overflow: auto;
  554. border-radius: 0 0 20rpx 20rpx;
  555. }
  556. .d {
  557. width: 6rpx;
  558. height: 6rpx;
  559. border-radius: 50%;
  560. background: #000000;
  561. margin-right: 20rpx;
  562. }
  563. .d-c {
  564. background: transparent;
  565. }
  566. .swiper-goods {
  567. width: 100%;
  568. height: 381rpx;
  569. border-radius: 20rpx;
  570. }
  571. .swiper-item-goods {
  572. display: block;
  573. height: 381rpx;
  574. border-radius: 20rpx;
  575. }
  576. .goods-img {
  577. width: 100%;
  578. height: 100%;
  579. border-radius: 20rpx;
  580. }
  581. .active {
  582. position: relative;
  583. color: #57CAFF;
  584. font-weight: 600;
  585. }
  586. .tab-scroll {
  587. width: 100%;
  588. // width: calc(100% - 62rpx);
  589. white-space: nowrap;
  590. position: relative;
  591. z-index: 2;
  592. }
  593. .box-b {
  594. width: 100%;
  595. height: 100vh;
  596. background: orangered;
  597. }
  598. .max-w-200 {
  599. max-width: 310rpx;
  600. // min-width: 200rpx;
  601. text-align: center;
  602. margin-right: 60rpx;
  603. display: inline-block;
  604. }
  605. .max-w-200:last-child {
  606. margin-right: 0;
  607. }
  608. .goods-info {
  609. margin-bottom: 10rpx;
  610. }
  611. .goods-info:last-child {
  612. padding-bottom: 30rpx;
  613. margin-bottom: 30rpx;
  614. border-bottom: 1rpx solid #EAEAEC;
  615. }
  616. .z-2 {
  617. position: relative;
  618. z-index: 2;
  619. }
  620. .right-icon {
  621. width: 6rpx;
  622. height: 10rpx;
  623. margin-right: 10rpx;
  624. }
  625. </style>