index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  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. 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. uni.navigateTo({
  200. url: `/pagesRest/recom/index?act_tags=${e.value}`
  201. })
  202. },
  203. // 平台活动
  204. toAct(e) {
  205. const that = this;
  206. uni.navigateTo({
  207. url: `/pagesRest/activity/info?id=${e._id}`
  208. })
  209. },
  210. // 购买
  211. toBuy(e) {
  212. const that = this;
  213. let id = e._id || e.id;
  214. uni.navigateTo({
  215. url: `/pagesHome/order/detail?id=${id}`
  216. })
  217. },
  218. toPath(e) {
  219. if (e && e.route && e.type == '0') {
  220. uni.redirectTo({
  221. url: `/${e.route}`
  222. })
  223. } else {
  224. uni.navigateTo({
  225. url: `/${e.route}`
  226. })
  227. }
  228. },
  229. // 分页
  230. toPage(e) {
  231. const that = this;
  232. let list = that.marketList;
  233. let limit = that.limit;
  234. if (that.total > list.length) {
  235. uni.showLoading({
  236. title: '加载中',
  237. mask: true
  238. })
  239. let page = that.page + 1;
  240. that.$set(that, `page`, page)
  241. let skip = page * limit;
  242. that.$set(that, `skip`, skip)
  243. that.searchMarket();
  244. uni.hideLoading();
  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. }
  260. </script>
  261. <style lang="scss">
  262. .main {
  263. padding: 2vw;
  264. .zero {
  265. margin: 0 0 2vw 0;
  266. }
  267. .zero:last-child {
  268. margin: 0
  269. }
  270. .one {
  271. background-color: var(--fFB1Color);
  272. border-radius: 20px;
  273. padding: 0 2vw;
  274. input {
  275. font-size: var(--font15Size);
  276. color: var(--fffColor);
  277. border-radius: 14px;
  278. width: 100%;
  279. padding: 1.5vw 0;
  280. }
  281. .placss {
  282. color: var(--fffColor);
  283. }
  284. }
  285. .two {
  286. swiper {
  287. height: 50vw;
  288. border-radius: 5px;
  289. }
  290. .list {
  291. border-radius: 5px;
  292. .image {
  293. width: 100%;
  294. height: 100%;
  295. border-radius: 5px;
  296. }
  297. }
  298. }
  299. .thr {
  300. display: flex;
  301. flex-direction: row;
  302. justify-content: space-around;
  303. flex-wrap: wrap;
  304. .list {
  305. width: 17vw;
  306. text-align: center;
  307. margin: 0 0 2vw 0;
  308. .image {
  309. width: 80%;
  310. height: 13vw;
  311. margin: 1.5vw 0 1.5vw 0;
  312. }
  313. .name {
  314. font-size: var(--font13Size);
  315. }
  316. }
  317. }
  318. .four {
  319. display: flex;
  320. flex-direction: row;
  321. justify-content: space-around;
  322. flex-wrap: wrap;
  323. background-color: var(--f2Color);
  324. padding: 2vw 0 0 0;
  325. .recomList {
  326. width: 41vw;
  327. display: flex;
  328. justify-content: space-around;
  329. background-image: linear-gradient(to bottom, rgba(250, 216, 213, 1) 5%, rgba(255, 255, 255, 1) 22%);
  330. margin: 0 0 2vw 0;
  331. border-radius: 5px;
  332. padding: 2vw;
  333. .list {
  334. width: 20vw;
  335. text-align: center;
  336. .list_1 {
  337. display: flex;
  338. justify-content: space-between;
  339. margin: 0 0 1vw 0;
  340. .txt {
  341. font-size: 15px;
  342. }
  343. .more {
  344. font-size: 12px;
  345. margin: 0 0 4px 0;
  346. }
  347. }
  348. .list_2 {
  349. margin: 0 0 1vw 0;
  350. .image {
  351. width: 96%;
  352. height: 18vw;
  353. }
  354. }
  355. .list_3 {
  356. width: 17vw;
  357. font-size: var(--font12Size);
  358. border: 1px solid var(--fFB1Color);
  359. border-radius: 25px;
  360. padding: 0 1vw;
  361. text-align: center;
  362. }
  363. }
  364. }
  365. }
  366. .act {
  367. background-color: var(--f2Color);
  368. padding: 2vw 2vw 0 2vw;
  369. display: flex;
  370. flex-direction: column;
  371. .act_1 {
  372. text-align: center;
  373. margin: 0 0 2vw 0;
  374. font-family: cursive;
  375. color: #ff0000;
  376. font-size: 20px;
  377. }
  378. .list {
  379. border-radius: 10px;
  380. position: relative;
  381. .img {
  382. .image {
  383. width: 100%;
  384. height: 14vh;
  385. box-shadow: 0 0 5px #f1f1f1;
  386. border-radius: 10px;
  387. }
  388. }
  389. .title {
  390. position: absolute;
  391. top: 5vw;
  392. text-align: center;
  393. width: 95%;
  394. left: 2vw;
  395. text {
  396. font-size: 20px;
  397. font-family: cursive;
  398. color: #000000;
  399. font-weight: bold;
  400. overflow: hidden;
  401. text-overflow: ellipsis;
  402. -webkit-line-clamp: 2;
  403. word-break: break-all;
  404. display: -webkit-box;
  405. -webkit-box-orient: vertical;
  406. }
  407. }
  408. .time {
  409. position: absolute;
  410. bottom: 2vw;
  411. right: 2vw;
  412. font-size: 12px;
  413. width: 100%;
  414. text-align: right;
  415. }
  416. }
  417. }
  418. .five {
  419. display: flex;
  420. flex-direction: column;
  421. background-color: var(--f2Color);
  422. padding: 2vw 0;
  423. .five_pubu {
  424. // column-count: 2;
  425. // column-gap: 2vw;
  426. display: flex;
  427. justify-content: space-between;
  428. flex-wrap: wrap;
  429. padding: 0 2vw;
  430. .list {
  431. // break-inside: avoid;
  432. width: 41vw;
  433. background-color: var(--fffColor);
  434. padding: 2vw;
  435. margin: 0 0 2vw 0;
  436. border-radius: 10px;
  437. .image {
  438. width: 100%;
  439. height: 40vw;
  440. }
  441. .name {
  442. font-size: var(--font14Size);
  443. margin: 0 0 1vw 0;
  444. }
  445. .other {
  446. display: flex;
  447. flex-direction: row;
  448. justify-content: space-between;
  449. .money {
  450. display: flex;
  451. .money_1 {
  452. color: var(--fFB1Color);
  453. font-size: 12px;
  454. text:last-child {
  455. font-size: 16px;
  456. padding: 0 0 0 1vw;
  457. }
  458. }
  459. .money_2 {
  460. font-size: 12px;
  461. margin: 0 0 0 2vw;
  462. color: var(--f99Color);
  463. text {
  464. text-decoration: line-through;
  465. }
  466. text:last-child {
  467. font-size: 16px;
  468. padding: 0 0 0 1vw;
  469. }
  470. }
  471. }
  472. }
  473. }
  474. }
  475. }
  476. }
  477. .scroll-view {
  478. position: absolute;
  479. top: 0;
  480. left: 0;
  481. right: 0;
  482. bottom: 0;
  483. .list-scroll-view {
  484. display: flex;
  485. flex-direction: column;
  486. }
  487. }
  488. .backTop {
  489. position: fixed;
  490. bottom: 20vw;
  491. right: 5vw;
  492. text {
  493. font-size: 30px;
  494. background-color: #0000005f;
  495. border-radius: 90px;
  496. }
  497. }
  498. </style>