index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view class="content">
  3. <u-swiper height="250" :list="imageTopList"></u-swiper>
  4. <view class="t1">
  5. <u-image height="40" src="/static/t1.png"></u-image>
  6. </view>
  7. <!-- 商品 -->
  8. <view class="goods">
  9. <view v-for="(item,index) in goodsList" :key="item.type.id" v-if="item.list.length">
  10. <u-section :title="item.type.name" line-color="#01c9b2" sub-title="更多" @click="toGoods(item.type)"></u-section>
  11. <view class="goods-list">
  12. <uni-coods :list="item.list"></uni-coods>
  13. </view>
  14. </view>
  15. <view v-else>
  16. <u-empty text="暂无商品" mode="list"></u-empty>
  17. </view>
  18. </view>
  19. <!-- 购物车 -->
  20. <uni-cart-fix></uni-cart-fix>
  21. </view>
  22. </template>
  23. <script>
  24. import {
  25. getGoodsClass,
  26. getGoodsList
  27. } from '@/api/goods.js'
  28. export default {
  29. components: {
  30. },
  31. data() {
  32. return {
  33. imageTopList:[
  34. {image:'/static/banner.png'},
  35. {image:'/static/banner1.png'}
  36. ],
  37. goodsList:[], // 商品
  38. goodsType:[], // 商品分类
  39. }
  40. },
  41. onLoad() {
  42. getGoodsClass({}).then(res => {
  43. console.log(res)
  44. if(res.status == 200){
  45. this.goodsType = res.data
  46. this.goodsType.map((item,index) => {
  47. this.getGoods(item,index)
  48. })
  49. }else{
  50. this.goodsList = []
  51. }
  52. })
  53. },
  54. methods: {
  55. // 更多商品
  56. toGoods(item){
  57. uni.navigateTo({
  58. url:"/pages/goods/goods?goodsTypeNo="+ item.goodsTypeNo + "&goldLimit="+ item.goldLimit
  59. })
  60. },
  61. // 查询商品
  62. getGoods(item,index){
  63. getGoodsList({pageNo:1,pageSize:item.popularizeGoodsLimit,goodsTypeNo:item.goodsTypeNo}).then(res => {
  64. console.log(res,'goodsList')
  65. if(res.status == 200&&res.data.list&&res.data.list.length){
  66. this.goodsList.push({
  67. type: item,
  68. list: res.data.list
  69. })
  70. this.goodsList.splice()
  71. }
  72. })
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .content {
  79. background: url(../../static/topBg.png) no-repeat top center;
  80. background-size: 100%;
  81. width: 100%;
  82. .goods{
  83. >view{
  84. padding: 25upx 20upx 10upx;
  85. background: #FFFFFF;
  86. border-radius: 15upx;
  87. box-shadow: 0upx 6upx 10upx #eee;
  88. margin-bottom: 20upx;
  89. > .goods-list{
  90. padding-top: 5upx;
  91. }
  92. }
  93. }
  94. .t1{
  95. padding: 20upx 0;
  96. }
  97. }
  98. </style>