"use strict"; const common_vendor = require("../../common/vendor.js"); const utils_media = require("../../utils/media.js"); const _sfc_main = { data() { return { url: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4", id: 0, pattern: { color: "#19c324", selectedColor: "#19c324", buttonColor: "rgba(0, 0, 0, 0)", icon: "cloud-download-filled", iconColor: "#fff" }, isDownload: false }; }, onLoad(options) { if (options.id) { this.id = options.id; this.$http.get("/resource/" + this.id).then((resp) => { this.url = resp.url; }).catch((err) => { console.log("请求异常"); }); } else { console.log("获取id异常"); } }, methods: { async downloadAction() { let userInfo = null; common_vendor.index.getStorage({ key: "user-info", success: function(res) { userInfo = res; }, fail: (err) => { this.$refs.adRewardedVideo.show(); } }); if (userInfo != null && userInfo.is_vip) { try { const url = "/resource/" + this.id; const result = await utils_media.downloadAndSaveVideo(url); if (result) { this.isDownload = true; this.pattern.iconColor = this.isDownload ? "#19c324" : "#fff"; this.$http.post("/resource/" + this.id + "/download"); } } catch (error) { console.error("下载失败:", error); } } }, onadload(e) { console.log("广告数据加载成功"); }, onadclose(e) { const detail = e.detail; if (detail && detail.isEnded) { console.log("onadclose " + detail.isEnded); } else { console.log("onadclose " + detail.isEnded); } }, onaderror(e) { console.log("onaderror: ", e.detail); } } }; if (!Array) { const _easycom_uni_fab2 = common_vendor.resolveComponent("uni-fab"); _easycom_uni_fab2(); } const _easycom_uni_fab = () => "../../uni_modules/uni-fab/components/uni-fab/uni-fab.js"; if (!Math) { _easycom_uni_fab(); } function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return { a: $data.url, b: common_vendor.sr("fab", "5a95e9e6-0"), c: common_vendor.o($options.downloadAction), d: common_vendor.p({ pattern: $data.pattern, horizontal: "right", vertical: "bottom", popMenu: false }) }; } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]); wx.createPage(MiniProgramPage);