<template>
  <view>
    <view class="section_1">
      <view class="text_box">
        <text>月授课数</text>
        <text>12</text>
        <text>节，月负责学员</text>
        <text>188</text>
        <text>名</text>
      </view>
    </view>
    <view class="section_2"></view>
    <view class="section_3"></view>
    <view class="section_3"></view>
  </view>
</template>

<script>
import user from '@/api/user.js';
import fuiIcon from "@/components/firstui/fui-icon/fui-icon.vue"

export default {
  components: {
    fuiIcon
  },
  data() {
    return {
      list: [],
      likes: 0,
      type: 1,
      type1: 1,
      activity_id: 0,
      um_id: 0,
      urls: 'http://medication.zeyan.wang/'
    }
  },
  onLoad() {
    const um_id = uni.getStorageSync('um_id');
    this.um_id = um_id
    if (um_id == '') {
      uni.navigateTo({
        url: '/pages/login/login'
      })
    }
    this.fetchData(this.um_id)
  },
  methods: {
    fetchData(um_id) {
      user.activity_index({
        um_id: um_id
      }).then(res => {
        console.log(res)
        if (res.status == 200) {
          if (res.data == null) {
            this.list = []
          } else {
            this.list = res.data
          }
        } else {
          uni.showToast({
            title: res.msg,
            icon: 'none'
          })
        }
      });
    },
    onPullDownRefresh() {
      this.fetchData(this.um_id)
    },
    publishing() {
      uni.navigateTo({
        url: '/pages/index/publishing'
      })
    },
    like(id, um_id) {
      user.activity_like({um_id: um_id, activity_id: id, type: 1}).then(res => {
        if (res.status == 200) {
          user.activity_index({
            um_id: um_id
          }).then(res => {
            console.log(res)
            if (res.status == 200) {
              this.list = res.data
            }
          });
          this.type = res.data.type
          this.activity_id = res.data.activity_id
        } else {
          uni.showToast({
            title: res.msg,
            icon: 'none'
          })
        }
      });
    },
    collection(id, um_id) {
      user.activity_like({um_id: um_id, activity_id: id, type: 2}).then(res => {
        if (res.status == 200) {
          console.log(res)
          this.fetchData(this.um_id)
          this.type1 = res.data.type
          this.activity_id = res.data.activity_id
        } else {
          uni.showToast({
            title: res.msg,
            icon: 'none'
          })
        }
      });
    },
    coninfo(item) {
      // user.coninfo({id:id}).then(res => {
      // 	if(res.status == 200){
      uni.setStorageSync('coninfo', item);
      uni.navigateTo({
        url: '/pages/index/coninfo'
      })
      // }else{
      // 	uni.showToast({
      // 		title: res.msg,
      // 		icon: 'none'
      // 	})
      // }
      // });
    },
    Comment(id) {
      uni.setStorageSync('actid', id);
      uni.navigateTo({
        url: '/pages/index/Comment'
      })
    }
  }
}
</script>

<style lang="less" scoped>

.section_1{
  border: 1px solid red;
  width: 700rpx;
  height: 264rpx;
  border-radius: 14rpx;
  .text_box{

  }
}

</style>