index.vue 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="container">
  3. <view class="intro">本项目已包含uni ui组件,无需import和注册,可直接使用。在代码区键入字母u,即可通过代码助手列出所有可用组件。光标置于组件名称处按F1,即可查看组件文档。</view>
  4. <text class="intro">详见:</text>
  5. <uni-link :href="href" :text="href"></uni-link>
  6. <!-- <mescroll-body ref="mescrollRef" @init="mescrollInit" @up="upCallback" @down="downCallback">
  7. <view class="content3" v-for="(item,index) in infoList">
  8. </view>
  9. </mescroll-body> -->
  10. </view>
  11. </template>
  12. <script>
  13. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  14. import {
  15. mapState,
  16. mapMutations
  17. } from 'vuex';
  18. export default {
  19. mixins: [MescrollMixin], // 使用mixin
  20. computed: {
  21. ...mapState(['hasLogin'])
  22. },
  23. data() {
  24. return {
  25. href: 'https://uniapp.dcloud.io/component/README?id=uniui',
  26. canReset: false,
  27. userInfo: {},
  28. infoList: []
  29. }
  30. },
  31. onShow() {
  32. // this.$nextTick(function() {
  33. // this.canReset && this.mescroll.resetUpScroll() // 重置列表数据为第一页
  34. // this.canReset && this.mescroll.scrollTo(0, 0) // 重置列表数据为第一页时,建议把滚动条也重置到顶部,避免无法再次翻页的问题
  35. // this.canReset = true // 过滤第一次的onShow事件,避免初始化界面时重复触发upCallback, 无需配置auto:false
  36. // });
  37. // if (this.hasLogin || uni.getStorageSync("userInfo").username) {
  38. // this.userInfo = uni.getStorageSync("userInfo")
  39. // this.isLogin = true
  40. // } else {
  41. // uni.navigateTo({
  42. // url: "/pages/login/login"
  43. // })
  44. // }
  45. },
  46. methods: {
  47. upCallback(page) {
  48. uni.showLoading({
  49. title: '数据加载中'
  50. })
  51. this.$request.baseRequest('pincheCarSharingApp', 'list', {
  52. remark2: this.route,
  53. carpoolingType: this.type,
  54. companyId: 1,
  55. pageNum: page.num,
  56. pageSize: page.size,
  57. }, failres => {
  58. console.log('res+++++', failres.errmsg)
  59. this.$refs.uToast.show({
  60. type: 'error',
  61. message: failres.errmsg,
  62. })
  63. uni.hideLoading()
  64. }).then(res => {
  65. // if (res.errno == 200) {
  66. uni.hideLoading()
  67. console.log(11)
  68. let curPageData = res.data.items;
  69. let totalPage = res.data.total;
  70. let curPageLen = curPageData.length;
  71. this.mescroll.endByPage(curPageLen, totalPage);
  72. console.log(res.data)
  73. // this.makeData(res.data)
  74. if (page.num == 1) this.infoList = []; //如果是第一页需手动置空列表
  75. this.infoList = this.infoList.concat(curPageData); //追加新数据
  76. // }
  77. })
  78. },
  79. }
  80. }
  81. </script>
  82. <style>
  83. .container {
  84. padding: 20px;
  85. font-size: 14px;
  86. line-height: 24px;
  87. }
  88. </style>