@@ -1,11 +1,6 @@ | |||||
import { request } from "../utils/request" | import { request } from "../utils/request" | ||||
export function voiceTotalApi() { | |||||
return request({ | |||||
url: `api/voiceMould/voiceTotal`, | |||||
method: 'GET', | |||||
}) | |||||
} | |||||
// 微信登录 | // 微信登录 | ||||
export function loginApi(data) { | export function loginApi(data) { | ||||
return request({ | return request({ | ||||
@@ -129,9 +129,14 @@ function inviteFriend() { | |||||
//#region 页面跳转 | //#region 页面跳转 | ||||
function bueCoin() { | function bueCoin() { | ||||
uni.navigateTo({ | |||||
url: "/pages/home/buyCoin", | |||||
uni.showToast({ | |||||
title: "暂未开放", | |||||
icon: "none", | |||||
mask: true, | |||||
}); | }); | ||||
// uni.navigateTo({ | |||||
// url: "/pages/home/buyCoin", | |||||
// }); | |||||
} | } | ||||
//#endregion --------------------- | //#endregion --------------------- | ||||
@@ -30,9 +30,7 @@ | |||||
<view class="coinBox" v-if="userInfoModulesPinia.token"> | <view class="coinBox" v-if="userInfoModulesPinia.token"> | ||||
我的金币: {{ userInfoModulesPinia.myGlod }} | 我的金币: {{ userInfoModulesPinia.myGlod }} | ||||
<image src="../../assets/icon/icon.png" mode="scaleToFill" /> | <image src="../../assets/icon/icon.png" mode="scaleToFill" /> | ||||
<text class="buyCoinText" @click="goOtherPage('buyCoin', 2)" | |||||
>购买金币</text | |||||
></view | |||||
<text class="buyCoinText" @click="goBuyCoin">购买金币</text></view | |||||
> | > | ||||
<view class="coinBox" v-if="!userInfoModulesPinia.token" | <view class="coinBox" v-if="!userInfoModulesPinia.token" | ||||
>登录即可体验更多功能哦! | >登录即可体验更多功能哦! | ||||
@@ -70,9 +68,7 @@ | |||||
v-for="item in PhotoList" | v-for="item in PhotoList" | ||||
:key="item.id" | :key="item.id" | ||||
class="showListItem" | class="showListItem" | ||||
@click=" | |||||
goOtherPage(`/pages/lookPhoto/index?id=${item.id}`, item.status) | |||||
" | |||||
@click="goLookPhoto(item.id, item.status)" | |||||
> | > | ||||
<view class="top"> | <view class="top"> | ||||
<text class="name">{{ item.title }}</text> | <text class="name">{{ item.title }}</text> | ||||
@@ -116,11 +112,7 @@ | |||||
<!-- 空处理 --> | <!-- 空处理 --> | ||||
<view v-show="PhotoList.length == 0" class="noData" | <view v-show="PhotoList.length == 0" class="noData" | ||||
>暂无数据 , | >暂无数据 , | ||||
<text | |||||
@click="goOtherPage('/pages/closeStyle/closeStyle', 2)" | |||||
class="goCreate" | |||||
>去生成!</text | |||||
> | |||||
<text @click="goCloseStyle" class="goCreate">去生成!</text> | |||||
</view> | </view> | ||||
</scroll-view> | </scroll-view> | ||||
<!-- 显示视频列表内容 --> | <!-- 显示视频列表内容 --> | ||||
@@ -246,47 +238,22 @@ function chooseAvatar() { | |||||
url: "/pages/uploadPhoto/uploadPhoto", | url: "/pages/uploadPhoto/uploadPhoto", | ||||
}); | }); | ||||
return; | return; | ||||
uni.chooseImage({ | |||||
count: 1, // 最多可以选择的图片张数,这里设置为1,只选择一张图片 | |||||
success: async (res) => { | |||||
// avatarUrl.value = res.tempFilePaths[0]; | |||||
// TODO: 在这里处理图片上传逻辑,你可以调用上传接口将图片上传到服务器 | |||||
// 示例代码: | |||||
// uploadImageToServer(tempFilePaths[0]); | |||||
// 图片压缩 | |||||
console.log(res.tempFiles[0].size); | |||||
if (userInfoModulesPinia.platForm != 1) { | |||||
uni.compressImage({ | |||||
src: res.tempFilePaths[0], | |||||
quality: 20, | |||||
success: (res2) => { | |||||
avatarUrl.value = res2.tempFilePath; | |||||
console.log(res2.tempFilePath); | |||||
}, | |||||
}); | |||||
} else { | |||||
const options = { | |||||
maxSizeMB: 2, // 最大压缩大小为 4MB | |||||
useWebWorker: true, // 使用 Web Worker 进行压缩,提高性能 | |||||
}; | |||||
const compressedFile = await imageCompression( | |||||
res.tempFiles[0], | |||||
options | |||||
); | |||||
//compressedFile是一个blob对象 | |||||
avatarUrl.value = URL.createObjectURL(compressedFile); | |||||
console.log(compressedFile); | |||||
// avatarUrl.value = compressedFile; | |||||
console.log("压缩图片h5"); | |||||
} | |||||
}, | |||||
fail: (err) => { | |||||
console.error("选择图片失败", err); | |||||
}, | |||||
} | |||||
//#endregion | |||||
//#region 路由跳转 | |||||
function goBuyCoin() { | |||||
uni.showToast({ | |||||
title: "暂未开放", | |||||
icon: "none", | |||||
mask: true, | |||||
}); | }); | ||||
// uni.navigateTo({ | |||||
// url: "/pages/home/buyCoin", | |||||
// }); | |||||
} | } | ||||
function goOtherPage(url, status) { | |||||
function goLookPhoto(id, status) { | |||||
if (status != 2) { | if (status != 2) { | ||||
uni.showToast({ | uni.showToast({ | ||||
title: "正在生成,请稍后", | title: "正在生成,请稍后", | ||||
@@ -295,9 +262,16 @@ function goOtherPage(url, status) { | |||||
return; | return; | ||||
} | } | ||||
uni.navigateTo({ | uni.navigateTo({ | ||||
url: url, | |||||
url: `/pages/lookPhoto/index?id=${id}`, | |||||
}); | }); | ||||
} | } | ||||
function goCloseStyle() { | |||||
uni.navigateTo({ | |||||
url: `/pages/closeStyle/closeStyle`, | |||||
}); | |||||
} | |||||
//#endregion | //#endregion | ||||
//#region tab | //#region tab | ||||
@@ -129,7 +129,7 @@ | |||||
import { ref, reactive, computed } from "vue"; | import { ref, reactive, computed } from "vue"; | ||||
import { onLoad } from "@dcloudio/uni-app"; | import { onLoad } from "@dcloudio/uni-app"; | ||||
import { | import { | ||||
voiceTotalApi, | |||||
loginApi, | |||||
loginPhoneApi, | loginPhoneApi, | ||||
getCodeApi, | getCodeApi, | ||||
loginByCodeApi, | loginByCodeApi, | ||||
@@ -137,7 +137,7 @@ import { | |||||
import { userInfoModules } from "@/store/modules/userInfo"; | import { userInfoModules } from "@/store/modules/userInfo"; | ||||
//#endregion | //#endregion | ||||
const userInfoModulesPinia = userInfoModules(); | const userInfoModulesPinia = userInfoModules(); | ||||
console.log(userInfoModulesPinia.platForm); | |||||
const pageClass = computed(() => { | const pageClass = computed(() => { | ||||
if (userInfoModulesPinia.platForm == 1) { | if (userInfoModulesPinia.platForm == 1) { | ||||
return "page pageH5"; | return "page pageH5"; | ||||
@@ -380,19 +380,161 @@ async function loginByCode() { | |||||
onLoad((options) => { | onLoad((options) => { | ||||
uni.hideHomeButton(); | uni.hideHomeButton(); | ||||
// workId.value = options.id; | // workId.value = options.id; | ||||
if (options.type == "tokenFfalse") { | if (options.type == "tokenFfalse") { | ||||
uni.showToast({ | uni.showToast({ | ||||
title: "登录失效,请重新登录", | title: "登录失效,请重新登录", | ||||
icon: "none", | icon: "none", | ||||
}); | }); | ||||
} | } | ||||
if (userInfoModulesPinia.platForm == 2) { | |||||
uni.login({ | |||||
provider: "weixin", // 使用微信登录授权 | |||||
success: async (res) => { | |||||
if (res.code) { | |||||
try { | |||||
uni.showLoading({ | |||||
title: "加载中...", | |||||
mask: true, | |||||
}); | |||||
const data = { | |||||
appId: userInfoModulesPinia.getAppId(), | |||||
code: res.code, | |||||
}; | |||||
const res2 = await loginApi(data); | |||||
userInfoModulesPinia.openId = res2.data.openId; | |||||
if (res2.data.token) { | |||||
userInfoModulesPinia.token = res2.data.token; | |||||
// uni.setStorageSync("token", userInfoModulesPinia.token); | |||||
console.log(userInfoModulesPinia.openId, "获取openid"); | |||||
// 获取头像和金币 | |||||
const res3 = await findImageApi(); | |||||
userInfoModulesPinia.myAvatar = | |||||
res3.data && res3.data.image ? res3.data.image : ""; | |||||
const res4 = await findGlodApi(); | |||||
if (!res4.data) { | |||||
userInfoModulesPinia.myGlod = 0; | |||||
} else { | |||||
userInfoModulesPinia.myGlod = res4.data.digitalAvatarResidueGlod | |||||
? res4.data.digitalAvatarResidueGlod | |||||
: 0; | |||||
} | |||||
uni.hideLoading(); | |||||
if (res2.data.token) { | |||||
// uni.redirectTo({ | |||||
// url: "/pages/index/index", | |||||
// }); | |||||
} else { | |||||
uni.redirectTo({ | |||||
url: "/pages/login/index", | |||||
}); | |||||
console.log("error1"); | |||||
uni.showToast({ | |||||
title: "登录失败,请重试", | |||||
icon: "none", | |||||
}); | |||||
} | |||||
} | |||||
uni.hideLoading(); | |||||
} catch (error) { | |||||
// uni.redirectTo({ | |||||
// url: "pages/index/index", | |||||
// }); | |||||
console.log(error, "error2"); | |||||
uni.showToast({ | |||||
title: "登录失败,请重试", | |||||
icon: "none", | |||||
}); | |||||
} | |||||
} else { | |||||
// uni.redirectTo({ | |||||
// url: "pages/index/index", | |||||
// }); | |||||
console.log("error3"); | |||||
uni.showToast({ | |||||
title: "登录失败,请重试", | |||||
icon: "none", | |||||
}); | |||||
} | |||||
}, | |||||
fail: (err) => { | |||||
// uni.redirectTo({ | |||||
// url: "pages/index/index", | |||||
// }); | |||||
console.log("error4"); | |||||
uni.showToast({ | |||||
title: "登录失败,请重试", | |||||
icon: "none", | |||||
}); | |||||
}, | |||||
}); | |||||
} | |||||
// 抖音头条授权 | |||||
else if (userInfoModulesPinia.platForm == 3) { | |||||
uni.login({ | |||||
provider: "toutiao", // 使用微信登录授权 | |||||
success: async (res) => { | |||||
if (res.code) { | |||||
try { | |||||
uni.showLoading({ | |||||
title: "加载中...", | |||||
mask: true, | |||||
}); | |||||
const data = { | |||||
appId: userInfoModulesPinia.getAppId(), | |||||
code: res.code, | |||||
}; | |||||
const res2 = await loginApi(data); | |||||
userInfoModulesPinia.openId = res2.data.openId; | |||||
if (res2.data.token) { | |||||
userInfoModulesPinia.token = res2.data.token; | |||||
// uni.setStorageSync("token", userInfoModulesPinia.token); | |||||
console.log(userInfoModulesPinia.openId, "获取openid"); | |||||
uni.hideLoading(); | |||||
} else { | |||||
uni.hideLoading(); | |||||
// uni.redirectTo({ | |||||
// url: "/pages/login/index", | |||||
// }); | |||||
console.log("error1"); | |||||
uni.showToast({ | |||||
title: "登录失败,请重试", | |||||
icon: "none", | |||||
}); | |||||
} | |||||
uni.hideLoading(); | |||||
} catch (error) { | |||||
uni.hideLoading(); | |||||
console.log(error, "error2"); | |||||
uni.showToast({ | |||||
title: "登录失败,请重试", | |||||
icon: "none", | |||||
}); | |||||
} | |||||
} else { | |||||
console.log("error3"); | |||||
uni.showToast({ | |||||
title: "登录失败,请重试", | |||||
icon: "none", | |||||
}); | |||||
} | |||||
}, | |||||
fail: (err) => { | |||||
console.log("error4"); | |||||
uni.showToast({ | |||||
title: "登录失败,请重试", | |||||
icon: "none", | |||||
}); | |||||
}, | |||||
}); | |||||
} | |||||
}); | }); | ||||
//#endregion --------------------------------- | //#endregion --------------------------------- | ||||
//#region | //#region | ||||
//#endregion --------------------------------- | //#endregion --------------------------------- | ||||
// voiceTotalApi(); | |||||
</script> | </script> | ||||
<style lang="scss"> | <style lang="scss"> | ||||
@@ -219,9 +219,14 @@ function inviteFriend() { | |||||
//#region 页面跳转 | //#region 页面跳转 | ||||
function buyCoin() { | function buyCoin() { | ||||
uni.navigateTo({ | |||||
url: "/pages/index/buyCoin", | |||||
uni.showToast({ | |||||
title: "暂未开放", | |||||
icon: "none", | |||||
mask: true, | |||||
}); | }); | ||||
// uni.navigateTo({ | |||||
// url: "/pages/index/buyCoin", | |||||
// }); | |||||
} | } | ||||
//#endregion --------------------- | //#endregion --------------------- | ||||
@@ -105,9 +105,14 @@ function previewImage(index) { | |||||
//#region 页面跳转 | //#region 页面跳转 | ||||
function bueCoin() { | function bueCoin() { | ||||
uni.navigateTo({ | |||||
url: "/pages/home/buyCoin", | |||||
uni.showToast({ | |||||
title: "暂未开放", | |||||
icon: "none", | |||||
mask: true, | |||||
}); | }); | ||||
// uni.navigateTo({ | |||||
// url: "/pages/home/buyCoin", | |||||
// }); | |||||
} | } | ||||
//#endregion --------------------- | //#endregion --------------------- | ||||