activity.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <view class="safe-area-inset-bottom">
  3. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption"
  4. :up="upOption">
  5. <card @operate="operate" :current="current" @checkboxChange="checkboxChange" @checkAllChange="checkAllChange" :cardList="dataList" ref="cardRef"></card>
  6. </mescroll-body>
  7. </view>
  8. </template>
  9. <script>
  10. import MescrollMixin from "@/components/mescroll-body/mescroll-mixins.js";
  11. import card from "./comps/card.vue"
  12. export default {
  13. mixins: [MescrollMixin],
  14. components:{
  15. card
  16. },
  17. data() {
  18. return {
  19. list: [{
  20. name: '发起',
  21. value:1
  22. }, {
  23. name: '可参加',
  24. value:2
  25. },
  26. {
  27. name:'已参加',
  28. value:3
  29. }],
  30. current: 0,
  31. dataList:[]
  32. }
  33. },
  34. onShow() {
  35. this.$util.reload(this.mescroll)
  36. },
  37. methods:{
  38. checkboxChange(e){
  39. let index=e.name
  40. this.dataList[index].checked=e.value
  41. this.$forceUpdate()
  42. },
  43. checkAllChange(e){
  44. this.dataList.forEach(item=>{
  45. item.checked = e.value
  46. })
  47. this.$forceUpdate()
  48. },
  49. change(index) {
  50. this.current = index
  51. this.mescroll.resetUpScroll();
  52. },
  53. checkAll(){
  54. if (!this.$isEmpty(this.dataList) && this.current !=1) {
  55. this.$refs.cardRef.showCheckAll()
  56. }
  57. },
  58. operate(){
  59. if (this.current==0) {
  60. this.stop()
  61. }else if (this.current==1) {
  62. this.join()
  63. }else if (this.current==2) {
  64. this.exit()
  65. }
  66. },
  67. exit(){
  68. this.$dialog.showModal("确定退出?").then(res=>{
  69. let ids= this.dataList.filter(item=>item.checked==true).map(item=>item.id)
  70. let operateList=[]
  71. ids.forEach(item=>{
  72. let tmp={
  73. activityId:item,
  74. joinType:1,
  75. joinId:this.vuex_mallId
  76. }
  77. operateList.push(tmp)
  78. })
  79. this.$api.activity.exit(operateList).then(res=>{
  80. if (res.success) {
  81. this.$refs.cardRef.hideCheckAll()
  82. this.mescroll.resetUpScroll();
  83. }
  84. })
  85. })
  86. },
  87. stop(){
  88. this.$dialog.showModal('确定停用活动?').then(res=>{
  89. let tmp=this.$u.deepClone(this.dataList)
  90. let operateList= tmp.filter(item=>item.checked==true)
  91. operateList.forEach(item=>{
  92. item.auditStatus=3
  93. })
  94. this.$api.activity.stop(operateList).then(res=>{
  95. if (res.success) {
  96. this.$refs.cardRef.hideCheckAll()
  97. this.mescroll.resetUpScroll();
  98. }
  99. })
  100. })
  101. },
  102. downCallback(){
  103. this.$refs.cardRef.hideCheckAll()
  104. this.mescroll.resetUpScroll();
  105. },
  106. upCallback(mescroll) {
  107. let params = {
  108. auditStatus:1,
  109. mallId:this.vuex_mallId,
  110. current:mescroll.num,
  111. size:mescroll.size,
  112. }
  113. try {
  114. this.$api.activity.list(params).then(res => {
  115. let data = res.data.records
  116. let total = res.data.total
  117. mescroll.endBySize(data.length, total);
  118. if (mescroll.num == 1) this.dataList = []; //如果是第一页需手动制空列表
  119. this.dataList = this.dataList.concat(data); //追加新数据
  120. this.dataList.forEach(item=>{
  121. item.checked=false
  122. item.labels=item.labelNames.split(',')
  123. })
  124. })
  125. } catch (e) {
  126. this.mescroll.endErr()
  127. }
  128. }
  129. }
  130. }
  131. </script>
  132. <style lang="scss" scoped>
  133. </style>