index.vue 14 KB

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