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/App.vue b/src/App.vue index e3f007e..416bfc9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -41,6 +41,26 @@ onLaunch(() => { console.log(res.osName, osName, "System"); }, }); + + uni.setStorageSync("userId", "114514"); + + const updateManager = uni.getUpdateManager(); + + updateManager.onUpdateReady(function (res) { + uni.showModal({ + title: "更新提示", + content: "有新的版本哦,请重启小程序应用更新", + showCancel: false, + confirmText: "立刻重启", + confirmColor: "#ff4f00", + success(res) { + if (res.confirm) { + // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 + updateManager.applyUpdate(); + } + }, + }); + }); }); onShow(() => { console.log("App Show!"); diff --git a/src/api/closeStyle.js b/src/api/closeStyle.js index 5bad618..b0bd978 100644 --- a/src/api/closeStyle.js +++ b/src/api/closeStyle.js @@ -1,9 +1,9 @@ -import request from "../utils/request" +import { request } from "../utils/request" // 获取风格列表 -export function getListApi(pageNum, pageSize) { +export function getListApi(pageNum, pageSize, sex) { return request({ - url: `api/digitalAvatarMould/list?pageNum=${pageNum}&pageSize=${pageSize}`, + url: `api/digitalAvatarMould/list?pageNum=${pageNum}&pageSize=${pageSize}&sex=${sex}`, method: 'GET', }) } 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..e4fc8ad 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:获取用户头像 @@ -49,6 +49,19 @@ export function getConsumeListApi(pageSize, pageNum) { }) } +/** +* @description:获取邀请记录 +* @param (pageSize, pageNum) +* @return: +*/ +export function getInviteListApi(pageSize, pageNum) { + return request({ + url: `api/userFrom/list?fromProject=5&pageSize=${pageSize}&pageNum=${pageNum}`, + method: 'get', + }) +} + + /** * @description:删除写真 * @param id diff --git a/src/api/login.js b/src/api/login.js index 9e241ca..8eb58b1 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -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 + }) } \ No newline at end of file diff --git a/src/api/lookPhoto.js b/src/api/lookPhoto.js index a41a8ac..df6e4f1 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" /** @@ -38,3 +38,17 @@ export function getSupperPhotoStateApi(id) { method: 'get', }) } + +/** +* @description:生成画报 +* @param {appId,img} +* @return: data +*/ +export function getUserQrcodeApi(data) { + return request({ + url: `/api/miniApp/getUserQrcode`, + method: 'POST', + responseType: "arraybuffer", + data + }) +} 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/assets/icon/delete.png b/src/assets/icon/delete.png new file mode 100644 index 0000000..a1c3cd5 Binary files /dev/null and b/src/assets/icon/delete.png differ diff --git a/src/assets/icon/sound-2.png b/src/assets/icon/sound-2.png new file mode 100644 index 0000000..f7ef17e Binary files /dev/null and b/src/assets/icon/sound-2.png differ diff --git a/src/assets/icon/sound.png b/src/assets/icon/sound.png new file mode 100644 index 0000000..669dca7 Binary files /dev/null and b/src/assets/icon/sound.png differ diff --git a/src/assets/icon/soundBG.png b/src/assets/icon/soundBG.png new file mode 100644 index 0000000..f7f5b24 Binary files /dev/null and b/src/assets/icon/soundBG.png differ diff --git a/src/assets/img/people.png b/src/assets/img/people.png new file mode 100644 index 0000000..c1d510b Binary files /dev/null and b/src/assets/img/people.png differ diff --git a/src/components/myLoading.vue b/src/components/myLoading.vue deleted file mode 100644 index 12f33ac..0000000 --- a/src/components/myLoading.vue +++ /dev/null @@ -1,10 +0,0 @@ - - - - - diff --git a/src/manifest.json b/src/manifest.json index d3d1d0c..0272db0 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -51,6 +51,9 @@ /* 小程序特有相关 */ "mp-weixin": { "appid": "wx75cf14e3a0d45821", + // "useExtendedLib": { + // "share": true // 确保分享功能已经开启 + // }, "permission": { "scope.userLocation": { "desc": "获取您的地理位置信息" @@ -67,7 +70,8 @@ "ignoreDevUnusedFiles": false, "ignoreUploadUnusedFiles": false }, - "usingComponents": true + "usingComponents": true, + "__usePrivacyCheck__": true }, "h5": { "title": "", @@ -80,7 +84,8 @@ "usingComponents": true }, "mp-toutiao": { - "usingComponents": true + "usingComponents": true, + "appid": "tt2eba5807b1883f9f01" }, "uniStatistics": { "enable": false diff --git a/src/pages.json b/src/pages.json index 578ffdb..8019679 100644 --- a/src/pages.json +++ b/src/pages.json @@ -30,6 +30,12 @@ "navigationBarTitleText": "上传成功" } }, + { + "path": "pages/uploadPhoto/camera ", + "style": { + "navigationBarTitleText": "拍照" + } + }, { "path": "pages/closeStyle/closeStyle", "style": { @@ -75,7 +81,7 @@ { "path": "pages/protocol/coin", "style": { - "navigationBarTitleText": "慧拍金币充值协议" + "navigationBarTitleText": "智像金币充值协议" } }, { diff --git a/src/pages/closeStyle/closeStyle.vue b/src/pages/closeStyle/closeStyle.vue index cde7a3e..c8098d3 100644 --- a/src/pages/closeStyle/closeStyle.vue +++ b/src/pages/closeStyle/closeStyle.vue @@ -1,13 +1,26 @@ @@ -64,11 +152,18 @@ //#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(); +const showPrivacy = ref(false); + const pageClass = computed(() => { if (userInfoModulesPinia.platForm == 1) { return "page pageH5"; @@ -76,7 +171,7 @@ const pageClass = computed(() => { return "page"; } }); -//#region 勾选 +//#region 勾选和手机号授权 const checkboxValue = ref([]); const checkboxList = ref([ { @@ -87,15 +182,17 @@ 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, + uid: urlUid.value, }; try { const res2 = await loginPhoneApi(data); @@ -110,7 +207,7 @@ async function getphonenumber(e) { } catch (error) { uni.showToast({ icon: "none", - title: "获取失败", + title: "获取手机号失败", }); } } else { @@ -126,7 +223,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 +232,7 @@ async function toCreate(e) { if (res.confirm) { checkboxValue.value = ["同意智像相机用户使用协议"]; // handleLogin(); - getphonenumber(e); + dogetphonenumber(e); } else if (res.cancel) { } }, @@ -192,23 +289,343 @@ const goPro = () => { }; //#endregion --------------------- -//#region +//#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); + console.log(res.code, "duanxing"); + 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--; + } 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; + console.log(res.code, "denglu"); + if (res.code != 200) { + uni.showToast({ + title: res.message, + icon: "none", + }); + } else { + // uni.switchTab({ + // url: "/pages/uploadPhoto/uploadPhoto", + // }); + } + } catch (error) { + uni.hideLoading(); + uni.showToast({ + title: "登录失败,请重试", + icon: "none", + }); + } +} +//#endregion --------------------- + +//#region 隐私协议 +const getPrivacySetting = (num) => { + const canIUsePrivacy = wx.canIUse("getPrivacySetting"); + // console.log(canIUsePrivacy, "canIUse getPrivacySetting"); + if (canIUsePrivacy) { + wx.getPrivacySetting({ + success: (res) => { + // console.log(res, "getPrivacySetting"); // 返回结果为: res = { needAuthorization: true/false, privacyContractName: '《xxx隐私保护指引》' } + if (res.needAuthorization) { + // 需要弹出隐私协议 + showPrivacy.value = true; + } else { + // 用户已经同意过隐私协议,所以不需要再弹出隐私协议,也能调用已声明过的隐私接口 + if (num == 1) { + // 返回token,直接跳转首页 + // uni.switchTab({ + // url: "/pages/uploadPhoto/uploadPhoto", + // }); + } else if (num == 2) { + // 没有返回token,无事发生 + } + } + }, + fail: () => {}, + complete: () => {}, + }); + } +}; + +// 关闭弹框直接退出小程序,仅对微信小程序生效 +const closePrivacy = () => { + wx.exitMiniProgram(); +}; + +const handleAgreePrivacyAuthorization = () => { + // console.log("Privacy Agreed!"); + showPrivacy.value = false; + // 用户同意隐私协议事件回调 + // 用户点击了同意,之后所有已声明过的隐私接口和组件都可以调用了 +}; + +const handleOpenPrivacyContract = () => { + // 打开隐私协议页面 + wx.openPrivacyContract({ + success: () => {}, // 打开成功 + fail: () => {}, // 打开失败 + complete: () => {}, + }); +}; +//#endregion --------------------------------- + +//#region 初始化 +const urlUid = ref(""); //通过邀请来的会携带邀请人ID参数 onLoad((options) => { + // 二维码扫描进入时 + if (options.scene) { + const str = decodeURIComponent(options.scene); + const regex = /_u:(\d+)/; // 正则表达式匹配_u:后面的数字 + const match = str.match(regex); + urlUid.value = match[1]; + } + // 分享链接进入时 + else if (options.userId) { + urlUid.value = options.userId; + } else { + urlUid.value = null; + } + console.log(urlUid.value, "邀请人id"); 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) { + getPrivacySetting(1); + } else { + console.log("error1"); + uni.showToast({ + title: "登录失败,请重试", + icon: "none", + }); + } + } else { + getPrivacySetting(2); + } + 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(); diff --git a/src/pages/lookPhoto/index.vue b/src/pages/lookPhoto/index.vue index ae5c1c5..5d924a8 100644 --- a/src/pages/lookPhoto/index.vue +++ b/src/pages/lookPhoto/index.vue @@ -2,6 +2,7 @@ - 左右滑动查看更多 + + 左右滑动查看更多 + 生成中,请稍后... - {{ supperTips() }} + + {{ supperTips() }} --> - + 邀请好友可获得2枚金币 - - + + + + + + 长按保存、分享、收藏 + 关闭 + + + diff --git a/src/pages/recorded/index.vue b/src/pages/recorded/index.vue index 2a23c32..ca19f17 100644 --- a/src/pages/recorded/index.vue +++ b/src/pages/recorded/index.vue @@ -1,75 +1,50 @@