"use strict";
const common_vendor = require("../../../common/vendor.js");
const common_js_net_projectApi = require("../../../common/js/net/projectApi.js");
const common_js_conver = require("../../../common/js/conver.js");
const _sfc_main = {
  setup() {
    const globalData = common_vendor.inject("globalData");
    common_vendor.index.__f__("log", "at pages/copyright/createBuy/createBuy.vue:159", globalData);
    return {
      globalData
    };
  },
  data() {
    return {
      msgType: "info",
      msgTxt: "",
      urgent: 0,
      projTypes: [],
      //全托管,写材料 type= ALL type =MATERIAL
      allPrice: 0,
      materialPrice: 0,
      isUrgent: false
      //是否加急
    };
  },
  onLoad(options) {
    common_vendor.index.setNavigationBarTitle({
      title: "创建软著"
    });
    common_vendor.index.setNavigationBarColor({
      frontColor: "#000000",
      // 必写项，字体颜色仅支持#ffffff和#000000
      backgroundColor: "#F0F0F0",
      // 传递的颜色值，仅支持十六进制颜色
      animation: {
        // 可选项
        duration: 500,
        timingFunc: "easeIn"
      }
    });
    this.doGetPrice();
  },
  methods: {
    moneyTxt: common_js_conver.moneyTxt,
    //是否加急
    doUrgent(e) {
      const _self = this;
      _self.isUrgent = !_self.isUrgent;
    },
    //获取单价
    doGetPrice() {
      common_vendor.index.showLoading({
        title: "加载中..."
      });
      const _self = this;
      common_js_net_projectApi.ProApi.doGetPrice().then((res) => {
        common_vendor.index.hideLoading();
        common_vendor.index.__f__("log", "at pages/copyright/createBuy/createBuy.vue:205", res);
        res.projTypes.forEach((el) => {
          if (el.type == "ALL") {
            _self.allPrice = el.price;
          } else if (el.type == "MATERIAL") {
            _self.materialPrice = el.price;
          }
        });
        _self.urgent = res.additional.urgent;
      }).catch((err) => {
        common_vendor.index.hideLoading();
        _self.msgType = "error";
        _self.msgTxt = "数据有误,请稍后重试";
        _self.$refs.msg.open();
        setTimeout(() => {
          common_vendor.index.navigateBack();
        }, 1500);
      });
    },
    //打开项目信息编辑页面
    doBuy(e) {
      const _self = this;
      var price = e.currentTarget.dataset.type == "ALL" ? _self.allPrice : _self.materialPrice;
      var type = e.currentTarget.dataset.type;
      if (type == "ALL" && _self.isUrgent) {
        price += _self.urgent;
      }
      const urgent = _self.isUrgent ? "URGENT" : "";
      common_vendor.index.navigateTo({
        url: `/pages/copyright/createProjectInfo/createProjectInfo?type=${type}&price=${price}&isUrgent=${urgent}`
      });
    },
    //点击复制
    copyLink() {
      const _self = this;
      common_vendor.index.setClipboardData({
        data: "https://www.aimzhu.com",
        success: () => {
          _self.msgTxt = "复制成功";
          _self.msgType = "success";
          _self.$refs.msg.open();
        },
        fail: (err) => {
          common_vendor.index.__f__("log", "at pages/copyright/createBuy/createBuy.vue:250", err);
        }
      });
    }
  }
};
if (!Array) {
  const _easycom_uni_popup_message2 = common_vendor.resolveComponent("uni-popup-message");
  const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  (_easycom_uni_popup_message2 + _easycom_uni_popup2)();
}
const _easycom_uni_popup_message = () => "../../../uni_modules/uni-popup/components/uni-popup-message/uni-popup-message.js";
const _easycom_uni_popup = () => "../../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
if (!Math) {
  (_easycom_uni_popup_message + _easycom_uni_popup)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return {
    a: $setup.globalData.locImg + "/banner_1.png",
    b: $setup.globalData.locImg + "/banner_2.png",
    c: $options.moneyTxt(10, 14, $data.allPrice / 100) + "-" + $options.moneyTxt(10, 14, ($data.allPrice + $data.urgent) / 100),
    d: common_vendor.o((...args) => $options.doBuy && $options.doBuy(...args)),
    e: $setup.globalData.locImg + "/ic_check_fit.png",
    f: $setup.globalData.locImg + "/ic_check_fit.png",
    g: $setup.globalData.locImg + "/ic_check_fit.png",
    h: $setup.globalData.locImg + "/ic_check_fit.png",
    i: $setup.globalData.locImg + "/ic_check_fit.png",
    j: $setup.globalData.locImg + "/ic_check_fit.png",
    k: $setup.globalData.locImg + "/ic_check_fit.png",
    l: $options.moneyTxt(10, 14, $data.materialPrice / 100),
    m: common_vendor.o((...args) => $options.doBuy && $options.doBuy(...args)),
    n: $setup.globalData.locImg + "/ic_check_fit.png",
    o: $setup.globalData.locImg + "/ic_check_fit.png",
    p: $setup.globalData.locImg + "/ic_check_fit.png",
    q: $setup.globalData.locImg + "/ic_check_fit.png",
    r: $setup.globalData.locImg + "/ic_check_fit.png",
    s: $setup.globalData.locImg + "/ic_check_fit.png",
    t: $setup.globalData.locImg + "/ic_check_fit.png",
    v: $setup.globalData.locImg + "/ic_check_fit.png",
    w: $setup.globalData.locImg + "/ic_check_fit.png",
    x: common_vendor.t($setup.globalData.appUrl),
    y: common_vendor.p({
      type: $data.msgType,
      message: $data.msgTxt,
      duration: 2e3
    }),
    z: common_vendor.sr("msg", "905bf38e-0"),
    A: common_vendor.p({
      type: "message"
    })
  };
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-905bf38e"]]);
swan.createPage(MiniProgramPage);
//# sourceMappingURL=../../../../.sourcemap/mp-baidu/pages/copyright/createBuy/createBuy.js.map
