<template>
  <view style="padding-top: 28rpx;">
    <view class="card">
      <view class="title">任务名称: {{task.title}}</view>
      <u-line style="margin: 14rpx 0;"></u-line>
      <!-- <view class="text">阶段类型: 单次</view> -->
      <view class="text" style="color: #FF7C32;" v-if="task.extend&&task.extend.shareholder">入股金额: {{task.extend.shareholder.money}}元</view>
    </view>
    <view class="card">
      <view class="title">任务描述</view>
      <u-line style="margin: 14rpx 0;"></u-line>
      <view class="text">{{task.content}}</view>
    </view>
    <view class="card">
      <view class="title">事件记录</view>
      <u-line style="margin: 14rpx 0;"></u-line>
       <u-steps v-if="task.extend&&task.extend.shareholder" :current="-1" direction="column" activeColor="#0122c7" dot inactiveColor="#0122c7">
          <u-steps-item v-for="(item, index) in task.extend.shareholder.user_list" :title="item.time" :desc="item.info">
          </u-steps-item>
        </u-steps>
    </view>
    <view class="card">
      <view class="title">温馨提示</view>
      <u-line style="margin: 14rpx 0;"></u-line>
      <view class="text" style="color: #FF7C32;">入股的金额将在次日凌晨更新到"股金管理"内，请于次日打开"股金管理"页面查看详情</view>
    </view>
    <mybtn v-if="task.status!=3 && task.status!=5" text="前往支付页面" @click="navTo(`/subpkg/topUp/topUp?task_id=${task_id}`)"></mybtn>
    <mybtn v-else :text="task.status==3?'已完成任务':'任务已关闭'" :my_btn_disabled="true"></mybtn>
  </view>
</template>

<script>
  import { taskShareholder } from "@/api/task.js"
  export default {
    data() {
      return {
        task:{},
        task_id: -1,
      };
    },
    onLoad(options) {
      this.task_id = options.task_id;
      this.loadTask();
      uni.$on('upBuyShare', this.loadTask);
    },
    methods:{
      async loadTask(){
        let res = await taskShareholder({
          id: this.task_id
        });
        this.task = res.data;
      },
      navTo (url) {
        if(url){
          uni.showLoading({
            title: '加载中',
            mask: true
          });
          uni.navigateTo({
          	url: url,
            success() {
              uni.hideLoading()
            }
          })
        }else Toast('暂未开放')
      },
    }
  }
</script>

<style lang="scss">
  .card {
    margin: 0 auto;
    margin-bottom: 28rpx;
    width: 694rpx;
    background: #FFFFFF;
    border-radius: 14rpx;
    padding: 28rpx;

    .title {
      font-size: 32rpx;
      font-weight: bold;
      color: #333333;
    }

    .text {
      line-height: 50rpx;
    }
  }
</style>