index.vue 14 KB

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