index.vue 14 KB

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