item.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <MeScroll :up="up" :down="down" @up="upFn" :fixed="false" @down="downFn" @init="initMeScroll">
  3. <card :list="list" ></card>
  4. </MeScroll>
  5. </template>
  6. <script>
  7. import MeScroll from '@/components/mescroll-body/mescroll-uni.vue'
  8. import card from './card.vue'
  9. var app=getApp()
  10. export default {
  11. components:{
  12. MeScroll,card
  13. },
  14. props: {
  15. type: Number,
  16. i: Number,
  17. item:Object
  18. },
  19. data() {
  20. return {
  21. loginType:'',
  22. isInit: false, // 是否初始化
  23. list: [], // 列表数据
  24. mescroll: null, // mescroll 对象
  25. // 上拉配置参数
  26. up: {
  27. noMoreSize: 2,
  28. auto: true,
  29. page: {
  30. page: 0,
  31. size: 10
  32. }
  33. },
  34. // 下拉配置参数
  35. down: {
  36. use: true,
  37. auto: false
  38. }
  39. }
  40. },
  41. watch:{
  42. type(val) {
  43. if(!this.isInit && val === this.i) {
  44. this.mescroll.resetUpScroll()
  45. }
  46. }
  47. },
  48. mounted() {
  49. if(!this.isInit && this.i === 0) {
  50. this.mescroll.resetUpScroll()
  51. }
  52. },
  53. created() {
  54. this.loginType=this.$cache.get('loginType')
  55. },
  56. methods: {
  57. /**
  58. * @param {Object} mescroll 初始化组件
  59. */
  60. initMeScroll(mescroll) {
  61. this.mescroll = mescroll
  62. },
  63. /**
  64. * @param {Object} mescroll 上拉回调
  65. */
  66. upFn(mescroll) {
  67. let params={
  68. current:mescroll.num,
  69. size:mescroll.size
  70. }
  71. if (!this.$isEmpty(this.item.value)) {
  72. params.age=100
  73. }
  74. if (this.loginType==this.$loginType.AGENCY) {
  75. //园区登陆
  76. let tenantId=this.$cache.get('agencyTenantId')
  77. params.tenantId=tenantId
  78. }else if (this.loginType==this.$loginType.ENTERPRISE) {
  79. //企业
  80. let creditCode=this.$cache.get('creditCode')
  81. params.enterpriseCreditCode=creditCode
  82. }else if (this.loginType==this.$loginType.STAFF) {
  83. //员工
  84. let phone=this.$cache.get('phone')
  85. params.phone=phone
  86. }
  87. try{
  88. this.$api.temperatureRecord.page(params).then(res=>{
  89. let data=res.data.records
  90. let length=data.length
  91. let total=res.data.total
  92. mescroll.endBySize(length, total);
  93. if(mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  94. this.list=this.list.concat(data); //追加新数据
  95. })
  96. }catch(e){
  97. mescroll.endErr();
  98. }
  99. },
  100. /**
  101. * 下拉回调
  102. * */
  103. downFn(mescroll) {
  104. setTimeout(()=>{
  105. this.mescroll.resetUpScroll()
  106. },1500)
  107. },
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. view{
  113. box-sizing: border-box;
  114. }
  115. </style>