index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. <template>
  2. <mobile-frame :frameStyle="frameStyle" @toPath="toPath">
  3. <scroll-view scroll-y="true" class="scroll-view" scroll-with-animation :scroll-top="scrollTop" @scroll="scroll"
  4. @scrolltolower="toPage">
  5. <view class="list-scroll-view">
  6. <view class="main">
  7. <view class="zero one">
  8. <input type="text" placeholder="搜索商品" @tap="toCommon('pagesHome/market/search')"
  9. placeholder-class="placss">
  10. </view>
  11. <view class="zero two">
  12. <swiper class="swiper" circular :indicator-dots="true" indicator-color="#ffffff"
  13. indicator-active-color="#FB1438" :autoplay="true" :interval="3000" :duration="1000">
  14. <swiper-item class="list" v-for="(item,index) in bannerList" :key="index"
  15. @tap="toBanner(item)">
  16. <image class="image" :src="item.url&&item.url.length>0?item.url[0].url:''" mode="">
  17. </image>
  18. </swiper-item>
  19. </swiper>
  20. </view>
  21. <view class="zero thr">
  22. <view class="list" v-for="(item,index) in btnList" :key="index" @tap="toIndexModel(item)">
  23. <image class="image" :src="item.url&&item.url.length>0?item.url[0].url:''" mode=""></image>
  24. <view class="textOver name">
  25. {{item.name}}
  26. </view>
  27. </view>
  28. </view>
  29. <view class="zero four" v-if="recomList&&recomList.length>0">
  30. <view class="recomList" v-for="(item,index) in recomList" :key="index"
  31. v-if="item.list&&item.list.length>0">
  32. <view class="list" v-for="(tag,indexs) in item.list" :key="indexs" @tap="toBuy(tag)">
  33. <view class="list_1">
  34. <view class="txt">
  35. <text>{{tag.title}}</text>
  36. </view>
  37. <view class="more" v-if="indexs==1" @tap.stop="toMore(tag)">
  38. <text>更多</text>
  39. </view>
  40. </view>
  41. <view class="list_2">
  42. <image class="image" :src="tag.url&&tag.url.length>0?tag.url[0].url:''" mode="">
  43. </image>
  44. </view>
  45. <view class="list_3 textOver">
  46. {{tag.name}}
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="zero act">
  52. <view class="list" v-for="(item,index) in platformactList" :key="index" @tap="toAct(item)">
  53. <view class="img">
  54. <image class="image" :src="item.cover&&item.cover.length>0?item.cover[0].url:''"
  55. mode="">
  56. </image>
  57. </view>
  58. <view class="title" v-if="item.act_time.is_use=='0'">
  59. <text>{{item.act_time.title}}</text>
  60. </view>
  61. <view class="time" v-if="item.act_time.is_use=='0'">
  62. <text>{{item.act_time.value}}</text>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="zero five">
  67. <view class="five_pubu">
  68. <view class="list" v-for="(item,index) in marketList" :key="index" @tap="toBuy(item)">
  69. <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''" mode="">
  70. </image>
  71. <view class="name textOver">
  72. {{item.name}}
  73. </view>
  74. <view class="other">
  75. <view class="money">
  76. <view class="money_1">
  77. <text>¥</text><text>{{item.sell_money||0}}</text>
  78. </view>
  79. <view class="money_2">
  80. <text>¥</text><text>{{item.flow_money||0}}</text>
  81. </view>
  82. </view>
  83. </view>
  84. <view class="other" v-if="item.leader_price">
  85. <view class="leader">
  86. <text>会员价</text><text>¥</text><text>{{item.leader_price||0}}</text>
  87. </view>
  88. </view>
  89. <view class="other" v-if="item.p_act">
  90. <text class="label" v-for="(tag,index) in item.p_act" :key="index">{{tag}}</text>
  91. </view>
  92. <view class="acttags">
  93. <text v-for="(i,indexx) in item.actTagsShow" :key="indexx">{{i.label}}</text>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. </scroll-view>
  101. <view class="backTop" v-if="old_scrollTop>500">
  102. <text @tap="goTop" class="iconfont icon-fanhuidingbu"></text>
  103. </view>
  104. </mobile-frame>
  105. </template>
  106. <script>
  107. export default {
  108. data() {
  109. return {
  110. // 店铺id
  111. shop: '',
  112. frameStyle: {
  113. useBar: true
  114. },
  115. bannerList: [ // 轮播图
  116. ],
  117. btnList: [ //功能按钮
  118. ],
  119. recomList: [ //推荐好物
  120. ],
  121. platformactList: [ //平台活动
  122. ],
  123. marketList: [ //商品列表
  124. ],
  125. total: 0,
  126. skip: 0,
  127. limit: 10,
  128. page: 0,
  129. // 返回顶部
  130. scrollTop: 0,
  131. old_scrollTop: 0
  132. };
  133. },
  134. onLoad: async function() {
  135. const that = this;
  136. await that.searchShop();
  137. },
  138. onPullDownRefresh: async function() {
  139. const that = this;
  140. that.clearPage();
  141. await that.search();
  142. uni.stopPullDownRefresh();
  143. },
  144. methods: {
  145. async search() {
  146. const that = this;
  147. let res;
  148. // 轮播图
  149. res = await that.$api(`/banner`, 'GET', {
  150. status: '0',
  151. shop: that.shop
  152. });
  153. if (res.errcode == '0') {
  154. that.$set(that, `bannerList`, res.data);
  155. }
  156. // 首页模块管理
  157. res = await that.$api(`/indexModule`, 'GET', {
  158. status: '0',
  159. shop: that.shop
  160. });
  161. if (res.errcode == '0') {
  162. that.$set(that, `btnList`, res.data);
  163. }
  164. // 推荐好货
  165. res = await that.$api(`/viewGoods/iatg`, 'GET', {
  166. shop: that.shop
  167. });
  168. if (res.errcode == '0') that.$set(that, `recomList`, res.data);
  169. // 平台活动
  170. res = await that.$api(`/platformAct`, 'GET', {
  171. show_index: '0',
  172. is_use: '0',
  173. shop: that.shop
  174. });
  175. if (res.errcode == '0') that.$set(that, `platformactList`, res.data);
  176. // 首页产品查询
  177. that.searchMarket()
  178. },
  179. // 首页产品查询
  180. async searchMarket() {
  181. const that = this;
  182. let res;
  183. let info = {
  184. skip: that.skip,
  185. limit: that.limit,
  186. shop: that.shop
  187. };
  188. // 首页产品列表
  189. res = await that.$api(`/viewGoods/indexGoodsList`, `GET`, {
  190. ...info
  191. });
  192. if (res.errcode == '0') {
  193. let list = [...that.marketList, ...res.data];
  194. that.$set(that, `marketList`, list);
  195. that.$set(that, `total`, res.total)
  196. }
  197. },
  198. // 公共跳转
  199. toCommon(e) {
  200. uni.navigateTo({
  201. url: `/${e}`
  202. })
  203. },
  204. // 轮播图跳转
  205. toBanner(e) {
  206. uni.navigateTo({
  207. url: `/${e.to}?id=${e._id}`
  208. })
  209. },
  210. // 首页模块菜单跳转
  211. toIndexModel(data) {
  212. if (data && data.status == '1') {
  213. uni.showToast({
  214. title: '升级中敬请期待!',
  215. icon: 'none'
  216. })
  217. } else {
  218. uni.navigateTo({
  219. url: `/${data.to}`
  220. })
  221. }
  222. },
  223. // 推荐好物更多
  224. toMore(e) {
  225. const that = this;
  226. uni.navigateTo({
  227. url: `/pagesRest/recom/index?act_tags=${e.value}`
  228. })
  229. },
  230. // 平台活动
  231. toAct(e) {
  232. const that = this;
  233. uni.navigateTo({
  234. url: `/pagesRest/activity/info?id=${e._id}`
  235. })
  236. },
  237. // 购买
  238. toBuy(e) {
  239. const that = this;
  240. let id = e._id || e.id;
  241. uni.navigateTo({
  242. url: `/pagesHome/order/detail?id=${id}`
  243. })
  244. },
  245. // 分页
  246. toPage(e) {
  247. const that = this;
  248. let list = that.marketList;
  249. let limit = that.limit;
  250. if (that.total > list.length) {
  251. uni.showLoading({
  252. title: '加载中',
  253. mask: true
  254. })
  255. let page = that.page + 1;
  256. that.$set(that, `page`, page)
  257. let skip = page * limit;
  258. that.$set(that, `skip`, skip)
  259. that.searchMarket();
  260. uni.hideLoading();
  261. }
  262. },
  263. // 计算高度
  264. scroll: function(e) {
  265. const that = this;
  266. that.old_scrollTop = e.detail.scrollTop
  267. },
  268. // 返回顶部
  269. goTop: function(e) {
  270. const that = this;
  271. that.scrollTop = that.old_scrollTop;
  272. that.$nextTick(function() {
  273. that.scrollTop = 0
  274. });
  275. },
  276. clearPage() {
  277. const that = this;
  278. that.$set(that, `bannerList`, [])
  279. that.$set(that, `btnList`, [])
  280. that.$set(that, `recomList`, [])
  281. that.$set(that, `platformactList`, [])
  282. that.$set(that, `marketList`, [])
  283. that.$set(that, `skip`, 0)
  284. that.$set(that, `limit`, 6)
  285. that.$set(that, `page`, 0)
  286. },
  287. // 菜单跳转
  288. toPath(e) {
  289. let url = `/${e.route}`;
  290. if (e.type == '0') uni.redirectTo({
  291. url
  292. })
  293. else {
  294. uni.navigateTo({
  295. url
  296. })
  297. }
  298. },
  299. // 店铺信息
  300. searchShop() {
  301. const that = this;
  302. uni.getStorage({
  303. key: 'shop',
  304. success: async function(res) {
  305. that.$set(that, `shop`, res.data);
  306. await that.search();
  307. }
  308. })
  309. }
  310. }
  311. }
  312. </script>
  313. <style lang="scss">
  314. .main {
  315. padding: 2vw;
  316. .zero {
  317. margin: 0 0 2vw 0;
  318. }
  319. .zero:last-child {
  320. margin: 0
  321. }
  322. .one {
  323. background-color: var(--fFB1Color);
  324. border-radius: 20px;
  325. padding: 0 2vw 0 5vw;
  326. input {
  327. font-size: var(--font15Size);
  328. color: var(--fffColor);
  329. border-radius: 14px;
  330. width: 100%;
  331. padding: 1.5vw;
  332. }
  333. .placss {
  334. color: var(--fffColor);
  335. }
  336. }
  337. .two {
  338. swiper {
  339. height: 50vw;
  340. border-radius: 5px;
  341. }
  342. .list {
  343. border-radius: 5px;
  344. .image {
  345. width: 100%;
  346. height: 100%;
  347. border-radius: 5px;
  348. }
  349. }
  350. }
  351. .thr {
  352. display: flex;
  353. flex-direction: row;
  354. justify-content: space-around;
  355. flex-wrap: wrap;
  356. .list {
  357. width: 17vw;
  358. text-align: center;
  359. margin: 0 0 2vw 0;
  360. .image {
  361. width: 80%;
  362. height: 13vw;
  363. margin: 1.5vw 0 1.5vw 0;
  364. }
  365. .name {
  366. font-size: var(--font13Size);
  367. }
  368. }
  369. }
  370. .four {
  371. display: flex;
  372. flex-direction: row;
  373. justify-content: space-around;
  374. flex-wrap: wrap;
  375. background-color: var(--f2Color);
  376. padding: 2vw 0 0 0;
  377. .recomList {
  378. width: 41vw;
  379. display: flex;
  380. justify-content: space-around;
  381. background-image: linear-gradient(to bottom, rgba(250, 216, 213, 1) 5%, rgba(255, 255, 255, 1) 22%);
  382. margin: 0 0 2vw 0;
  383. border-radius: 5px;
  384. padding: 2vw;
  385. .list {
  386. width: 20vw;
  387. text-align: center;
  388. .list_1 {
  389. display: flex;
  390. justify-content: space-between;
  391. margin: 0 0 1vw 0;
  392. .txt {
  393. font-size: 15px;
  394. }
  395. .more {
  396. font-size: 12px;
  397. margin: 0 0 4px 0;
  398. }
  399. }
  400. .list_2 {
  401. margin: 0 0 1vw 0;
  402. .image {
  403. width: 96%;
  404. height: 18vw;
  405. }
  406. }
  407. .list_3 {
  408. width: 17vw;
  409. font-size: var(--font12Size);
  410. border: 1px solid var(--fFB1Color);
  411. border-radius: 25px;
  412. padding: 0 1vw;
  413. text-align: center;
  414. }
  415. }
  416. }
  417. }
  418. .act {
  419. background-color: var(--f2Color);
  420. padding: 2vw 2vw 0 2vw;
  421. display: flex;
  422. flex-direction: column;
  423. .act_1 {
  424. text-align: center;
  425. margin: 0 0 2vw 0;
  426. font-family: cursive;
  427. color: var(--fFB1Color);
  428. font-size: 20px;
  429. }
  430. .list {
  431. border-radius: 10px;
  432. position: relative;
  433. .img {
  434. .image {
  435. width: 100%;
  436. height: 14vh;
  437. box-shadow: 0 0 5px #f1f1f1;
  438. border-radius: 10px;
  439. }
  440. }
  441. .title {
  442. position: absolute;
  443. top: 5vw;
  444. text-align: center;
  445. width: 95%;
  446. left: 2vw;
  447. text {
  448. font-size: 20px;
  449. font-family: cursive;
  450. color: #000000;
  451. font-weight: bold;
  452. overflow: hidden;
  453. text-overflow: ellipsis;
  454. -webkit-line-clamp: 2;
  455. word-break: break-all;
  456. display: -webkit-box;
  457. -webkit-box-orient: vertical;
  458. }
  459. }
  460. .time {
  461. position: absolute;
  462. bottom: 2vw;
  463. right: 2vw;
  464. font-size: 12px;
  465. width: 100%;
  466. text-align: right;
  467. }
  468. }
  469. }
  470. .five {
  471. display: flex;
  472. flex-direction: column;
  473. background-color: var(--f2Color);
  474. padding: 2vw 0;
  475. .five_pubu {
  476. // column-count: 2;
  477. // column-gap: 2vw;
  478. display: flex;
  479. justify-content: space-between;
  480. flex-wrap: wrap;
  481. padding: 0 2vw;
  482. .list {
  483. // break-inside: avoid;
  484. position: relative;
  485. width: 41vw;
  486. background-color: var(--fffColor);
  487. padding: 2vw;
  488. margin: 0 0 2vw 0;
  489. border-radius: 10px;
  490. .image {
  491. width: 100%;
  492. height: 40vw;
  493. }
  494. .name {
  495. font-size: var(--font14Size);
  496. }
  497. .other {
  498. display: flex;
  499. flex-direction: row;
  500. padding: 1vw 0 0 0;
  501. .money {
  502. display: flex;
  503. .money_1 {
  504. color: var(--fFB1Color);
  505. font-size: 12px;
  506. text:last-child {
  507. font-size: 16px;
  508. padding: 0 0 0 1vw;
  509. }
  510. }
  511. .money_2 {
  512. font-size: 12px;
  513. margin: 0 0 0 2vw;
  514. color: var(--f99Color);
  515. text {
  516. text-decoration: line-through;
  517. }
  518. text:last-child {
  519. font-size: 16px;
  520. padding: 0 0 0 1vw;
  521. }
  522. }
  523. }
  524. .label {
  525. font-size: 12px;
  526. color: #FFA500;
  527. border: 1px solid #FFA500;
  528. border-radius: 5px;
  529. padding: 0 1vw;
  530. margin: 0 1vw 0 0;
  531. }
  532. .leader {
  533. font-size: 12px;
  534. text-align: center;
  535. color: #23B67A;
  536. text:last-child {
  537. font-size: 16px;
  538. padding: 0 0 0 1vw;
  539. }
  540. }
  541. }
  542. .acttags {
  543. position: absolute;
  544. top: 2vw;
  545. width: 93%;
  546. text {
  547. display: inline-block;
  548. background-color: var(--fFB1Color);
  549. color: #fff;
  550. border-radius: 1vw;
  551. padding: 0.5vw;
  552. font-size: 12px;
  553. margin: 0 1vw 0 0;
  554. }
  555. }
  556. }
  557. }
  558. }
  559. }
  560. .scroll-view {
  561. position: absolute;
  562. top: 0;
  563. left: 0;
  564. right: 0;
  565. bottom: 0;
  566. .list-scroll-view {
  567. display: flex;
  568. flex-direction: column;
  569. }
  570. }
  571. .backTop {
  572. position: fixed;
  573. bottom: 20vw;
  574. right: 5vw;
  575. text {
  576. font-size: 30px;
  577. background-color: #0000005f;
  578. border-radius: 90px;
  579. }
  580. }
  581. </style>