index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  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: 160rpx">
  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.reLaunch({
  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. advertsType: 1,
  243. }).then((res) => {
  244. if (res.state == "Success") {
  245. this.advList = res.content.records.filter((e, i) => {
  246. return i < 10;
  247. });
  248. this.loading = false;
  249. resolve(2);
  250. }
  251. });
  252. });
  253. },
  254. // 广告位
  255. getAdv() {
  256. return new Promise((resolve, reject) => {
  257. getAdv({
  258. currentPage: 1,
  259. pageSize: 99,
  260. advertsType: 2,
  261. }).then((res) => {
  262. if (res.state == "Success") {
  263. this.advList1 = res.content.records.filter((e, i) => {
  264. return i < 10;
  265. });;
  266. this.loading = false;
  267. resolve(2);
  268. }
  269. });
  270. });
  271. },
  272. // 金刚区
  273. getSearchMenu() {
  274. return new Promise((resolve, reject) => {
  275. searchMenu({
  276. currentPage: 1,
  277. pageSize: 4,
  278. belongType: 1,
  279. status: 1,
  280. }).then((res) => {
  281. if (res.state == "Success") {
  282. this.discountsList = res.content.records;
  283. resolve(1);
  284. }
  285. });
  286. });
  287. },
  288. // 跳转优惠详情
  289. goDetail(item) {
  290. // url = "/pages/home/detail";
  291. // uni.navigateTo({
  292. // url: `${url}`,
  293. // success(res) {
  294. // // res.eventChannel.emit("banner", banner);
  295. // },
  296. // });
  297. uni.navigateTo({
  298. url: `./searchResult?column=${item.columnName}&goodsCateId=${item.goodsCateId}&columnId=${item.id}`,
  299. });
  300. console.log("item", item);
  301. },
  302. appSearch() {
  303. if (this.status == "noMore") return;
  304. this.status = "loading";
  305. appSearch({
  306. ...this.query,
  307. qualityType:1,
  308. }).then((res) => {
  309. if (res.state == "Success") {
  310. this.loading = false;
  311. let list = [];
  312. let list1 = [];
  313. res.content.records.map((item, index) => {
  314. if (index % 2) {
  315. list1.push(item);
  316. } else {
  317. list.push(item);
  318. }
  319. });
  320. this.list = this.list.concat(list);
  321. this.list1 = this.list1.concat(list1);
  322. let total = this.list.length + this.list1.length;
  323. if (total >= res.content.total) {
  324. this.status = "noMore";
  325. } else {
  326. this.status = "more";
  327. this.query.currentPage++;
  328. }
  329. }
  330. });
  331. },
  332. loadMore() {
  333. console.log("loadMore");
  334. if (this.query["location.lat"] && this.query["location.lon"]) {
  335. this.appSearch();
  336. }
  337. },
  338. // 获取当前城市
  339. getCity() {
  340. let that = this;
  341. return new Promise((resolve, reject) => {
  342. uni.getLocation({
  343. type: "gcj02",
  344. success: (res) => {
  345. // 解析地址
  346. that.query["location.lat"] = res.latitude;
  347. that.query["location.lon"] = res.longitude;
  348. // 存储经纬度
  349. uni.setStorageSync(
  350. "location",
  351. JSON.stringify({
  352. latitude: res.latitude,
  353. longitude: res.longitude,
  354. })
  355. );
  356. qqmapsdk.reverseGeocoder({
  357. location: {
  358. latitude: res.latitude,
  359. longitude: res.longitude,
  360. },
  361. success: function (res) {
  362. // 市
  363. that.city = res.result.address_component.city;
  364. resolve();
  365. },
  366. fail: function (res) {
  367. that.city = "定位失败";
  368. },
  369. });
  370. },
  371. fail: (res) => {
  372. console.log("获取经纬度失败");
  373. },
  374. });
  375. });
  376. },
  377. },
  378. };
  379. </script>
  380. <style lang="scss">
  381. .navBarBox .navBar .logo {
  382. width: 0rpx;
  383. height: 82rpx;
  384. // margin-right: 10rpx;
  385. }
  386. .navBarBox .navBar {
  387. font-size: 35rpx;
  388. font-weight: bold;
  389. padding: 3rpx 50rpx;
  390. padding-bottom: 8rpx;
  391. display: flex;
  392. flex-direction: row;
  393. justify-content: center;
  394. align-items: center;
  395. }
  396. .content {
  397. // padding-top: 24%;
  398. display: flex;
  399. flex-direction: column;
  400. background-color: #fafafa;
  401. justify-content: center;
  402. }
  403. page {
  404. background-color: #fafafa;
  405. }
  406. .search-box {
  407. width: 100vw;
  408. }
  409. .swiper-box {
  410. position: relative;
  411. margin: 0 24rpx 10rpx;
  412. padding-top: 20rpx;
  413. width: 702rpx;
  414. height: 280rpx;
  415. border-radius: 16rpx;
  416. .progress {
  417. position: absolute;
  418. top: 38rpx;
  419. right: 20rpx;
  420. z-index: 2;
  421. color: #ffffff;
  422. font-size: 16rpx;
  423. background: rgba(255, 255, 255, 0.3);
  424. padding: 2rpx 10rpx;
  425. border-radius: 14rpx;
  426. }
  427. .swiper {
  428. position: relative;
  429. height: 100%;
  430. padding: 0 10rpx;
  431. .swiper-item {
  432. width: 100%;
  433. height: 100%;
  434. border-radius: 16rpx;
  435. object-fit: cover;
  436. }
  437. }
  438. }
  439. .discount-list {
  440. display: flex;
  441. flex-wrap: wrap;
  442. width: 100%;
  443. justify-content: space-evenly;
  444. // padding: 30rpx 0;
  445. // margin: 0 0rpx 0rpx;
  446. background: #fafafa;
  447. border-radius: 16rpx;
  448. position: relative;
  449. top: 0rpx;
  450. padding-top: 20rpx;
  451. .discount-item {
  452. width: 20%;
  453. display: flex;
  454. flex-direction: column;
  455. align-items: center;
  456. margin-top: 10rpx;
  457. margin-bottom: 10rpx;
  458. position: relative;
  459. .icon {
  460. width: 56rpx;
  461. height: 56rpx;
  462. }
  463. .title {
  464. font-size: 26rpx;
  465. margin-top: 10rpx;
  466. }
  467. .tag {
  468. position: absolute;
  469. top: -20rpx;
  470. left: 50%;
  471. background: #ff0615;
  472. box-shadow: inset 0rpx 6rpx 12rpx 2rpx rgba(255, 255, 255, 0.16);
  473. border-radius: 12rpx 14rpx 14rpx 0rpx;
  474. color: #fff;
  475. white-space: nowrap;
  476. font-size: 18rpx;
  477. line-height: -14rpx;
  478. height: 24rpx;
  479. padding: 0 10rpx;
  480. // width: fit-content;
  481. background-size: 100% 34rpx;
  482. }
  483. .desc {
  484. color: #ff0817;
  485. font-size: 16rpx;
  486. text-align: center;
  487. margin-top: 4rpx;
  488. }
  489. }
  490. }
  491. .sub-title {
  492. margin: 20rpx 0;
  493. padding-left: 40rpx;
  494. font-size: 30rpx;
  495. font-weight: bold;
  496. }
  497. .goods-list {
  498. border-radius: 16rpx 16rpx 0 0;
  499. margin-bottom: 60rpx;
  500. }
  501. .zs-list {
  502. display: flex;
  503. flex-wrap: wrap;
  504. justify-content: space-between;
  505. padding: 0 24rpx;
  506. .left {
  507. .adv-swiper {
  508. width: 340rpx;
  509. height: 444rpx;
  510. margin-bottom: 25rpx;
  511. .adv-item {
  512. width: 340rpx;
  513. height: 444rpx;
  514. }
  515. }
  516. }
  517. .right {
  518. }
  519. .store-item {
  520. width: 340rpx;
  521. margin-bottom: 25rpx;
  522. // box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0, 0, 0, 0.08);
  523. border-radius: 16rpx;
  524. background: #fff;
  525. .icon {
  526. width: 100%;
  527. height: 300rpx;
  528. border-radius: 16rpx 16rpx 0 0;
  529. }
  530. .info {
  531. padding: 20rpx;
  532. background: #fff;
  533. border-radius: 0 0 16rpx 16rpx;
  534. position: relative;
  535. .title {
  536. // font-weight: bold;
  537. width: 100%;
  538. white-space: nowrap;
  539. text-overflow: ellipsis;
  540. overflow: hidden;
  541. }
  542. .tags {
  543. display: flex;
  544. align-items: center;
  545. .tag-item {
  546. line-height: 50rpx;
  547. border-radius: 8rpx;
  548. padding: 6rpx 0;
  549. font-size: 24rpx;
  550. margin-left: 10rpx;
  551. display: flex;
  552. .label {
  553. background: #fff;
  554. color: #fe5b47;
  555. padding: 0 10rpx;
  556. border-radius: 8rpx 0 0 8rpx;
  557. }
  558. .value {
  559. color: #fff;
  560. background: rgba(255, 255, 255, 0.2);
  561. padding: 0 14rpx;
  562. border-radius: 0 8rpx 8rpx 0;
  563. }
  564. }
  565. }
  566. .goods-price {
  567. display: flex;
  568. align-items: center;
  569. margin-top: 15rpx;
  570. justify-content: space-between;
  571. color: #ff4d3a;
  572. font-weight: bold;
  573. font-size: 30rpx;
  574. .distance {
  575. font-weight: normal;
  576. font-size: 20rpx;
  577. color: #999;
  578. }
  579. .position {
  580. color: 999;
  581. width: 25rpx;
  582. height: 29rpx;
  583. margin-right: 8rpx;
  584. }
  585. }
  586. }
  587. }
  588. }
  589. </style>