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