group-goods-info.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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 :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" v-for="(goods_item,goods_index) in item_item.goods" :key="goods_index">
  78. <view class="">
  79. {{goods_item.name}}
  80. </view>
  81. <view class="">
  82. {{goods_item.number}}{{goods_item.unit}}
  83. </view>
  84. </view>
  85. </view>
  86. <view class="item-info">
  87. <view class="align-items-center mb-10">
  88. <view class="d"></view>
  89. <view class="fs-32">
  90. 备注
  91. </view>
  92. </view>
  93. <view class="fs-24">
  94. 温馨提示:套餐用餐前请提前验券
  95. </view>
  96. </view>
  97. </view>
  98. <view class="fs-34 fc-3 mb-18">
  99. 购买须知
  100. </view>
  101. <view class="item-goods-box b-rad-20 bgc-f p-24 box-border-box mb-32">
  102. <view class="mb-10 fs-30 fw-600 fc-3">
  103. 有效期
  104. </view>
  105. <view class="b-b-F9F9F9 pb-10 mb-10" v-if="item.time_type === 1">
  106. {{item.start_time}} 至 {{item.end_time}}
  107. </view>
  108. <view class="b-b-F9F9F9 pb-10 mb-10" v-else>
  109. 购买后{{item.valid_day}}天
  110. </view>
  111. <view class="mb-10 fs-30 fw-600 fc-3">
  112. 使用时间
  113. </view>
  114. <view class="b-b-F9F9F9 pb-10 mb-10">
  115. {{item.usable_time == 1?'24小时可用':item.timeData}}
  116. </view>
  117. <view class="mb-10 fs-30 fw-600 fc-3">
  118. 使用规则
  119. </view>
  120. <view class="align-items-center mb-10" v-for="(use_message_item,use_message_index) in item.use_message" :key="use_message_index">
  121. <view class="d"></view>
  122. <view class="">
  123. {{use_message_item.notice}}
  124. </view>
  125. </view>
  126. </view>
  127. </scroll-view>
  128. </swiper-item>
  129. </swiper>
  130. </view>
  131. </template>
  132. <script>
  133. import {
  134. groupInfo,
  135. groupIndexGoods
  136. } from '@/api/group.js'
  137. export default {
  138. components: {},
  139. data() {
  140. return {
  141. shop_id: '',
  142. goods_id: '',
  143. shop_name: '',
  144. sift_data: [],
  145. sift_id: 0,
  146. currentindex: 0,
  147. contentScrollW: 0, // 导航区宽度
  148. scrollLeft: 0, // 横向滚动条位置
  149. isActive: 0,
  150. swiper_data: []
  151. };
  152. },
  153. onLoad(data) {
  154. if (data) {
  155. this.shop_id = data.shop_id
  156. this.goods_id = data.goods_id
  157. this.shop_name = data.shop_name
  158. // this.groupInfo()
  159. this.groupIndexGoods()
  160. }
  161. // console.log(data);
  162. },
  163. watch: {
  164. // swiper与上面选项卡联动
  165. currentindex(newval) {
  166. this.isActive = newval;
  167. this.scrollLeft = 0;
  168. // 滑动swiper后,每个选项距离其父元素最左侧的距离
  169. console.log(newval);
  170. if (newval === 0) {
  171. this.scrollLeft = this.sift_data[newval].left - 60
  172. } else {
  173. this.scrollLeft = (this.sift_data[newval].left - ((this.sift_data[(newval - 1)].width) / 2)) - 60
  174. }
  175. // for (let i = 0; i < newval - 1; i++) {
  176. // this.scrollLeft += (this.sift_data[i].width + (this.sift_data[i].left))
  177. console.log(this.scrollLeft);
  178. // };
  179. },
  180. },
  181. mounted() {
  182. this.$nextTick(() => {
  183. setTimeout(() => {
  184. this.getScrollW()
  185. }, 500)
  186. })
  187. },
  188. methods: {
  189. setTimeData(timeData) {
  190. let time = ''
  191. let array = ''
  192. timeData.forEach((v, k) => {
  193. v.forEach((i, j) => {
  194. let timeTwo = ''
  195. if (j == 0 || j == 3) {
  196. timeTwo = i + '-'
  197. } else {
  198. timeTwo = i
  199. }
  200. array = array + timeTwo
  201. })
  202. if (timeData.length === k + 1) {
  203. time = time + array + '可用'
  204. } else {
  205. time = time + array + '可用' + ','
  206. }
  207. array = ''
  208. })
  209. console.log(time);
  210. return time
  211. },
  212. change(e) {
  213. const {
  214. current
  215. } = e.detail;
  216. console.log(current);
  217. this.currentindex = current;
  218. },
  219. getScrollW() {
  220. const query = uni.createSelectorQuery().in(this);
  221. query.select('.tab-scroll').boundingClientRect(data => {
  222. // 拿到 scroll-view 组件宽度
  223. this.contentScrollW = data.width
  224. // console.log(data, '00000000000000');
  225. }).exec();
  226. query.selectAll('.tab-scroll_item').boundingClientRect(data => {
  227. let dataLen = data.length;
  228. // console.log(data, '11111111111111111111');
  229. for (let i = 0; i < dataLen; i++) {
  230. // scroll-view 子元素组件距离左边栏的距离
  231. this.sift_data[i].left = data[i].left;
  232. // scroll-view 子元素组件宽度
  233. this.sift_data[i].width = data[i].width
  234. // console.log(this.sift_data);
  235. }
  236. }).exec()
  237. },
  238. chenked(index) {
  239. this.isActive = index;
  240. this.scrollLeft = 0;
  241. console.log(this.scrollLeft);
  242. for (let i = 0; i < index - 1; i++) {
  243. this.scrollLeft += this.sift_data[i].width
  244. console.log(this.scrollLeft);
  245. };
  246. },
  247. groupIndexGoods() {
  248. groupIndexGoods({
  249. goods_id: this.goods_id,
  250. shop_id: this.shop_id
  251. }).then((res) => {
  252. if (res.code === 1) {
  253. this.sift_data = res.data
  254. this.swiper_data = []
  255. this.sift_data.forEach((v, k) => {
  256. this.groupInfo(v.id)
  257. })
  258. }
  259. })
  260. },
  261. groupInfo(goodsId) {
  262. groupInfo({
  263. id: goodsId,
  264. shop_id: this.shop_id
  265. }).then((res) => {
  266. if (res.code === 1) {
  267. if (res.data.usable_time === 2) {
  268. res.data.timeData = this.setTimeData(res.data.usable_time_arr)
  269. }
  270. this.swiper_data.push(res.data)
  271. }
  272. })
  273. }
  274. },
  275. }
  276. </script>
  277. <style lang="scss" scoped>
  278. .d{
  279. width: 10rpx;
  280. height: 10rpx;
  281. border-radius: 50%;
  282. background: #ccc;
  283. margin-right: 20rpx;
  284. }
  285. .swiper-goods {
  286. width: 100%;
  287. height: 470rpx;
  288. border-radius: 20rpx;
  289. }
  290. .swiper-item-goods {
  291. display: block;
  292. height: 470rpx;
  293. border-radius: 20rpx;
  294. }
  295. .goods-img {
  296. width: 100%;
  297. height: 100%;
  298. border-radius: 20rpx;
  299. }
  300. .active {
  301. position: relative;
  302. color: #57CAFF;
  303. font-weight: 600;
  304. }
  305. .tab-scroll {
  306. width: calc(100% - 62rpx);
  307. white-space: nowrap;
  308. }
  309. .box-b {
  310. width: 100%;
  311. height: 100vh;
  312. background: orangered;
  313. }
  314. .max-w-200 {
  315. max-width: 310rpx;
  316. // min-width: 200rpx;
  317. text-align: center;
  318. margin-right: 60rpx;
  319. display: inline-block;
  320. }
  321. .max-w-200:last-child {
  322. margin-right: 0;
  323. }
  324. .goods-info{
  325. margin-bottom: 10rpx;
  326. }
  327. .goods-info:last-child{
  328. padding-bottom: 10rpx;
  329. margin-bottom: 10rpx;
  330. border-bottom: 1rpx solid #F9F9F9;
  331. }
  332. </style>