提交 598b3c87 编写于 作者: A Anne_LXM

feat: 兼容uni-app-x web端

上级 c76aede3
...@@ -3,7 +3,7 @@ import config from '@/uni_modules/uni-id-pages-x/config.uts'; ...@@ -3,7 +3,7 @@ import config from '@/uni_modules/uni-id-pages-x/config.uts';
export const loginSuccess = (_ : UTSJSONObject) => { export const loginSuccess = (_ : UTSJSONObject) => {
// console.log('loginSuccess', e); // console.log('loginSuccess', e);
// console.log("新用户uid", e["uid"]); // console.log("新用户uid", e["uid"]);
// state.currentUserInfo = uniCloud.getCurrentUserInfo() // state.currentUserInfo = uniCloud.getCurrentUserInfo()
mutations.updateUserInfo(null) mutations.updateUserInfo(null)
// state.userInfo["_id"] = e["uid"] // state.userInfo["_id"] = e["uid"]
state.isLogin = true state.isLogin = true
...@@ -13,7 +13,7 @@ export const loginSuccess = (_ : UTSJSONObject) => { ...@@ -13,7 +13,7 @@ export const loginSuccess = (_ : UTSJSONObject) => {
function loginAfterToPage() { function loginAfterToPage() {
const pages = getCurrentPages() const pages = getCurrentPages()
const currentPage = pages[pages.length - 1] const currentPage = pages[pages.length - 1]
const uniIdRedirectUrl = currentPage.options.get("uniIdRedirectUrl"); const uniIdRedirectUrl = currentPage.options["uniIdRedirectUrl"];
if (uniIdRedirectUrl != null) { if (uniIdRedirectUrl != null) {
// console.log('uniIdRedirectUrl', uniIdRedirectUrl); // console.log('uniIdRedirectUrl', uniIdRedirectUrl);
uni.redirectTo({ uni.redirectTo({
......
...@@ -143,7 +143,7 @@ ...@@ -143,7 +143,7 @@
// console.log('res', res); // console.log('res', res);
let tempFiles = res.tempFiles as UTSJSONObject[]; let tempFiles = res.tempFiles as UTSJSONObject[];
let tempFile = tempFiles[0]; let tempFile = tempFiles[0];
let tempFileName = tempFile.getString('name') let tempFileName = tempFile.getString('name')
let tempFilePath = tempFile.getString('path') let tempFilePath = tempFile.getString('path')
if (tempFileName == null) { if (tempFileName == null) {
tempFileName = "" tempFileName = ""
...@@ -151,26 +151,26 @@ ...@@ -151,26 +151,26 @@
if (tempFilePath == null) { if (tempFilePath == null) {
tempFilePath = "" tempFilePath = ""
} }
// console.log(9527,tempFileName.length); console.log(9527,tempFileName.length);
// console.error('tempFileName',tempFileName); console.log('tempFileName',tempFileName);
// console.error('tempFilePath',tempFilePath); console.log('tempFilePath',tempFilePath);
let avatar_file = { let avatar_file = {
// #ifdef H5 // #ifdef WEB
extname: tempFileName.split(".")[tempFileName.split(".").length - 1], extname: tempFileName.split(".")[tempFileName.split(".").length - 1],
// #endif // #endif
// #ifndef H5 // #ifndef WEB
extname: tempFilePath.split(".")[tempFilePath.split(".").length - 1], extname: tempFilePath.split(".")[tempFilePath.split(".").length - 1],
// #endif // #endif
name: tempFileName, name: tempFileName,
url: tempFilePath url: tempFilePath
} as UTSJSONObject } as UTSJSONObject
console.error('avatar_file', avatar_file); console.log('avatar_file', avatar_file);
let filePath = res.tempFilePaths[0] let filePath = res.tempFilePaths[0]
//非app端剪裁头像,app端用内置的原生裁剪 //非app端剪裁头像,app端用内置的原生裁剪
// #ifndef UNI-APP-X // #ifndef UNI-APP-X
filePath = await new Promise((callback) => { filePath = await new Promise((callback) => {
// #ifdef H5 // #ifdef WEB
if (!this.isPC) { if (!this.isPC) {
callback(filePath) callback(filePath)
} }
...@@ -192,7 +192,13 @@ ...@@ -192,7 +192,13 @@
}) })
// #endif // #endif
console.log("state",state)
console.log("state.userInfo",state.userInfo)
console.log("this.userInfo",this.userInfo)
let _id = this.userInfo["_id"] as string let _id = this.userInfo["_id"] as string
console.log("id",_id)
// if(_id != null){ // if(_id != null){
// _id = "" as string // _id = "" as string
// } // }
......
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
}, },
mounted() { mounted() {
this.smsCodeRef = (this.$refs["smsCode"] as UniIdPagesXSmsCodeComponentPublicInstance) this.smsCodeRef = (this.$refs["smsCode"] as UniIdPagesXSmsCodeComponentPublicInstance)
uni.$on('uni-id-pages-x-loginBySmsCode-showPopupCaptcha',(callback : () => void)=>{
this.showPopupCaptcha(callback)
})
}, },
methods: { methods: {
sendSmsCode() { sendSmsCode() {
......
...@@ -133,15 +133,22 @@ ...@@ -133,15 +133,22 @@
// console.log('reset'); // console.log('reset');
}, },
sendSmsCode() { sendSmsCode() {
// console.log("state.pendingAgreements", state.pendingAgreements); console.log("state.pendingAgreements", state.pendingAgreements);
if (state.pendingAgreements) { if (state.pendingAgreements) {
// uni.hideKeyboard(); // uni.hideKeyboard();
this.sendSmsCaptchaCP!.setFocus(false); this.sendSmsCaptchaCP!.setFocus(false);
(this.$parent as ComponentPublicInstance).$callMethod("showPopupCaptcha", () => { // web端尚未完全支持
if (!state.pendingAgreements) { // (this.$parent as ComponentPublicInstance).$callMethod("showPopupCaptcha", () => {
this.sendSmsCode() // if (!state.pendingAgreements) {
} // this.sendSmsCode()
}); // }
// });
// 临时方案
uni.$emit('uni-id-pages-x-loginBySmsCode-showPopupCaptcha',()=>{
if (!state.pendingAgreements) {
this.sendSmsCode()
}
})
uni.showToast({ uni.showToast({
title: '未同意隐私政策协议', title: '未同意隐私政策协议',
icon: 'none' icon: 'none'
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
<script> <script>
export default { export default {
onLoad(param : Map<string, string>) { onLoad(param) {
const url = param.get("url") as string; const url = param["url"] as string;
let title = param.get("title") as string; let title = param["title"] as string;
// console.log('url', url); // console.log('url', url);
if (url.substring(0, 4) != 'http') { if (url.substring(0, 4) != 'http') {
uni.showModal({ uni.showModal({
...@@ -40,4 +40,4 @@ ...@@ -40,4 +40,4 @@
flex: 1; flex: 1;
height: 100%; height: 100%;
} }
</style> </style>
\ No newline at end of file
...@@ -32,12 +32,11 @@ ...@@ -32,12 +32,11 @@
mounted() { mounted() {
this.smsCodeRef = (this.$refs["smsCode"] as UniIdPagesXSmsCodeComponentPublicInstance) this.smsCodeRef = (this.$refs["smsCode"] as UniIdPagesXSmsCodeComponentPublicInstance)
}, },
onLoad(param : Map<string, string>) { onLoad(param) {
const mobile = param.get("mobile") const mobile = param["mobile"]
// const email = param.get("email") // const email = param.get("email")
// console.log('mobile--', mobile); // console.log('mobile--', mobile);
// console.log('email--', email); // console.log('email--', email);
if (mobile != null) { if (mobile != null) {
this.$nextTick(() => { this.$nextTick(() => {
this.smsCodeRef!.mobile = mobile this.smsCodeRef!.mobile = mobile
......
...@@ -34,7 +34,7 @@ type Mutations = { ...@@ -34,7 +34,7 @@ type Mutations = {
updateUserInfo(param: null | UTSJSONObject): void updateUserInfo(param: null | UTSJSONObject): void
} }
export const mutations = { export const mutations = {
updateUserInfo(param: null | UTSJSONObject) { updateUserInfo: function (param: null | UTSJSONObject) {
console.log('updateUserInfo', param); // param为 null 时从云端获取数据更新,为UTSJSONObject时直接根据传入的值来更新 console.log('updateUserInfo', param); // param为 null 时从云端获取数据更新,为UTSJSONObject时直接根据传入的值来更新
function afterUpdateUserInfo() { function afterUpdateUserInfo() {
// console.log('afterUpdateUserInfo', state.userInfo); // console.log('afterUpdateUserInfo', state.userInfo);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册