index.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="page">
  3. <navBar :title="name" :back="true" color="black" background="white" />
  4. <view class="con" v-if="list.length!=0">
  5. <view class="item" v-for="(item,index) in list" @click="goDetail(item)">
  6. <view class="topBox">
  7. <image :src="picBase+item.cover" mode=""></image>
  8. </view>
  9. <view class="bottom">
  10. <view class="txt">
  11. {{item.name}}
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="con" v-else style="justify-content: center;">
  17. <u-empty mode="data" text="暂无数据" width="160" height="160" :icon="picUrl+'/static/other/empty.png'">
  18. </u-empty>
  19. </view>
  20. <u-loadmore v-if="list.length!=0" style="" loadmoreText="已经到底啦" color="#CCCCCC" lineColor="#CCCCCC" line />
  21. <u-loading-page :loading="loading" image="/static/index/logo.png" loading-text="页面加载中..."></u-loading-page>
  22. </view>
  23. </template>
  24. <script>
  25. import {
  26. getMallReq,
  27. } from '@/api/test/index.js'
  28. export default {
  29. components: {
  30. },
  31. data() {
  32. return {
  33. picUrl: this.$picUrl,
  34. picBase: this.$picBase,
  35. list: [],
  36. name: '',
  37. brand: 0,
  38. type: 0,
  39. typeNameId: 0,
  40. pid: -1,
  41. loading: true
  42. }
  43. },
  44. async onLoad(o) {
  45. console.log('typeNameId ', o.typeNameId, 'pId ', o.pid);
  46. this.pid = o.pid
  47. this.name = o.name
  48. this.typeNameId = o.typeNameId
  49. this.brand = o.brand
  50. this.type = o.type
  51. },
  52. async onShow() {
  53. let res = await getMallReq({
  54. typeNameId: this.typeNameId,
  55. pid: this.pid
  56. // brand: this.brand,
  57. // type: this.type,
  58. })
  59. if (res.code == 0) {
  60. this.list = res.data
  61. this.loading = false
  62. console.log('获取商城列表数据返回值-子分类: ', res);
  63. } else {
  64. this.loading = false
  65. uni.showToast({
  66. title: res.message,
  67. icon: 'none'
  68. })
  69. }
  70. },
  71. methods: {
  72. goDetail(item) {
  73. getApp().mallItem = item
  74. uni.navigateTo({
  75. url: '/pages/mall/detail/index'
  76. })
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. @import "./index.scss";
  83. </style>