index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. <template>
  2. <view class="content">
  3. <zs-header :background="background"></zs-header>
  4. <view class="top-box">
  5. <view class="progress">
  6. <!-- {{ current + 1 + "/" + bannerList.length }} -->
  7. <view class="indicator" v-for="item in advList.length">
  8. <view :class="['block', item == current ? 'active' : '']"> </view>
  9. </view>
  10. </view>
  11. <!-- <view class="goods-box">
  12. <view class="goods-title">
  13. {{ bannerList[current].title }}
  14. </view>
  15. <view class="goods-subtitle">
  16. {{ bannerList[current].subtitle }}
  17. </view>
  18. </view> -->
  19. <swiper class="swiper" @change="swiperChange" :indicator-dots="false" circular :current="current"
  20. indicatorMode="line" :autoplay="true" :interval="3000" :duration="1000">
  21. <swiper-item v-for="(item, index) in advList" :key="index">
  22. <image class="swiper-item" mode="" @click="jump(item.jumpUrl)" :src="item.advertsImg"> </image>
  23. </swiper-item>
  24. </swiper>
  25. </view>
  26. <view class="card-box">
  27. <view class="card-item" @click="toTeaShop">
  28. <view class="card-title">
  29. <view class="card-item-title">
  30. <view class="card-img">
  31. <image class="card-item-img" src="https://oss.dev.zonelife.cn/static/guida/img/milktea/index/self.png">
  32. </image>
  33. </view>
  34. <view class="title-moji">到店自提</view>
  35. <view class="subtitle">提前点单免排队</view>
  36. </view>
  37. </view>
  38. </view>
  39. <!-- <view class="card-item">
  40. <view class="card-title">
  41. <view class="card-item-title">
  42. <view class="card-img">
  43. <image class="card-item-img" src="https://oss.dev.zonelife.cn/static/guida/img/milktea/index/send.png">
  44. </image>
  45. </view>
  46. <view class="title-moji">更多选择</view>
  47. <view class="subtitle">尽情期待...</view>
  48. </view>
  49. </view>
  50. </view> -->
  51. </view>
  52. <view class="swiper-box" style="height: 200rpx">
  53. <swiper class="swiper" @change="swiperChange" :indicator-dots="false" circular :autoplay="false" :interval="3000"
  54. :duration="1000">
  55. <swiper-item v-for="(item, index) in advList1" :key="item.id" @click="jump(item.jumpUrl)">
  56. <image class="swiper-item" mode="" :src="item.advertsImg"> </image>
  57. </swiper-item>
  58. </swiper>
  59. </view>
  60. <view class="sub-title">
  61. <view>精选推荐</view>
  62. </view>
  63. <view class="goods-list">
  64. <zs-list class="store-box" mt="0" @load="loadMore" :status="status">
  65. <view class="left">
  66. <view class="store-item" v-for="(item, index) in list" :key="index" @click="goGoodsDetail(item)">
  67. <zs-img :src="item.goodsImg" width="340rpx" height="340rpx" mode="widthFix"></zs-img>
  68. <view class="info">
  69. <view class="title">
  70. {{ item.goodsName }}
  71. </view>
  72. <view class="goods-price">
  73. <view> ¥{{ item.realPrice }} </view>
  74. <view class="distance"> 销售{{ item.saleNum }} </view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <view class="right">
  80. <view class="store-item" v-for="(item, index) in list1" :key="index" @click="goGoodsDetail(item)">
  81. <zs-img :src="item.goodsImg" width="340rpx" height="340rpx" mode="widthFix"></zs-img>
  82. <view class="info">
  83. <view class="title">
  84. {{ item.goodsName }}
  85. </view>
  86. <view class="goods-price">
  87. <!-- <image
  88. class="position"
  89. src="../../static/position.png"
  90. mode=""
  91. ></image> -->
  92. <view> ¥{{ item.realPrice }}</view>
  93. <view class="distance">
  94. 销售{{ item.saleNum }}
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. </zs-list>
  101. </view>
  102. </view>
  103. </template>
  104. <script>
  105. import { getUserDetail, getMenu, getAdv } from "@/api/common.js";
  106. import { appSearch } from "@/api/shop.js";
  107. import {getGdShopInfo} from '@/api/study.js';
  108. // 腾讯地图
  109. // // var QQMapWX = require("../../libs/qqmap-wx-jssdk.min.js");
  110. // var qqmapsdk = new QQMapWX({ key: "KX5BZ-B64RC-RO62W-AMWAZ-VVTC3-YAFXF" });
  111. export default {
  112. data() {
  113. return {
  114. advList: [],
  115. advList1: [],
  116. discountsList: [], //菜单
  117. current: 0,
  118. loading: false,
  119. background:false,
  120. navBarHeight: 0,
  121. bannerList: [
  122. {
  123. src: "http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/LasLcHe8z6F9c7c569e98cf778f866ac466404589d03.png/1.png",
  124. theme: "#FD9E59",
  125. title: "春季新品",
  126. subtitle: "蜜桃乌龙海盐芝士茶",
  127. },
  128. {
  129. src: "http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/QdulVZUZ9HYH190ae2e9392281ee1b845573e68ece1e.png/1.png",
  130. theme: "#FDD34C",
  131. title: "清仓处理",
  132. subtitle: "农夫山泉矿泉水",
  133. },
  134. {
  135. src: "http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/N7kknVWzDPKLbb7e15025599a818bbf11e3b030b6765.png/1.png",
  136. theme: "#B0ACF9",
  137. title: "正在热卖",
  138. subtitle: "哇哈哈AD盖",
  139. },
  140. ],
  141. list: [],
  142. list1: [],
  143. status: "more",
  144. query: {
  145. queryName: "",
  146. "location.lat": 0,
  147. "location.lon": 0,
  148. currentPage: 1,
  149. pageSize: 10,
  150. status: 3
  151. },
  152. };
  153. },
  154. onLoad(options) {
  155. this.columnId = options.columnId;
  156. Promise.all([this.getMenu(), this.getBanner(), this.getAdv()]).then((res) => {
  157. // this.search();
  158. });
  159. },
  160. created() {
  161. this.loading = true;
  162. this.navBarHeight = this.$navHight(1);
  163. this.navBarHeight = this.navBarHeight + 10 + "px";
  164. },
  165. methods: {
  166. goGoodsDetail(item) {
  167. uni.setStorageSync("shopInfo", JSON.stringify(item));
  168. uni.navigateTo({
  169. url: `../detail/goodsDetail/index?id=${item.goodsId}`,
  170. });
  171. },
  172. // swiper变动
  173. swiperChange(val) {
  174. this.current = val.target.current;
  175. },
  176. toTeaShop() {
  177. const shopId = uni.getStorageSync("gdTeaId");
  178. const teaCateId = uni.getStorageSync("teaCateId");
  179. uni.navigateTo({
  180. url: `../pages/index/searchResult?column=奶茶&goodsCateId=${teaCateId}&shopId=${shopId}&columnId=${this.columnId}`,
  181. });
  182. },
  183. // Banner
  184. getBanner() {
  185. return new Promise((resolve, reject) => {
  186. getAdv({
  187. currentPage: 1,
  188. pageSize: 99,
  189. belongType: 1,
  190. advertsType: 3,
  191. }).then((res) => {
  192. if (res.state == "Success") {
  193. this.advList = res.content.records.filter((e, i) => {
  194. return i < 10;
  195. });
  196. this.loading = false;
  197. resolve(2);
  198. }
  199. });
  200. });
  201. },
  202. // 广告位
  203. getAdv() {
  204. return new Promise((resolve, reject) => {
  205. getAdv({
  206. currentPage: 1,
  207. pageSize: 99,
  208. belongType: 1,
  209. advertsType: 4,
  210. }).then((res) => {
  211. if (res.state == "Success") {
  212. this.advList1 = res.content.records.filter((e, i) => {
  213. return i < 10;
  214. });;
  215. this.loading = false;
  216. resolve(2);
  217. }
  218. });
  219. });
  220. },
  221. // 金刚区
  222. getMenu() {
  223. return new Promise((resolve, reject) => {
  224. getMenu({ currentPage: 1, pageSize: 10 }).then((res) => {
  225. if (res.state == "Success") {
  226. this.discountsList = res.content.records.slice(0, 5);
  227. resolve(1);
  228. }
  229. });
  230. });
  231. },
  232. // 跳转优惠详情
  233. goDetail(url, id, banner, title) {
  234. url = "/pages/home/detail";
  235. uni.navigateTo({
  236. url: `${url}`,
  237. success(res) {
  238. // res.eventChannel.emit("banner", banner);
  239. },
  240. });
  241. },
  242. jump(url) {
  243. uni.navigateTo({
  244. url,
  245. });
  246. },
  247. search() {
  248. if (this.status == "noMore") return;
  249. this.status = "loading";
  250. const shopId = uni.getStorageSync("gdTeaId");
  251. appSearch({
  252. ...this.query,
  253. shopId,
  254. qualityType: 1,
  255. }).then((res) => {
  256. if (res.state == "Success") {
  257. this.loading = false;
  258. let list = [];
  259. let list1 = [];
  260. res.content.records.map((item, index) => {
  261. if (index % 2) {
  262. list1.push(item);
  263. } else {
  264. list.push(item);
  265. }
  266. });
  267. this.list = this.list.concat(list);
  268. this.list1 = this.list1.concat(list1);
  269. let total = this.list.length + this.list1.length;
  270. if (total >= res.content.total) {
  271. this.status = "noMore";
  272. } else {
  273. this.status = "more";
  274. this.query.currentPage++;
  275. }
  276. }
  277. });
  278. },
  279. loadMore() {
  280. console.log("loadMore");
  281. if (uni.getStorageSync("gdTeaId")) {
  282. this.search();
  283. }else{
  284. // 获取贵大文创ID
  285. getGdShopInfo().then(res=>{
  286. console.log('res',res);
  287. if(res.state == "Success"){
  288. uni.setStorageSync('gdShopId',res.content.shopId)
  289. uni.setStorageSync("gdTeaId",res.content.teaShop.shopId)
  290. uni.setStorageSync("teaCateId",res.content.teaCateId)
  291. this.search();
  292. }
  293. })
  294. }
  295. },
  296. },
  297. onPageScroll(e) {
  298. if (e.scrollTop >= 50) {
  299. this.background = true
  300. } else {
  301. this.background = false
  302. }
  303. },
  304. };
  305. </script>
  306. <style lang="scss">
  307. page {
  308. background-color: #fafafa;
  309. }
  310. .content {
  311. // padding-top: 24%;
  312. display: flex;
  313. flex-direction: column;
  314. background-color: #fafafa;
  315. justify-content: center;
  316. .top-box {
  317. background: linear-gradient(180deg, var(--bg) 0%, #fff 100%);
  318. // padding: 100rpx 32rpx 0;
  319. height: 716rpx;
  320. box-sizing: border-box;
  321. display: flex;
  322. flex-direction: column;
  323. justify-content: flex-end;
  324. .progress {
  325. position: absolute;
  326. top: 35%;
  327. right: 80%;
  328. display: flex;
  329. z-index: 2;
  330. color: #ffffff;
  331. font-size: 16rpx;
  332. // background: rgba(255, 255, 255, 0.3);
  333. padding: 2rpx 10rpx;
  334. border-radius: 14rpx;
  335. .block {
  336. width: 30rpx;
  337. height: 10rpx;
  338. margin-left: 10rpx;
  339. background: #fff;
  340. border-radius: 10px;
  341. }
  342. .active {
  343. background: #b4b4b4;
  344. }
  345. }
  346. .goods-box {
  347. position: absolute;
  348. top: 10%;
  349. z-index: 22;
  350. margin-left: 20rpx;
  351. .goods-title {
  352. font-size: 70rpx;
  353. color: #000;
  354. margin-bottom: 10rpx;
  355. }
  356. .goods-subtitle {
  357. font-size: 35rpx;
  358. color: #8b8b8b;
  359. }
  360. }
  361. .swiper {
  362. height: 100%;
  363. border-radius: 16rpx;
  364. .swiper-item {
  365. width: 100%;
  366. height: 100%;
  367. // border-radius: 16rpx;
  368. }
  369. }
  370. }
  371. .card-box {
  372. background-color: white;
  373. border-radius: 15rpx;
  374. padding: 40rpx 20rpx;
  375. display: flex;
  376. align-items: center;
  377. justify-content: space-between;
  378. z-index: 9999;
  379. margin: -15% 20rpx 20rpx 20rpx;
  380. .title-moji {
  381. font-size: 40rpx;
  382. margin-bottom: 10rpx;
  383. text-align: center;
  384. }
  385. .subtitle {
  386. text-align: center;
  387. font-size: 30rpx;
  388. color: #8b8b8b;
  389. }
  390. .card-item {
  391. position: relative;
  392. flex: 1;
  393. }
  394. // .card-item:nth-child(1) {
  395. // ::after {
  396. // content: "";
  397. // position: absolute;
  398. // margin: 0 auto;
  399. // right: 0;
  400. // top: 30rpx;
  401. // width: 1px;
  402. // height: 120rpx;
  403. // background: #FFD9D9;
  404. // }
  405. // }
  406. .card-img {
  407. display: flex;
  408. justify-content: center;
  409. // padding: 40rpx 0 50rpx 0;
  410. .card-item-img {
  411. width: 90rpx;
  412. height: 90rpx;
  413. }
  414. }
  415. // height: 300rpx;
  416. }
  417. }
  418. .search-box {
  419. width: 100vw;
  420. }
  421. .swiper-box {
  422. position: relative;
  423. margin: 0 24rpx 10rpx;
  424. padding-top: 20rpx;
  425. width: 702rpx;
  426. height: 280rpx;
  427. border-radius: 16rpx;
  428. .progress {
  429. position: absolute;
  430. top: 38rpx;
  431. right: 20rpx;
  432. z-index: 2;
  433. color: #ffffff;
  434. font-size: 16rpx;
  435. background: rgba(255, 255, 255, 0.3);
  436. padding: 2rpx 10rpx;
  437. border-radius: 14rpx;
  438. }
  439. .swiper {
  440. position: relative;
  441. height: 100%;
  442. padding: 0 10rpx;
  443. .swiper-item {
  444. width: 100%;
  445. height: 100%;
  446. border-radius: 16rpx;
  447. object-fit: cover;
  448. }
  449. }
  450. }
  451. .discount-list {
  452. display: flex;
  453. flex-wrap: wrap;
  454. width: 100%;
  455. // padding: 30rpx 0;
  456. // margin: 0 0rpx 0rpx;
  457. background: #fafafa;
  458. border-radius: 16rpx;
  459. position: relative;
  460. top: 0rpx;
  461. padding-top: 20rpx;
  462. .discount-item {
  463. width: 20%;
  464. display: flex;
  465. flex-direction: column;
  466. align-items: center;
  467. margin-top: 10rpx;
  468. margin-bottom: 10rpx;
  469. position: relative;
  470. .icon {
  471. width: 56rpx;
  472. height: 56rpx;
  473. }
  474. .title {
  475. font-size: 26rpx;
  476. margin-top: 10rpx;
  477. }
  478. .tag {
  479. position: absolute;
  480. top: -20rpx;
  481. left: 50%;
  482. background: #ff0615;
  483. box-shadow: inset 0rpx 6rpx 12rpx 2rpx rgba(255, 255, 255, 0.16);
  484. border-radius: 12rpx 14rpx 14rpx 0rpx;
  485. color: #fff;
  486. white-space: nowrap;
  487. font-size: 18rpx;
  488. line-height: -14rpx;
  489. height: 24rpx;
  490. padding: 0 10rpx;
  491. // width: fit-content;
  492. background-size: 100% 34rpx;
  493. }
  494. .desc {
  495. color: #ff0817;
  496. font-size: 16rpx;
  497. text-align: center;
  498. margin-top: 4rpx;
  499. }
  500. }
  501. }
  502. .sub-title {
  503. margin: 20rpx 0;
  504. padding-left: 40rpx;
  505. font-size: 30rpx;
  506. font-weight: bold;
  507. }
  508. .goods-list {
  509. border-radius: 16rpx 16rpx 0 0;
  510. }
  511. .zs-list {
  512. display: flex;
  513. flex-wrap: wrap;
  514. justify-content: space-between;
  515. padding: 0 24rpx;
  516. .left {
  517. .adv-swiper {
  518. width: 340rpx;
  519. height: 444rpx;
  520. margin-bottom: 25rpx;
  521. .adv-item {
  522. width: 340rpx;
  523. height: 444rpx;
  524. }
  525. }
  526. }
  527. .right {}
  528. .store-item {
  529. width: 340rpx;
  530. margin-bottom: 25rpx;
  531. // box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0, 0, 0, 0.08);
  532. border-radius: 16rpx;
  533. background: #fff;
  534. .icon {
  535. width: 100%;
  536. height: 300rpx;
  537. border-radius: 16rpx 16rpx 0 0;
  538. }
  539. .info {
  540. padding: 20rpx;
  541. background: #fff;
  542. border-radius: 0 0 16rpx 16rpx;
  543. position: relative;
  544. .title {
  545. // font-weight: bold;
  546. width: 100%;
  547. white-space: nowrap;
  548. text-overflow: ellipsis;
  549. overflow: hidden;
  550. }
  551. .tags {
  552. display: flex;
  553. align-items: center;
  554. .tag-item {
  555. line-height: 50rpx;
  556. border-radius: 8rpx;
  557. padding: 6rpx 0;
  558. font-size: 24rpx;
  559. margin-left: 10rpx;
  560. display: flex;
  561. .label {
  562. background: #fff;
  563. color: #fe5b47;
  564. padding: 0 10rpx;
  565. border-radius: 8rpx 0 0 8rpx;
  566. }
  567. .value {
  568. color: #fff;
  569. background: rgba(255, 255, 255, 0.2);
  570. padding: 0 14rpx;
  571. border-radius: 0 8rpx 8rpx 0;
  572. }
  573. }
  574. }
  575. .goods-price {
  576. display: flex;
  577. align-items: center;
  578. margin-top: 15rpx;
  579. justify-content: space-between;
  580. color: #202020;
  581. .distance {
  582. color: #999;
  583. }
  584. .position {
  585. color: 999;
  586. width: 25rpx;
  587. height: 29rpx;
  588. margin-right: 8rpx;
  589. }
  590. }
  591. }
  592. }
  593. }
  594. </style>