index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  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="" :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() { },
  152. created() {
  153. this.loading = true;
  154. this.navBarHeight = this.$navHight(1);
  155. this.navBarHeight = this.navBarHeight + 10 + "px";
  156. Promise.all([this.getMenu(), this.getBanner(), this.getAdv()]).then((res) => {
  157. this.search();
  158. });
  159. },
  160. methods: {
  161. goGoodsDetail(item) {
  162. uni.setStorageSync("shopInfo", JSON.stringify(item));
  163. uni.navigateTo({
  164. url: `../detail/goodsDetail/index?id=${item.goodsId}`,
  165. });
  166. },
  167. // swiper变动
  168. swiperChange(val) {
  169. this.current = val.target.current;
  170. },
  171. toTeaShop(){
  172. const shopId = uni.getStorageSync("gdTeaId");
  173. uni.navigateTo({
  174. url: `../pages/index/searchResult?column=奶茶&goodsCateId=46&shopId=${shopId}&columnId=66`,
  175. });
  176. },
  177. // Banner
  178. getBanner() {
  179. return new Promise((resolve, reject) => {
  180. getAdv({
  181. currentPage: 1,
  182. pageSize: 99,
  183. belongType: 1,
  184. advertsType: 3,
  185. }).then((res) => {
  186. if (res.state == "Success") {
  187. this.advList = res.content.records.filter((e, i) => {
  188. return i < 10;
  189. });
  190. this.loading = false;
  191. resolve(2);
  192. }
  193. });
  194. });
  195. },
  196. // 广告位
  197. getAdv() {
  198. return new Promise((resolve, reject) => {
  199. getAdv({
  200. currentPage: 1,
  201. pageSize: 99,
  202. belongType: 1,
  203. advertsType: 4,
  204. }).then((res) => {
  205. if (res.state == "Success") {
  206. this.advList1 = res.content.records.filter((e, i) => {
  207. return i < 10;
  208. });;
  209. this.loading = false;
  210. resolve(2);
  211. }
  212. });
  213. });
  214. },
  215. // 金刚区
  216. getMenu() {
  217. return new Promise((resolve, reject) => {
  218. getMenu({ currentPage: 1, pageSize: 10 }).then((res) => {
  219. if (res.state == "Success") {
  220. this.discountsList = res.content.records.slice(0, 5);
  221. resolve(1);
  222. }
  223. });
  224. });
  225. },
  226. // 跳转优惠详情
  227. goDetail(url, id, banner, title) {
  228. url = "/pages/home/detail";
  229. uni.navigateTo({
  230. url: `${url}`,
  231. success(res) {
  232. // res.eventChannel.emit("banner", banner);
  233. },
  234. });
  235. },
  236. search() {
  237. if (this.status == "noMore") return;
  238. this.status = "loading";
  239. const shopId = uni.getStorageSync("gdTeaId");
  240. appSearch({
  241. ...this.query,
  242. shopId,
  243. qualityType: 1,
  244. }).then((res) => {
  245. if (res.state == "Success") {
  246. this.loading = false;
  247. let list = [];
  248. let list1 = [];
  249. res.content.records.map((item, index) => {
  250. if (index % 2) {
  251. list1.push(item);
  252. } else {
  253. list.push(item);
  254. }
  255. });
  256. this.list = this.list.concat(list);
  257. this.list1 = this.list1.concat(list1);
  258. let total = this.list.length + this.list1.length;
  259. if (total >= res.content.total) {
  260. this.status = "noMore";
  261. } else {
  262. this.status = "more";
  263. this.query.currentPage++;
  264. }
  265. }
  266. });
  267. },
  268. loadMore() {
  269. console.log("loadMore");
  270. if (this.query["location.lat"] && this.query["location.lon"]) {
  271. this.search();
  272. }
  273. },
  274. },
  275. };
  276. </script>
  277. <style lang="scss">
  278. page {
  279. background-color: #fafafa;
  280. }
  281. .content {
  282. // padding-top: 24%;
  283. display: flex;
  284. flex-direction: column;
  285. background-color: #fafafa;
  286. justify-content: center;
  287. .top-box {
  288. background: linear-gradient(180deg, var(--bg) 0%, #fff 100%);
  289. // padding: 100rpx 32rpx 0;
  290. height: 716rpx;
  291. box-sizing: border-box;
  292. display: flex;
  293. flex-direction: column;
  294. justify-content: flex-end;
  295. .progress {
  296. position: absolute;
  297. top: 35%;
  298. right: 80%;
  299. display: flex;
  300. z-index: 2;
  301. color: #ffffff;
  302. font-size: 16rpx;
  303. // background: rgba(255, 255, 255, 0.3);
  304. padding: 2rpx 10rpx;
  305. border-radius: 14rpx;
  306. .block {
  307. width: 30rpx;
  308. height: 10rpx;
  309. margin-left: 10rpx;
  310. background: #fff;
  311. border-radius: 10px;
  312. }
  313. .active {
  314. background: #b4b4b4;
  315. }
  316. }
  317. .goods-box {
  318. position: absolute;
  319. top: 10%;
  320. z-index: 22;
  321. margin-left: 20rpx;
  322. .goods-title {
  323. font-size: 70rpx;
  324. color: #000;
  325. margin-bottom: 10rpx;
  326. }
  327. .goods-subtitle {
  328. font-size: 35rpx;
  329. color: #8b8b8b;
  330. }
  331. }
  332. .swiper {
  333. height: 100%;
  334. border-radius: 16rpx;
  335. .swiper-item {
  336. width: 100%;
  337. height: 100%;
  338. // border-radius: 16rpx;
  339. }
  340. }
  341. }
  342. .card-box {
  343. background-color: white;
  344. border-radius: 15rpx;
  345. padding: 40rpx 20rpx;
  346. display: flex;
  347. align-items: center;
  348. justify-content: space-between;
  349. z-index: 9999;
  350. margin: -15% 20rpx 20rpx 20rpx;
  351. .title-moji {
  352. font-size: 40rpx;
  353. margin-bottom: 10rpx;
  354. text-align: center;
  355. }
  356. .subtitle {
  357. text-align: center;
  358. font-size: 30rpx;
  359. color: #8b8b8b;
  360. }
  361. .card-item {
  362. position: relative;
  363. flex: 1;
  364. }
  365. .card-item:nth-child(1) {
  366. ::after {
  367. content: "";
  368. position: absolute;
  369. margin: 0 auto;
  370. right: 0;
  371. top: 30rpx;
  372. width: 1px;
  373. height: 120rpx;
  374. background: #FFD9D9;
  375. }
  376. }
  377. .card-img {
  378. display: flex;
  379. justify-content: center;
  380. // padding: 40rpx 0 50rpx 0;
  381. .card-item-img {
  382. width: 90rpx;
  383. height: 90rpx;
  384. }
  385. }
  386. // height: 300rpx;
  387. }
  388. }
  389. .search-box {
  390. width: 100vw;
  391. }
  392. .swiper-box {
  393. position: relative;
  394. margin: 0 24rpx 10rpx;
  395. padding-top: 20rpx;
  396. width: 702rpx;
  397. height: 280rpx;
  398. border-radius: 16rpx;
  399. .progress {
  400. position: absolute;
  401. top: 38rpx;
  402. right: 20rpx;
  403. z-index: 2;
  404. color: #ffffff;
  405. font-size: 16rpx;
  406. background: rgba(255, 255, 255, 0.3);
  407. padding: 2rpx 10rpx;
  408. border-radius: 14rpx;
  409. }
  410. .swiper {
  411. position: relative;
  412. height: 100%;
  413. padding: 0 10rpx;
  414. .swiper-item {
  415. width: 100%;
  416. height: 100%;
  417. border-radius: 16rpx;
  418. object-fit: cover;
  419. }
  420. }
  421. }
  422. .discount-list {
  423. display: flex;
  424. flex-wrap: wrap;
  425. width: 100%;
  426. // padding: 30rpx 0;
  427. // margin: 0 0rpx 0rpx;
  428. background: #fafafa;
  429. border-radius: 16rpx;
  430. position: relative;
  431. top: 0rpx;
  432. padding-top: 20rpx;
  433. .discount-item {
  434. width: 20%;
  435. display: flex;
  436. flex-direction: column;
  437. align-items: center;
  438. margin-top: 10rpx;
  439. margin-bottom: 10rpx;
  440. position: relative;
  441. .icon {
  442. width: 56rpx;
  443. height: 56rpx;
  444. }
  445. .title {
  446. font-size: 26rpx;
  447. margin-top: 10rpx;
  448. }
  449. .tag {
  450. position: absolute;
  451. top: -20rpx;
  452. left: 50%;
  453. background: #ff0615;
  454. box-shadow: inset 0rpx 6rpx 12rpx 2rpx rgba(255, 255, 255, 0.16);
  455. border-radius: 12rpx 14rpx 14rpx 0rpx;
  456. color: #fff;
  457. white-space: nowrap;
  458. font-size: 18rpx;
  459. line-height: -14rpx;
  460. height: 24rpx;
  461. padding: 0 10rpx;
  462. // width: fit-content;
  463. background-size: 100% 34rpx;
  464. }
  465. .desc {
  466. color: #ff0817;
  467. font-size: 16rpx;
  468. text-align: center;
  469. margin-top: 4rpx;
  470. }
  471. }
  472. }
  473. .sub-title {
  474. margin: 20rpx 0;
  475. padding-left: 40rpx;
  476. font-size: 30rpx;
  477. font-weight: bold;
  478. }
  479. .goods-list {
  480. border-radius: 16rpx 16rpx 0 0;
  481. }
  482. .zs-list {
  483. display: flex;
  484. flex-wrap: wrap;
  485. justify-content: space-between;
  486. padding: 0 24rpx;
  487. .left {
  488. .adv-swiper {
  489. width: 340rpx;
  490. height: 444rpx;
  491. margin-bottom: 25rpx;
  492. .adv-item {
  493. width: 340rpx;
  494. height: 444rpx;
  495. }
  496. }
  497. }
  498. .right {}
  499. .store-item {
  500. width: 340rpx;
  501. margin-bottom: 25rpx;
  502. // box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0, 0, 0, 0.08);
  503. border-radius: 16rpx;
  504. background: #fff;
  505. .icon {
  506. width: 100%;
  507. height: 300rpx;
  508. border-radius: 16rpx 16rpx 0 0;
  509. }
  510. .info {
  511. padding: 20rpx;
  512. background: #fff;
  513. border-radius: 0 0 16rpx 16rpx;
  514. position: relative;
  515. .title {
  516. // font-weight: bold;
  517. width: 100%;
  518. white-space: nowrap;
  519. text-overflow: ellipsis;
  520. overflow: hidden;
  521. }
  522. .tags {
  523. display: flex;
  524. align-items: center;
  525. .tag-item {
  526. line-height: 50rpx;
  527. border-radius: 8rpx;
  528. padding: 6rpx 0;
  529. font-size: 24rpx;
  530. margin-left: 10rpx;
  531. display: flex;
  532. .label {
  533. background: #fff;
  534. color: #fe5b47;
  535. padding: 0 10rpx;
  536. border-radius: 8rpx 0 0 8rpx;
  537. }
  538. .value {
  539. color: #fff;
  540. background: rgba(255, 255, 255, 0.2);
  541. padding: 0 14rpx;
  542. border-radius: 0 8rpx 8rpx 0;
  543. }
  544. }
  545. }
  546. .goods-price {
  547. display: flex;
  548. align-items: center;
  549. margin-top: 15rpx;
  550. justify-content: space-between;
  551. color: #202020;
  552. .distance {
  553. color: #999;
  554. }
  555. .position {
  556. color: 999;
  557. width: 25rpx;
  558. height: 29rpx;
  559. margin-right: 8rpx;
  560. }
  561. }
  562. }
  563. }
  564. }
  565. </style>