group-goods-info.vue 12 KB

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