@@ -56,6 +56,7 @@ | |||
"dayjs": "^1.11.9", | |||
"js-audio-recorder": "^1.0.7", | |||
"pinia": "2.0.33", | |||
"pinia-plugin-persistedstate": "^3.2.0", | |||
"uview-plus": "^3.1.34", | |||
"vue": "^3.2.45", | |||
"vue-i18n": "^9.1.9" | |||
@@ -10,6 +10,7 @@ import { findImageApi, findGlodApi } from "./api/home"; | |||
const userInfoModulesPinia = userInfoModules(); | |||
onLaunch(() => { | |||
console.log("App Launch!"); | |||
// 获取平台及系统信息 | |||
uni.getSystemInfo({ | |||
success: function (res) { | |||
@@ -18,9 +18,9 @@ | |||
@change="" | |||
@click="" | |||
></u-swiper> --> | |||
<u-swiper | |||
<!-- <u-swiper | |||
v-if="createState == 2" | |||
height="350" | |||
height="320" | |||
:list="swiperList" | |||
keyName="image" | |||
previousMargin="60" | |||
@@ -31,7 +31,20 @@ | |||
:autoplay="false" | |||
radius="5" | |||
bgColor="#1f2123" | |||
></u-swiper> --> | |||
<u-swiper | |||
v-if="createState == 2" | |||
indicator | |||
indicatorMode="dot" | |||
circular | |||
:radius="30" | |||
:autoplay="false" | |||
:list="swiperList" | |||
keyName="image" | |||
@change="getSwiperIndex" | |||
@click="previewImage" | |||
></u-swiper> | |||
<view class="checkMore">左右滑动查看更多</view> | |||
<!-- @click="goLookPhoto" --> | |||
<image | |||
v-if="createState != 2" | |||
@@ -71,10 +84,14 @@ const workId = ref(null); //作品id | |||
const createState = ref(null); //制作状态:1生成中,2完成,3失败 | |||
const styleId = ref(null); //风格id | |||
const styleData = ref(""); //风格信息 | |||
onLoad((options) => { | |||
workId.value = options.id; | |||
// workId.value = "856433830235262976"; | |||
// workId.value = options.id; | |||
workId.value = "857147862095679488"; | |||
getWorkInfo(); | |||
// let getWindowInfo = uni.getWindowInfo().screenWidth; | |||
// console.log(getWindowInfo, "页面宽度"); | |||
}); | |||
async function getWorkInfo() { | |||
try { | |||
@@ -86,6 +103,9 @@ async function getWorkInfo() { | |||
const res = await findWorkByIdApi(workId.value); | |||
if (res.data.photoList) { | |||
swiperList.value = res.data.photoList; | |||
swiperList.value.forEach((item) => { | |||
previewImageList.value.push(item.image); | |||
}); | |||
} | |||
createState.value = res.data.status; | |||
styleId.value = res.data.digitalAvatarId; | |||
@@ -122,7 +142,18 @@ function goLookPhoto() { | |||
//#endregion --------------------- | |||
//#region 轮播图 | |||
const swiperIndex = ref(0); | |||
const previewImageList = ref([]); //预览图片列表 | |||
function getSwiperIndex(index) { | |||
swiperIndex.value = index.current; | |||
} | |||
function previewImage(index) { | |||
uni.previewImage({ | |||
current: index, //预览图片的下标 | |||
urls: previewImageList.value, //预览图片的地址,必须要数组形式,如果不是数组形式就转换成数组形式就可以 | |||
loop: true, | |||
}); | |||
} | |||
//#endregion --------------------- | |||
//#region | |||
@@ -181,9 +212,33 @@ function goLookPhoto() { | |||
} | |||
} | |||
} | |||
// .u-swiper { | |||
// width: 100%; | |||
// height: 695rpx !important; | |||
// } | |||
.u-swiper { | |||
width: 100%; | |||
height: 695rpx !important; | |||
margin-top: 40rpx; | |||
margin-bottom: 30rpx; | |||
width: 540rpx; | |||
height: 720rpx !important; | |||
border-radius: 50rpx; | |||
swiper { | |||
width: 100%; | |||
height: 720rpx !important; | |||
image { | |||
width: 100%; | |||
height: 720rpx !important; | |||
} | |||
} | |||
// h5 | |||
:deep(.u-swiper__wrapper) { | |||
width: 100%; | |||
height: 720rpx !important; | |||
image { | |||
width: 100%; | |||
height: 720rpx !important; | |||
} | |||
} | |||
} | |||
.logo { | |||
width: 520rpx; | |||
@@ -215,7 +270,7 @@ function goLookPhoto() { | |||
margin-bottom: 30rpx; | |||
} | |||
.anew { | |||
margin-top: 120rpx; | |||
margin-top: 80rpx; | |||
} | |||
} | |||
</style> |
@@ -4,6 +4,7 @@ | |||
<u-swiper | |||
indicator | |||
indicatorMode="dot" | |||
circular | |||
:radius="30" | |||
:autoplay="false" | |||
:list="swiperList" | |||
@@ -244,6 +245,9 @@ function buyCoin() { | |||
</script> | |||
<style lang="scss"> | |||
.page { | |||
background-color: rgba(24, 25, 26, 1); | |||
} | |||
// 轮播图 | |||
.u-swiper { | |||
margin-top: 40rpx; | |||
@@ -135,6 +135,7 @@ function chooseImage() { | |||
quality: 40, | |||
success: (res2) => { | |||
showImgUrl.value = res2.tempFilePath; | |||
toCloseStyle(); | |||
}, | |||
}); | |||
} else { | |||
@@ -211,6 +212,7 @@ async function toCloseStyle() { | |||
}, | |||
success: (res) => { | |||
if (JSON.parse(res.data).code != 200) { | |||
uni.hideLoading(); | |||
uploadState.value = 4; | |||
return; | |||
} | |||
@@ -229,6 +231,7 @@ async function toCloseStyle() { | |||
success: async (res2) => { | |||
let moment = res2; | |||
if (JSON.parse(res2.data).code != 200) { | |||
uni.hideLoading(); | |||
uploadState.value = 5; | |||
uni.showToast({ | |||
title: "网络被数字人偷走了, 请稍后重试", | |||
@@ -246,10 +249,13 @@ async function toCloseStyle() { | |||
// 改变全局的头像 | |||
userInfoModulesPinia.myAvatar = JSON.parse(moment.data).data.url; | |||
uploadState.value = 1; | |||
uni.hideLoading(); | |||
showImgUrl.value = null; | |||
uni.navigateTo({ | |||
url: "/pages/uploadPhoto/success", | |||
}); | |||
} else { | |||
uni.hideLoading(); | |||
uni.showToast({ | |||
title: "网络被数字人偷走了, 请稍后重试", | |||
icon: "none", | |||
@@ -258,19 +264,25 @@ async function toCloseStyle() { | |||
}, | |||
fail: () => { | |||
uploadState.value = 5; | |||
uni.hideLoading(); | |||
uni.showToast({ | |||
title: "网络被数字人偷走了, 请稍后重试", | |||
icon: "none", | |||
}); | |||
}, | |||
}); | |||
}, | |||
fail: () => { | |||
uploadState.value = 1; | |||
uni.hideLoading(); | |||
uni.showToast({ | |||
title: "网络被数字人偷走了, 请稍后重试", | |||
icon: "none", | |||
}); | |||
}, | |||
complete: (complete) => { | |||
uni.hideLoading(); | |||
}, | |||
// complete: (complete) => { | |||
// uni.hideLoading(); | |||
// }, | |||
}); | |||
} | |||
} | |||
@@ -300,6 +312,7 @@ onLoad((options) => { | |||
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(); | |||
@@ -365,8 +378,6 @@ onLoad((options) => { | |||
} | |||
console.log(options); | |||
}); | |||
//#endregion --------------------- | |||
onShow(() => { | |||
// 若来自我的页面的更换头像按钮,直接触发以下操作 | |||
const action = uni.getStorageSync("action"); | |||
@@ -376,7 +387,9 @@ onShow(() => { | |||
} | |||
}); | |||
//#region | |||
//#endregion --------------------- | |||
//#region 公共方法 | |||
function goOtherPage(url) { | |||
uni.navigateTo({ | |||
url: url, | |||
@@ -1,9 +1,10 @@ | |||
// import { createPinia } from 'pinia' | |||
import * as Pinia from 'pinia' | |||
import { createUnistorage } from 'pinia-plugin-unistorage' | |||
// import { createUnistorage } from 'pinia-plugin-unistorage' | |||
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate' | |||
// const store = createPinia(); | |||
const store = Pinia.createPinia() | |||
store.use(createUnistorage()) | |||
// store.use(createUnistorage()) | |||
Pinia.use(piniaPluginPersistedstate) | |||
export { store, Pinia }; |
@@ -3524,6 +3524,11 @@ pify@^2.3.0: | |||
resolved "https://registry.npmmirror.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" | |||
integrity sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog== | |||
pinia-plugin-persistedstate@^3.2.0: | |||
version "3.2.0" | |||
resolved "https://registry.yarnpkg.com/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-3.2.0.tgz#9932ca2ae88aa6c0d6763bebc6447d7bd1f097d0" | |||
integrity sha512-tZbNGf2vjAQcIm7alK40sE51Qu/m9oWr+rEgNm/2AWr1huFxj72CjvpQcIQzMknDBJEkQznCLAGtJTIcLKrKdw== | |||
pinia-plugin-unistorage@^0.0.17: | |||
version "0.0.17" | |||
resolved "https://registry.yarnpkg.com/pinia-plugin-unistorage/-/pinia-plugin-unistorage-0.0.17.tgz#b237d1146069c400b5b81ac5dac0467e3d07db68" | |||