index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. <template>
  2. <view class="container">
  3. <swiper class="banner" indicator-dots="true" autoplay="true" interval="3000" duration="1000">
  4. <swiper-item v-for="(item, index) in banner" :key="index">
  5. <navigator v-if="item.link" :url="item.link">
  6. <image :src="item.image_url" background-size="cover"></image>
  7. </navigator>
  8. <image v-else :src="item.image_url" background-size="cover"></image>
  9. </swiper-item>
  10. </swiper>
  11. <view class="a-section a-topic" v-if="channel.length > 0">
  12. <view class="m-menu">
  13. <navigator class="item" v-for="(item, index) in channel" :key="index" :url="item.url">
  14. <image :src="item.icon_url" background-size="cover"></image>
  15. <text>{{item.name}}</text>
  16. </navigator>
  17. </view>
  18. </view>
  19. <view class="a-section a-topic" v-if="brands.length > 0">
  20. <view class="a-section a-brand">
  21. <view class="h">
  22. <navigator url="/pages/brand/brand">
  23. <text class="txt">品牌制造商直供</text>
  24. </navigator>
  25. </view>
  26. </view>
  27. <view class="b">
  28. <scroll-view scroll-x="true" class="list">
  29. <view class="item" v-for="(item, index) in brands" :key="index">
  30. <navigator :url="'/pages/brandDetail/brandDetail?id='+item.id">
  31. <image class="img" :src="item.new_pic_url" background-size="cover"></image>
  32. <view class="np">
  33. <text class="name">{{item.name}}</text>
  34. <text class="price">¥{{item.floor_price}}元起</text>
  35. </view>
  36. <text class="desc">{{item.simple_desc}}</text>
  37. </navigator>
  38. </view>
  39. </scroll-view>
  40. </view>
  41. </view>
  42. <view class="a-section a-topic" v-if="topics.length > 0">
  43. <view class="a-section a-brand">
  44. <view class="h">
  45. <navigator open-type="switchTab" url="/pages/topic/topic">
  46. <text class="txt">专题精选</text>
  47. </navigator>
  48. </view>
  49. </view>
  50. <view class="b">
  51. <scroll-view scroll-x="true" class="list">
  52. <view class="item" v-for="(item, index) in topics" :key="index">
  53. <navigator :url="'/pages/topicDetail/topicDetail?id='+item.id">
  54. <image class="img" :src="item.scene_pic_url" background-size="cover"></image>
  55. <view class="np">
  56. <text class="name">{{item.title}}</text>
  57. <text class="price">¥{{item.price_info}}元起</text>
  58. </view>
  59. <text class="desc">{{item.subtitle}}</text>
  60. </navigator>
  61. </view>
  62. </scroll-view>
  63. </view>
  64. </view>
  65. <view class="a-section a-new" v-if="newGoods.length > 0">
  66. <view class="h">
  67. <view>
  68. <navigator url="../newGoods/newGoods">
  69. <text class="txt">周一周四 · 新品首发</text>
  70. </navigator>
  71. </view>
  72. </view>
  73. <view class="b">
  74. <view class="item" v-for="(item, index) in newGoods" :key="index">
  75. <navigator :url="'/pages/goods/goods?id='+item.id">
  76. <image class="img" :src="item.list_pic_url" background-size="cover"></image>
  77. <text class="name">{{item.name}}</text>
  78. <text class="price">¥{{item.retail_price}}</text>
  79. </navigator>
  80. </view>
  81. </view>
  82. </view>
  83. <view class="a-section a-popular" v-if="hotGoods.length > 0">
  84. <view class="h">
  85. <view>
  86. <navigator url="../hotGoods/hotGoods">
  87. <text class="txt">人气推荐</text>
  88. </navigator>
  89. </view>
  90. </view>
  91. <view class="b">
  92. <view class="item" v-for="(item, index) in hotGoods" :key="index">
  93. <navigator :url="'/pages/goods/goods?id='+item.id">
  94. <image class="img" :src="item.list_pic_url" background-size="cover"></image>
  95. <view class="right">
  96. <view class="text">
  97. <text class="name">{{item.name}}</text>
  98. <text class="desc">{{item.goods_brief}}</text>
  99. <text class="price">¥{{item.retail_price}}</text>
  100. </view>
  101. </view>
  102. </navigator>
  103. </view>
  104. </view>
  105. </view>
  106. <view class="good-grid" v-for="(item, index) in floorGoods" :key="index">
  107. <view class="h">
  108. <view>
  109. <text>{{item.name}}</text>
  110. </view>
  111. </view>
  112. <view class="b">
  113. <view class="item" v-for="(iitem, iindex) in item.goodsList" :key="iindex">
  114. <view :class="'item ' + iindex % 2 == 0 ? '' : 'item-b'">
  115. <navigator :url="'/pages/goods/goods?id='+item.id">
  116. <image class="img" :src="iitem.list_pic_url" background-size="cover"></image>
  117. <text class="name">{{iitem.name}}</text>
  118. <text class="price">¥{{iitem.retail_price}}</text>
  119. </navigator>
  120. </view>
  121. </view>
  122. <view class="item item-b item-more">
  123. <navigator :url="'/pages/category/category?id='+item.id" class="more-a">
  124. <view class="txt">{{'更多'+item.name+'好物'}}</view>
  125. <image class="icon" src="../../static/images/icon_go_more.png" background-size="cover"></image>
  126. </navigator>
  127. </view>
  128. </view>
  129. </view>
  130. </view>
  131. </template>
  132. <script>
  133. const api = require('@/utils/api.js');
  134. const util = require("@/utils/util.js")
  135. export default {
  136. data() {
  137. return {
  138. newGoods: [],
  139. hotGoods: [],
  140. topics: [],
  141. brands: [],
  142. floorGoods: [],
  143. banner: [],
  144. channel: []
  145. }
  146. },
  147. methods: {
  148. getIndexData: function() {
  149. let that = this;
  150. util.request(api.IndexUrlNewGoods).then(function(res) {
  151. if (res.errno === 0) {
  152. that.newGoods = res.data.newGoodsList
  153. }
  154. });
  155. util.request(api.IndexUrlHotGoods).then(function(res) {
  156. if (res.errno === 0) {
  157. that.hotGoods = res.data.hotGoodsList
  158. }
  159. });
  160. util.request(api.IndexUrlTopic).then(function(res) {
  161. if (res.errno === 0) {
  162. that.topics = res.data.topicList
  163. }
  164. });
  165. util.request(api.IndexUrlBrand).then(function(res) {
  166. if (res.errno === 0) {
  167. that.brands = res.data.brandList
  168. }
  169. });
  170. util.request(api.IndexUrlCategory).then(function(res) {
  171. if (res.errno === 0) {
  172. that.floorGoods = res.data.categoryList
  173. }
  174. });
  175. util.request(api.IndexUrlBanner).then(function(res) {
  176. if (res.errno === 0) {
  177. that.banner = res.data.banner
  178. }
  179. });
  180. util.request(api.IndexUrlChannel).then(function(res) {
  181. if (res.errno === 0) {
  182. that.channel = res.data.channel
  183. }
  184. });
  185. },
  186. },
  187. // 增加下拉刷新数据的功能
  188. onPullDownRefresh() {
  189. this.getIndexData();
  190. },
  191. onShareAppMessage: function() {
  192. return {
  193. title: '微同开源商城',
  194. path: '/pages/index/index'
  195. }
  196. },
  197. onLoad: function() {
  198. this.getIndexData();
  199. }
  200. }
  201. </script>
  202. <style lang="scss">
  203. .banner {
  204. width: 750rpx;
  205. height: 417rpx;
  206. }
  207. .banner image {
  208. width: 100%;
  209. height: 417rpx;
  210. }
  211. .m-menu {
  212. display: flex;
  213. height: 181rpx;
  214. width: 750rpx;
  215. flex-flow: row nowrap;
  216. align-items: center;
  217. justify-content: space-between;
  218. background-color: #fff;
  219. }
  220. .m-menu .item {
  221. flex: 1;
  222. display: block;
  223. padding: 20rpx 0;
  224. }
  225. .m-menu image {
  226. display: block;
  227. width: 58rpx;
  228. height: 58rpx;
  229. margin: 0 auto;
  230. margin-bottom: 12rpx;
  231. }
  232. .m-menu text {
  233. display: block;
  234. font-size: 24rpx;
  235. text-align: center;
  236. margin: 0 auto;
  237. line-height: 1;
  238. color: #333;
  239. }
  240. .a-section {
  241. width: 750rpx;
  242. height: auto;
  243. overflow: hidden;
  244. background: #fff;
  245. color: #333;
  246. margin-top: 20rpx;
  247. }
  248. .a-section .h {
  249. display: flex;
  250. flex-flow: row nowrap;
  251. align-items: center;
  252. justify-content: center;
  253. height: 130rpx;
  254. }
  255. .a-section .h .txt {
  256. padding-right: 30rpx;
  257. background-size: 16.656rpx 27rpx;
  258. display: inline-block;
  259. height: 36rpx;
  260. font-size: 33rpx;
  261. line-height: 36rpx;
  262. }
  263. .a-brand .b {
  264. width: 750rpx;
  265. height: auto;
  266. overflow: hidden;
  267. position: relative;
  268. }
  269. .a-brand .wrap {
  270. position: relative;
  271. }
  272. .a-brand .img {
  273. position: absolute;
  274. left: 0;
  275. top: 0;
  276. }
  277. .a-brand .mt {
  278. position: absolute;
  279. z-index: 2;
  280. padding: 27rpx 31rpx;
  281. left: 0;
  282. top: 0;
  283. }
  284. .a-brand .mt .brand {
  285. display: block;
  286. font-size: 33rpx;
  287. height: 43rpx;
  288. color: #333;
  289. }
  290. .a-brand .mt .price,
  291. .a-brand .mt .unit {
  292. font-size: 25rpx;
  293. color: #999;
  294. }
  295. .a-brand .item-1 {
  296. float: left;
  297. width: 375rpx;
  298. height: 252rpx;
  299. overflow: hidden;
  300. border-top: 1rpx solid #fff;
  301. margin-left: 1rpx;
  302. }
  303. .a-brand .item-1:nth-child(2n+1) {
  304. margin-left: 0;
  305. width: 374rpx;
  306. }
  307. .a-brand .item-1 .img {
  308. width: 375rpx;
  309. height: 253rpx;
  310. }
  311. .a-new .b {
  312. width: 750rpx;
  313. height: auto;
  314. overflow: hidden;
  315. padding: 0 31rpx 45rpx 31rpx;
  316. }
  317. .a-new .b .item {
  318. float: left;
  319. width: 302rpx;
  320. margin-top: 10rpx;
  321. margin-left: 21rpx;
  322. margin-right: 21rpx;
  323. }
  324. .a-new .b .item-b {
  325. margin-left: 42rpx;
  326. }
  327. .a-new .b .img {
  328. width: 302rpx;
  329. height: 302rpx;
  330. }
  331. .a-new .b .name {
  332. text-align: center;
  333. display: block;
  334. width: 302rpx;
  335. height: 35rpx;
  336. margin-bottom: 14rpx;
  337. overflow: hidden;
  338. font-size: 30rpx;
  339. color: #333;
  340. }
  341. .a-new .b .price {
  342. display: block;
  343. text-align: center;
  344. line-height: 30rpx;
  345. font-size: 30rpx;
  346. color: #b4282d;
  347. }
  348. .a-popular {
  349. width: 750rpx;
  350. height: auto;
  351. overflow: hidden;
  352. }
  353. .a-popular .b .item {
  354. border-top: 1px solid #d9d9d9;
  355. margin: 0 20rpx;
  356. height: 264rpx;
  357. width: 710rpx;
  358. }
  359. .a-popular .b .img {
  360. margin-top: 12rpx;
  361. margin-right: 12rpx;
  362. float: left;
  363. width: 240rpx;
  364. height: 240rpx;
  365. }
  366. .a-popular .b .right {
  367. float: left;
  368. height: 264rpx;
  369. width: 456rpx;
  370. display: flex;
  371. flex-flow: row nowrap;
  372. }
  373. .a-popular .b .text {
  374. display: flex;
  375. flex-wrap: nowrap;
  376. flex-direction: column;
  377. justify-content: center;
  378. overflow: hidden;
  379. height: 264rpx;
  380. width: 456rpx;
  381. }
  382. .a-popular .b .name {
  383. width: 456rpx;
  384. display: block;
  385. color: #333;
  386. line-height: 50rpx;
  387. font-size: 30rpx;
  388. }
  389. .a-popular .b .desc {
  390. width: 456rpx;
  391. display: block;
  392. color: #999;
  393. line-height: 50rpx;
  394. font-size: 25rpx;
  395. }
  396. .a-popular .b .price {
  397. width: 456rpx;
  398. display: block;
  399. color: #b4282d;
  400. line-height: 50rpx;
  401. font-size: 33rpx;
  402. }
  403. .a-topic .b {
  404. height: 533rpx;
  405. width: 750rpx;
  406. padding: 0 0 48rpx 0;
  407. }
  408. .a-topic .b .list {
  409. height: 533rpx;
  410. width: 750rpx;
  411. white-space: nowrap;
  412. }
  413. .a-topic .b .item {
  414. display: inline-block;
  415. height: 533rpx;
  416. width: 680.5rpx;
  417. margin-left: 30rpx;
  418. overflow: hidden;
  419. }
  420. .a-topic .b .item:last-child {
  421. margin-right: 30rpx;
  422. }
  423. .a-topic .b .img {
  424. height: 387.5rpx;
  425. width: 680.5rpx;
  426. margin-bottom: 30rpx;
  427. }
  428. .a-topic .b .np {
  429. height: 35rpx;
  430. margin-bottom: 13.5rpx;
  431. color: #333;
  432. font-size: 30rpx;
  433. }
  434. .a-topic .b .np .price {
  435. margin-left: 20.8rpx;
  436. color: #b4282d;
  437. }
  438. .a-topic .b .desc {
  439. display: block;
  440. height: 30rpx;
  441. color: #999;
  442. font-size: 24rpx;
  443. white-space: nowrap;
  444. overflow: hidden;
  445. text-overflow: ellipsis;
  446. }
  447. .good-grid {
  448. width: 750rpx;
  449. height: auto;
  450. overflow: hidden;
  451. }
  452. .good-grid .h {
  453. display: flex;
  454. flex-flow: row nowrap;
  455. align-items: center;
  456. justify-content: center;
  457. height: 130rpx;
  458. font-size: 33rpx;
  459. color: #333;
  460. }
  461. .good-grid .b {
  462. width: 750rpx;
  463. padding: 0 6.25rpx;
  464. height: auto;
  465. overflow: hidden;
  466. }
  467. .good-grid .b .item {
  468. float: left;
  469. background: #fff;
  470. width: 365rpx;
  471. margin-bottom: 6.25rpx;
  472. height: 452rpx;
  473. overflow: hidden;
  474. text-align: center;
  475. }
  476. .good-grid .b .item .a {
  477. height: 452rpx;
  478. width: 100%;
  479. }
  480. .good-grid .b .item-b {
  481. margin-left: 6.25rpx;
  482. }
  483. .good-grid .item .img {
  484. margin-top: 20rpx;
  485. width: 302rpx;
  486. height: 302rpx;
  487. }
  488. .good-grid .item .name {
  489. display: block;
  490. width: 365.625rpx;
  491. padding: 0 20rpx;
  492. overflow: hidden;
  493. height: 35rpx;
  494. margin: 11.5rpx 0 22rpx 0;
  495. text-align: center;
  496. font-size: 30rpx;
  497. color: #333;
  498. }
  499. .good-grid .item .price {
  500. display: block;
  501. width: 365.625rpx;
  502. height: 30rpx;
  503. text-align: center;
  504. font-size: 30rpx;
  505. color: #b4282d;
  506. }
  507. .good-grid .more-item {
  508. height: 100%;
  509. width: 100%;
  510. }
  511. .more-a {
  512. height: 100%;
  513. width: 100%;
  514. display: flex;
  515. flex-direction: column;
  516. align-items: center;
  517. justify-content: center;
  518. }
  519. .good-grid .more-a .txt {
  520. height: 33rpx;
  521. width: 100%;
  522. line-height: 33rpx;
  523. color: #333;
  524. font-size: 33rpx;
  525. }
  526. .good-grid .more-a .icon {
  527. margin: 60rpx auto 0 auto;
  528. width: 70rpx;
  529. height: 70rpx;
  530. }
  531. </style>