@@ -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,4 +1,4 @@ | |||
import request from "../utils/request" | |||
import { request } from "../utils/request" | |||
export function voiceTotalApi() { | |||
return request({ | |||
@@ -22,4 +22,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: { | |||
@@ -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" | |||
@@ -59,6 +82,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> | |||
@@ -66,7 +128,12 @@ | |||
//#region 导入 | |||
import { ref, reactive, computed } from "vue"; | |||
import { onLoad } from "@dcloudio/uni-app"; | |||
import { voiceTotalApi, loginPhoneApi } from "../../api/login.js"; | |||
import { | |||
voiceTotalApi, | |||
loginPhoneApi, | |||
getCodeApi, | |||
loginByCodeApi, | |||
} from "../../api/login.js"; | |||
import { userInfoModules } from "@/store/modules/userInfo"; | |||
//#endregion | |||
const userInfoModulesPinia = userInfoModules(); | |||
@@ -89,12 +156,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, | |||
@@ -112,7 +180,7 @@ async function getphonenumber(e) { | |||
} catch (error) { | |||
uni.showToast({ | |||
icon: "none", | |||
title: "获取失败", | |||
title: "获取手机号失败", | |||
}); | |||
} | |||
} else { | |||
@@ -128,7 +196,7 @@ async function toCreate(e) { | |||
console.log(); | |||
if (checkboxValue.value[0]) { | |||
// await handleLogin(); | |||
await getphonenumber(e); | |||
await dogetphonenumber(e); | |||
} else { | |||
uni.showModal({ | |||
title: "提示", | |||
@@ -137,7 +205,7 @@ async function toCreate(e) { | |||
if (res.confirm) { | |||
checkboxValue.value = ["同意智像相机用户使用协议"]; | |||
// handleLogin(); | |||
getphonenumber(e); | |||
dogetphonenumber(e); | |||
} else if (res.cancel) { | |||
} | |||
}, | |||
@@ -194,6 +262,120 @@ 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(); | |||
@@ -265,4 +447,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> |
@@ -255,7 +255,7 @@ async function photoSupper() { | |||
console.log(res); | |||
uni.hideLoading(); | |||
uni.showToast({ | |||
title: "高清处理请求成功,请重稍后", | |||
title: "高清处理请求成功,请稍后", | |||
icon: "none", | |||
}); | |||
@@ -87,6 +87,7 @@ | |||
//#region 导入 | |||
import { ref, reactive, nextTick } from "vue"; | |||
import { onLoad, onShow } from "@dcloudio/uni-app"; | |||
import { BASE_URL } from "@/utils/request"; | |||
import { loginApi } from "../../api/login"; | |||
import { addImageApi } from "../../api/uploadphoto.js"; | |||
import { userInfoModules } from "@/store/modules/userInfo"; | |||
@@ -103,7 +104,6 @@ const showImgData = ref(null); //上传数据 | |||
// 点击上传图片 | |||
function chooseImage() { | |||
console.log("chooseImage"); | |||
// 检查token | |||
if (!userInfoModulesPinia.token) { | |||
uni.showModal({ | |||
@@ -201,7 +201,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: { | |||
@@ -219,7 +219,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: { | |||
@@ -237,7 +237,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: { | |||
@@ -321,22 +321,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); | |||
@@ -407,7 +406,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 } |