index.vue 13 KB

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