index.vue 12 KB

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