"use strict";
const common_vendor = require("./common/vendor.js");
const components_NationalDictionary = require("./components/NationalDictionary.js");
const components_request = require("./components/request.js");
const components_formatDate = require("./components/formatDate.js");
const _sfc_main = {
  data() {
    return {
      genders: "",
      //性别
      Gender: [
        { label: "男", value: 1 },
        { label: "女", value: 2 }
      ],
      Country: components_NationalDictionary.optionsArray,
      countrys: "",
      //国家
      nameAnchor: "",
      //主播名称
      numberCoins: "",
      //金币数量
      session: "",
      //场数
      remarks: "",
      //备注
      Display: false,
      Hint: false,
      datetimesingle: "",
      //日期
      id: "",
      //用户id
      sendingTime: "",
      //发送时间
      filterable: true,
      //是否可搜索
      AnchorList: [],
      //主播列表
      selectedId: null,
      //选择的主播
      selectedIddata: null,
      //选择的主播数据
      AnchorProfilePicture: "",
      //选择的主播头像
      senderId: ""
      //发送者id
    };
  },
  props: {
    message: {
      type: Object
    }
  },
  watch: {
    message(newQuestion, oldQuestion) {
      this.numberCoins = newQuestion.coin;
      this.session = newQuestion.pkNumber;
      this.remarks = newQuestion.remark;
      this.datetimesingle = components_formatDate.formatDate(newQuestion.pkTime);
      this.id = newQuestion.id;
      this.nameAnchor = newQuestion.anchorId;
      this.countrys = newQuestion.country;
      this.genders = newQuestion.sex === "1" ? 1 : 2;
      this.AnchorProfilePicture = newQuestion.anchorIcon.split("/").pop();
      this.senderId = newQuestion.senderId;
    }
  },
  methods: {
    //关闭弹窗
    close() {
      this.$refs.popup.close();
    },
    //确认选择
    invite() {
      if (this.selectedId) {
        this.nameAnchor = this.selectedIddata.anchorId;
        this.AnchorProfilePicture = this.selectedIddata.headerIcon;
        this.genders = this.selectedIddata.gender;
        this.countrys = this.selectedIddata.country;
        this.close();
      } else {
        common_vendor.index.showToast({
          title: "请选择主播",
          icon: "none",
          duration: 2e3
        });
      }
    },
    //选中的主播
    Select(id, item) {
      if (this.selectedId !== id) {
        this.selectedId = id;
        this.selectedIddata = item;
      } else {
        this.selectedId = null;
        this.selectedIddata = null;
      }
    },
    //获取主播列表
    getAnchorList() {
      components_request.request({
        url: "anchor/list",
        method: "POST",
        data: {
          id: this.id
        },
        userInfo: true
      }).then((res) => {
        this.triggered = false;
        if (res.code == 200) {
          this.AnchorList = res.data;
        } else {
          common_vendor.index.__f__("log", "at pages/Mine/minecomponents/recompose/recompose.vue:300", res.msg);
        }
      });
    },
    //选择我的主播
    chooseMyStreamer() {
      this.$refs.popup.open("center");
      this.getAnchorList();
    },
    //性别
    gender(item) {
      this.genders = item.value;
    },
    //日期
    country(item) {
      this.countrys = item.value;
    },
    // //主播名称
    // handleOverlayClick(event) {
    //   if (event.target === this.$el) {
    //     this.Display = false;
    //     this.Hint = false;
    //   }
    // },
    open() {
      if (this.Display) {
        this.Display = false;
        this.Hint = false;
      } else {
        this.Display = true;
      }
    },
    //获取主播名称以及头像地址
    blur(event) {
      if (this.nameAnchor !== event.target.value) {
        this.nameAnchor = event.target.value;
        common_vendor.index.showLoading({
          title: "正在验证主播",
          mask: true
        });
        common_vendor.index.request({
          url: "https://python.yolojt.com/api/" + this.nameAnchor,
          success: (res) => {
            if (res.data.code === 200) {
              common_vendor.index.hideLoading();
              common_vendor.index.showToast({
                title: "查询成功",
                icon: "none",
                duration: 3e3
              });
              this.AnchorProfilePicture = res.data.data;
            } else {
              common_vendor.index.hideLoading();
              common_vendor.index.showToast({
                title: "未查询到该主播",
                icon: "none",
                duration: 3e3
              });
            }
          },
          fail: function(res) {
            common_vendor.index.hideLoading();
            common_vendor.index.showToast({
              title: "网络请求失败",
              icon: "none",
              duration: 3e3
            });
          }
        });
      } else {
        return;
      }
    },
    async Publish() {
      if (this.nameAnchor == "" && this.nameAnchor == null || this.genders == 0 && this.genders == null || this.numberCoins == "" && this.numberCoins == null || this.datetimesingle == "" && this.datetimesingle == null || this.countrys == "" && his.countrys == null || this.datetimesingle == "" && this.datetimesingle == null || this.session == "" && this.session == null) {
        this.Hint = true;
        return;
      }
      if (this.remarks.includes(this.nameAnchor)) {
        common_vendor.index.showToast({
          title: "备注中不能包含主播昵称",
          icon: "none",
          duration: 2e3
        });
        return;
      }
      const isoString = this.datetimesingle.replace(" ", "T");
      const timestamp = Date.parse(isoString);
      if (isNaN(timestamp)) {
        throw new Error(`Invalid date format: ${this.datetimesingle}`);
      }
      this.sendingTime = Math.floor(timestamp / 1e3);
      const secondsTimestamp = Math.floor(Date.now() / 1e3);
      if (this.sendingTime < secondsTimestamp) {
        common_vendor.index.showToast({
          title: "日期不能早于当前时间",
          icon: "none",
          duration: 2e3
        });
        return;
      }
      common_vendor.index.showLoading({
        title: "修改中...",
        mask: true
      });
      const res = await components_request.request({
        url: "pk/updatePkInfoById",
        method: "POST",
        data: {
          id: this.id,
          anchorId: this.nameAnchor,
          pkTime: this.sendingTime,
          sex: this.genders,
          country: this.countrys,
          coin: this.numberCoins,
          remark: this.remarks,
          senderId: this.senderId,
          anchorIcon: this.AnchorProfilePicture,
          pkNumber: this.session
        },
        userInfo: true
      });
      if (res.code === 200) {
        this.Display = false;
        this.Hint = false;
        this.nameAnchor = "";
        this.genders = 0;
        this.numberCoins = "";
        this.remarks = "";
        this.datetimesingle = "";
        this.session = "";
        common_vendor.index.hideLoading();
        this.$emit("Refresh");
        common_vendor.index.showToast({
          title: "修改成功",
          icon: "success",
          duration: 2e3
        });
      } else {
        common_vendor.index.hideLoading();
        common_vendor.index.showToast({
          title: "修改失败",
          icon: "none",
          duration: 2e3
        });
      }
    }
  }
};
if (!Array) {
  const _easycom_wht_select2 = common_vendor.resolveComponent("wht-select");
  const _easycom_uni_number_box2 = common_vendor.resolveComponent("uni-number-box");
  const _easycom_uni_datetime_picker2 = common_vendor.resolveComponent("uni-datetime-picker");
  const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
  const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  (_easycom_wht_select2 + _easycom_uni_number_box2 + _easycom_uni_datetime_picker2 + _easycom_uni_easyinput2 + _easycom_uni_popup2)();
}
const _easycom_wht_select = () => "./uni_modules/wht-select/components/wht-select/wht-select.js";
const _easycom_uni_number_box = () => "./uni_modules/uni-number-box/components/uni-number-box/uni-number-box.js";
const _easycom_uni_datetime_picker = () => "./uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.js";
const _easycom_uni_easyinput = () => "./uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
const _easycom_uni_popup = () => "./uni_modules/uni-popup/components/uni-popup/uni-popup.js";
if (!Math) {
  (_easycom_wht_select + _easycom_uni_number_box + _easycom_uni_datetime_picker + _easycom_uni_easyinput + _easycom_uni_popup)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: $data.Display
  }, $data.Display ? common_vendor.e({
    b: common_vendor.o$1(($event) => $options.open()),
    c: common_vendor.o$1((...args) => _ctx.NameAnchor && _ctx.NameAnchor(...args)),
    d: common_vendor.o$1((...args) => $options.blur && $options.blur(...args)),
    e: $data.nameAnchor,
    f: $data.nameAnchor === "" && $data.Hint === true
  }, $data.nameAnchor === "" && $data.Hint === true ? {} : {}, {
    g: common_vendor.o$1((...args) => $options.chooseMyStreamer && $options.chooseMyStreamer(...args)),
    h: common_vendor.o$1($options.country),
    i: common_vendor.o$1($options.blur),
    j: common_vendor.p({
      backgroundColor: "#ffffff",
      placeholderColor: "#666666",
      textColor: "#666666",
      borderColor: "#ffffff",
      options: $data.Country,
      filterable: $data.filterable,
      placeholder: "请选择国家",
      value: $data.countrys
    }),
    k: $data.countrys === "" || $data.countrys === null && $data.Hint === true
  }, $data.countrys === "" || $data.countrys === null && $data.Hint === true ? {} : {}, {
    l: common_vendor.o$1($options.gender),
    m: common_vendor.p({
      backgroundColor: "#ffffff",
      placeholderColor: "#666666",
      textColor: "#666666",
      borderColor: "#ffffff",
      options: $data.Gender,
      placeholder: "性别",
      value: $data.genders
    }),
    n: $data.genders === 0
  }, $data.genders === 0 ? {} : {}, {
    o: $data.genders === 1
  }, $data.genders === 1 ? {} : {}, {
    p: $data.genders === 2
  }, $data.genders === 2 ? {} : {}, {
    q: $data.genders === 0 || $data.genders === null && $data.Hint === true
  }, $data.genders === 0 || $data.genders === null && $data.Hint === true ? {} : {}, {
    r: common_vendor.o$1(($event) => $data.numberCoins = $event),
    s: common_vendor.p({
      max: 9999999999,
      background: "#03ABA8",
      modelValue: $data.numberCoins
    }),
    t: $data.numberCoins === "" || $data.numberCoins === null && $data.Hint === true
  }, $data.numberCoins === "" || $data.numberCoins === null && $data.Hint === true ? {} : {}, {
    v: common_vendor.o$1(($event) => $data.datetimesingle = $event),
    w: common_vendor.p({
      type: "datetime",
      ["hide-second"]: "true",
      modelValue: $data.datetimesingle
    }),
    x: $data.datetimesingle === "" || $data.datetimesingle === null && $data.Hint === true
  }, $data.datetimesingle === "" || $data.datetimesingle === null && $data.Hint === true ? {} : {}, {
    y: common_vendor.o$1(($event) => $data.session = $event),
    z: common_vendor.p({
      background: "#03ABA8",
      modelValue: $data.session
    }),
    A: $data.session === "" || $data.session === null && $data.Hint === true
  }, $data.session === "" || $data.session === null && $data.Hint === true ? {} : {}, {
    B: common_vendor.o$1(($event) => $data.remarks = $event),
    C: common_vendor.p({
      type: "textarea",
      placeholder: "备注",
      modelValue: $data.remarks
    }),
    D: common_vendor.o$1(($event) => $options.Publish()),
    E: common_vendor.o$1(() => {
    }),
    F: common_vendor.n($data.Display ? "create-module" : "close-animation "),
    G: common_vendor.o$1(($event) => $options.open())
  }) : {}, {
    H: $data.AnchorList.length !== 0
  }, $data.AnchorList.length !== 0 ? {
    I: common_vendor.f($data.AnchorList, (item, index, i0) => {
      return {
        a: item.headerIcon,
        b: common_vendor.t(item.anchorId),
        c: common_vendor.t(item.country),
        d: common_vendor.o$1(($event) => $options.Select(item.id, item), index),
        e: $data.selectedId === item.id ? "#b8ff8c74" : "#ffffff",
        f: index
      };
    })
  } : {}, {
    J: $data.AnchorList.length === 0
  }, $data.AnchorList.length === 0 ? {} : {}, {
    K: common_vendor.o$1(($event) => $options.invite()),
    L: common_vendor.o$1(($event) => $options.close()),
    M: common_vendor.sr("popup", "4e606fe0-6"),
    N: common_vendor.p({
      type: "center",
      ["border-radius"]: "10px 10px 0 0"
    })
  });
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-4e606fe0"]]);
exports.MiniProgramPage = MiniProgramPage;
//# sourceMappingURL=../.sourcemap/mp-weixin/recompose.js.map
