index.vue 13 KB

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