330 lines
11 KiB
JavaScript
330 lines
11 KiB
JavaScript
"use strict";
|
||
const common_vendor = require("../../common/vendor.js");
|
||
const utils_system = require("../../utils/system.js");
|
||
const api_apis = require("../../api/apis.js");
|
||
if (!Array) {
|
||
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
||
const _easycom_uni_dateformat2 = common_vendor.resolveComponent("uni-dateformat");
|
||
const _easycom_uni_rate2 = common_vendor.resolveComponent("uni-rate");
|
||
const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
|
||
(_easycom_uni_icons2 + _easycom_uni_dateformat2 + _easycom_uni_rate2 + _easycom_uni_popup2)();
|
||
}
|
||
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
|
||
const _easycom_uni_dateformat = () => "../../uni_modules/uni-dateformat/components/uni-dateformat/uni-dateformat.js";
|
||
const _easycom_uni_rate = () => "../../uni_modules/uni-rate/components/uni-rate/uni-rate.js";
|
||
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
|
||
if (!Math) {
|
||
(_easycom_uni_icons + _easycom_uni_dateformat + _easycom_uni_rate + _easycom_uni_popup)();
|
||
}
|
||
const _sfc_main = {
|
||
__name: "preview",
|
||
setup(__props) {
|
||
const maskState = common_vendor.ref(true);
|
||
const infoPopup = common_vendor.ref(null);
|
||
const currentInfo = common_vendor.ref({});
|
||
const scorePopup = common_vendor.ref(null);
|
||
const userScore = common_vendor.ref(0);
|
||
const isScore = common_vendor.ref(false);
|
||
const classList = common_vendor.ref([]);
|
||
const currentId = common_vendor.ref(null);
|
||
const currentIndex = common_vendor.ref(0);
|
||
const readImgs = common_vendor.ref([]);
|
||
const storgClassList = common_vendor.index.getStorageSync("storgClassList") || [];
|
||
classList.value = storgClassList.map((item) => {
|
||
return {
|
||
...item,
|
||
//注意 _small.webp是小图,要看大图的话,需要将后缀改变成.jpg
|
||
picurl: item.smallPicurl.replace("_small.webp", ".jpg")
|
||
};
|
||
});
|
||
common_vendor.onLoad(async (e) => {
|
||
currentId.value = e.id;
|
||
if (e.type == "share") {
|
||
let res = await api_apis.apiDetailWall({ id: currentId.value });
|
||
classList.value = res.data.map((item) => {
|
||
return {
|
||
...item,
|
||
picurl: item.smallPicurl.replace("_small.webp", ".jpg")
|
||
};
|
||
});
|
||
}
|
||
currentIndex.value = classList.value.findIndex((item) => item._id == currentId.value);
|
||
readImgsFun();
|
||
currentInfo.value = classList.value[currentIndex.value];
|
||
});
|
||
const swiperChange = (e) => {
|
||
currentIndex.value = e.detail.current;
|
||
readImgsFun();
|
||
currentInfo.value = classList.value[currentIndex.value];
|
||
};
|
||
const readImgsFun = () => {
|
||
readImgs.value.push(
|
||
currentIndex.value <= 0 ? classList.value.length - 1 : currentIndex.value - 1,
|
||
currentIndex.value,
|
||
currentIndex.value >= classList.value.length - 1 ? 0 : currentIndex.value + 1
|
||
);
|
||
readImgs.value = [...new Set(readImgs.value)];
|
||
};
|
||
const clickInfo = () => {
|
||
infoPopup.value.open();
|
||
};
|
||
const clickInfoClose = () => {
|
||
infoPopup.value.close();
|
||
};
|
||
const clickScore = () => {
|
||
if (currentInfo.value.userScore) {
|
||
isScore.value = true;
|
||
userScore.value = currentInfo.value.userScore;
|
||
}
|
||
scorePopup.value.open();
|
||
};
|
||
const clickScoreClose = () => {
|
||
scorePopup.value.close();
|
||
userScore.value = 0;
|
||
isScore.value = false;
|
||
};
|
||
const submitScore = async () => {
|
||
common_vendor.index.showLoading({
|
||
title: "加载中..."
|
||
});
|
||
let {
|
||
classid,
|
||
_id: wallId
|
||
} = currentInfo.value;
|
||
let res = await api_apis.apiGetSetScore({
|
||
classid,
|
||
wallId,
|
||
userScore: userScore.value
|
||
});
|
||
common_vendor.index.hideLoading();
|
||
if (res.errCode === 0) {
|
||
common_vendor.index.showToast({
|
||
title: "评分成功",
|
||
icon: "none"
|
||
});
|
||
}
|
||
classList.value[currentIndex.value].userScore = userScore.value;
|
||
common_vendor.index.setStorageSync("storgClassList", classList.value);
|
||
clickScoreClose();
|
||
};
|
||
const maskChange = () => {
|
||
maskState.value = !maskState.value;
|
||
};
|
||
const goBack = () => {
|
||
common_vendor.index.navigateBack({
|
||
success: () => {
|
||
},
|
||
fail: (err) => {
|
||
common_vendor.index.reLaunch({
|
||
url: "/pages/index/index"
|
||
});
|
||
}
|
||
});
|
||
};
|
||
const clickDownload = async () => {
|
||
try {
|
||
common_vendor.index.showLoading({
|
||
title: "下载中...",
|
||
// 显示过程中不允许点击其他的东西
|
||
mask: true
|
||
});
|
||
let {
|
||
classid,
|
||
_id: wallId
|
||
} = currentInfo.value;
|
||
let res = await api_apis.apiWriteDownload({
|
||
classid,
|
||
wallId
|
||
});
|
||
if (res.errCode != 0) {
|
||
throw res;
|
||
}
|
||
common_vendor.index.getImageInfo({
|
||
// 这个getImageInfo是为了根据网络地址获得一个临时下载地址,以便能够下载到相册里面
|
||
//单纯的使用 saveImageToPhotosAlbum 是不能够保存图片的
|
||
src: currentInfo.value.picurl,
|
||
success: (res2) => {
|
||
common_vendor.index.saveImageToPhotosAlbum({
|
||
filePath: res2.path,
|
||
success: (res3) => {
|
||
common_vendor.index.showToast({
|
||
title: "保存成功,请到相册查看",
|
||
icon: "none"
|
||
});
|
||
},
|
||
fail: (err) => {
|
||
if (err.errMsg == "saveImagePhotoAlbum:fail cancel") {
|
||
common_vendor.index.showToast({
|
||
title: "保存失败,请重新点击下载",
|
||
icon: "none"
|
||
});
|
||
return;
|
||
}
|
||
common_vendor.index.showModal({
|
||
title: "授权提示",
|
||
content: "需要授权保存相册",
|
||
//success表示系统回复了的情况
|
||
success: (res3) => {
|
||
if (res3.confirm) {
|
||
common_vendor.index.openSetting({
|
||
success: (setting) => {
|
||
common_vendor.index.__f__(
|
||
"log",
|
||
"at pages/preview/preview.vue:404",
|
||
setting
|
||
);
|
||
if (setting.authSetting["scope.writePhotosAlbum"]) {
|
||
common_vendor.index.showToast({
|
||
title: "获取授权成功",
|
||
icon: "none"
|
||
});
|
||
} else {
|
||
common_vendor.index.showToast({
|
||
title: "获取权限失败",
|
||
icon: "none"
|
||
});
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
});
|
||
},
|
||
//complete表示无论成功还是失败都会做的事件
|
||
complete: () => {
|
||
common_vendor.index.hideLoading();
|
||
}
|
||
});
|
||
}
|
||
});
|
||
} catch (err) {
|
||
common_vendor.index.hideLoading();
|
||
}
|
||
};
|
||
common_vendor.onShareAppMessage((e) => {
|
||
return {
|
||
title: "hzb壁纸-",
|
||
// 必须传递id进去,否则进不去内部页面
|
||
path: "/pages/preview/preview?id=" + currentId.value + "&type=share"
|
||
};
|
||
});
|
||
common_vendor.onShareTimeline(() => {
|
||
return {
|
||
// 标题
|
||
title: "hzb壁纸~~~",
|
||
// 分享时候的图片地址。可以本地也可以网络图
|
||
// imageUrl:"/static/images/logo2.jpg"
|
||
//要想看朋友圈这个,需要带的query参数
|
||
// type表示是分享传入的
|
||
query: "id=" + currentId.value + "&type=share"
|
||
};
|
||
});
|
||
return (_ctx, _cache) => {
|
||
return {
|
||
a: common_vendor.f(classList.value, (item, index, i0) => {
|
||
return common_vendor.e({
|
||
a: readImgs.value.includes(index)
|
||
}, readImgs.value.includes(index) ? {
|
||
b: common_vendor.o(maskChange, item._id),
|
||
c: item.picurl
|
||
} : {}, {
|
||
d: item._id
|
||
});
|
||
}),
|
||
b: currentIndex.value,
|
||
c: common_vendor.o(swiperChange),
|
||
d: common_vendor.p({
|
||
type: "back",
|
||
color: "#fff",
|
||
size: "20"
|
||
}),
|
||
e: common_vendor.o(goBack),
|
||
f: common_vendor.unref(utils_system.getPreviewBarHeight)() + "px",
|
||
g: common_vendor.t(currentIndex.value + 1),
|
||
h: common_vendor.t(classList.value.length),
|
||
i: common_vendor.p({
|
||
date: Date.now(),
|
||
format: "hh:mm"
|
||
}),
|
||
j: common_vendor.p({
|
||
date: Date.now(),
|
||
format: "MM月dd日"
|
||
}),
|
||
k: common_vendor.p({
|
||
type: "info",
|
||
size: "23"
|
||
}),
|
||
l: common_vendor.o(clickInfo),
|
||
m: common_vendor.p({
|
||
type: "star",
|
||
size: "23"
|
||
}),
|
||
n: common_vendor.t(currentInfo.value.score),
|
||
o: common_vendor.o(clickScore),
|
||
p: common_vendor.p({
|
||
type: "download",
|
||
size: "23"
|
||
}),
|
||
q: common_vendor.o(clickDownload),
|
||
r: maskState.value,
|
||
s: common_vendor.p({
|
||
type: "closeempty",
|
||
size: "18",
|
||
color: "#999"
|
||
}),
|
||
t: common_vendor.o(clickInfoClose),
|
||
v: common_vendor.t(currentInfo.value._id),
|
||
w: common_vendor.t(currentInfo.value.nickname),
|
||
x: common_vendor.p({
|
||
readonly: true,
|
||
touchable: false,
|
||
value: currentInfo.value.score,
|
||
size: "16"
|
||
}),
|
||
y: common_vendor.t(currentInfo.value.score),
|
||
z: common_vendor.t(currentInfo.value.description),
|
||
A: common_vendor.f(currentInfo.value.tabs, (tab, k0, i0) => {
|
||
return {
|
||
a: common_vendor.t(tab),
|
||
b: tab
|
||
};
|
||
}),
|
||
B: common_vendor.sr(infoPopup, "2dad6c07-6", {
|
||
"k": "infoPopup"
|
||
}),
|
||
C: common_vendor.p({
|
||
type: "bottom"
|
||
}),
|
||
D: common_vendor.t(isScore.value ? "已经评分过了~" : "壁纸评分"),
|
||
E: common_vendor.p({
|
||
type: "closeempty",
|
||
size: "18",
|
||
color: "#999"
|
||
}),
|
||
F: common_vendor.o(clickScoreClose),
|
||
G: common_vendor.o(_ctx.onChange),
|
||
H: common_vendor.o(($event) => userScore.value = $event),
|
||
I: common_vendor.p({
|
||
disabled: isScore.value,
|
||
["disabled-color"]: "#FFCA3E",
|
||
allowHalf: true,
|
||
modelValue: userScore.value
|
||
}),
|
||
J: common_vendor.t(userScore.value),
|
||
K: common_vendor.o(submitScore),
|
||
L: !userScore.value || isScore.value,
|
||
M: common_vendor.sr(scorePopup, "2dad6c07-9", {
|
||
"k": "scorePopup"
|
||
}),
|
||
N: common_vendor.p({
|
||
["is-mask-click"]: false
|
||
})
|
||
};
|
||
};
|
||
}
|
||
};
|
||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-2dad6c07"]]);
|
||
_sfc_main.__runtimeHooks = 6;
|
||
wx.createPage(MiniProgramPage);
|
||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/preview/preview.js.map
|