index.vue 12 KB

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