ts_aimz_uni/unpackage/dist/dev/mp-baidu/pages/index/home.js
2025-05-28 16:22:03 +08:00

621 lines
23 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";
const common_vendor = require("../../common/vendor.js");
const common_js_net_projectApi = require("../../common/js/net/projectApi.js");
const common_js_net_UserApi = require("../../common/js/net/UserApi.js");
const common_js_cache_storage = require("../../common/js/cache/storage.js");
const common_js_net_mainUrl = require("../../common/js/net/mainUrl.js");
const common_js_conver = require("../../common/js/conver.js");
const common_js_util = require("../../common/js/util.js");
const common_js_data = require("../../common/js/data.js");
const AdPopup = () => "../../components/ad-popup2.js";
const ContainerLoading = () => "../../components/container-loading.js";
const DownloadProgress = () => "../../components/download-progress.js";
const _sfc_main = {
components: {
ContainerLoading,
DownloadProgress,
AdPopup
},
data() {
return {
contentHeight: 100,
totalHeight: 50,
statusBarHeight: 24,
defaultNotice: "用AI创造用平台保护——欢迎来到您的著作权守护站!",
noticeContent: this.defaultNotice,
currentStatus: "PROCESSING",
//默认状态 PROCESSING进行中 COMPLETE完成
listLoading: "loading",
//loading 状态
listRefreshTrig: false,
//是否正在刷新
imgUrl: common_js_net_mainUrl.previewUrl,
cUrl: common_js_net_mainUrl.copyrightUrl,
sysPreviewUrl: "",
//系统预览地址
pageData: {
page: 1,
rows: 10
},
typeList: common_js_data.homeTypeList,
currentType: "",
expandList: common_js_data.expandList,
currentExpand: "",
tagList: [],
currentTag: "",
projectList: [],
//项目列表
hasMore: true,
//是否存在更多数据
isLoadMore: false,
//是否正在加载更多
loadMore: "more",
//加载更多的状态 more/loading/noMore
tempItem: null,
//点击下载的临时条目
downloadProgress: 0,
//下载文件进度
downloading: false,
//下载文件中
msgType: "success",
//消息类型 success error warn info
msgTxt: "",
//消息内容
showAd: false,
//显示优惠卷广告
tempCoupons: null,
//优惠卷
isNoShowToday: false
//今日不再显示
};
},
onLoad() {
const _self = this;
_self.doGetNotice();
_self.doGetTagList();
const params = _self.buildParams(1, true);
_self.doGetSelfList(params, true);
const noShowToday = common_js_cache_storage.get("noShowToday");
const currentDate = (/* @__PURE__ */ new Date()).toLocaleDateString();
if (noShowToday && noShowToday === currentDate) {
this.isNoShowToday = true;
} else {
_self.doGetClaimsCoupons();
}
this.countBarHeight();
this.getMineInfo();
},
onReady() {
this.calculateRemainingHeight();
},
onPullDownRefresh() {
this.doRefreshList();
common_vendor.index.stopPullDownRefresh();
},
methods: {
status: common_js_conver.status,
moneyTxt: common_js_conver.moneyTxt,
//计算状态栏等高度
countBarHeight() {
const deviceInfo = common_vendor.index.getSystemInfoSync();
common_vendor.index.__f__("log", "at pages/index/home.vue:338", "设备信息", deviceInfo);
this.statusBarHeight = deviceInfo.statusBarHeight;
this.totalHeight = deviceInfo.osName.toLowerCase() == "ios" ? 48 : 50;
common_vendor.index.__f__("log", "at pages/index/home.vue:341", "系统平台", deviceInfo.osName);
},
//获取我的个人信息
getMineInfo() {
common_js_net_UserApi.UserApi.doGetMineAccount().then((res) => {
common_js_cache_storage.set("userId", res.userId);
}).catch((err) => {
common_vendor.index.__f__("log", "at pages/index/home.vue:351", err);
});
},
//获取可以申领的优惠卷
doGetClaimsCoupons() {
common_js_net_UserApi.UserApi.doGetClaimsCouponsList().then((res) => {
if (res && res.length > 0) {
this.tempCoupons = res[0];
this.showAd = true;
}
}).catch((err) => {
common_vendor.index.__f__("log", "at pages/index/home.vue:365", err);
});
},
// 获取通知信息
doGetNotice() {
const _self = this;
common_vendor.index.__f__("log", "at pages/index/home.vue:371", _self.defaultNotice);
common_js_net_projectApi.ProApi.doGetNotice().then((res) => {
common_vendor.index.__f__("log", "at pages/index/home.vue:374", res);
_self.noticeContent = res.data && res.data != "" ? res.data : _self.defaultNotice;
}).catch((err) => {
common_vendor.index.__f__("log", "at pages/index/home.vue:378", err);
});
},
//去创建项目
createCopy() {
common_vendor.index.navigateTo({
url: "/pages/copyright/createBuy/createBuy"
});
},
//去充值
goPayment() {
common_vendor.index.navigateTo({
url: "/pages/pay/payment/payment"
});
},
//切换状态
doChangeStatus(e) {
this.currentStatus = e;
const params = this.buildParams(1, true);
this.doGetSelfList(params, true);
},
//获取标签
doGetTagList() {
const _self = this;
common_js_net_projectApi.ProApi.doGetTagList().then((res) => {
_self.tagList = res;
}).catch((err) => {
common_vendor.index.__f__("log", "at pages/index/home.vue:407", err);
});
},
//切换type
doChangeType(type) {
const _self = this;
_self.currentType = type == _self.currentType ? "" : type;
const params = _self.buildParams(1, true);
_self.doGetSelfList(params, true);
},
//切换expand
doChangeExpand(expand) {
const _self = this;
_self.currentExpand = expand == _self.currentExpand ? "" : expand;
const params = _self.buildParams(1, true);
_self.doGetSelfList(params, true);
},
//切换tag
doChangeTag(tag) {
const _self = this;
_self.currentTag = tag == _self.currentTag ? "" : tag;
const params = _self.buildParams(1, true);
_self.doGetSelfList(params, true);
},
//构建请求参数
buildParams(page, isRefresh) {
const _self = this;
_self.projectList = isRefresh ? [] : _self.projectList;
_self.pageData.page = page;
const [part1, part2] = _self.currentTag.split(":");
const params = {
page: _self.pageData.page,
rows: _self.pageData.rows,
tagNot: part2 ? part2 : "",
tagDataId: part1,
chargeType: _self.currentType,
//
chargeAdditionals: _self.currentExpand,
//额外附加
status: _self.currentStatus
//当前项目状态
};
return params;
},
//获取项目列表
doGetSelfList(params, isRefresh) {
const _self = this;
_self.listLoading = isRefresh ? "loading" : "";
common_js_net_projectApi.ProApi.doGetSelfProjectList(params).then((res) => {
common_vendor.index.__f__("log", "at pages/index/home.vue:454", res);
var status = "success";
status = res.rows && res.rows.length > 0 ? "success" : "empty";
const list = _self.addPrefixToPreviewImgs(res.rows);
_self.listLoading = isRefresh ? status : "";
_self.projectList = _self.projectList.concat(list);
_self.listRefreshTrig = false;
_self.isLoadMore = false;
_self.hasMore = _self.projectList.length < res.total;
if (_self.hasMore) {
_self.loadMore = "more";
} else {
_self.loadMore = "noMore";
}
}).catch((err) => {
_self.listLoading = "error";
_self.listRefreshTrig = false;
_self.isLoadMore = false;
_self.hasMore = true;
_self.loadMore = "more";
});
},
//刷新列表
doRefreshList() {
common_vendor.index.__f__("log", "at pages/index/home.vue:479", "页面刷新...");
const _self = this;
_self.listRefreshTrig = true;
_self.listLoading = "loading";
const params = _self.buildParams(1, true);
_self.doGetSelfList(params, true);
},
//加载更多
doLoadMore() {
const _self = this;
if (_self.isLoadMore || !_self.hasMore) {
return;
}
_self.isLoadMore = true;
_self.loadMore = "loading";
_self.pageData.page = ++_self.pageData.page;
const params = _self.buildParams(_self.pageData.page, false);
_self.doGetSelfList(params, false);
},
//计算剩余高度
calculateRemainingHeight() {
const systemInfo = common_vendor.index.getSystemInfoSync();
const windowHeight = systemInfo.windowHeight;
const screenHeight = systemInfo.screenHeight;
const screenWidth = systemInfo.screenWidth;
common_vendor.index.__f__("log", "at pages/index/home.vue:506", "系统属性", systemInfo);
const query = common_vendor.index.createSelectorQuery().in(this);
query.select("#up-box").boundingClientRect((data) => {
if (data) {
const occupiedHeight = data.height;
let tabbarHeight = screenHeight - windowHeight;
this.contentHeight = windowHeight - occupiedHeight - tabbarHeight - 10;
common_vendor.index.__f__("log", "at pages/index/home.vue:521", "计算前内容高度", this.contentHeight);
let coverHeight = common_js_util.pxToRpx(this.contentHeight, screenWidth);
this.contentHeight = coverHeight;
common_vendor.index.__f__("log", "at pages/index/home.vue:524", "头布局高度", occupiedHeight);
common_vendor.index.__f__("log", "at pages/index/home.vue:525", "屏幕高度", screenHeight);
common_vendor.index.__f__("log", "at pages/index/home.vue:526", "窗口高度", windowHeight);
common_vendor.index.__f__("log", "at pages/index/home.vue:527", "计算内容高度", this.contentHeight);
} else {
common_vendor.index.__f__("log", "at pages/index/home.vue:529", "未获取到高度");
}
}).exec();
},
//为列表图片添加前缀
addPrefixToPreviewImgs(data) {
const prefix = this.imgUrl;
return data.map((item) => {
const aiStatuses = Object.values(item.aiSetting);
const genderStatus = item.generate.generateStatus;
const isGenerating = () => genderStatus === "GENERATING" || aiStatuses.includes("GENERATING");
const isSuccess = () => aiStatuses.every((s) => s === "SUCCESS") && genderStatus === "SUCCESS";
const shouldRegenerate = () => genderStatus === "FAILED";
if (isGenerating()) {
item.btnStatus = "GENERATING";
} else if (isSuccess()) {
item.btnStatus = "DOWNLOAD";
} else if (!aiStatuses.every((s) => s === "SUCCESS")) {
item.btnStatus = "AIGEN";
} else if (shouldRegenerate()) {
item.btnStatus = "RELOAD";
} else {
item.btnStatus = "GEN";
}
if (item.codeTypePage && item.codeTypePage.previewImgs) {
const imgIds = item.codeTypePage.previewImgs.split(",");
item.codeTypePage.previewImgs = imgIds.map((id) => prefix + id);
}
return item;
});
},
//显示下载弹窗
doShowDownload(item) {
common_vendor.index.__f__("log", "at pages/index/home.vue:566", "点击了下载");
this.$refs.downloadPopup.open();
this.sysPreviewUrl = `${this.cUrl}/${item.previewUrl}`;
this.tempItem = item;
},
//复制链接到剪贴板
copyLink() {
common_vendor.index.setClipboardData({
data: this.sysPreviewUrl,
success: function() {
common_vendor.index.__f__("log", "at pages/index/home.vue:576", "success");
}
});
},
//获取下载文件的响应头
getFileHeader(url, header) {
return new Promise((resolve, reject) => {
common_vendor.index.request({
url,
method: "HEAD",
header,
success: resolve,
fail: reject
});
});
},
//点击下载
async download(e) {
const _self = this;
const postfix = e.currentTarget.dataset.type;
_self.downloadProgress = 0;
_self.downloading = true;
this.$refs.downloadPopup.close();
const path = e.currentTarget.dataset.path;
const url = this.cUrl + path + _self.tempItem.projId;
_self.tempItem.projId + "." + postfix;
const token = common_js_cache_storage.get("token");
const header = {};
if (token) {
header.Auth = `Bearer ${token}`;
}
const downloadRes = await _self.doDownload(url, header);
if (downloadRes && downloadRes.statusCode == 200) {
if (downloadRes.tempFilePath.endsWith(".txt")) {
_self.msgTxt = "下载成功";
_self.msgType = "success";
_self.$refs.msg.open();
_self.showDownload = false;
_self.downloading = false;
_self.downloadProgress = 0;
common_vendor.index.navigateTo({
url: "/pages/common/readTxt/readTxt?filePath=" + downloadRes.tempFilePath
});
} else {
common_vendor.index.openDocument({
filePath: downloadRes.tempFilePath,
showMenu: true,
success(res) {
common_vendor.index.__f__("log", "at pages/index/home.vue:626", res);
_self.showDownload = false;
_self.downloading = false;
_self.downloadProgress = 0;
},
fail(err) {
_self.showErr("很抱歉,文件下载出现问题。建议您稍作等待,之后再尝试下载。");
}
});
}
} else {
_self.showErr("很抱歉,文件下载出现问题。建议您稍作等待,之后再尝试下载。");
}
},
//下载文件
doDownload(url, header) {
const _self = this;
return new Promise((resolve, reject) => {
const downloadTask = common_vendor.index.downloadFile({
url,
header,
success: resolve,
fail: reject
});
downloadTask.onProgressUpdate((res) => {
_self.downloadProgress = res.progress;
});
});
},
showErr(msg) {
const _self = this;
_self.msgTxt = msg;
_self.msgType = "error";
_self.showDownload = false;
_self.downloading = false;
_self.downloadProgress = 0;
_self.$refs.msg.open();
},
//关闭广告
doCloseAd(e) {
const isShow = e;
common_vendor.index.__f__("log", "at pages/index/home.vue:667", "关闭广告", e);
if (isShow) {
const currentDate = (/* @__PURE__ */ new Date()).toLocaleDateString();
common_js_cache_storage.set("noShowToday", currentDate);
this.isNoShowToday = true;
}
this.showAd = false;
},
//收下优惠卷
doFurlCoupons(e) {
common_vendor.index.__f__("log", "at pages/index/home.vue:677", "收下优惠卷");
const _self = this;
const isShow = e;
if (isShow) {
const currentDate = (/* @__PURE__ */ new Date()).toLocaleDateString();
common_js_cache_storage.set("noShowToday", currentDate);
_slef.isNoShowToday = true;
}
common_vendor.index.showLoading({
title: "领取中..."
});
const coupons = {
couponId: _self.tempCoupons.couponId
};
common_js_net_UserApi.UserApi.doSaveCoupons(coupons).then((res) => {
common_vendor.index.hideLoading();
_self.msgType = "success";
_self.msgTxt = "本次领取操作已成功,您可以在 “我的” 页面查看相关信息。";
_self.$refs.msg.open();
}).catch((err) => {
common_vendor.index.hideLoading();
_self.msgType = "error";
_self.msgTxt = err.msg ? err.msg : "本次领取操作未成功,请重新进入小程序后再次尝试。";
_self.$refs.msg.open();
});
},
//去生成项目
doCreatePro(e) {
common_vendor.index.showLoading({
title: "生成中..."
});
const _self = this;
const item = e.currentTarget.dataset.value;
common_js_net_projectApi.ProApi.doBuildProject(item.projId).then((res) => {
common_vendor.index.hideLoading();
common_vendor.index.__f__("log", "at pages/index/home.vue:717", res);
_self.msgTxt = "正在生成中,请耐心等待";
_self.msgType = "success";
_self.$refs.msg.open();
_self.doRefreshList();
}).catch((err) => {
common_vendor.index.__f__("log", "at pages/index/home.vue:724", err);
common_vendor.index.hideLoading();
_self.msgType = "error";
_self.msgTxt = err.msg ? err.msg : "生成失败,请稍后重试";
_self.$refs.msg.open();
});
},
//重新生成
doReCreate(e) {
common_vendor.index.__f__("log", "at pages/index/home.vue:733", e);
const item = e.currentTarget.dataset.value;
const _self = this;
common_vendor.index.showLoading({
title: "提交中..."
});
common_js_net_projectApi.ProApi.doReCreate(item.projId).then((res) => {
common_vendor.index.hideLoading();
_self.msgType = "success";
_self.msgTxt = "提交成功,正在生成中,请耐心等待";
_self.$refs.msg.open();
_self.doRefreshList();
}).catch((err) => {
common_vendor.index.hideLoading();
_self.msgTxt = err.msg ? err.msg : "提交失败,请稍后重试";
_self.msgType = "error";
_self.$refs.msg.open();
});
}
}
};
if (!Array) {
const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
const _component_ContainerLoading = common_vendor.resolveComponent("ContainerLoading");
const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
const _component_DownloadProgress = common_vendor.resolveComponent("DownloadProgress");
const _component_AdPopup = common_vendor.resolveComponent("AdPopup");
const _easycom_uni_popup_message2 = common_vendor.resolveComponent("uni-popup-message");
(_easycom_uni_load_more2 + _component_ContainerLoading + _easycom_uni_popup2 + _component_DownloadProgress + _component_AdPopup + _easycom_uni_popup_message2)();
}
const _easycom_uni_load_more = () => "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
const _easycom_uni_popup_message = () => "../../uni_modules/uni-popup/components/uni-popup-message/uni-popup-message.js";
if (!Math) {
(_easycom_uni_load_more + _easycom_uni_popup + _easycom_uni_popup_message)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: $data.totalHeight + "px",
b: $data.statusBarHeight + "px",
c: common_vendor.o((...args) => $options.createCopy && $options.createCopy(...args)),
d: common_vendor.o((...args) => $options.goPayment && $options.goPayment(...args)),
e: common_vendor.t($data.noticeContent),
f: common_vendor.o(($event) => $options.doChangeStatus("PROCESSING")),
g: common_vendor.n($data.currentStatus == "PROCESSING" ? "btn-select" : "btn-normal"),
h: common_vendor.o(($event) => $options.doChangeStatus("COMPLETE")),
i: common_vendor.n($data.currentStatus == "COMPLETE" ? "btn-select" : "btn-normal"),
j: common_vendor.f($data.typeList, (item, index, i0) => {
return {
a: index,
b: common_vendor.t(item.label),
c: common_vendor.n($data.currentType == item.value ? "tab-select" : "tab-normal"),
d: common_vendor.o(($event) => $options.doChangeType(item.value))
};
}),
k: common_vendor.f($data.expandList, (item, index, i0) => {
return {
a: index,
b: common_vendor.t(item.label),
c: common_vendor.n($data.currentExpand == item.value ? "tab-select" : "tab-normal"),
d: common_vendor.o(($event) => $options.doChangeExpand(item.value))
};
}),
l: common_vendor.f($data.tagList, (item, index, i0) => {
return {
a: index,
b: common_vendor.t(item.value),
c: common_vendor.n($data.currentTag == item.key ? "tab-select" : "tab-normal"),
d: common_vendor.o(($event) => $options.doChangeTag(item.key))
};
}),
m: common_vendor.f($data.projectList, (item, index, i0) => {
return common_vendor.e({
a: index,
b: common_vendor.f(item.codeTypePage.previewImgs, (imgItem, imgIndex, i1) => {
return {
a: imgIndex,
b: imgItem
};
}),
c: common_vendor.t($options.status(item.generate.generateStatus, item.aiSetting.settingStatus)),
d: common_vendor.t(item.projName),
e: common_vendor.t(item.apply.applyContactName),
f: common_vendor.t(item.gmtCreate),
g: item.pay.servicePackageId != ""
}, item.pay.servicePackageId != "" ? {} : {
h: $options.moneyTxt(8, 12, item.pay.payment / 100)
}, {
i: item.btnStatus == "DOWNLOAD"
}, item.btnStatus == "DOWNLOAD" ? {
j: common_vendor.o(($event) => $options.doShowDownload(item))
} : item.btnStatus == "AIGEN" ? {
l: common_vendor.o(($event) => $options.doCreatePro(item))
} : item.btnStatus == "RELOAD" ? {
n: common_vendor.o(($event) => $options.doReCreate(item))
} : item.btnStatus == "GEN" ? {
p: common_vendor.o(($event) => $options.doCreatePro(item))
} : {}, {
k: item.btnStatus == "AIGEN",
m: item.btnStatus == "RELOAD",
o: item.btnStatus == "GEN"
});
}),
n: common_vendor.p({
status: $data.loadMore,
color: "var(--divider-color)"
}),
o: $data.contentHeight + "rpx",
p: common_vendor.o((...args) => $options.doLoadMore && $options.doLoadMore(...args)),
q: $data.contentHeight + "rpx",
r: common_vendor.j({
"doRefresh": common_vendor.o($options.doRefreshList)
}),
s: common_vendor.p({
loadingVisible: $data.listLoading
}),
t: common_vendor.t($data.sysPreviewUrl),
v: common_vendor.o((...args) => $options.copyLink && $options.copyLink(...args)),
w: common_vendor.o((...args) => $options.download && $options.download(...args)),
x: common_vendor.o((...args) => $options.download && $options.download(...args)),
y: common_vendor.o((...args) => $options.download && $options.download(...args)),
z: common_vendor.o((...args) => $options.download && $options.download(...args)),
A: common_vendor.o((...args) => $options.download && $options.download(...args)),
B: common_vendor.o((...args) => $options.download && $options.download(...args)),
C: common_vendor.sr("downloadPopup", "7b6d5f55-2"),
D: common_vendor.p({
type: "bottom",
["border-radius"]: "15rpx 15rpx 0rpx 0rpx"
}),
E: common_vendor.p({
isShow: $data.downloading,
progress: $data.downloadProgress
}),
F: common_vendor.j({
"adClose": common_vendor.o($options.doCloseAd),
"adFurl": common_vendor.o($options.doFurlCoupons)
}),
G: common_vendor.p({
coupons: $data.tempCoupons,
visible: $data.showAd
}),
H: common_vendor.p({
isTop: false,
type: $data.msgType,
message: $data.msgTxt,
duration: 2e3
}),
I: common_vendor.sr("msg", "7b6d5f55-5"),
J: common_vendor.p({
type: "message"
})
};
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
swan.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-baidu/pages/index/home.js.map