<!--
 * @Descripttion: 
 * @version: 
 * @Author: 王三华
 * @Date: 2023-07-25 10:26:06
-->
<!--
 * @Descripttion:
 * @version:
 * @Author: kBank
 * @Date: 2022-08-08 10:42:29
-->
<template>
  <view>
    <u-popup
      :show="isTree"
      class="notice"
      width="70%"
      @close="closeTap"
      closeable
      round="10"
      mode="center"
    >
      <div
        class="shareClass"
        :style="{ backgroundImage: `url(${treeObj.cover})` }"
      >
        <div class="cha" @click="isTree = false">
          <i class="el-icon-close"></i>
        </div>
        <div class="titTre">{{ treeObj.actName }}</div>
        <img
          class="shareImg"
          @click="toPayTree"
          src="@/static/images/zs.png"
          alt=""
        />
      </div>
    </u-popup>
    <u-popup
      :show="isGoods"
      class="notice1"
      width="70%"
      @close="closeTap"
      closeable
      round="10"
      mode="center"
    >
      <view class="goodsDiag">
        <view class="dis_t">{{ '种植' }}</view>
        <view class="dis_a">
          <view class="disFlex">
            <view class="dis_l">{{ '数量' }}:</view>
            <u-number-box
              v-model="treeObj.quantity"
              @change="treePrice"
              :min="treeMin"
            ></u-number-box>
          </view>
          <view class="disFlex">
            <view class="dis_l">{{ '公益金' }}:</view>
            <view class="dis_r">￥{{ treeObj.amount | numberToCurrency }}</view>
          </view>
        </view>
        <view class="btns" @click="payGoods">{{ '确定' }}</view>
      </view>
    </u-popup>
  </view>
</template>

<script>
import * as api from "@/config/index.js";
export default {
  name: "Title",
  props: {
    userInfo: {
      type: Object,
    },
    publishLocationIndex: {
      type: Number,
    },
  },
  data() {
    return {
      noticeFlag: false,
      content: "",
      treeObj: {},
      treeMin: 0,
      isTree: false,
      isGoods: false,
    };
  },
  mounted() {
    // this.getUserTc();
  },
  methods: {
    treePrice(e) {
      let amount = e.value * Number(this.treeObj.price);
      this.$set(this.treeObj, "amount", amount);
    },
    payGoods() {
      let str = JSON.stringify(this.treeObj);
      uni.navigateTo({ url: "/pages/pay/treePay?treeObj=" + str });
      this.closeTap();
    },
    toPayTree() {
      this.isGoods = true;
      this.isTree = false;
    },
    getData(index) {
      api.queryTreeActivity().then((res) => {
        if (res.data) {
          if (index) {
            this.treeObj = res.data;
            this.treeMin = res.data.quantity;
            this.$set(
              this.treeObj,
              "amount",
              Number(res.data.quantity) * Number(res.data.price)
            );
            this.isTree = true;
          } else {
            if (res.data.isStrongAlert == 0) {
              this.treeObj = res.data;
              this.treeMin = res.data.quantity;
              this.$set(
                this.treeObj,
                "amount",
                Number(res.data.quantity) * Number(res.data.price)
              );
              this.isTree = true;
            }
          }
        }
      });
    },
    closeTap() {
      this.isTree = false;
      this.isGoods = false;
    },
    getUserTc(data) {
      api
        .indexPopScreen({
          grade: this.userInfo.pkGradeId,
          awards: this.userInfo.pkAwardsId,
        })
        .then((res) => {
          if (res.code == "200") {
            let list = JSON.parse(localStorage.getItem("menuList"));
            let arr = res.data[0].publishLocation.split(",");
            arr.forEach((items) => {
              if (items == this.publishLocationIndex) {
                this.noticeFlag = true;
                this.content = res.data[0];
              }
            });
          }
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.close-icons {
  position: absolute;
  right: 30rpx;
  top: 30rpx;
}
.notice ::v-deep .u-popup__content {
  height: 1120rpx;
  width: 690rpx;
}
.notice1 ::v-deep .u-popup__content {
  height: 620rpx;
  width: 690rpx;
}
.notice {
  // height: 700rpx;
}
::v-deep .el-dialog__headerbtn i {
  font-size: 24px;
  //visibility: hidden;
  color: #333;
}
::v-deep .el-dialog {
  margin-top: 113px !important;
  height: 815px;
  margin-bottom: 0;
}
::v-deep .el-dialog__body {
  padding-bottom: 20px;
}
.surebtn1 {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 20px;
  //justify-content: space-around;
  .btn {
    width: 200px;
    height: 66px;
    background: #d5251d;
    border-radius: 6px 6px 6px 6px;
    text-align: center;
    font-size: 22px;
    font-family: PingFang SC-Medium, PingFang SC;
    font-weight: 500;
    color: #ffffff;
    line-height: 66px;
    cursor: pointer;
  }
  .hh {
    background: #cccccc;
    margin-right: 78px;
  }
}
::v-deep .el-dialog__header {
  text-align: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding-bottom: 20px;
}
::v-deep .el-dialog__title {
  font-size: 32px;
  color: #333;
  font-weight: bold;
}
::v-deep .el-dialog__body {
  text-align: center;
  padding-top: 10px;
}
.title {
  font-size: 40rpx;
  text-align: center;
  margin: 20rpx auto;
  color: #333;
  font-weight: bold;
}
.img-auto {
  text-align: center;
  height: 685px;
  overflow-y: auto;
  ::v-deep p {
    font-size: 14px;
  }
  ::v-deep img {
    max-width: 100%;
    height: auto;
  }
}
.shareClass {
  border-radius: 10px 10px 10px 10px;
  // background-image: url('../assets/images/sm.png');
  background-size: 100%;
  background-repeat: no-repeat;
  // text-align: center;
  position: relative;
  height: 750px;
  text-align: center;
}
.cha {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 28px;
}
.titTre {
  font-size: 32px;
  font-weight: 600;
  color: #055316;
  padding-top: 20px;
}
.shareImg {
  width: 221px;
  height: 73px;
  position: absolute;
  left: 10px;
  right: 0;
  margin: 0 auto;
  bottom: 7%;
  cursor: pointer;
}
::v-deep .u-popup__content__close {
  z-index: 100000;
}
.goodsDiag {
  text-align: center;
  .dis_t {
    font-size: 28px;
    font-weight: 500;
    color: #333;
    margin-top: 40px;
  }
  .dis_a {
    margin-top: 40px;
  }
  .disFlex {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
  }
  .dis_l {
    margin-right: 10px;
  }
  .dis_r {
    color: #e3000f;
    font-size: 28px;
    font-weight: 500;
  }
  .btns {
    margin: 0 auto;
    background: #005BAC;
    color: #fff;
    width: 300rpx;
    height: 60rpx;
    line-height: 60rpx;
    border-radius: 20px;
    margin-top: 40px;
  }
}
</style>
