step1.js 3.06 KB
"use strict";
const common_vendor = require("../../common/vendor.js");
const config = require("../../config.js");
if (!Array) {
  const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  _easycom_uni_icons2();
}
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
if (!Math) {
  _easycom_uni_icons();
}
const _sfc_main = {
  __name: "step1",
  props: {
    activity: {
      type: Object,
      default: () => {
      }
    }
  },
  emits: ["next"],
  setup(__props, { emit }) {
    const agree = common_vendor.ref(false);
    function changeAgree() {
      if (agree.value) {
        agree.value = false;
      } else {
        agree.value = true;
      }
    }
    function downLoad(url) {
      console.log(url);
      common_vendor.index.showLoading({
        title: "下载中"
      });
      common_vendor.index.downloadFile({
        url,
        success: function(res) {
          common_vendor.index.hideLoading();
          console.log(res);
          var filePath = res.tempFilePath;
          common_vendor.index.showLoading({
            title: "正在打开"
          });
          common_vendor.index.openDocument({
            filePath,
            showMenu: true,
            success: function(res2) {
              common_vendor.index.hideLoading();
            },
            fail: function(err) {
              common_vendor.index.hideLoading();
              common_vendor.index.showToast({
                title: "打开失败",
                icon: "none",
                duration: 2e3
              });
            }
          });
        },
        fail: function(error) {
          console.log(error);
          common_vendor.index.hideLoading();
          common_vendor.index.showToast({
            title: `下载失败`,
            icon: "none",
            duration: 2e3
          });
        }
      });
    }
    function next() {
      if (agree.value) {
        emit("next");
      } else {
        common_vendor.index.showToast({
          title: `请确认报名须知`,
          icon: "none"
        });
      }
    }
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.o(($event) => {
          var _a, _b;
          return downLoad(common_vendor.unref(config.config).trainUrl_api + ((_b = (_a = __props.activity) == null ? void 0 : _a.signNoticeAttachment) == null ? void 0 : _b.url));
        }),
        b: agree.value
      }, agree.value ? {
        c: common_vendor.p({
          type: "checkbox-filled",
          color: "#C5161E",
          size: "20"
        })
      } : {
        d: common_vendor.p({
          type: "checkbox",
          color: "#bbbbbb",
          size: "20"
        })
      }, {
        e: common_vendor.o(changeAgree),
        f: common_vendor.o(next),
        g: common_vendor.n(agree.value ? "btn-red" : "btn-gary")
      });
    };
  }
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-b5bc287a"], ["__file", "/Users/yangyang/ztx_wx_minapp/training/components/step1.vue"]]);
wx.createComponent(Component);