@@ -2,7 +2,7 @@ | |||
"appid": "wx75cf14e3a0d45821", | |||
wx-"appid": "wx75cf14e3a0d45821", | |||
git commit -m "feat: " | |||
git commit --no-verify -m "提交时的注释" 跳过检验 |
@@ -1,4 +1,4 @@ | |||
import request from "../utils/request" | |||
import { request } from "../utils/request" | |||
// 获取风格列表 | |||
export function getListApi(pageNum, pageSize) { | |||
@@ -1,4 +1,4 @@ | |||
import request from "../utils/request" | |||
import { request } from "../utils/request" | |||
/** | |||
* @description:获取金币价格列表 | |||
@@ -1,4 +1,4 @@ | |||
import request from "../utils/request" | |||
import { request } from "../utils/request" | |||
// 获取风格列表 | |||
export function findWorkByIdApi(id) { | |||
@@ -1,4 +1,4 @@ | |||
import request from "../utils/request" | |||
import { request } from "../utils/request" | |||
/** | |||
* @description:获取用户头像 | |||
@@ -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) { | |||
return request({ | |||
@@ -22,4 +17,26 @@ export function loginPhoneApi(data) { | |||
method: 'POST', | |||
data | |||
}) | |||
} | |||
// 获取短信验证码 | |||
export function getCodeApi(phone) { | |||
return request({ | |||
url: `api/user/sendLoginPhoneCode?phone=${phone}`, | |||
method: 'get', | |||
}) | |||
} | |||
/** | |||
* @description:短信登录 | |||
* @param {*} (appId, openId,phone,code) | |||
* @return: list | |||
*/ | |||
export function loginByCodeApi(data) { | |||
return request({ | |||
url: `api/miniApp/loginPhoneCode`, | |||
method: 'POST', | |||
data | |||
}) | |||
} |
@@ -1,4 +1,4 @@ | |||
import request from "../utils/request" | |||
import { request } from "../utils/request" | |||
/** | |||
@@ -1,4 +1,4 @@ | |||
import request from "../utils/request" | |||
import { request } from "../utils/request" | |||
// /api/baidu/checkPhoto | |||
// /api/userDigital/checkPhoto | |||
@@ -80,7 +80,8 @@ | |||
"usingComponents": true | |||
}, | |||
"mp-toutiao": { | |||
"usingComponents": true | |||
"usingComponents": true, | |||
"appid": "tt2eba5807b1883f9f01" | |||
}, | |||
"uniStatistics": { | |||
"enable": false | |||
@@ -106,6 +106,7 @@ | |||
//#region 导入 | |||
import { ref, reactive } from "vue"; | |||
import { onLoad } from "@dcloudio/uni-app"; | |||
import { BASE_URL } from "@/utils/request"; | |||
import { | |||
findByIdApi, | |||
findImageApi, | |||
@@ -194,7 +195,7 @@ function chooseImg(index) { | |||
}); | |||
// 百度敏感信息检测 | |||
uni.uploadFile({ | |||
url: "https://test.metavatar.cc/C/api/baidu/checkPhoto", //上传图片api | |||
url: BASE_URL + "api/baidu/checkPhoto", //上传图片api | |||
filePath: res.tempFilePaths[0], | |||
name: "file", | |||
formData: { | |||
@@ -215,7 +216,7 @@ function chooseImg(index) { | |||
} else { | |||
// 人脸识别接口 | |||
uni.uploadFile({ | |||
url: "https://test.metavatar.cc/C/api/userDigital/checkPhoto", //上传图片api | |||
url: BASE_URL + "api/userDigital/checkPhoto", //上传图片api | |||
filePath: res.tempFilePaths[0], | |||
name: "file", | |||
formData: { | |||
@@ -236,7 +237,7 @@ function chooseImg(index) { | |||
} else { | |||
// 上传接口 | |||
uni.uploadFile({ | |||
url: "https://test.metavatar.cc/C/api/upload/awsImgUpload", //上传图片api | |||
url: BASE_URL + "api/upload/awsImgUpload", //上传图片api | |||
filePath: res.tempFilePaths[0], | |||
name: "file", | |||
formData: { | |||
@@ -129,9 +129,14 @@ function inviteFriend() { | |||
//#region 页面跳转 | |||
function bueCoin() { | |||
uni.navigateTo({ | |||
url: "/pages/home/buyCoin", | |||
uni.showToast({ | |||
title: "暂未开放", | |||
icon: "none", | |||
mask: true, | |||
}); | |||
// uni.navigateTo({ | |||
// url: "/pages/home/buyCoin", | |||
// }); | |||
} | |||
//#endregion --------------------- | |||
@@ -30,9 +30,7 @@ | |||
<view class="coinBox" v-if="userInfoModulesPinia.token"> | |||
我的金币: {{ userInfoModulesPinia.myGlod }} | |||
<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" | |||
>登录即可体验更多功能哦! | |||
@@ -70,9 +68,7 @@ | |||
v-for="item in PhotoList" | |||
:key="item.id" | |||
class="showListItem" | |||
@click=" | |||
goOtherPage(`/pages/lookPhoto/index?id=${item.id}`, item.status) | |||
" | |||
@click="goLookPhoto(item.id, item.status)" | |||
> | |||
<view class="top"> | |||
<text class="name">{{ item.title }}</text> | |||
@@ -116,11 +112,7 @@ | |||
<!-- 空处理 --> | |||
<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> | |||
</scroll-view> | |||
<!-- 显示视频列表内容 --> | |||
@@ -252,47 +244,22 @@ function chooseAvatar() { | |||
url: "/pages/uploadPhoto/uploadPhoto", | |||
}); | |||
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) { | |||
uni.showToast({ | |||
title: "正在生成,请稍后", | |||
@@ -301,9 +268,16 @@ function goOtherPage(url, status) { | |||
return; | |||
} | |||
uni.navigateTo({ | |||
url: url, | |||
url: `/pages/lookPhoto/index?id=${id}`, | |||
}); | |||
} | |||
function goCloseStyle() { | |||
uni.navigateTo({ | |||
url: `/pages/closeStyle/closeStyle`, | |||
}); | |||
} | |||
//#endregion | |||
//#region tab | |||
@@ -20,7 +20,7 @@ | |||
</view> | |||
<view class="bottomBox"> | |||
<button | |||
v-if="!checkboxValue[0]" | |||
v-if="!checkboxValue[0] && userInfoModulesPinia.platForm == 2" | |||
class="bottomBtn" | |||
type="default" | |||
id="getPhoneNumber" | |||
@@ -29,7 +29,7 @@ | |||
开始制作我的数字写真 | |||
</button> | |||
<button | |||
v-if="checkboxValue[0]" | |||
v-if="checkboxValue[0] && userInfoModulesPinia.platForm == 2" | |||
class="bottomBtn" | |||
open-type="getPhoneNumber" | |||
type="default" | |||
@@ -38,8 +38,31 @@ | |||
> | |||
开始制作我的数字写真 | |||
</button> | |||
<!-- 抖音获取手机号 --> | |||
<!-- <button | |||
v-if="userInfoModulesPinia.platForm == 3" | |||
class="bottomBtn" | |||
open-type="getPhoneNumber" | |||
type="default" | |||
id="getPhoneNumber" | |||
@getphonenumber="dogetphonenumber" | |||
> | |||
开始制作我的数字分身 | |||
</button> --> | |||
<!-- 手机号登录 --> | |||
<button | |||
v-if="userInfoModulesPinia.platForm == 3" | |||
class="bottomBtn" | |||
type="default" | |||
id="getPhoneNumber" | |||
@click="phoneLogin" | |||
> | |||
开始制作我的数字分身 | |||
</button> | |||
<!-- <view class="bottomBtn" @click="toCreate"> 开始制作我的数字写真 </view> --> | |||
<!-- 同意协议 --> | |||
<u-checkbox-group | |||
v-if="userInfoModulesPinia.platForm == 2" | |||
v-model="checkboxValue" | |||
placement="row" | |||
@change="changedCheckbox" | |||
@@ -57,6 +80,45 @@ | |||
</text> | |||
</u-checkbox-group> | |||
</view> | |||
<!-- 手机号验证码登录 --> | |||
<view class="phoneLoginForm" v-show="userInfoModulesPinia.platForm == 3"> | |||
<u--form | |||
labelPosition="left" | |||
:model="formData" | |||
:rules="rules" | |||
ref="formRef" | |||
> | |||
<u-form-item | |||
labelWidth="80" | |||
label="手机号" | |||
prop="phoneNum" | |||
borderBottom | |||
ref="form1" | |||
> | |||
<u--input | |||
type="number" | |||
v-model="formData.phoneNum" | |||
border="none" | |||
></u--input> | |||
</u-form-item> | |||
<!-- 获取验证码 --> | |||
<!-- 验证码 --> | |||
<view class="getCodeBtn" @click="getCode"> | |||
{{ backwardsNum < 60 ? backwardsNum : "发送验证码" }} | |||
</view> | |||
<!-- <view v-if="backwardsNums <= 0" class="getCodeBtn">{{ | |||
backwardsNum | |||
}}</view> --> | |||
<u-form-item labelWidth="80" label="验证码 " borderBottom ref="form2"> | |||
<u--input | |||
type="number" | |||
v-model="formData.codeNum" | |||
border="none" | |||
></u--input> | |||
</u-form-item> | |||
</u--form> | |||
<view class="loginBtn" @click="loginByCode">登录</view> | |||
</view> | |||
</view> | |||
</template> | |||
@@ -64,11 +126,16 @@ | |||
//#region 导入 | |||
import { ref, reactive, computed } from "vue"; | |||
import { onLoad } from "@dcloudio/uni-app"; | |||
import { voiceTotalApi, loginPhoneApi } from "../../api/login.js"; | |||
import { | |||
loginApi, | |||
loginPhoneApi, | |||
getCodeApi, | |||
loginByCodeApi, | |||
} from "../../api/login.js"; | |||
import { userInfoModules } from "@/store/modules/userInfo"; | |||
//#endregion | |||
const userInfoModulesPinia = userInfoModules(); | |||
console.log(userInfoModulesPinia.platForm); | |||
const pageClass = computed(() => { | |||
if (userInfoModulesPinia.platForm == 1) { | |||
return "page pageH5"; | |||
@@ -87,12 +154,13 @@ function changedCheckbox(e) { | |||
console.log(e); | |||
} | |||
async function getphonenumber(e) { | |||
console.log(e); | |||
async function dogetphonenumber(e) { | |||
console.log(e, "e"); | |||
if (e.detail.errMsg.includes("ok")) { | |||
// if (e.detail.errMsg.includes("fail")) { | |||
//用户授权了手机号 | |||
const data = { | |||
appId: "wx75cf14e3a0d45821", | |||
appId: userInfoModulesPinia.getAppId(), | |||
openId: userInfoModulesPinia.openId, | |||
encryptedData: e.detail.encryptedData, | |||
iv: e.detail.iv, | |||
@@ -110,7 +178,7 @@ async function getphonenumber(e) { | |||
} catch (error) { | |||
uni.showToast({ | |||
icon: "none", | |||
title: "获取失败", | |||
title: "获取手机号失败", | |||
}); | |||
} | |||
} else { | |||
@@ -126,7 +194,7 @@ async function toCreate(e) { | |||
console.log(); | |||
if (checkboxValue.value[0]) { | |||
// await handleLogin(); | |||
await getphonenumber(e); | |||
await dogetphonenumber(e); | |||
} else { | |||
uni.showModal({ | |||
title: "提示", | |||
@@ -135,7 +203,7 @@ async function toCreate(e) { | |||
if (res.confirm) { | |||
checkboxValue.value = ["同意智像相机用户使用协议"]; | |||
// handleLogin(); | |||
getphonenumber(e); | |||
dogetphonenumber(e); | |||
} else if (res.cancel) { | |||
} | |||
}, | |||
@@ -192,23 +260,279 @@ const goPro = () => { | |||
}; | |||
//#endregion --------------------- | |||
//#region 手机号登录 | |||
const formData = ref({ | |||
phoneNum: null, | |||
codeNum: null, | |||
}); | |||
const rules = { | |||
phoneNum: [ | |||
{ | |||
required: true, | |||
message: "请填写手机号", | |||
trigger: ["blur"], | |||
}, | |||
{ | |||
// 自定义验证函数,见上说明 | |||
validator: (rule, value, callback) => { | |||
// 上面有说,返回true表示校验通过,返回false表示不通过 | |||
// uni.$u.test.mobile()就是返回true或者false的 | |||
return uni.$u.test.mobile(value); | |||
}, | |||
message: "手机号码不正确", | |||
// 触发器可以同时用blur和change | |||
trigger: ["blur"], | |||
}, | |||
], | |||
}; | |||
const formRef = ref(null); | |||
const form1 = ref(null); | |||
const backwardsNum = ref(60); | |||
const countdownTimer = ref(null); // 倒计时的计时器 | |||
const timerFlag = ref(false); | |||
function getCode() { | |||
if (timerFlag.value) { | |||
return; // 如果倒计时尚未结束,不执行倒计时操作 | |||
} | |||
timerFlag.value = true; | |||
formRef.value | |||
.validate() | |||
.then(async (res) => { | |||
try { | |||
uni.showLoading({ | |||
title: "请稍后", | |||
mask: true, | |||
}); | |||
const res = await getCodeApi(formData.value.phoneNum); | |||
uni.hideLoading(); | |||
if (res.code != 200) { | |||
uni.showToast({ | |||
title: res.message, | |||
icon: "none", | |||
}); | |||
} | |||
console.log(res); | |||
// 表单验证通过后开始倒计时 | |||
countdownTimer.value = setInterval(() => { | |||
if (backwardsNum.value > 0) { | |||
backwardsNum.value--; | |||
console.log(backwardsNum.value); | |||
} else { | |||
clearInterval(countdownTimer.value); | |||
countdownTimer.value = null; | |||
backwardsNum.value = 60; | |||
timerFlag.value = false; | |||
} | |||
}, 1000); | |||
} catch (error) { | |||
uni.hideLoading(); | |||
uni.$u.toast("短信验证码获取失败"); | |||
clearInterval(countdownTimer.value); | |||
countdownTimer.value = null; | |||
backwardsNum.value = 5; | |||
timerFlag.value = false; | |||
} | |||
}) | |||
.catch((errors) => { | |||
console.log(errors); | |||
}); | |||
} | |||
async function loginByCode() { | |||
uni.showLoading({ | |||
title: "请稍后", | |||
mask: true, | |||
}); | |||
const data = { | |||
appId: userInfoModulesPinia.getAppId(), | |||
openId: userInfoModulesPinia.openId, | |||
phone: formData.value.phoneNum, | |||
code: formData.value.codeNum, | |||
}; | |||
try { | |||
const res = await loginByCodeApi(data); | |||
console.log(res); | |||
uni.hideLoading(); | |||
userInfoModulesPinia.token = res.data.token; | |||
if (res.code != 200) { | |||
uni.showToast({ | |||
title: res.message, | |||
icon: "none", | |||
}); | |||
} else { | |||
uni.redirectTo({ | |||
url: "/pages/uploadPhoto/uploadPhoto", | |||
}); | |||
} | |||
} catch (error) { | |||
uni.hideLoading(); | |||
uni.showToast({ | |||
title: "登录失败,请重试", | |||
icon: "none", | |||
}); | |||
} | |||
} | |||
//#endregion --------------------- | |||
//#region | |||
onLoad((options) => { | |||
uni.hideHomeButton(); | |||
// workId.value = options.id; | |||
if (options.type == "tokenFfalse") { | |||
uni.showToast({ | |||
title: "登录失效,请重新登录", | |||
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 --------------------------------- | |||
//#region | |||
//#endregion --------------------------------- | |||
// voiceTotalApi(); | |||
</script> | |||
<style lang="scss"> | |||
@@ -263,4 +587,30 @@ onLoad((options) => { | |||
} | |||
} | |||
} | |||
.phoneLoginForm { | |||
position: absolute; | |||
top: 20%; | |||
left: 30rpx; | |||
width: 690rpx; | |||
z-index: 9; | |||
background-color: #fff; | |||
padding: 30rpx; | |||
.u-code { | |||
width: 100%; | |||
height: 50rpx; | |||
background-color: green; | |||
color: #ff4f00; | |||
} | |||
.getCodeBtn { | |||
background-color: green; | |||
text-align: center; | |||
line-height: 50rpx; | |||
} | |||
.loginBtn { | |||
background-color: #ff4f00; | |||
text-align: center; | |||
line-height: 50rpx; | |||
} | |||
} | |||
</style> |
@@ -219,9 +219,14 @@ function inviteFriend() { | |||
//#region 页面跳转 | |||
function buyCoin() { | |||
uni.navigateTo({ | |||
url: "/pages/index/buyCoin", | |||
uni.showToast({ | |||
title: "暂未开放", | |||
icon: "none", | |||
mask: true, | |||
}); | |||
// uni.navigateTo({ | |||
// url: "/pages/index/buyCoin", | |||
// }); | |||
} | |||
//#endregion --------------------- | |||
@@ -255,6 +260,7 @@ async function photoSupper() { | |||
console.log(res); | |||
uni.hideLoading(); | |||
uni.showToast({ | |||
title: "高清处理请求成功,请稍后", | |||
title: "高清处理请求成功,请稍等", | |||
icon: "none", | |||
}); | |||
@@ -105,9 +105,14 @@ function previewImage(index) { | |||
//#region 页面跳转 | |||
function bueCoin() { | |||
uni.navigateTo({ | |||
url: "/pages/home/buyCoin", | |||
uni.showToast({ | |||
title: "暂未开放", | |||
icon: "none", | |||
mask: true, | |||
}); | |||
// uni.navigateTo({ | |||
// url: "/pages/home/buyCoin", | |||
// }); | |||
} | |||
//#endregion --------------------- | |||
@@ -109,7 +109,6 @@ const showImgData = ref(null); //上传数据 | |||
// 点击上传图片 | |||
function chooseImage() { | |||
console.log("chooseImage"); | |||
// 检查token | |||
if (!userInfoModulesPinia.token) { | |||
uni.showModal({ | |||
@@ -207,7 +206,7 @@ async function toCloseStyle() { | |||
console.log(showImgUrl2.value.path); | |||
// 百度敏感信息检测 | |||
uni.uploadFile({ | |||
url: "https://test.metavatar.cc/C/api/baidu/checkPhoto", //上传图片api | |||
url: BASE_URL + "api/baidu/checkPhoto", //上传图片api | |||
filePath: showImgUrl2.value.path, | |||
name: "file", | |||
formData: { | |||
@@ -225,7 +224,7 @@ async function toCloseStyle() { | |||
} | |||
// 人脸识别接口 | |||
uni.uploadFile({ | |||
url: "https://test.metavatar.cc/C/api/userDigital/checkPhoto", //上传图片api | |||
url: BASE_URL + "api/userDigital/checkPhoto", //上传图片api | |||
filePath: showImgUrl2.value.path, | |||
name: "file", | |||
formData: { | |||
@@ -243,7 +242,7 @@ async function toCloseStyle() { | |||
} | |||
// 上传接口 | |||
uni.uploadFile({ | |||
url: "https://test.metavatar.cc/C/api/upload/awsImgUpload", //上传图片api | |||
url: BASE_URL + "api/upload/awsImgUpload", //上传图片api | |||
filePath: showImgUrl2.value.path, | |||
name: "file", | |||
formData: { | |||
@@ -327,22 +326,21 @@ async function toCloseStyle() { | |||
//#region 页面初始化 | |||
onLoad((options) => { | |||
// showImgUrl.value = userInfoModulesPinia.myAvatar; | |||
// 获取微信小程序的 AppID | |||
// const appid = uni.getAccountInfoSync().miniProgram.appId; | |||
// 微信登录授权 | |||
if (userInfoModulesPinia.platForm != 1) { | |||
if (userInfoModulesPinia.platForm == 2) { | |||
uni.login({ | |||
provider: "weixin", // 使用微信登录授权 | |||
success: async (res) => { | |||
console.log(res); | |||
if (res.code) { | |||
console.log(res.code); | |||
try { | |||
uni.showLoading({ | |||
title: "加载中...", | |||
mask: true, | |||
}); | |||
const data = { | |||
appId: "wx75cf14e3a0d45821", | |||
appId: userInfoModulesPinia.getAppId(), | |||
code: res.code, | |||
}; | |||
const res2 = await loginApi(data); | |||
@@ -413,7 +411,77 @@ onLoad((options) => { | |||
}, | |||
}); | |||
} | |||
console.log(options); | |||
// 抖音头条授权 | |||
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"); | |||
// 获取头像和金币 | |||
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(); | |||
} 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", | |||
}); | |||
}, | |||
}); | |||
} | |||
}); | |||
onShow(() => { | |||
// 若来自我的页面的更换头像按钮,直接触发以下操作 | |||
@@ -14,6 +14,8 @@ export const userInfoModules = defineStore("userInfoStore", () => { | |||
const token = ref(null) | |||
const myAvatar = ref('') | |||
const myGlod = ref(0) | |||
const wxappid = "wx75cf14e3a0d45821" | |||
const dyappid = "tt2eba5807b1883f9f01" | |||
/** | |||
* @description:依托平台:(web、mp-weixin、mp-toutiao) | |||
* @example 平台名:"web-H5",枚举值:1 | |||
@@ -40,7 +42,14 @@ export const userInfoModules = defineStore("userInfoStore", () => { | |||
// async function getMyGlod(params) { | |||
// } | |||
return { userInfo, openId, token, myAvatar, myGlod, platForm, hostSystem }; | |||
function getAppId() { | |||
if (platForm.value == 2) { | |||
return wxappid | |||
} else if (platForm.value == 3) { | |||
return dyappid | |||
} | |||
} | |||
return { userInfo, openId, token, myAvatar, myGlod, platForm, hostSystem, wxappid, dyappid, getAppId }; | |||
}, | |||
{ | |||
@@ -45,4 +45,4 @@ const request = (requestObj) => { | |||
}) | |||
}) | |||
}; | |||
export default request | |||
export { BASE_URL, request } |