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=""></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" v-if="item.act_time.is_use=='0'">
  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. const that = this;
  118. that.search();
  119. },
  120. onHide: function() {
  121. const that = this;
  122. // that.clearPage();
  123. },
  124. onUnload: function() {
  125. console.log('1');
  126. },
  127. methods: {
  128. async search() {
  129. const that = this;
  130. let res;
  131. // 轮播图
  132. res = await that.$api(`/banner`, 'GET', {
  133. status: '0'
  134. });
  135. if (res.errcode == '0') {
  136. let data = res.data.sort(function(a, b) {
  137. return a.sort - b.sort
  138. });
  139. that.$set(that, `bannerList`, data);
  140. }
  141. // 首页模块管理
  142. res = await that.$api(`/indexModule`, 'GET', {});
  143. if (res.errcode == '0') {
  144. let data = res.data.sort(function(a, b) {
  145. return a.sort - b.sort
  146. });
  147. that.$set(that, `btnList`, data);
  148. }
  149. // 推荐好货
  150. res = await that.$api(`/viewGoods/iatg`, 'GET', {});
  151. if (res.errcode == '0') that.$set(that, `recomList`, res.data);
  152. // 平台活动
  153. res = await that.$api(`/platformAct`, 'GET', {
  154. show_index: 0
  155. });
  156. if (res.errcode == '0') that.$set(that, `platformactList`, res.data);
  157. // 首页产品查询
  158. that.searchMarket()
  159. },
  160. // 首页产品查询
  161. async searchMarket() {
  162. const that = this;
  163. let res;
  164. let info = {
  165. skip: that.skip,
  166. limit: that.limit
  167. };
  168. // 首页产品列表
  169. res = await that.$api(`/viewGoods/indexGoodsList`, `GET`, {
  170. ...info
  171. });
  172. if (res.errcode == '0') {
  173. let list = [...that.marketList, ...res.data];
  174. that.$set(that, `marketList`, list);
  175. that.$set(that, `total`, res.total)
  176. }
  177. },
  178. // 公共跳转
  179. toCommon(e) {
  180. uni.navigateTo({
  181. url: `/${e}`
  182. })
  183. },
  184. // 轮播图跳转
  185. toBanner(e) {
  186. uni.navigateTo({
  187. url: `/${e.to}?id=${e._id}`
  188. })
  189. },
  190. // 首页模块菜单跳转
  191. toIndexModel(data) {
  192. if (data && data.status == '1') {
  193. uni.showToast({
  194. title: '模块禁用',
  195. icon: 'none'
  196. })
  197. } else {
  198. uni.navigateTo({
  199. url: `/${data.to}`
  200. })
  201. }
  202. },
  203. // 推荐好物更多
  204. toMore(e) {
  205. const that = this;
  206. // that.clearPage();
  207. uni.navigateTo({
  208. url: `/pagesRest/recom/index?act_tags=${e.value}`
  209. })
  210. },
  211. // 平台活动
  212. toAct(e) {
  213. const that = this;
  214. // that.clearPage();
  215. uni.navigateTo({
  216. url: `/pagesRest/activity/info?id=${e._id}`
  217. })
  218. },
  219. // 购买
  220. toBuy(e) {
  221. const that = this;
  222. let id = e._id || e.id;
  223. // that.clearPage();
  224. uni.navigateTo({
  225. url: `/pagesHome/order/detail?id=${id}`
  226. })
  227. },
  228. toPath(e) {
  229. if (e && e.route && e.type == '0') {
  230. uni.redirectTo({
  231. url: `/${e.route}`
  232. })
  233. } else {
  234. uni.navigateTo({
  235. url: `/${e.route}`
  236. })
  237. }
  238. },
  239. // 分页
  240. toPage(e) {
  241. const that = this;
  242. let list = that.marketList;
  243. let limit = that.limit;
  244. if (that.total > list.length) {
  245. uni.showLoading({
  246. title: '加载中',
  247. mask: true
  248. })
  249. let page = that.page + 1;
  250. that.$set(that, `page`, page)
  251. let skip = page * limit;
  252. that.$set(that, `skip`, skip)
  253. that.searchMarket();
  254. uni.hideLoading();
  255. }
  256. },
  257. // 计算高度
  258. scroll: function(e) {
  259. this.old.scrollTop = e.detail.scrollTop
  260. },
  261. // 返回顶部
  262. goTop: function(e) {
  263. this.scrollTop = this.old.scrollTop
  264. this.$nextTick(function() {
  265. this.scrollTop = 0
  266. });
  267. },
  268. // 清空列表
  269. clearPage() {
  270. const that = this;
  271. that.$set(that, `marketList`, [])
  272. that.$set(that, `skip`, 0)
  273. that.$set(that, `limit`, 6)
  274. that.$set(that, `page`, 0);
  275. that.$set(that, `market_type`, '1');
  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>