@@ -1,5 +1,10 @@ | |||
# Suimang-wxapp | |||
setStorageSync 键名 | |||
userId --用户id,用于邀请分享功能 | |||
loginAwardCoin --注册奖励金币 | |||
inviteAwardCoin --邀请奖励金币 | |||
plat --根据平台不同来返回的值,用于发送请求 1为微信,2为抖音 | |||
wx-"appid": "wx75cf14e3a0d45821", | |||
@@ -19,8 +19,10 @@ onLaunch(() => { | |||
if (res.uniPlatform == "web") { | |||
uniPlatform = 1; | |||
} else if (res.uniPlatform == "mp-weixin") { | |||
uni.setStorageSync("plat", 1); | |||
uniPlatform = 2; | |||
} else if (res.uniPlatform == "mp-toutiao") { | |||
uni.setStorageSync("plat", 2); | |||
uniPlatform = 3; | |||
} | |||
if (res.osName == "windows") { | |||
@@ -42,7 +44,7 @@ onLaunch(() => { | |||
}, | |||
}); | |||
uni.setStorageSync("userId", "114514"); | |||
// uni.setStorageSync("userId", "114514"); | |||
const updateManager = uni.getUpdateManager(); | |||
@@ -52,3 +52,15 @@ export function getUserQrcodeApi(data) { | |||
data | |||
}) | |||
} | |||
/** | |||
* @description:获取订阅消息模版id | |||
* @param | |||
* @return: data | |||
*/ | |||
export function getTemplateMsgApi() { | |||
return request({ | |||
url: `api/templateMsg/list?projectType=5&plat=${uni.getStorageSync("plat")}&type=1`, | |||
method: 'get', | |||
}) | |||
} |
@@ -27,4 +27,29 @@ export function addImageApi(data) { | |||
method: 'post', | |||
data | |||
}); | |||
} | |||
/** | |||
* @description:获取登陆,注册送多少金币的接口 | |||
* @param "projectType":5,//智像固定5 "type":1-注册,2-邀请 | |||
* @return: data | |||
*/ | |||
export function getProjectConfigApi(data) { | |||
return request({ | |||
url: `api/glodConfig/getProjectConfig`, | |||
method: 'post', | |||
data | |||
}) | |||
} | |||
/** | |||
* @description:获取照片生成次数,判断是不是首次生成 | |||
* @param "projectType":5,//智像固定5 "type":1-注册,2-邀请 | |||
* @return: data | |||
*/ | |||
export function getCountApi() { | |||
return request({ | |||
url: `api/digitalAvatarPhoto/getCount`, | |||
method: 'get', | |||
}) | |||
} |
@@ -0,0 +1,225 @@ | |||
<template> | |||
<div class="page"> | |||
<!-- 性别tab --> | |||
<view class="sexTab"> | |||
<view @click="sex = 2" class="sex" :class="sex == 2 ? 'sexActive' : ''" | |||
>女</view | |||
> | |||
<view @click="sex = 1" class="sex" :class="sex == 1 ? 'sexActive' : ''" | |||
>男</view | |||
> | |||
</view> | |||
<u-list | |||
class="styleListBox" | |||
@scrolltolower="scrolltolower" | |||
lowerThreshold="100" | |||
> | |||
<u-list-item class="glodYBox"> | |||
<u-list-item | |||
v-for="item in styleList" | |||
:key="item.id" | |||
class="styleListBoxItme" | |||
> | |||
<view class="styleInfo" @click="createPhoto(item)"> | |||
<image :src="item.coverImg" mode="aspectFit" /> | |||
<text class="name">{{ item.title }}</text> | |||
<text class="single">{{ peopleNum(item.mouldType) }}</text> | |||
</view> | |||
</u-list-item> | |||
</u-list-item> | |||
</u-list> | |||
</div> | |||
</template> | |||
<script setup> | |||
//#region 导入 | |||
import { onPullDownRefresh } from "@dcloudio/uni-app"; | |||
import { ref, reactive, watch } from "vue"; | |||
import { getListApi } from "../../api/closeStyle"; | |||
//#endregion | |||
//#region 页面下拉刷新 | |||
// onPullDownRefresh(async () => { | |||
// uni.showLoading({ | |||
// title: "加载中...", | |||
// mask: true, | |||
// }); | |||
// pageNum.value = 1; | |||
// pageSize.value = 8; | |||
// styleList.value = []; | |||
// await getList(); | |||
// uni.hideLoading(); | |||
// uni.stopPullDownRefresh(); | |||
// }); | |||
//#endregion | |||
//#region 列表加载 | |||
const pageNum = ref(1); | |||
const pageSize = ref(20); | |||
const sex = ref(2); //1男2女 | |||
const styleList = ref([]); | |||
// 得到列表 | |||
async function getList() { | |||
try { | |||
uni.showLoading({ | |||
title: "加载中...", | |||
mask: true, | |||
}); | |||
const res = await getListApi(pageNum.value, pageSize.value, sex.value); | |||
styleList.value = res.data.list; | |||
uni.hideLoading(); | |||
} catch (error) { | |||
uni.hideLoading(); | |||
uni.showToast({ | |||
title: "获取列表失败,请重试", | |||
icon: "none", | |||
}); | |||
} | |||
} | |||
// 监听性别tab变化 | |||
watch( | |||
() => sex.value, | |||
(sex) => { | |||
pageNum.value = 1; | |||
pageSize.value = 20; | |||
getList(); | |||
} | |||
); | |||
getList(); | |||
// 触底加载更多 | |||
const scrolltolower = async () => { | |||
try { | |||
uni.showLoading({ | |||
title: "加载中...", | |||
mask: true, | |||
}); | |||
pageNum.value += 1; | |||
const res = await getListApi(pageNum.value, pageSize.value, sex.value); | |||
styleList.value.push(...res.data.list); | |||
setTimeout(function () { | |||
uni.hideLoading(); | |||
}, 500); | |||
if (res.data.list.length == 0) { | |||
pageNum.value -= 1; | |||
uni.showToast({ | |||
title: "已加载全部内容", | |||
icon: "none", | |||
}); | |||
} | |||
} catch (error) { | |||
setTimeout(function () { | |||
uni.hideLoading(); | |||
}, 500); | |||
uni.showToast({ | |||
title: "获取数据失败,请重试", | |||
icon: "none", | |||
}); | |||
} | |||
}; | |||
// 处理单人双人多人 | |||
function peopleNum(num) { | |||
if (num == 1) { | |||
return "单人"; | |||
} else if (num == 2) { | |||
return "双人"; | |||
} else if (num == 3) { | |||
return "三人"; | |||
} | |||
} | |||
//#endregion --------------------- | |||
//#region 点击图片 | |||
function createPhoto(item) { | |||
if (item.mouldType == 1) { | |||
uni.navigateTo({ | |||
url: `/pages/closeStyle/goCreatePhoto?id=${item.id}`, | |||
}); | |||
} else { | |||
uni.navigateTo({ | |||
url: `/pages/closeStyle/multiplayer?id=${item.id}`, | |||
}); | |||
} | |||
} | |||
//#endregion --------------------- | |||
</script> | |||
<style lang="scss"> | |||
.page { | |||
background-color: #222527; | |||
} | |||
.sexTab { | |||
margin: 20rpx 0; | |||
width: 100%; | |||
height: 60rpx; | |||
display: flex; | |||
justify-content: space-evenly; | |||
line-height: 54rpx; | |||
text-align: center; | |||
.sex { | |||
border-radius: 20rpx; | |||
border: 2rpx solid #ccc; | |||
width: 40%; | |||
} | |||
.sexActive { | |||
color: #ff4f00; | |||
border: 2rpx solid #ff4f00; | |||
transition: all 0.3s; | |||
} | |||
} | |||
.u-list { | |||
overflow: hidden; | |||
height: calc(100vh - 200rpx) !important; | |||
width: 650rpx; | |||
.glodYBox { | |||
display: flex !important; | |||
flex-direction: row !important; | |||
flex-wrap: wrap !important; | |||
justify-content: space-between !important; | |||
} | |||
.u-list-item { | |||
display: flex !important; | |||
flex-direction: row !important; | |||
flex-wrap: wrap !important; | |||
justify-content: space-between !important; | |||
} | |||
.styleInfo { | |||
position: relative; | |||
display: flex !important; | |||
flex-wrap: wrap !important; | |||
width: 300rpx; | |||
height: 480rpx; | |||
margin-bottom: 50rpx; | |||
border-radius: 24rpx; | |||
overflow: hidden; | |||
image { | |||
width: 300rpx; | |||
height: 400rpx; | |||
} | |||
.name { | |||
background-color: #393b3d; | |||
width: 100%; | |||
height: 80rpx; | |||
text-align: center; | |||
line-height: 80rpx; | |||
font-size: 30rpx; | |||
font-weight: bold; | |||
} | |||
.single { | |||
position: absolute; | |||
top: 11rpx; | |||
right: 13rpx; | |||
width: 72rpx; | |||
height: 41rpx; | |||
text-align: center; | |||
line-height: 41rpx; | |||
background: rgba(0, 0, 0, 0.4); | |||
font-size: 22rpx; | |||
// opacity: 0.4; | |||
border-radius: 12rpx; | |||
} | |||
} | |||
} | |||
</style> |
@@ -1,14 +1,22 @@ | |||
<template> | |||
<div class="page"> | |||
<!-- 性别tab --> | |||
<view class="sexTab"> | |||
<!-- <view class="sexTab"> | |||
<view @click="sex = 2" class="sex" :class="sex == 2 ? 'sexActive' : ''" | |||
>女</view | |||
> | |||
<view @click="sex = 1" class="sex" :class="sex == 1 ? 'sexActive' : ''" | |||
>男</view | |||
> | |||
</view> | |||
</view> --> | |||
<u-tabs | |||
:list="tabList" | |||
lineWidth="70" | |||
lineColor="#ff4f00" | |||
:activeStyle="{ color: '#ff4f00' }" | |||
:inactiveStyle="{ color: '#fff' }" | |||
@click="chooseTab" | |||
></u-tabs> | |||
<u-list | |||
class="styleListBox" | |||
@scrolltolower="scrolltolower" | |||
@@ -143,32 +151,53 @@ function createPhoto(item) { | |||
} | |||
} | |||
//#endregion --------------------- | |||
//#region tab栏 | |||
const tabList = ref([ | |||
{ name: "女", id: 2 }, | |||
{ name: "男", id: 1 }, | |||
// { name: "多人", id: 3 }, | |||
// { name: "电影明星", id: 4 }, | |||
// { name: "体育", id: 5 }, | |||
]); | |||
function chooseTab(item) { | |||
sex.value = item.id; | |||
} | |||
//#endregion | |||
</script> | |||
<style lang="scss"> | |||
.page { | |||
background-color: #222527; | |||
} | |||
.sexTab { | |||
margin: 20rpx 0; | |||
width: 100%; | |||
height: 60rpx; | |||
display: flex; | |||
justify-content: space-evenly; | |||
line-height: 54rpx; | |||
text-align: center; | |||
.sex { | |||
border-radius: 20rpx; | |||
border: 2rpx solid #ccc; | |||
width: 40%; | |||
} | |||
.sexActive { | |||
color: #ff4f00; | |||
border: 2rpx solid #ff4f00; | |||
transition: all 0.3s; | |||
// .sexTab { | |||
// margin: 20rpx 0; | |||
// width: 100%; | |||
// height: 60rpx; | |||
// display: flex; | |||
// justify-content: space-evenly; | |||
// line-height: 54rpx; | |||
// text-align: center; | |||
// .sex { | |||
// border-radius: 20rpx; | |||
// border: 2rpx solid #ccc; | |||
// width: 40%; | |||
// } | |||
// .sexActive { | |||
// color: #ff4f00; | |||
// border: 2rpx solid #ff4f00; | |||
// transition: all 0.3s; | |||
// } | |||
// } | |||
.u-tabs { | |||
max-width: 100%; | |||
color: #fff !important; | |||
margin-bottom: 30rpx; | |||
.u-tabs__wrapper__nav__item { | |||
width: 200rpx; | |||
height: 90rpx !important; | |||
} | |||
} | |||
.u-list { | |||
overflow: hidden; | |||
height: calc(100vh - 200rpx) !important; | |||
@@ -147,17 +147,23 @@ | |||
class="InviteBox" | |||
v-show="showListActive == 3 && userInfoModulesPinia.token" | |||
> | |||
<scroll-view :scroll-y="true" class="showInviteList"> | |||
<view v-for="item in 9" :key="item" class="InviteList"> | |||
<scroll-view | |||
:scroll-y="true" | |||
class="showInviteList" | |||
@scrolltolower="getMoreInviteList" | |||
> | |||
<view v-for="item in InviteList" :key="item.id" class="InviteList"> | |||
<up-avatar :src="avatarUrl" size="50"></up-avatar> | |||
<view class="info"> | |||
<view class="name">猕猴桃</view> | |||
<view class="time">2023/7/29</view> | |||
<view class="name">{{ item.userPhone }}</view> | |||
<view class="time">{{ | |||
dayjs(item.createDate).format("YYYY-MM-DD HH:mm:ss") | |||
}}</view> | |||
</view> | |||
<view class="getCoin"> 金币+2 </view> | |||
<view class="getCoin"> +{{ item.goldNum }}金币 </view> | |||
</view> | |||
</scroll-view> | |||
<view class="inviteBtn">继续邀请好友</view> | |||
<button open-type="share" class="inviteBtn">继续邀请好友</button> | |||
</view> | |||
<!-- 显示消费列表内容 --> | |||
<view | |||
@@ -296,7 +302,7 @@ function goCloseStyle() { | |||
const tabList = ref([ | |||
{ name: "我的写真", id: 1 }, | |||
// { name: "我的视频", id: 2 }, | |||
// { name: "我的邀请", id: 3 }, | |||
{ name: "我的邀请", id: 3 }, | |||
{ name: "消费记录", id: 4 }, | |||
]); | |||
const showListActive = ref(1); | |||
@@ -404,7 +410,7 @@ function getSymbol(type) { | |||
} | |||
//#endregion 获取图片,金币, | |||
//#region 获取消费记录 | |||
//#region 获取邀请记录 | |||
const pageSize3 = ref(20); | |||
const pageNum3 = ref(1); | |||
const InviteList = ref(20); | |||
@@ -416,11 +422,11 @@ async function getInviteList(pageSize, pageNum) { | |||
} | |||
/** | |||
* @description:触底加载更多消费记录 | |||
* @description:触底加载更多邀请记录 | |||
*/ | |||
async function getMoreInviteList() { | |||
try { | |||
pageNum2.value += 1; | |||
pageNum3.value += 1; | |||
const res = await getInviteListApi(pageSize3.value, pageNum3.value); | |||
if (res.data && res.data.list && res.data.list.length == 0) { | |||
pageNum3.value -= 1; | |||
@@ -825,6 +831,7 @@ onShareAppMessage((res) => { | |||
line-height: 100rpx; | |||
text-align: center; | |||
font-size: 30rpx; | |||
color: #fff; | |||
background-color: rgba(255, 79, 0, 1); | |||
border-radius: 50rpx; | |||
} | |||
@@ -910,11 +917,23 @@ onShareAppMessage((res) => { | |||
padding: 0 50rpx; | |||
height: 65rpx; | |||
line-height: 65rpx; | |||
text-align: center; | |||
.name, | |||
.coin { | |||
width: 25%; | |||
font-weight: 900; | |||
white-space: nowrap; | |||
overflow: hidden; | |||
text-overflow: ellipsis; | |||
} | |||
.name { | |||
text-align: start; | |||
} | |||
.coin { | |||
text-align: end; | |||
} | |||
.time { | |||
flex: 1; | |||
font-weight: 100; | |||
} | |||
} | |||
@@ -152,6 +152,7 @@ | |||
//#region 导入 | |||
import { ref, reactive, computed } from "vue"; | |||
import { onLoad } from "@dcloudio/uni-app"; | |||
import { findImageApi, findGlodApi } from "../../api/home"; | |||
import { | |||
loginApi, | |||
loginPhoneApi, | |||
@@ -481,6 +482,10 @@ onLoad((options) => { | |||
icon: "none", | |||
}); | |||
} | |||
// 已有token时直接登录 | |||
if (uni.getStorageSync("token")) { | |||
uni.switchTab({ url: "/pages/uploadPhoto/uploadPhoto" }); | |||
} | |||
if (userInfoModulesPinia.platForm == 2) { | |||
uni.login({ | |||
@@ -500,20 +505,26 @@ onLoad((options) => { | |||
userInfoModulesPinia.openId = res2.data.openId; | |||
if (res2.data.token) { | |||
userInfoModulesPinia.token = res2.data.token; | |||
// uni.setStorageSync("token", userInfoModulesPinia.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; | |||
// } | |||
const res3 = await findImageApi(); | |||
if (res3.data) { | |||
uni.setStorageSync("userId", res3.data.id); | |||
} | |||
userInfoModulesPinia.myAvatar = | |||
res3.data && res3.data.image ? res3.data.image : ""; | |||
const res4 = await findGlodApi(); | |||
if (res4.data) { | |||
uni.setStorageSync("userId", res4.data.id); | |||
} | |||
if (!res4.data) { | |||
userInfoModulesPinia.myGlod = 0; | |||
} else { | |||
userInfoModulesPinia.myGlod = res4.data.digitalAvatarResidueGlod | |||
? res4.data.digitalAvatarResidueGlod | |||
: 0; | |||
} | |||
uni.hideLoading(); | |||
if (res2.data.token) { | |||
getPrivacySetting(1); | |||
@@ -20,7 +20,18 @@ | |||
mode="aspectFit" | |||
/> | |||
<view v-if="createState == 2" class="checkMore">左右滑动查看更多</view> | |||
<view v-if="createState != 2" class="wait">生成中,请稍后...</view> | |||
<view | |||
v-if="createState != 2 && userInfoModulesPinia.platForm == 2" | |||
class="wait" | |||
>生成中,请稍后...</view | |||
> | |||
<view | |||
@click="subscribe" | |||
v-if="createState != 2" | |||
style="text-decoration: underline; color: #ff4f00" | |||
class="wait" | |||
>做好后通知我</view | |||
> | |||
<!-- <view class="uploadBtn grayBtn"> | |||
<text>我要让照片说话</text> | |||
<view class="free"> | |||
@@ -40,7 +51,7 @@ | |||
<!-- 底部 --> | |||
<view class="bottomBox"> | |||
<view v-if="createState == 2" class="tips"> | |||
<text>邀请好友可获得2枚金币</text> | |||
<text>邀请好友可获得{{ loginAwardCoin }}枚金币</text> | |||
</view> | |||
<button open-type="share" class="shareBtn">分享</button> | |||
<view v-if="createState == 2" class="shareBtn" @click="getUserQrcode" | |||
@@ -66,6 +77,7 @@ import { | |||
onShareTimeline, | |||
} from "@dcloudio/uni-app"; | |||
import { BASE_URL } from "../../utils/request"; | |||
import { findGlodApi } from "../../api/home"; | |||
import { ref, reactive, watch } from "vue"; | |||
import { userInfoModules } from "@/store/modules/userInfo"; | |||
import { | |||
@@ -73,16 +85,28 @@ import { | |||
photoSupperApi, | |||
getSupperPhotoStateApi, | |||
getUserQrcodeApi, | |||
getTemplateMsgApi, | |||
} from "../../api/lookPhoto.js"; | |||
//#endregion | |||
const userInfoModulesPinia = userInfoModules(); | |||
//#region 轮播图 | |||
const createState = ref(null); //制作状态:1生成中,2完成,3失败 | |||
const createState = ref(1); //制作状态:1生成中,2完成,3失败 | |||
const workId = ref(null); //作品id | |||
const loginAwardCoin = uni.getStorageSync("loginAwardCoin"); | |||
onLoad(async (options) => { | |||
workId.value = options.id; | |||
await getTemplateMsg(); | |||
await getSwiperList(); | |||
await getSupperPhotoState(swiperList.value[0].id); | |||
// 重新获取金币 | |||
const res4 = await findGlodApi(); | |||
if (!res4.data) { | |||
userInfoModulesPinia.myGlod = 0; | |||
} else { | |||
userInfoModulesPinia.myGlod = res4.data.digitalAvatarResidueGlod | |||
? res4.data.digitalAvatarResidueGlod | |||
: 0; | |||
} | |||
}); | |||
onHide(() => { | |||
clearTimeout(timer); | |||
@@ -107,7 +131,7 @@ async function getSwiperList() { | |||
}); | |||
} | |||
if (createState.value != 2) { | |||
if (res.data.status != 2) { | |||
timer.value = setTimeout(() => { | |||
getSwiperList(); | |||
}, 3000); | |||
@@ -405,6 +429,77 @@ async function getUserQrcode() { | |||
//#endregion --------------------- | |||
//#region 订阅消息 | |||
const templateId = ref([]); | |||
async function getTemplateMsg() { | |||
try { | |||
const res = await getTemplateMsgApi(); | |||
if (res.data) { | |||
res.data.forEach((item) => { | |||
templateId.value.push(item.templateId); | |||
}); | |||
} | |||
} catch (error) { | |||
console.log("获取订阅消息模版失败", error); | |||
} | |||
} | |||
function subscribe() { | |||
uni.requestSubscribeMessage({ | |||
//此处填写刚才申请模板的模板ID | |||
tmplIds: templateId.value, | |||
success(res) { | |||
console.log(res); | |||
let failFlag = true; | |||
templateId.value.forEach((item) => { | |||
if (res[item] == "accept") { | |||
uni.showToast({ | |||
title: "订阅成功", | |||
icon: "success", | |||
}); | |||
failFlag = false; | |||
} | |||
}); | |||
if (failFlag) { | |||
// uni.showToast({ | |||
// duration: 5000, | |||
// title: "订阅失败 ,您可以在小程序设置->通知管理 \n 中重新启用订阅功能", | |||
// icon: "none", | |||
// }); | |||
uni.showModal({ | |||
title: "提示", | |||
content: | |||
"订阅失败 ,您可以在 \n 小程序设置->通知管理 \n 中重新启用订阅功能", | |||
confirmText: "确定", | |||
showCancel: false, | |||
}); | |||
} | |||
// if (res[templateId[0]] == "accept") { | |||
// uni.showToast({ | |||
// title: "订阅成功", | |||
// icon: "success", | |||
// }); | |||
// // 用户允许订阅 | |||
// } else { | |||
// uni.showToast({ | |||
// title: "订阅失败", | |||
// icon: "none", | |||
// }); | |||
// // 用户拒绝订阅 | |||
// } | |||
}, | |||
fail(err) { | |||
console.error("订阅消息失败", err); | |||
uni.showToast({ | |||
title: "订阅失败", | |||
icon: "none", | |||
}); | |||
}, | |||
}); | |||
} | |||
//#endregion --------------------- | |||
//#region | |||
//#endregion --------------------- | |||
@@ -47,10 +47,10 @@ | |||
<view class="grayBtn" v-if="uploadState == 4" @click="chooseImage" | |||
>重新上传</view | |||
> | |||
<!-- <view class="free" v-if="false"> | |||
<view class="free" v-if="countNum == 0"> | |||
<image src="../../assets/icon/blackBG.png" mode="aspectFit" /> | |||
<text>新用户免费制作</text> | |||
</view> --> | |||
</view> | |||
</view> | |||
<!-- 底部盒子 --> | |||
<view class="bottomBox"> | |||
@@ -97,10 +97,15 @@ import { ref, reactive, nextTick } from "vue"; | |||
import { BASE_URL } from "../../utils/request"; | |||
import { onLoad, onShow } from "@dcloudio/uni-app"; | |||
import { loginApi } from "../../api/login"; | |||
import { addImageApi } from "../../api/uploadphoto.js"; | |||
import { | |||
addImageApi, | |||
getProjectConfigApi, | |||
getCountApi, | |||
} from "../../api/uploadphoto.js"; | |||
import { userInfoModules } from "@/store/modules/userInfo"; | |||
import imageCompression from "browser-image-compression"; //压缩图片插件 | |||
import { findImageApi, findGlodApi } from "../../api/home"; | |||
//#endregion | |||
const userInfoModulesPinia = userInfoModules(); | |||
@@ -348,11 +353,13 @@ onLoad((options) => { | |||
userInfoModulesPinia.openId = res2.data.openId; | |||
if (res2.data.token) { | |||
userInfoModulesPinia.token = res2.data.token; | |||
// uni.setStorageSync("token", userInfoModulesPinia.token); | |||
uni.setStorageSync("token", userInfoModulesPinia.token); | |||
console.log(userInfoModulesPinia.openId, "获取openid"); | |||
// 获取头像和金币 | |||
const res3 = await findImageApi(); | |||
if (res3.data) { | |||
uni.setStorageSync("userId", res3.data.id); | |||
} | |||
userInfoModulesPinia.myAvatar = | |||
res3.data && res3.data.image ? res3.data.image : ""; | |||
const res4 = await findGlodApi(); | |||
@@ -366,6 +373,7 @@ onLoad((options) => { | |||
? res4.data.digitalAvatarResidueGlod | |||
: 0; | |||
} | |||
uni.hideLoading(); | |||
if (res2.data.token) { | |||
// uni.redirectTo({ | |||
@@ -487,6 +495,7 @@ onLoad((options) => { | |||
}, | |||
}); | |||
} | |||
// 如果是从相机页返回 | |||
}); | |||
onShow(() => { | |||
@@ -502,6 +511,7 @@ onShow(() => { | |||
toCloseStyle(); | |||
uni.removeStorageSync("action"); | |||
} | |||
getCount(); | |||
}); | |||
//#endregion --------------------- | |||
@@ -527,6 +537,45 @@ function takePhoto() { | |||
} | |||
//#endregion --------------------- | |||
//#region 获取邀请 注册等奖励金币数量 | |||
async function getProjectConfig() { | |||
const data1 = { | |||
projectType: 5, | |||
type: 1, | |||
}; | |||
const data2 = { | |||
projectType: 5, | |||
type: 2, | |||
}; | |||
try { | |||
const res1 = await getProjectConfigApi(data1); | |||
uni.setStorageSync("loginAwardCoin", res1.data.glodNum); | |||
const res2 = await getProjectConfigApi(data2); | |||
uni.setStorageSync("inviteAwardCoin", res2.data.glodNum); | |||
} catch (error) { | |||
console.log("获取邀请 注册等奖励金币数量失败", error); | |||
} | |||
} | |||
getProjectConfig(); | |||
//#endregion --------------------- | |||
//#region 是否首次生成 | |||
const countNum = ref(0); | |||
async function getCount() { | |||
try { | |||
const res = await getCountApi(); | |||
if (res.data) { | |||
countNum.value = res.data; | |||
} else { | |||
countNum.value = 0; | |||
} | |||
} catch (error) { | |||
console.log("是否首次生成", error); | |||
} | |||
} | |||
//#endregion --------------------- | |||
//#region | |||
//#endregion --------------------- | |||
@@ -15,10 +15,12 @@ const request = (requestObj) => { | |||
data: requestObj.data, | |||
header: { | |||
// Authorization: userInfoModulesPinia.token, | |||
token: userInfoModulesPinia.token, | |||
// token: userInfoModulesPinia.token, | |||
token: uni.getStorageSync("token"), | |||
}, | |||
success: (res) => { | |||
if (res.data.code == 1052) { | |||
uni.setStorageSync("token", null) | |||
uni.reLaunch({ | |||
url: "/pages/login/index?type=tokenFfalse", | |||
}); | |||