activity.vue 3.7 KB

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