index.vue 12 KB

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