apps.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view class="pageHome">
  3. <yx-navbar :isBack="false" title="移动应用"></yx-navbar>
  4. <view class="pageIndex">
  5. <view class="tabs">
  6. <view class="tab" :class="tabIndex == 0 ? 'active' : ''" @click="onClickTab(0)">
  7. <text>系统应用</text>
  8. </view>
  9. <view class="tab" :class="tabIndex == 1 ? 'active' : ''" @click="onClickTab(1)">
  10. <text>我的应用</text>
  11. </view>
  12. </view>
  13. <view class="search">
  14. <u-search
  15. placeholder="请输入应该名称" v-model="params.appName" :show-action="false"
  16. bg-color="#f6f6f6" @change="onSearch" shape="square"
  17. ></u-search>
  18. </view>
  19. <scroll-view class="content" scroll-y @scrolltolower="getData(false)">
  20. <view class="main" v-if="dataList.length ">
  21. <view class="infoList" v-for="(item, index) in dataList" :key="index" @click="goDetail(item)">
  22. <img v-if="item.appIcon" class="infoImg" :src="item.appIcon" alt="">
  23. <img v-else class="infoImg" src="../../static/img/no-bg-img.jpg" alt="">
  24. <view class="info-box">
  25. <view class="name">{{ item.appName }}</view>
  26. <view class="describe">{{ item.appDescription }}</view>
  27. <view class="info">
  28. <view class="num"><i class="el-icon-view"></i> 访问量:0</view>
  29. <view class="dateTime">{{ item.date }}</view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <template v-if="!loading&&!dataList.length">
  35. <image class="none" v-if="params.appName" src="../../static/img/no-search.png" style="width: 100%" mode="aspectFit"></image>
  36. <image class="none" v-else src="../../static/img/no-data.png" style="width: 100%" mode="aspectFit"></image>
  37. </template>
  38. </scroll-view>
  39. </view>
  40. <tab-bar tabbarValue='移动应用'></tab-bar>
  41. </view>
  42. </template>
  43. <script>
  44. import {systemAppPage, mineAppPage} from '@/common/api.js'
  45. import moment from 'moment'
  46. export default {
  47. data() {
  48. return {
  49. tabIndex: 0,
  50. params: {size: 10, current: 1, appName: "", publishStatus: 1},
  51. dataList: [],
  52. loading: true,
  53. }
  54. },
  55. onShow() {
  56. this.getData(true)
  57. },
  58. methods: {
  59. getData(reload) {
  60. if (reload) {
  61. this.params.current = 1
  62. }
  63. this.loading = true
  64. if (this.tabIndex === 0) {
  65. systemAppPage({...this.params}).then(res => {
  66. let data = res.data.records
  67. data.forEach(item => {
  68. item.date = moment(item.createTime).format('YYYY-MM-DD')
  69. })
  70. if (data.length) this.params.current++
  71. this.dataList = reload ? data : this.dataList.concat(data)
  72. }).finally(() => this.loading = false)
  73. }
  74. if (this.tabIndex === 1) {
  75. mineAppPage({...this.params}).then(res => {
  76. let data = res.data.records
  77. data.forEach(item => {
  78. item.date = moment(item.createTime).format('YYYY-MM-DD')
  79. })
  80. if (data.length) this.params.current++
  81. this.dataList = reload ? data : this.dataList.concat(data)
  82. }).finally(() => this.loading = false)
  83. }
  84. },
  85. onClickTab(index) {
  86. this.tabIndex = index
  87. this.params.appName = ''
  88. this.getData(true)
  89. },
  90. onSearch(e) {
  91. this.getData(true)
  92. },
  93. goDetail(item) {
  94. uni.navigateTo({url: `/pages/detail/app?id=${item.appId}&title=${item.appName}`})
  95. },
  96. }
  97. }
  98. </script>
  99. <style lang="less">
  100. @import "./home.less";
  101. </style>