index.vue 14 KB

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