Browse Source

3超分

master
congzc 1 year ago
parent
commit
115c4f3810
4 changed files with 144 additions and 40 deletions
  1. +26
    -0
      src/api/lookPhoto.js
  2. +2
    -2
      src/pages/createing/index.vue
  3. +115
    -38
      src/pages/lookPhoto/index.vue
  4. +1
    -0
      src/style/my.scss

+ 26
- 0
src/api/lookPhoto.js View File

@@ -12,3 +12,29 @@ export function getPhotoListApi(id) {
method: 'get',
})
}


/**
* @description:超分
* @param id
* @return: data
*/
export function photoSupperApi(data) {
return request({
url: `/api/digitalAvatarPhoto/photoSupper`,
method: 'post',
data
})
}

/**
* @description:超分 查询超分状态
* @param id
* @return: data
*/
export function getSupperPhotoStateApi(id) {
return request({
url: `/api/digitalAvatarPhoto/getSupperPhoto?id=${id}`,
method: 'get',
})
}

+ 2
- 2
src/pages/createing/index.vue View File

@@ -86,8 +86,8 @@ const styleId = ref(null); //风格id
const styleData = ref(""); //风格信息
onLoad((options) => {
// workId.value = options.id;
workId.value = "857147862095679488";
workId.value = options.id;
// workId.value = "857147862095679488";
getWorkInfo();
// let getWindowInfo = uni.getWindowInfo().screenWidth;


+ 115
- 38
src/pages/lookPhoto/index.vue View File

@@ -22,6 +22,12 @@
<view @click="downloadImg" class="uploadBtn">
<text>下载照片</text>
</view>
<view class="grayBtn" @click="photoSupper">
<!-- <view v-if="supperPhotoState == 0 || supperPhotoState == 3" class="free">
<text>耗金币1枚</text>
</view> -->
{{ supperTips() }}
</view>
<!-- 底部 -->
<view class="bottomBox">
<view class="tips">
@@ -69,16 +75,21 @@
// import myloading from '../../components/myLoading.vue'
//#region 导入
import { onLoad } from "@dcloudio/uni-app";
import { ref, reactive } from "vue";
import { ref, reactive, watch } from "vue";
import { userInfoModules } from "@/store/modules/userInfo";
import { getPhotoListApi } from "../../api/lookPhoto.js";
import {
getPhotoListApi,
photoSupperApi,
getSupperPhotoStateApi,
} from "../../api/lookPhoto.js";
//#endregion
const userInfoModulesPinia = userInfoModules();
//#region 轮播图
const workId = ref(null);
onLoad((options) => {
const workId = ref(null); //作品id
onLoad(async (options) => {
workId.value = options.id;
getSwiperList();
await getSwiperList();
await getSupperPhotoState(swiperList.value[0].id);
});
const swiperList = ref([]); //轮播图
const previewImageList = ref([]); //预览图片列表
@@ -88,7 +99,11 @@ async function getSwiperList() {
console.log(res.data.photoList);
swiperList.value = res.data.photoList;
swiperList.value.forEach((item) => {
previewImageList.value.push(item.image);
if (item.imageSuper) {
previewImageList.value.push(item.imageSuper);
} else {
previewImageList.value.push(item.image);
}
});
}
//#endregion ---------------------
@@ -102,7 +117,9 @@ function downloadImg() {
let filePath = wx.env.USER_DATA_PATH + "/" + "zhixiang.png";
uni.downloadFile({
filePath: filePath,
url: swiperList.value[swiperIndex.value].image, //仅为示例,并非真实的资源
url: swiperList.value[swiperIndex.value].imageSuper
? swiperList.value[swiperIndex.value].imageSuper
: swiperList.value[swiperIndex.value].image, //仅为示例,并非真实的资源
// url: "http://tmp/iFlp7n9vAaaEa3276321f9c19ed0031617eb27119af4.png", //仅为示例,并非真实的资源
success: (res) => {
let data = res;
@@ -239,6 +256,79 @@ function buyCoin() {
}
//#endregion ---------------------
//#region 超分相关
const supperPhotoState = ref(false);
async function photoSupper() {
if (supperPhotoState.value == 1 || supperPhotoState.value == 2) {
return;
}
// uni.showModal({
// title: "提示",
// content: "确定高清处理?",
// success: function (res) {
// if (res.confirm) {
// checkboxValue.value = ["同意智像相机用户使用协议"];
// // handleLogin();
// getphonenumber(e);
// } else if (res.cancel) {
// }
// },
// fail: (err) => {},
// });
try {
uni.showLoading({
title: "高清处理中...",
mask: true,
});
const res = await photoSupperApi({
id: swiperList.value[swiperIndex.value].id,
});
console.log(res);
uni.hideLoading();
uni.showToast({
title: "高清处理请求成功,请重稍后",
icon: "none",
});
getSupperPhotoState(swiperList.value[swiperIndex.value].id);
} catch (error) {
console.log(error, "超分失败");
uni.hideLoading();
uni.showToast({
title: "高清处理失败,请重试",
icon: "none",
});
}
}
async function getSupperPhotoState(id) {
try {
const res = await getSupperPhotoStateApi(id);
supperPhotoState.value = res.data.status;
console.log(supperPhotoState.value, "状态");
} catch (error) {
console.log(error, "超分失败");
}
}
function supperTips(params) {
if (supperPhotoState.value == 0 || supperPhotoState.value == 3) {
return "一键高清";
} else if (supperPhotoState.value == 1) {
return "高清处理中,请稍后";
} else if (supperPhotoState.value == 2) {
return "已高清处理";
}
}
watch(
() => swiperIndex.value,
(index) => {
getSupperPhotoState(swiperList.value[index].id);
}
);
//#endregion ---------------------
//#region
//#endregion ---------------------
@@ -282,7 +372,7 @@ function buyCoin() {
// 俩按钮
.uploadBtn {
position: relative;
margin-top: 140rpx;
margin-top: 100rpx;
width: 520rpx;
height: 100rpx;
line-height: 100rpx;
@@ -326,18 +416,30 @@ function buyCoin() {
}
}
.grayBtn {
background-color: transparent;
border: 1px solid #6a6c6e;
margin-top: 50rpx;
.free {
position: absolute;
color: #fff;
top: -18rpx;
right: -70rpx;
width: 142rpx;
height: 50rpx;
background-color: #ff4f00;
border-radius: 25rpx 25rpx 25rpx 0;
font-size: 22rpx;
font-weight: 900;
line-height: 50rpx;
text-align: center;
}
}
.bottomBox {
flex: 1;
position: absolute;
// position: absolute;
bottom: 80rpx;
width: 100%;
display: flex;
justify-content: space-between;
padding: 65rpx 50rpx 0;
padding: 65rpx 10rpx 0;
.tips {
position: absolute;
top: 0rpx;
@@ -360,29 +462,4 @@ function buyCoin() {
background-color: rgba(255, 255, 255, 0.1);
}
}
// .bottomBox {
// width: 100%;
// display: flex;
// flex-direction: column;
// align-items: center;
// justify-content: center;
// .balance {
// margin-top: 30rpx;
// font-size: 40rpx;
// margin-bottom: 50rpx;
// }
// .buttonBox {
// width: 60%;
// }
// .shareBox {
// margin-top: 90rpx;
// width: 100%;
// display: flex;
// justify-content: space-between;
// .buttonBox {
// width: 30%;
// }
// }
// }
</style>

+ 1
- 0
src/style/my.scss View File

@@ -96,6 +96,7 @@ view {
}
.grayBtn {
position: relative;
margin-top: 30rpx;
background-color: transparent;
width: 520rpx;


Loading…
Cancel
Save