index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  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. onShareTimeline() {
  137. return {
  138. title: "印象贵大文创",
  139. query: "id=1",
  140. imageUrl: "https://oss.dev.zonelife.cn/static/guida/img/logo.jpg",
  141. };
  142. },
  143. onShareAppMessage() {
  144. return {
  145. title: "印象贵大文创",
  146. path: "/pages/index/index",
  147. };
  148. },
  149. methods: {
  150. goGoodsDetail(item) {
  151. uni.setStorageSync("shopInfo", JSON.stringify(item));
  152. uni.navigateTo({
  153. url: `../../detail/goodsDetail/index?id=${item.goodsId}`,
  154. });
  155. },
  156. // 点击搜索
  157. handleSearch() {
  158. if (!uni.getStorageSync("token")) {
  159. return uni.showModal({
  160. title: "请登录",
  161. confirmText: "去登录",
  162. success(res) {
  163. console.log(res);
  164. if (res.confirm) {
  165. uni.navigateTo({
  166. url: "/login/login/login?redirect=/pages/index/index",
  167. });
  168. }
  169. },
  170. });
  171. }
  172. uni.reLaunch({
  173. url: "./search",
  174. });
  175. // if(!val) return
  176. // this.query.queryName = val
  177. // this.query.pageCurrent = 1
  178. // this.list = []
  179. // this.list1 = []
  180. // this.status = 'more'
  181. // this.search()
  182. },
  183. // swiper变动
  184. swiperChange(val) {
  185. this.current = val.target.current;
  186. },
  187. swiperChangeAd(val) {
  188. this.current1 = val.target.current;
  189. },
  190. // Banner
  191. getBanner() {
  192. return new Promise((resolve, reject) => {
  193. getAdv({
  194. currentPage: 1,
  195. pageSize: 99,
  196. belongType: 1,
  197. advertsType: 1,
  198. }).then((res) => {
  199. if (res.state == "Success") {
  200. this.advList = res.content.records.filter((e, i) => {
  201. return i < 10;
  202. });
  203. this.loading = false;
  204. resolve(2);
  205. }
  206. });
  207. });
  208. },
  209. // 广告位
  210. getAdv() {
  211. return new Promise((resolve, reject) => {
  212. getAdv({
  213. currentPage: 1,
  214. pageSize: 99,
  215. belongType: 1,
  216. advertsType: 2,
  217. }).then((res) => {
  218. if (res.state == "Success") {
  219. this.advList1 = res.content.records.filter((e, i) => {
  220. return i < 10;
  221. });;
  222. this.loading = false;
  223. resolve(2);
  224. }
  225. });
  226. });
  227. },
  228. // 金刚区
  229. getSearchMenu() {
  230. return new Promise((resolve, reject) => {
  231. searchMenu({
  232. currentPage: 1,
  233. pageSize: 5,
  234. columnId: 0,
  235. belongType: 1,
  236. status: 1,
  237. }).then((res) => {
  238. if (res.state == "Success") {
  239. this.discountsList = res.content.records;
  240. resolve(1);
  241. }
  242. });
  243. });
  244. },
  245. jump(url) {
  246. uni.navigateTo({
  247. url,
  248. });
  249. },
  250. // 跳转优惠详情
  251. goDetail(item) {
  252. // url = "/pages/home/detail";
  253. // uni.navigateTo({
  254. // url: `${url}`,
  255. // success(res) {
  256. // // res.eventChannel.emit("banner", banner);
  257. // },
  258. // });
  259. if (item.columnName == '咖啡奶茶' || item.columnName == '奶茶单点') {
  260. uni.navigateTo(
  261. {
  262. url: "/milktea/index"
  263. }
  264. )
  265. } else {
  266. uni.navigateTo({
  267. url: `./searchResult?column=${item.columnName}&goodsCateId=${item.goodsCateId}&columnId=${item.id}`,
  268. });
  269. }
  270. console.log("item", item);
  271. },
  272. appSearch() {
  273. if (this.status == "noMore") return;
  274. this.status = "loading";
  275. appSearch({
  276. ...this.query,
  277. qualityType: 1,
  278. }).then((res) => {
  279. if (res.state == "Success") {
  280. this.loading = false;
  281. let list = [];
  282. let list1 = [];
  283. res.content.records.map((item, index) => {
  284. if (index % 2) {
  285. list1.push(item);
  286. } else {
  287. list.push(item);
  288. }
  289. });
  290. this.list = this.list.concat(list);
  291. this.list1 = this.list1.concat(list1);
  292. let total = this.list.length + this.list1.length;
  293. if (total >= res.content.total) {
  294. this.status = "noMore";
  295. } else {
  296. this.status = "more";
  297. this.query.currentPage++;
  298. }
  299. }
  300. });
  301. },
  302. loadMore() {
  303. console.log("loadMore");
  304. if (this.query["location.lat"] && this.query["location.lon"]) {
  305. this.appSearch();
  306. }
  307. },
  308. // 获取当前城市
  309. getCity() {
  310. let that = this;
  311. return new Promise((resolve, reject) => {
  312. uni.getLocation({
  313. type: "gcj02",
  314. success: (res) => {
  315. // 解析地址
  316. that.query["location.lat"] = res.latitude;
  317. that.query["location.lon"] = res.longitude;
  318. // 存储经纬度
  319. uni.setStorageSync(
  320. "location",
  321. JSON.stringify({
  322. latitude: res.latitude,
  323. longitude: res.longitude,
  324. })
  325. );
  326. qqmapsdk.reverseGeocoder({
  327. location: {
  328. latitude: res.latitude,
  329. longitude: res.longitude,
  330. },
  331. success: function (res) {
  332. // 市
  333. that.city = res.result.address_component.city;
  334. resolve();
  335. },
  336. fail: function (res) {
  337. that.city = "定位失败";
  338. },
  339. });
  340. },
  341. fail: (res) => {
  342. console.log("获取经纬度失败");
  343. },
  344. });
  345. });
  346. },
  347. },
  348. };
  349. </script>
  350. <style lang="scss">
  351. .navBarBox .navBar .logo {
  352. width: 0rpx;
  353. height: 82rpx;
  354. // margin-right: 10rpx;
  355. }
  356. .navBarBox .navBar {
  357. font-size: 35rpx;
  358. font-weight: bold;
  359. padding: 3rpx 50rpx;
  360. padding-bottom: 8rpx;
  361. display: flex;
  362. flex-direction: row;
  363. justify-content: center;
  364. align-items: center;
  365. }
  366. .content {
  367. // padding-top: 24%;
  368. display: flex;
  369. flex-direction: column;
  370. background-color: #fafafa;
  371. justify-content: center;
  372. }
  373. page {
  374. background-color: #fafafa;
  375. }
  376. .search-box {
  377. width: 100vw;
  378. }
  379. .swiper-box {
  380. position: relative;
  381. margin: 0 20rpx 10rpx;
  382. padding-top: 20rpx;
  383. width: 710rpx;
  384. height: 320rpx;
  385. border-radius: 16rpx;
  386. .progress {
  387. position: absolute;
  388. top: 38rpx;
  389. right: 20rpx;
  390. z-index: 2;
  391. color: #ffffff;
  392. font-size: 16rpx;
  393. background: rgba(255, 255, 255, 0.3);
  394. padding: 2rpx 10rpx;
  395. border-radius: 14rpx;
  396. }
  397. .swiper {
  398. position: relative;
  399. height: 100%;
  400. padding: 0 10rpx;
  401. .swiper-item {
  402. width: 100%;
  403. height: 100%;
  404. border-radius: 16rpx;
  405. object-fit: cover;
  406. }
  407. }
  408. }
  409. .discount-list {
  410. display: flex;
  411. flex-wrap: wrap;
  412. width: 100%;
  413. justify-content: space-evenly;
  414. // padding: 30rpx 0;
  415. // margin: 0 0rpx 0rpx;
  416. background: #fafafa;
  417. border-radius: 16rpx;
  418. position: relative;
  419. top: 0rpx;
  420. padding-top: 20rpx;
  421. .discount-item {
  422. width: 20%;
  423. display: flex;
  424. flex-direction: column;
  425. align-items: center;
  426. margin-top: 10rpx;
  427. margin-bottom: 10rpx;
  428. position: relative;
  429. .icon {
  430. width: 56rpx;
  431. height: 56rpx;
  432. }
  433. .title {
  434. font-size: 26rpx;
  435. margin-top: 10rpx;
  436. }
  437. .tag {
  438. position: absolute;
  439. top: -20rpx;
  440. left: 50%;
  441. background: #ff0615;
  442. box-shadow: inset 0rpx 6rpx 12rpx 2rpx rgba(255, 255, 255, 0.16);
  443. border-radius: 12rpx 14rpx 14rpx 0rpx;
  444. color: #fff;
  445. white-space: nowrap;
  446. font-size: 18rpx;
  447. line-height: -14rpx;
  448. height: 24rpx;
  449. padding: 0 10rpx;
  450. // width: fit-content;
  451. background-size: 100% 34rpx;
  452. }
  453. .desc {
  454. color: #ff0817;
  455. font-size: 16rpx;
  456. text-align: center;
  457. margin-top: 4rpx;
  458. }
  459. }
  460. }
  461. .sub-title {
  462. margin: 20rpx 0;
  463. padding-left: 40rpx;
  464. font-size: 30rpx;
  465. font-weight: bold;
  466. }
  467. .goods-list {
  468. border-radius: 16rpx 16rpx 0 0;
  469. margin-bottom: 60rpx;
  470. }
  471. .zs-list {
  472. display: flex;
  473. flex-wrap: wrap;
  474. justify-content: space-between;
  475. padding: 0 20rpx;
  476. .left {
  477. .adv-swiper {
  478. width: 340rpx;
  479. height: 444rpx;
  480. margin-bottom: 25rpx;
  481. .adv-item {
  482. width: 340rpx;
  483. height: 444rpx;
  484. }
  485. }
  486. }
  487. .right {}
  488. .store-item {
  489. width: 340rpx;
  490. margin-bottom: 25rpx;
  491. // box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0, 0, 0, 0.08);
  492. border-radius: 16rpx;
  493. background: #fff;
  494. .icon {
  495. width: 100%;
  496. height: 300rpx;
  497. border-radius: 16rpx 16rpx 0 0;
  498. }
  499. .info {
  500. padding: 20rpx;
  501. background: #fff;
  502. border-radius: 0 0 16rpx 16rpx;
  503. position: relative;
  504. .title {
  505. // font-weight: bold;
  506. width: 100%;
  507. white-space: nowrap;
  508. text-overflow: ellipsis;
  509. overflow: hidden;
  510. }
  511. .tags {
  512. display: flex;
  513. align-items: center;
  514. .tag-item {
  515. line-height: 50rpx;
  516. border-radius: 8rpx;
  517. padding: 6rpx 0;
  518. font-size: 24rpx;
  519. margin-left: 10rpx;
  520. display: flex;
  521. .label {
  522. background: #fff;
  523. color: #fe5b47;
  524. padding: 0 10rpx;
  525. border-radius: 8rpx 0 0 8rpx;
  526. }
  527. .value {
  528. color: #fff;
  529. background: rgba(255, 255, 255, 0.2);
  530. padding: 0 14rpx;
  531. border-radius: 0 8rpx 8rpx 0;
  532. }
  533. }
  534. }
  535. .goods-price {
  536. display: flex;
  537. align-items: center;
  538. margin-top: 15rpx;
  539. justify-content: space-between;
  540. color: #ff4d3a;
  541. font-weight: bold;
  542. font-size: 30rpx;
  543. .distance {
  544. font-weight: normal;
  545. font-size: 20rpx;
  546. color: #999;
  547. }
  548. .position {
  549. color: 999;
  550. width: 25rpx;
  551. height: 29rpx;
  552. margin-right: 8rpx;
  553. }
  554. }
  555. }
  556. }
  557. }
  558. </style>