<template>
  <view class="container">
    <view class="back-top"></view>

    <uni-group mode="card" class="card">
      <view class="box">
        <text class="title">结算单号:</text>
        <text>{{ orderDetail.orderNo || '' }}</text>
      </view>
      <view class="box">
        <text class="title">结算平台:</text>
        <text>{{ setPlatform(orderDetail.platform) || '' }}</text>
      </view>
      <view class="box">
        <text class="title">应用:</text>
        <text>{{ setAppType(orderDetail.appType) || '' }}</text>
      </view>
      <view class="box">
        <text class="title">收益类型:</text>
        <text>{{ setType(orderDetail.type) || '' }}</text>
      </view>
      <view class="box">
        <text class="title">结算收入:</text>
        <MoneyView :character="'￥'" :size="26" :value="orderDetail.profit || 0" :color="'#0b6375'"/> 元
      </view>
      <view class="box">
        <text class="title">转入时间:</text>
        <text>{{ orderDetail.walletTime || '' }}</text>
      </view>
    </uni-group>
  </view>
</template>

<script>
import { queryFrontEndAmtDetails } from "@/api/profit.js";
import MoneyView from "@/components/money-view/money-view.vue"
export default {
  components: {
    MoneyView
  },
  data() {
    return {
      orderDetail: {
        id: 0,
        orderNo: "",
        platform: "",
        appType: "",
        type: "",
        profit: 0,
        walletTime: "",
		userInfo:{}
      },
    };
  },
  created() {
  	const userInfo = uni.getStorageSync('userInfo')
  	if (!userInfo) {
  		console.log('havent userInfo')
  		uni.showModal({
  			content: '艺术家账户过期,请重新登录！',
  			showCancel: false,
  			success() {
  				//没有缓存则跳转登录页面
  				uni.reLaunch({
  					url: '/pages/login/login'
  				});
  			}
  		});
  	} else {
  		this.userInfo = userInfo;
  		console.log('have userInfo')
  	}
  },
  onLoad: function (option) {
    //option为object类型，会序列化上个页面传递的参数
    this.orderDetail.id = option.id;
    //console.log('this.id',this.id)
    this.queryFrontEndAmtDetails();
  },
  methods: {
    // 查询指定艺术家转入钱包收益详情
    async queryFrontEndAmtDetails() {
	  let that = this;
      const res = await queryFrontEndAmtDetails(that.orderDetail.id);
      //console.log('res', res)
      if (res.data.code === 200) {
        that.orderDetail = res.data.data;
      } else {
        uni.showModal({
          content: "转入钱包收益详情数据加载失败！",
          showCancel: false,
        });
      }
    },
    setPlatform(data) {
      if (data == "0") {
        return "抖音";
      } else if (data == "1") {
        return "快手";
      } else if (data == "2") {
        return "微信";
      } else if (data == "3") {
        return "uniapp";
      }
    },
    setAppType(data) {
      if (data == "0") {
        return "节点壁纸";
      }
    },
    setType(data) {
      if (data == "0") {
        return "广告浏览";
      } else if (data == "1") {
        return "邀请";
      } else if (data == "2") {
        return "会员";
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.container {

  .back-top {
    width: 100%;
    position: absolute;
    height: 240rpx;
    background: $uni-primary;
  }
  .card {
    width: 100%;
    position: absolute;
  }
  ::v-deep .uni-group--card {
    margin: 40rpx !important;
    background: $uni-bg-base-color !important;
    padding-top: 40rpx;
    border-radius: 20rpx !important;
  }
  .title {
    color: $uni-white;
    display: block;
    width: 140rpx;
    margin-right: 20rpx;
    font-size: 26rpx;
    font-weight: 600;
  }
  .box {
    display: flex;
    font-size: 24rpx;
    margin-bottom: 40rpx;
    color: $uni-secondary-color;
    line-height: 26rpx;
  }

  .border {
    width: 100%;
    height: 2rpx;
    background: $uni-secondary-color;
    margin-bottom: 40rpx;
  }

}

</style>
