detail.vue 15 KB

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