index.vue 14 KB

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