index.vue 15 KB

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