index.vue 15 KB

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