group-goods-info.vue 9.3 KB

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