index.vue 12 KB

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