index.vue 14 KB

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