index.vue 13 KB

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