diff --git a/README.md b/README.md
index 1e3a9ca..b9c19e8 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
-"appid": "wx75cf14e3a0d45821",
+wx-"appid": "wx75cf14e3a0d45821",
git commit -m "feat: "
git commit --no-verify -m "提交时的注释" 跳过检验
diff --git a/src/api/closeStyle.js b/src/api/closeStyle.js
index 5bad618..c2101ea 100644
--- a/src/api/closeStyle.js
+++ b/src/api/closeStyle.js
@@ -1,4 +1,4 @@
-import request from "../utils/request"
+import { request } from "../utils/request"
// 获取风格列表
export function getListApi(pageNum, pageSize) {
diff --git a/src/api/coin.js b/src/api/coin.js
index 2cec1eb..ebe9d6b 100644
--- a/src/api/coin.js
+++ b/src/api/coin.js
@@ -1,4 +1,4 @@
-import request from "../utils/request"
+import { request } from "../utils/request"
/**
* @description:获取金币价格列表
diff --git a/src/api/createing.js b/src/api/createing.js
index dd736c8..e706c3d 100644
--- a/src/api/createing.js
+++ b/src/api/createing.js
@@ -1,4 +1,4 @@
-import request from "../utils/request"
+import { request } from "../utils/request"
// 获取风格列表
export function findWorkByIdApi(id) {
diff --git a/src/api/home.js b/src/api/home.js
index bef45f6..db87b83 100644
--- a/src/api/home.js
+++ b/src/api/home.js
@@ -1,4 +1,4 @@
-import request from "../utils/request"
+import { request } from "../utils/request"
/**
* @description:获取用户头像
diff --git a/src/api/login.js b/src/api/login.js
index 9e241ca..d8acf3f 100644
--- a/src/api/login.js
+++ b/src/api/login.js
@@ -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
+ })
}
\ No newline at end of file
diff --git a/src/api/lookPhoto.js b/src/api/lookPhoto.js
index a41a8ac..7a07bdc 100644
--- a/src/api/lookPhoto.js
+++ b/src/api/lookPhoto.js
@@ -1,4 +1,4 @@
-import request from "../utils/request"
+import { request } from "../utils/request"
/**
diff --git a/src/api/uploadphoto.js b/src/api/uploadphoto.js
index c0ada9f..7006a54 100644
--- a/src/api/uploadphoto.js
+++ b/src/api/uploadphoto.js
@@ -1,4 +1,4 @@
-import request from "../utils/request"
+import { request } from "../utils/request"
// /api/baidu/checkPhoto
// /api/userDigital/checkPhoto
diff --git a/src/manifest.json b/src/manifest.json
index d3d1d0c..d8babf8 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -80,7 +80,8 @@
"usingComponents": true
},
"mp-toutiao": {
- "usingComponents": true
+ "usingComponents": true,
+ "appid": "tt2eba5807b1883f9f01"
},
"uniStatistics": {
"enable": false
diff --git a/src/pages/closeStyle/multiplayer.vue b/src/pages/closeStyle/multiplayer.vue
index 207cbd3..bf54483 100644
--- a/src/pages/closeStyle/multiplayer.vue
+++ b/src/pages/closeStyle/multiplayer.vue
@@ -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: {
diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue
index b734ffa..18b950c 100644
--- a/src/pages/login/index.vue
+++ b/src/pages/login/index.vue
@@ -20,7 +20,7 @@
+
+
+
+
+
+
+
+
+
+ {{ backwardsNum < 60 ? backwardsNum : "发送验证码" }}
+
+
+
+
+
+
+ 登录
+
@@ -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;
+ }
+}
diff --git a/src/pages/lookPhoto/index.vue b/src/pages/lookPhoto/index.vue
index 5c03082..fecb9ac 100644
--- a/src/pages/lookPhoto/index.vue
+++ b/src/pages/lookPhoto/index.vue
@@ -255,7 +255,7 @@ async function photoSupper() {
console.log(res);
uni.hideLoading();
uni.showToast({
- title: "高清处理请求成功,请重稍后",
+ title: "高清处理请求成功,请稍后",
icon: "none",
});
diff --git a/src/pages/uploadPhoto/uploadPhoto.vue b/src/pages/uploadPhoto/uploadPhoto.vue
index 1cb6590..ee9c1e4 100644
--- a/src/pages/uploadPhoto/uploadPhoto.vue
+++ b/src/pages/uploadPhoto/uploadPhoto.vue
@@ -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(() => {
// 若来自我的页面的更换头像按钮,直接触发以下操作
diff --git a/src/store/modules/userInfo.js b/src/store/modules/userInfo.js
index ebc18bc..28fa216 100644
--- a/src/store/modules/userInfo.js
+++ b/src/store/modules/userInfo.js
@@ -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 };
},
{
diff --git a/src/utils/request.js b/src/utils/request.js
index 4549b7e..f2c923b 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -45,4 +45,4 @@ const request = (requestObj) => {
})
})
};
-export default request
\ No newline at end of file
+export { BASE_URL, request }
\ No newline at end of file