<template>
    <view>
      <view class="border-style" v-for="item in list" :key="item.rowindex">
        <view style="padding: 10px">
          <view class="content-style">
            <u--image :src="item.attinfos[0].url" :width="tovw(355)" :height="tovw(180)"   :lazy-load="true">
              <template v-slot:loading>
                <u-loading-icon color="red"></u-loading-icon>
              </template>
            </u--image>
          </view>
        </view>
        <view class="button-style">
          <view>
            <span style="color: #666666;font-size: 14px">状态：</span>
            <span :style="{color: item.isonsale=='1'?'#E3041F':'#999999',fontSize: '14px'}">{{item.isonsale == '1'?'上架':'下架'}}</span>
          </view>
          <view style="width: 100px;height: 40px;line-height: 40px;margin-top:5px;vertical-align: middle">
            <u-button :text="item.isonsale == '0'?'上架':'下架'" :color="item.isonsale == '0'?'#C30D23':'#999999'" @click="clickSale(item)"></u-button>
          </view>

        </view>
      </view>
    </view>
</template>

<script>
export default {
  data(){
    return {
      buttonText:'下架',
      title:'',
      list:[]
    }
  },
  onLoad(options){
    this.getList(true)
    if (options.title){
      this.title = options.title
    }
    uni.setNavigationBarTitle({
      title:'6C红人服务管理'
    })
  },
  methods:{
    getList(init = false){
      this.$Http.base({
        "id": 20240511110302,
        "content": {
          "title": this.title?this.title:"6C红人服务"
        },
      }).then(res =>{
        console.log(res.data,'红人服务管理')
        this.list = res.data
      })
    },
    clickSale(item){
      console.log(item,'数据上下架')
      this.$Http.base({
        "id": 20240511133302,
        "content": {
          "linksids": [item.linksid],
          "isonsale":item.isonsale == '1'?0:1
        },
      }).then(res =>{
        this.getList(true)
      })
    }
  }
}
</script>

<style lang="scss">
  .border-style{
    height: 255px;
    background: #FFFFFF;
    border-radius: 0px 0px 0px 0px;
    margin-bottom: 10px;
    .content-style {
      height: 180px;
      border: 0px solid #707070;
    }
    .button-style {
      padding: 0 10px 10px 10px ;
      height: 45px;
      line-height: 45px;
      vertical-align: center;
      display: flex;
      justify-content: space-between;
    }
  }
</style>
