apps.vue 3.5 KB

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