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. }
  81. this.$dialog.showModal("确定退出?").then(res=>{
  82. let operateList=[]
  83. ids.forEach(item=>{
  84. let tmp={
  85. activityId:item,
  86. joinType:1,
  87. joinId:this.vuex_mallId
  88. }
  89. operateList.push(tmp)
  90. })
  91. this.$api.activity.exit(operateList).then(res=>{
  92. if (res.success) {
  93. this.$refs.cardRef.hideCheckAll()
  94. this.mescroll.resetUpScroll();
  95. }
  96. })
  97. })
  98. },
  99. stop(){
  100. let tmp=this.$u.deepClone(this.dataList)
  101. let operateList= tmp.filter(item=>item.checked==true)
  102. if (this.$isEmpty(operateList)) {
  103. this.$u.toast('至少选择一项活动')
  104. return
  105. }
  106. this.$dialog.showModal('确定停用活动?').then(res=>{
  107. operateList.forEach(item=>{
  108. item.auditStatus=3
  109. })
  110. this.$api.activity.stop(operateList).then(res=>{
  111. if (res.success) {
  112. this.$refs.cardRef.hideCheckAll()
  113. this.mescroll.resetUpScroll();
  114. }
  115. })
  116. })
  117. },
  118. downCallback(){
  119. this.$refs.cardRef.hideCheckAll()
  120. this.mescroll.resetUpScroll();
  121. },
  122. upCallback(mescroll) {
  123. let params = {
  124. selectType:this.list[this.current].value,
  125. sponsorId:this.vuex_shopId,
  126. current:mescroll.num,
  127. size:mescroll.size,
  128. }
  129. try {
  130. this.$api.activity.list(params).then(res => {
  131. let data = res.data.records
  132. let total = res.data.total
  133. mescroll.endBySize(data.length, total);
  134. if (mescroll.num == 1) this.dataList = []; //如果是第一页需手动制空列表
  135. this.dataList = this.dataList.concat(data); //追加新数据
  136. this.dataList.forEach(item=>{
  137. item.checked=false
  138. item.labels=item.labelNames.split(',')
  139. })
  140. })
  141. } catch (e) {
  142. this.mescroll.endErr()
  143. }
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. </style>