index.vue 15 KB

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