item.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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: false,
  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.i==1) {
  72. //异常记录
  73. params.isException=1
  74. }
  75. if (this.loginType==this.$loginType.AGENCY) {
  76. //园区登陆
  77. let tenantId=this.$cache.get('agencyTenantId')
  78. params.tenantId=tenantId
  79. }else if (this.loginType==this.$loginType.ENTERPRISE) {
  80. //企业
  81. let creditCode=this.$cache.get('creditCode')
  82. params.enterpriseCreditCode=creditCode
  83. }else if (this.loginType==this.$loginType.STAFF) {
  84. //员工
  85. let phone=this.$cache.get('phone')
  86. params.phone=phone
  87. }
  88. try{
  89. this.$api.temperatureRecord.page(params).then(res=>{
  90. let data=res.data.records
  91. let length=data.length
  92. let total=res.data.total
  93. mescroll.endBySize(length, total);
  94. if(mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  95. this.list=this.list.concat(data); //追加新数据
  96. })
  97. }catch(e){
  98. mescroll.endErr();
  99. }
  100. },
  101. /**
  102. * 下拉回调
  103. * */
  104. downFn(mescroll) {
  105. setTimeout(()=>{
  106. this.mescroll.resetUpScroll()
  107. },1500)
  108. },
  109. }
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. view{
  114. box-sizing: border-box;
  115. }
  116. </style>