index.vue 11 KB

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