index.vue 12 KB

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