item.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <MeScroll :up="up" :down="down" @up="upFn" :fixed="false" @down="downFn" @init="initMeScroll">
  3. <card @deleteItem="deleteItem" :list="list" @cancel="cancel"></card>
  4. </MeScroll>
  5. </template>
  6. <script>
  7. import MeScroll from '@/comps/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. refresh:Boolean,
  16. type: Number,
  17. i: Number,
  18. item:Object
  19. },
  20. data() {
  21. return {
  22. isInit: false, // 是否初始化
  23. list: [], // 列表数据
  24. mescroll: null, // mescroll 对象
  25. // 上拉配置参数
  26. up: {
  27. noMoreSize: 5,
  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. refresh() {
  43. console.log("我要刷新了");
  44. this.mescroll.resetUpScroll()
  45. },
  46. type(val) {
  47. if(!this.isInit && val === this.i) {
  48. this.mescroll.resetUpScroll()
  49. }
  50. }
  51. },
  52. mounted() {
  53. if(!this.isInit && this.i === 0) {
  54. this.mescroll.resetUpScroll()
  55. }
  56. },
  57. methods: {
  58. /**
  59. * @param {Object} item 删除订单
  60. */
  61. deleteItem(item){
  62. let that=this
  63. app.globalData.twoFailHint("确定要取消该工单?",function(){
  64. //删除状态
  65. item.status=-1
  66. let operation='estateRepair/addEstateRepair'
  67. app.globalData.postRequest(item, operation, function (res) {
  68. if (res.data.add_result==true) {
  69. app.globalData.oneFailHint("删除成功成功");
  70. that.mescroll.resetUpScroll()
  71. }else{
  72. app.globalData.oneFailHint(res.data.add_result);
  73. }
  74. });
  75. })
  76. },
  77. /**
  78. * 取消订单
  79. * @param {Object} item 订单实体
  80. */
  81. cancel(item){
  82. let that=this
  83. app.globalData.twoFailHint("确定要取消该工单?",function(){
  84. item.handleStatus=-1
  85. let operation='estateRepair/addEstateRepair'
  86. app.globalData.postRequest(item, operation, function (res) {
  87. if (res.data.add_result==true) {
  88. app.globalData.oneFailHint("取消成功");
  89. that.mescroll.resetUpScroll()
  90. }else{
  91. app.globalData.oneFailHint(res.data.add_result);
  92. }
  93. });
  94. })
  95. },
  96. /**
  97. * @param {Object} mescroll 初始化组件
  98. */
  99. initMeScroll(mescroll) {
  100. this.mescroll = mescroll
  101. },
  102. /**
  103. * @param {Object} mescroll 上拉回调
  104. */
  105. upFn(mescroll) {
  106. let that=this
  107. let data={
  108. "page":{
  109. current:mescroll.num,
  110. size:mescroll.size,
  111. },
  112. memberId:getApp().globalData.member.id,
  113. handleStatus:this.item.value
  114. }
  115. //已处理,待评价
  116. if (this.item.value==2) {
  117. //已处理
  118. data.handleStatus=1
  119. //待评价
  120. data.estimateStatus=0
  121. }
  122. let operation='estateRepair/estateRepairList'
  123. try{
  124. app.globalData.postRequest(data, operation, function (res) {
  125. let estateRepairList=res.data.estateRepairList
  126. let length=estateRepairList.records.length
  127. let data=estateRepairList.records
  128. mescroll.endBySize(length, estateRepairList.total);
  129. if(mescroll.num == 1) that.list = []; //如果是第一页需手动制空列表
  130. that.list=that.list.concat(data); //追加新数据
  131. });
  132. }catch(e){
  133. mescroll.endErr();
  134. }
  135. },
  136. /**
  137. * 下拉回调
  138. * */
  139. downFn(mescroll) {
  140. setTimeout(()=>{
  141. this.list=[]
  142. this.mescroll.resetUpScroll()
  143. },1500)
  144. },
  145. }
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. view{
  150. box-sizing: border-box;
  151. }
  152. </style>