group-goods-info.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <template>
  2. <view class="flex-common-css iPhone-bottom box-border-box">
  3. <Nav :title="shop_name" :bgckgroundBox='"transparent"' leftIconColor="#333" titleColor="#333"></Nav>
  4. <uni-popup ref="popup" type="top" border-radius="0 0 10px 10px">
  5. <view class="pop-box bgc-f" :style="[{'padding-top': popTop + 'px'}]">
  6. <view class="p-24 box-border-box">
  7. <view class="fs-32 fc-3 mb-20">
  8. 全部团购
  9. </view>
  10. <view class="align-items-center flex-wrap-wrap">
  11. <view class="w-50 p-24 box-border-box text-overflow-ellipsis-one"
  12. v-for="(item,index) in sift_data" :key="index" :class="{'active':isActive==index}"
  13. @click="popChenked(index)">
  14. {{item.title}}
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </uni-popup>
  20. <view class="sift-box p-12-24 box-border-box align-items-center">
  21. <scroll-view scroll-x="true" scroll-with-animation :scroll-left="scrollLeft" class="flex-1 tab-scroll">
  22. <view class="max-w-200 text-overflow-ellipsis-one tab-scroll_item fs-28"
  23. v-for="(item,index) in sift_data" :key="index" :class="{'active':isActive==index}"
  24. @click="chenked(index)">
  25. {{item.title}}
  26. </view>
  27. </scroll-view>
  28. <uni-icons @click="openPop" class="flex-shrink0 ml-16" type="bars" size="22"></uni-icons>
  29. </view>
  30. <swiper @change="change" :current="isActive" class="swiper-content common-view-css">
  31. <swiper-item class="swiperitem-content w-h-100" v-for="(item,index) in swiper_data" :key="index">
  32. <view class="w-h-100 flex-direction">
  33. <scroll-view v-if="item!==''" :scroll-y="true" class="scroll-view-css p-12-24 box-border-box">
  34. <view class="item-goods-box b-rad-20 bgc-f p-24 box-border-box mb-32">
  35. <view class="fs-36 fw-600 fc-3 letter-spacing-3 mb-18">
  36. {{item.title}}
  37. </view>
  38. <view class="p-b-20 mb-20 b-b-F9F9F9">
  39. <swiper class="swiper-goods">
  40. <swiper-item class="swiper-item-goods"
  41. v-for="(goods_item, goods_index) in item.image" :key="goods_index">
  42. <image class="goods-img" :src="goods_item" mode="aspectFill"></image>
  43. </swiper-item>
  44. </swiper>
  45. </view>
  46. <view class="align-items-flex-start mb-16" v-show="item.is_quota == 1">
  47. <view class="mr-18 fs-26">
  48. 限购
  49. </view>
  50. <view class="align-items-center">
  51. <view class="mr-8 fs-26">
  52. 每人限购{{item.quota_num}}张,
  53. </view>
  54. </view>
  55. </view>
  56. <view class="align-items-flex-start mb-16">
  57. <view class="mr-18 fs-26">
  58. 限用
  59. </view>
  60. <view class="align-items-center">
  61. <view class="fs-26" v-show="item.restricted === 1">
  62. 不限用
  63. </view>
  64. <view class="fs-26" v-show="item.restricted === 2">
  65. 每张卷限{{item.restricted_num}}人使用
  66. </view>
  67. <view class="fs-26" v-show="item.restricted === 3">
  68. 每桌限用{{item.restricted_num}}张
  69. </view>
  70. </view>
  71. </view>
  72. <view class="align-items-flex-start mb-16">
  73. <view class="mr-18 fs-26">
  74. 须知
  75. </view>
  76. <view class="fs-26" v-show="item.usable_time == 1">
  77. 24小时可用
  78. </view>
  79. <view class="" v-show="item.usable_time == 2">
  80. {{item.timeData}}
  81. </view>
  82. </view>
  83. <view class="align-items-flex-start">
  84. <view class="mr-18 fs-26">
  85. 保障
  86. </view>
  87. <view class="">
  88. 随时退,过期自动退
  89. </view>
  90. </view>
  91. </view>
  92. <view class="fs-34 fc-3 mb-18">
  93. 团购详情
  94. </view>
  95. <view class="item-goods-box b-rad-20 bgc-f p-24 box-border-box mb-32">
  96. <view class="item-info" v-for="(item_item,item_index) in item.item" :key="item_index">
  97. <view class="align-items-center mb-10">
  98. <view class="d"></view>
  99. <view class="fs-32 fw-b">
  100. {{item_item.name}}
  101. </view>
  102. </view>
  103. <view class="align-items-center flex-justify-space goods-info"
  104. v-for="(goods_item,goods_index) in item_item.goods" :key="goods_index">
  105. <div class="align-items-center">
  106. <view class="d d-c"></view>
  107. <view class="fs-28">
  108. {{goods_item.name}}
  109. </view>
  110. </div>
  111. <view class="align-items-center">
  112. <view class="fc-9 mr-18">
  113. ({{goods_item.number}}{{goods_item.unit}})
  114. </view>
  115. <view class="">
  116. ¥{{goods_item.price}}
  117. </view>
  118. </view>
  119. </view>
  120. </view>
  121. <view class="item-info">
  122. <view class="align-items-center mb-10">
  123. <view class="d"></view>
  124. <view class="fs-32 fw-b">
  125. 备注
  126. </view>
  127. </view>
  128. <view class="fs-24">
  129. 温馨提示:套餐用餐前请提前验券
  130. </view>
  131. </view>
  132. </view>
  133. <view class="fs-34 fc-3 mb-18">
  134. 购买须知
  135. </view>
  136. <view class="item-goods-box b-rad-20 bgc-f p-24 box-border-box mb-32">
  137. <view class="mb-10 fs-30 fw-600 fc-3">
  138. 有效期
  139. </view>
  140. <view class="b-b-F9F9F9 pb-10 mb-10" v-if="item.time_type === 1">
  141. {{item.start_time}} 至 {{item.end_time}}
  142. </view>
  143. <view class="b-b-F9F9F9 pb-10 mb-10" v-else>
  144. 购买后{{item.valid_day}}天
  145. </view>
  146. <view class="mb-10 fs-30 fw-600 fc-3">
  147. 使用时间
  148. </view>
  149. <view class="b-b-F9F9F9 pb-10 mb-10">
  150. {{item.usable_time == 1?'24小时可用':item.timeData}}
  151. </view>
  152. <view class="mb-10 fs-30 fw-600 fc-3">
  153. 使用规则
  154. </view>
  155. <view class="align-items-center mb-10"
  156. v-for="(use_message_item,use_message_index) in item.use_message"
  157. :key="use_message_index">
  158. <view class="d"></view>
  159. <view class="">
  160. {{use_message_item.notice}}
  161. </view>
  162. </view>
  163. </view>
  164. </scroll-view>
  165. <view class="but-box p-24 box-border-box bgc-f">
  166. <view class="but bgc-3 align-items-center flex-justify-space plr-24 box-border-box">
  167. <view class="fc-f fs-32">
  168. 折后 <text class="fc-f fs-34">¥</text>{{item.price}}
  169. </view>
  170. <view class="but-right fc-f fs-32 bgc-41ABF5" @click="goToUrl">
  171. 立即团购
  172. </view>
  173. </view>
  174. </view>
  175. </view>
  176. </swiper-item>
  177. </swiper>
  178. </view>
  179. </template>
  180. <script>
  181. import {
  182. groupInfo,
  183. groupIndexGoods
  184. } from '@/api/group.js'
  185. export default {
  186. components: {},
  187. data() {
  188. return {
  189. shop_id: '',
  190. goods_id: '',
  191. shop_name: '',
  192. sift_data: [],
  193. sift_id: 0,
  194. currentindex: 0,
  195. contentScrollW: 0, // 导航区宽度
  196. scrollLeft: 0, // 横向滚动条位置
  197. isActive: 0,
  198. swiper_data: [],
  199. goodsList: [],
  200. popTop: 0
  201. };
  202. },
  203. onLoad(data) {
  204. if (data) {
  205. this.shop_id = data.shop_id
  206. this.goods_id = data.goods_id
  207. this.shop_name = data.shop_name
  208. // this.groupInfo()
  209. this.groupIndexGoods()
  210. }
  211. // console.log(data);
  212. },
  213. watch: {
  214. // swiper与上面选项卡联动
  215. currentindex(newval) {
  216. this.isActive = newval;
  217. this.scrollLeft = 0;
  218. // 滑动swiper后,每个选项距离其父元素最左侧的距离
  219. console.log(newval);
  220. if (newval === 0) {
  221. this.scrollLeft = this.sift_data[newval].left - 60
  222. } else {
  223. this.scrollLeft = (this.sift_data[newval].left - ((this.sift_data[(newval - 1)].width) / 2)) - 60
  224. }
  225. // for (let i = 0; i < newval - 1; i++) {
  226. // this.scrollLeft += (this.sift_data[i].width + (this.sift_data[i].left))
  227. console.log(this.scrollLeft);
  228. // };
  229. },
  230. },
  231. mounted() {
  232. this.$nextTick(() => {
  233. setTimeout(() => {
  234. this.getScrollW()
  235. }, 500)
  236. uni.getSystemInfo({
  237. success: (e) => {
  238. let statusBarH = e.statusBarHeight + 10
  239. let custom = 0;
  240. custom = wx.getMenuButtonBoundingClientRect()
  241. let customBarH = custom.height;
  242. this.popTop = statusBarH + customBarH;
  243. }
  244. })
  245. })
  246. },
  247. methods: {
  248. goToUrl() {
  249. uni.navigateTo({
  250. url: '/pages-buy/group-pay?shop_id=' + this.sift_data[this.isActive].shop_id + '&goods_id=' +
  251. this.sift_data[this.isActive].id
  252. });
  253. },
  254. openPop() {
  255. this.$refs.popup.open()
  256. },
  257. setTimeData(timeData) {
  258. let time = ''
  259. let array = ''
  260. timeData.forEach((v, k) => {
  261. v.forEach((i, j) => {
  262. let timeTwo = ''
  263. if (j == 0 || j == 3) {
  264. timeTwo = i + '-'
  265. } else {
  266. timeTwo = i
  267. }
  268. array = array + timeTwo
  269. })
  270. if (timeData.length === k + 1) {
  271. time = time + array + '可用'
  272. } else {
  273. time = time + array + '可用' + ','
  274. }
  275. array = ''
  276. })
  277. console.log(time);
  278. return time
  279. },
  280. change(e) {
  281. const {
  282. current
  283. } = e.detail;
  284. console.log(current);
  285. this.currentindex = current;
  286. },
  287. getScrollW() {
  288. const query = uni.createSelectorQuery().in(this);
  289. query.select('.tab-scroll').boundingClientRect(data => {
  290. // 拿到 scroll-view 组件宽度
  291. this.contentScrollW = data.width
  292. // console.log(data, '00000000000000');
  293. }).exec();
  294. query.selectAll('.tab-scroll_item').boundingClientRect(data => {
  295. let dataLen = data.length;
  296. // console.log(data, '11111111111111111111');
  297. for (let i = 0; i < dataLen; i++) {
  298. // scroll-view 子元素组件距离左边栏的距离
  299. this.sift_data[i].left = data[i].left;
  300. // scroll-view 子元素组件宽度
  301. this.sift_data[i].width = data[i].width
  302. // console.log(this.sift_data);
  303. }
  304. }).exec()
  305. },
  306. popChenked(index) {
  307. this.chenked(index)
  308. this.$refs.popup.close()
  309. },
  310. chenked(index) {
  311. this.isActive = index;
  312. this.scrollLeft = 0;
  313. console.log(this.scrollLeft);
  314. for (let i = 0; i < index - 1; i++) {
  315. this.scrollLeft += this.sift_data[i].width
  316. console.log(this.scrollLeft);
  317. };
  318. },
  319. groupIndexGoods() {
  320. groupIndexGoods({
  321. goods_id: this.goods_id,
  322. shop_id: this.shop_id
  323. }).then((res) => {
  324. if (res.code === 1) {
  325. this.sift_data = res.data
  326. this.swiper_data = []
  327. this.processGroupInfo(0);
  328. }
  329. })
  330. },
  331. processGroupInfo(index) {
  332. if (index < this.sift_data.length) {
  333. const v = this.sift_data[index];
  334. this.groupInfo(v.id).then(() => {
  335. this.processGroupInfo(index + 1);
  336. });
  337. }
  338. },
  339. groupInfo(goodsId) {
  340. return new Promise((resolve) => {
  341. groupInfo({
  342. id: goodsId,
  343. shop_id: this.shop_id
  344. }).then((res) => {
  345. if (res.code === 1) {
  346. if (res.data.usable_time === 2) {
  347. res.data.timeData = this.setTimeData(res.data.usable_time_arr)
  348. }
  349. this.swiper_data.push(res.data);
  350. }
  351. resolve();
  352. });
  353. });
  354. }
  355. },
  356. }
  357. </script>
  358. <style lang="scss" scoped>
  359. .w-h-100 {
  360. width: 100%;
  361. height: 100%;
  362. }
  363. .overflow-auto {
  364. overflow: auto;
  365. }
  366. .but-box {
  367. width: 100%;
  368. }
  369. .but {
  370. width: 100%;
  371. height: 90rpx;
  372. line-height: 90rpx;
  373. border-radius: 200rpx;
  374. position: relative;
  375. }
  376. .but-right {
  377. position: absolute;
  378. right: 0;
  379. top: 0;
  380. width: 30%;
  381. height: 90rpx;
  382. line-height: 90rpx;
  383. padding: 0 24rpx 0 0;
  384. box-sizing: border-box;
  385. border-radius: 0 200rpx 200rpx 0;
  386. text-align: center;
  387. }
  388. .w-50 {
  389. width: 50%;
  390. }
  391. .pop-box {
  392. width: 100%;
  393. max-height: 40vh;
  394. overflow: auto;
  395. border-radius: 0 0 20rpx 20rpx;
  396. }
  397. .d {
  398. width: 10rpx;
  399. height: 10rpx;
  400. border-radius: 50%;
  401. background: #ccc;
  402. margin-right: 20rpx;
  403. }
  404. .d-c {
  405. background: transparent;
  406. }
  407. .swiper-goods {
  408. width: 100%;
  409. height: 470rpx;
  410. border-radius: 20rpx;
  411. }
  412. .swiper-item-goods {
  413. display: block;
  414. height: 470rpx;
  415. border-radius: 20rpx;
  416. }
  417. .goods-img {
  418. width: 100%;
  419. height: 100%;
  420. border-radius: 20rpx;
  421. }
  422. .active {
  423. position: relative;
  424. color: #57CAFF;
  425. font-weight: 600;
  426. }
  427. .tab-scroll {
  428. width: calc(100% - 62rpx);
  429. white-space: nowrap;
  430. }
  431. .box-b {
  432. width: 100%;
  433. height: 100vh;
  434. background: orangered;
  435. }
  436. .max-w-200 {
  437. max-width: 310rpx;
  438. // min-width: 200rpx;
  439. text-align: center;
  440. margin-right: 60rpx;
  441. display: inline-block;
  442. }
  443. .max-w-200:last-child {
  444. margin-right: 0;
  445. }
  446. .goods-info {
  447. margin-bottom: 10rpx;
  448. }
  449. .goods-info:last-child {
  450. padding-bottom: 10rpx;
  451. margin-bottom: 10rpx;
  452. border-bottom: 1rpx solid #F9F9F9;
  453. }
  454. </style>