index.vue 11 KB

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