index.vue 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. <u-toast ref="uToast"></u-toast>
  11. </view>
  12. </template>
  13. <script>
  14. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  15. import {
  16. mapState,
  17. mapMutations
  18. } from 'vuex';
  19. export default {
  20. mixins: [MescrollMixin], // 使用mixin
  21. computed: {
  22. ...mapState(['hasLogin'])
  23. },
  24. data() {
  25. return {
  26. href: 'https://uniapp.dcloud.io/component/README?id=uniui',
  27. canReset: false,
  28. userInfo: {},
  29. infoList: []
  30. }
  31. },
  32. onShow() {
  33. // this.$refs.uToast.show({
  34. // type: 'success',
  35. // message: '提交成功!',
  36. // })
  37. // this.$nextTick(function() {
  38. // this.canReset && this.mescroll.resetUpScroll() // 重置列表数据为第一页
  39. // this.canReset && this.mescroll.scrollTo(0, 0) // 重置列表数据为第一页时,建议把滚动条也重置到顶部,避免无法再次翻页的问题
  40. // this.canReset = true // 过滤第一次的onShow事件,避免初始化界面时重复触发upCallback, 无需配置auto:false
  41. // });
  42. // if (this.hasLogin || uni.getStorageSync("userInfo").username) {
  43. // this.userInfo = uni.getStorageSync("userInfo")
  44. // this.isLogin = true
  45. // } else {
  46. // uni.navigateTo({
  47. // url: "/pages/login/login"
  48. // })
  49. // }
  50. },
  51. methods: {
  52. upCallback(page) {
  53. uni.showLoading({
  54. title: '数据加载中'
  55. })
  56. this.$request.baseRequest('pincheCarSharingApp', 'list', {
  57. remark2: this.route,
  58. carpoolingType: this.type,
  59. companyId: 1,
  60. pageNum: page.num,
  61. pageSize: page.size,
  62. }, failres => {
  63. console.log('res+++++', failres.errmsg)
  64. this.$refs.uToast.show({
  65. type: 'error',
  66. message: failres.errmsg,
  67. })
  68. uni.hideLoading()
  69. }).then(res => {
  70. // if (res.errno == 200) {
  71. uni.hideLoading()
  72. console.log(11)
  73. let curPageData = res.data.items;
  74. let totalPage = res.data.total;
  75. let curPageLen = curPageData.length;
  76. this.mescroll.endByPage(curPageLen, totalPage);
  77. console.log(res.data)
  78. // this.makeData(res.data)
  79. if (page.num == 1) this.infoList = []; //如果是第一页需手动置空列表
  80. this.infoList = this.infoList.concat(curPageData); //追加新数据
  81. // }
  82. })
  83. },
  84. }
  85. }
  86. </script>
  87. <style>
  88. .container {
  89. padding: 20px;
  90. font-size: 14px;
  91. line-height: 24px;
  92. }
  93. </style>