提交 a0ba05a5 编写于 作者: A Anne_LXM

feat: 兼容uni-app-x web端

上级 5e52c620
......@@ -35,6 +35,8 @@
</script>
<style>
@import url("/uni_modules/uni-id-pages-x/common/common.scss");
/*每个页面公共css */
.uni-row {
flex-direction: row;
......
......@@ -11,7 +11,7 @@
<script>
export default {
emits: ["modelValue"],
emits: ["update:modelValue"],
props: {
cursorSpacing: {
type: Number,
......@@ -101,7 +101,7 @@
}).then((result : UTSJSONObject) => {
this.captchaBase64 = (result.getString('captchaBase64') as string)
})
.catch<void>((err : any | null) : void => {
.catch((err : any | null) : void => {
const error = err as UniCloudError
console.error(error)
console.error(error.code)
......
......@@ -16,7 +16,7 @@
<script>
let confirmCallBack = ():void=>console.log('未传入回调函数')
export default {
emits:["modelValue","confirm","cancel"],
emits:["confirm","cancel","update:modelValue"],
data() {
return {
focus: false,
......
......@@ -75,7 +75,7 @@
data() {
return {
needAgreements:true,
$popupComponent:null as null | UniPopupComponentPublicInstance
popupComponent:null as null | UniPopupComponentPublicInstance
}
},
mounted() {
......@@ -88,7 +88,7 @@
}
state.pendingAgreements = this.needAgreements;
this.$popupComponent = (this.$refs['popup'] as UniPopupComponentPublicInstance)
this.popupComponent = (this.$refs['popup'] as UniPopupComponentPublicInstance)
// this.showPopupAgreements(()=>{
// console.log('showPopupAgreements after');
// })
......@@ -116,17 +116,17 @@
},
showPopupAgreements(callback: () => void){
confirmCallBack = callback;
this.$popupComponent!.open()
this.popupComponent!.open()
},
cancel(){
state.pendingAgreements = true;
this.$popupComponent!.close()
this.popupComponent!.close()
},
confirm(){
state.pendingAgreements = false;
// console.log('state.pendingAgreements',state.pendingAgreements);
confirmCallBack();
this.$popupComponent!.close()
this.popupComponent!.close()
}
},
}
......
......@@ -151,11 +151,9 @@
if (tempFilePath == null) {
tempFilePath = ""
}
// console.log(9527,tempFileName.length);
// console.error('tempFileName',tempFileName);
// console.error('tempFilePath',tempFilePath);
let avatar_file = {
// #ifdef H5
extname: tempFileName.split(".")[tempFileName.split(".").length - 1],
......@@ -211,13 +209,13 @@
filePath,
cloudPath,
})
.then<void>(function (res) {
.then(function (res) {
// console.log('res777777777',res);
avatar_file.url = res.fileID
// console.log('avatar_file111', avatar_file);
mutations.updateUserInfo({ avatar_file } as UTSJSONObject)
})
.catch<void>(function (err : any | null) {
.catch(function (err : any | null) {
const error = err as UniCloudError
uni.showModal({
content: '上传失败,' + error.errMsg,
......@@ -243,6 +241,10 @@
</script>
<style>
.default-avatarUrl{
width:44px;
height:44px;
}
.avatar-box-root {
background-color: #fff;
}
......@@ -257,7 +259,6 @@
display: inline-block;
box-sizing: border-box;
/* #endif */
border-radius: 100px;
text-align: center;
padding: 1px;
......
......@@ -71,7 +71,7 @@
},
watch: {
agree(agree) {
this.univerifyStyle.privacyTerms.defaultCheckBoxState = agree
this.univerifyStyle.privacyTerms!.defaultCheckBoxState = agree
}
},
methods: {
......@@ -127,8 +127,8 @@
.fab-login-box {
width: 750rpx;
position: fixed;
bottom: 30;
left: 0;
bottom: 30px;
left: 0px;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-around;
......
......@@ -20,7 +20,7 @@
<script>
export default {
name: 'MyInput',
emits: ["modelValue", "blur", "focus", "confirm"],
emits: ["blur", "focus", "confirm", "update:modelValue"],
data() {
return {
visiblePwd: false
......@@ -117,17 +117,17 @@
if(eventName == "click" && this.visiblePwdOption == 'click'){
this.visiblePwd = !this.visiblePwd
}else if(eventName == "touch"){
switch (eventName){
case "touchstart":
this.visiblePwd = true
break;
case "touchend":
this.visiblePwd = false
break;
case "touchcancel":
this.visiblePwd = false
break;
}
// switch (eventName){
// case "touchstart":
// this.visiblePwd = true
// break;
// case "touchend":
// this.visiblePwd = false
// break;
// case "touchcancel":
// this.visiblePwd = false
// break;
// }
}
}
}
......
......@@ -81,11 +81,10 @@
}
data.set(keyName, this.username)
// console.log('data',data);
console.log('data',data);
if (state.pendingAgreements) {
this.showPopupCaptcha(() => {
// console.log('state.pendingAgreements', state.pendingAgreements);
if (!state.pendingAgreements) {
this.loginByPwd()
}
......@@ -102,11 +101,11 @@
uni.hideLoading()
this.loginCaptcha = ""
})
.then(e => {
// console.log('uniIdCo.login res',e);
.then((e:UTSJSONObject) => {
console.log('uniIdCo.login res',e);
loginSuccess(e)
})
.catch<void>((err : any | null) : void => {
.catch((err : any | null) : void => {
const error = err as UniCloudError
console.error(error)
console.error(error.code)
......
......@@ -16,7 +16,6 @@
</template>
<script>
import { state } from '@/uni_modules/uni-id-pages-x/store.uts';
import { loginSuccess } from '@/uni_modules/uni-id-pages-x/common/common.uts';
const uniIdCo = uniCloud.importObject("uni-id-co", { "customUI": true })
export default {
......@@ -24,17 +23,15 @@
data() {
return {
captcha: "",
$smsCodeRef: null as null | UniIdPagesXSmsCodeComponentPublicInstance
smsCodeRef: null as null | UniIdPagesXSmsCodeComponentPublicInstance
}
},
computed: {
},
mounted() {
this.$smsCodeRef = (this.$refs["smsCode"] as UniIdPagesXSmsCodeComponentPublicInstance)
this.smsCodeRef = (this.$refs["smsCode"] as UniIdPagesXSmsCodeComponentPublicInstance)
},
methods: {
sendSmsCode() {
this.$smsCodeRef!.$callMethod('sendSmsCode');
this.smsCodeRef!.$callMethod('sendSmsCode');
},
smsCodeInput(param : UTSJSONObject) {
// console.log('smsCodeInput param', param);
......@@ -53,18 +50,17 @@
.finally(() : void => {
uni.hideLoading()
})
.then<void>((e : UTSJSONObject) : void => {
// console.log('then');
.then((e : UTSJSONObject) : void => {
// console.log(e);
this.$smsCodeRef!.$callMethod("hideCodeInput");
this.smsCodeRef!.$callMethod("hideCodeInput");
uni.showToast({
title: '登录成功',
icon: 'none'
});
loginSuccess(e)
this.$smsCodeRef!.$callMethod('clearCodeInput')
this.smsCodeRef!.$callMethod('clearCodeInput')
})
.catch<void>((err : any | null) : void => {
.catch((err : any | null) : void => {
const error = err as UniCloudError
console.error(error)
console.error(error.code)
......@@ -78,7 +74,7 @@
icon: 'none',
mask: false
});
this.$smsCodeRef!.$callMethod('clearCodeInput')
this.smsCodeRef!.$callMethod('clearCodeInput')
this.captcha = ""
}
})
......
......@@ -14,7 +14,7 @@
<script>
let confirmCallBack = (_ : string) : void => {}// console.log('未传入回调函数,value:', value)
export default {
emits: ["confirm"],
emits: ["confirm","cancel"],
data() {
return {
title: "默认标题" as string,
......
......@@ -20,7 +20,7 @@
<script>
export default {
emits: ["modelValue", "blur", "focus", "reGetSmsCode"],
emits: ["update:modelValue","reGetSmsCode","blur", "focus" ],
data() {
return {
smsCodeList: ["\u200b", "\u200b", "\u200b", "\u200b", "\u200b", "\u200b"],
......
......@@ -24,13 +24,14 @@
export default {
name: "uni-id-pages-x-smsCode",
components: { fabSmsCodeInput },
emits:["input"],
data() {
return {
mobile: "",
sendSmsCaptcha: "",
smsCode: "",
$fabSmsCodeInputEl: null as null | ComponentPublicInstance,
$sendSmsCaptchaCP: null as null | UniCaptchaComponentPublicInstance,
fabSmsCodeInputEl: null as null | ComponentPublicInstance,
sendSmsCaptchaCP: null as null | UniCaptchaComponentPublicInstance,
reverseNumber: 0
}
},
......@@ -51,7 +52,7 @@
mobile(mobile) {
this.emitInput()
if (mobile.length == 11) {
this.$sendSmsCaptchaCP!.setFocus(true);
this.sendSmsCaptchaCP!.setFocus(true);
// 倒计时归零,允许再次发送
this.reverseNumber = 0
}
......@@ -68,8 +69,8 @@
}
},
mounted() {
this.$fabSmsCodeInputEl = this.$refs["fab-sms-code-input"] as ComponentPublicInstance;
this.$sendSmsCaptchaCP = this.$refs["sendSmsCaptcha"] as UniCaptchaComponentPublicInstance;
this.fabSmsCodeInputEl = this.$refs["fab-sms-code-input"] as ComponentPublicInstance;
this.sendSmsCaptchaCP = this.$refs["sendSmsCaptcha"] as UniCaptchaComponentPublicInstance;
// 加载好,手机号码输入框就自动获取焦点
// TO 临时方案解决 this.$nextTick 无效,由setTimeout 300 代替
......@@ -82,7 +83,7 @@
(this.$refs['mobileInput'] as UniIdPagesXInputComponentPublicInstance).setFocus(val);
},
showCodeInput() {
if (reverseNumber == 0) {
if (this.reverseNumber == 0) {
this.reverseNumber = 6
//开始倒计时
let reverseTimer = function () { }
......@@ -96,7 +97,7 @@
}
reverseTimer()
}
this.$fabSmsCodeInputEl?.$callMethod('show', true);
this.fabSmsCodeInputEl?.$callMethod('show', true);
},
emitInput() {
const param : UTSJSONObject = {
......@@ -116,13 +117,13 @@
reGetSmsCode() {
this.hideCodeInput();
this.clearCodeInput();
this.$sendSmsCaptchaCP!.getImageCaptcha(true);
this.sendSmsCaptchaCP!.getImageCaptcha(true);
},
hideCodeInput() {
this.$fabSmsCodeInputEl!.$callMethod("hide");
this.fabSmsCodeInputEl!.$callMethod("hide");
},
clearCodeInput() {
this.$fabSmsCodeInputEl!.$callMethod('clear')
this.fabSmsCodeInputEl!.$callMethod('clear')
},
reset() {
this.smsCode = ""
......@@ -135,9 +136,8 @@
// console.log("state.pendingAgreements", state.pendingAgreements);
if (state.pendingAgreements) {
// uni.hideKeyboard();
this.$sendSmsCaptchaCP!.setFocus(false);
this.sendSmsCaptchaCP!.setFocus(false);
(this.$parent as ComponentPublicInstance).$callMethod("showPopupCaptcha", () => {
// console.log('state.pendingAgreements', state.pendingAgreements);
if (!state.pendingAgreements) {
this.sendSmsCode()
}
......@@ -166,7 +166,7 @@
}
if (this.sendSmsCaptcha.length != 4) {
this.$sendSmsCaptchaCP!.setFocus(true)
this.sendSmsCaptchaCP!.setFocus(true)
uni.showToast({
title: '请先输入图形验证码',
icon: 'none',
......@@ -201,7 +201,7 @@
// console.log('result', result);
this.showCodeInput()
})
.catch<void>((err : any | null) : void => {
.catch((err : any | null) : void => {
const error = err as UniCloudError
// console.error(error.message)
// console.error(error.code)
......@@ -214,7 +214,7 @@
duration: 3000,
mask: false
});
this.$sendSmsCaptchaCP!.getImageCaptcha(true);
this.sendSmsCaptchaCP!.getImageCaptcha(true);
this.sendSmsCaptcha = "";
break;
case "uni-id-invalid-sms-template-id":
......
......@@ -13,10 +13,10 @@ export default {
]
},
"loginTypes":[
"smsCode",
// #ifdef APP && ( uniVersion > 3.99 || uniVersion == 3.99)
"univerify",
// #endif
"smsCode",
"username",
// 以下登录方式 uni-app x 暂不支持
/*
......
......@@ -14,24 +14,25 @@ const uniIdCo = uniCloud.importObject('uni-id-co', {
const loginTypes = config.getArray<string>('loginTypes');
const debug = config.getBoolean('debug') as boolean;
// #ifdef APP
// #ifdef APP && ( uniVersion > 3.99 || uniVersion == 3.99)
import Univerify from '@/uni_modules/uni-id-pages-x/lib/Univerify.uts'
// #endif
export default async function () {
// 有打开调试模式的情况下
if (debug) {
// 1. 检查本地uni-id-pages中配置的登录方式,服务器端是否已经配置正确。否则提醒并引导去配置
// 调用云对象,获取服务端已正确配置的登录方式
uniIdCo.getSupportedLoginType().then(res=>{
uniIdCo.getSupportedLoginType().then((res:UTSJSONObject)=>{
// console.log('7777res',res)
let supportedLoginType = res.getArray('supportedLoginType')
let supportedLoginType = res.getArray<string>('supportedLoginType')
console.log('supportedLoginType: ',supportedLoginType);
if(supportedLoginType == null){
supportedLoginType = []
}
// 登录方式,服务端和客户端的映射关系
const data:UTSJSONObject = {
"smsCode": 'mobile-code',
"univerify": 'univerify',
"username": 'username-password',
"weixin": 'weixin',
......@@ -46,12 +47,13 @@ export default async function () {
"weixinMobile": 'weixin'
};
// 遍历客户端配置的登录方式,与服务端比对。并在错误时抛出错误提示
const list = loginTypes?.filter((type:string):boolean =>{
const list = loginTypes?.filter((type:string):boolean =>type != 'smsCode')
?.filter((type:string):boolean =>{
let currentType = data.getString(type);
if(currentType == null){
currentType = ""
}
return !(supportedLoginType.includes(currentType))
return supportedLoginType?.includes(currentType) != true
})
if (list?.length != 0) {
console.error(
......@@ -114,7 +116,6 @@ export default async function () {
handleInterceptor(e.url)
}
})
}
// #endif
......
......@@ -80,7 +80,7 @@
}
</script>
<style lang="scss" scoped>
<style lang="scss">
@import url("/uni_modules/uni-id-pages-x/common/common.scss");
.app-logo {
......
......@@ -173,7 +173,7 @@
});
loginSuccess(e)
})
.catch<void>((err : any | null) : void => {
.catch((err : any | null) : void => {
const error = err as UniCloudError
console.error(error)
console.error(error.code)
......
......@@ -23,14 +23,14 @@
data() {
return {
smsCode: "",
$smsCodeRef: null as null | UniIdPagesXSmsCodeComponentPublicInstance,
smsCodeRef: null as null | UniIdPagesXSmsCodeComponentPublicInstance,
password: "",
password2: "",
captcha: ""
}
},
mounted() {
this.$smsCodeRef = (this.$refs["smsCode"] as UniIdPagesXSmsCodeComponentPublicInstance)
this.smsCodeRef = (this.$refs["smsCode"] as UniIdPagesXSmsCodeComponentPublicInstance)
},
onLoad(param : Map<string, string>) {
const mobile = param.get("mobile")
......@@ -40,7 +40,7 @@
if (mobile != null) {
this.$nextTick(() => {
this.$smsCodeRef!.mobile = mobile
this.smsCodeRef!.mobile = mobile
})
}
},
......@@ -85,7 +85,7 @@
}
});
}
this.$smsCodeRef!.sendSmsCode();
this.smsCodeRef!.sendSmsCode();
},
resetPwdBySms(param : UTSJSONObject) {
uni.showLoading({ "title": "请求中" })
......@@ -95,17 +95,17 @@
.finally(() : void => {
uni.hideLoading()
})
.then<void>((_ : UTSJSONObject) : void => {
.then((_ : UTSJSONObject) : void => {
// console.log('then');
// console.log(e);
this.$smsCodeRef!.hideCodeInput();
this.smsCodeRef!.hideCodeInput();
uni.showToast({
title: '重置成功',
icon: 'none'
});
uni.navigateBack()
})
.catch<void>((err : any | null) : void => {
.catch((err : any | null) : void => {
const error = err as UniCloudError
console.error(error)
console.error(error.code)
......@@ -119,7 +119,7 @@
icon: 'none',
mask: false
});
this.$smsCodeRef!.clearCodeInput()
this.smsCodeRef!.clearCodeInput()
this.captcha = ""
}
})
......
......@@ -18,7 +18,7 @@
export default {
data() {
return {
$smsCodeEl: null as null | UniIdPagesXSmsCodeComponentPublicInstance,
smsCodeEl: null as null | UniIdPagesXSmsCodeComponentPublicInstance,
needCaptcha: false,
captcha: ""
}
......@@ -28,11 +28,11 @@
watch: {
},
mounted() {
this.$smsCodeEl = (this.$refs["smsCode"] as UniIdPagesXSmsCodeComponentPublicInstance)
this.smsCodeEl = (this.$refs["smsCode"] as UniIdPagesXSmsCodeComponentPublicInstance)
},
methods: {
sendSmsCode() {
this.$smsCodeEl!.sendSmsCode();
this.smsCodeEl!.sendSmsCode();
},
smsCodeInput(param : UTSJSONObject) {
// console.log('smsCodeInput param', param);
......@@ -69,9 +69,9 @@
.finally(() : void => {
uni.hideLoading()
})
.then<void>((e : UTSJSONObject) : void => {
.then((e : UTSJSONObject) : void => {
// console.log('then');
// console.log(e);
console.log(e);
uni.showToast({
title: '绑定成功',
icon: 'none',
......@@ -84,7 +84,7 @@
"mobile": param.getString("mobile")
} as UTSJSONObject)
})
.catch<void>((err : any | null) : void => {
.catch((err : any | null) : void => {
const error = err as UniCloudError
console.error(error)
console.error(error.code)
......@@ -93,9 +93,9 @@
//登录失败,自动重新获取验证码
return setCaptchaRetry()
} else if (error.code == "uni-id-mobile-verify-code-error") {
this.$smsCodeEl!.clearCodeInput();
this.smsCodeEl!.clearCodeInput();
} else {
this.$smsCodeEl!.reset();
this.smsCodeEl!.reset();
this.captcha = ""
}
uni.showToast({
......@@ -108,7 +108,7 @@
},
popupCaptchaCancel() {
// console.log('popupCaptchaCancel');
this.$smsCodeEl!.reset();
this.smsCodeEl!.reset();
this.captcha = ""
}
}
......
......@@ -57,11 +57,11 @@
.update({
"nickname": this.nickname
})
.then<void>(() => {
.then(() => {
mutations.updateUserInfo({ "nickname": this.nickname } as UTSJSONObject)
uni.navigateBack()
})
.catch<void>((err : any | null) => {
.catch((err : any | null) => {
const error = err as UniCloudError
console.error('error', error);
})
......
......@@ -83,8 +83,6 @@
return authStatus as number
}
},
onShow() {
},
props: {
showLoginManage: {
type: Boolean,
......
......@@ -35,7 +35,7 @@ type Mutations = {
}
export const mutations = {
updateUserInfo(param: null | UTSJSONObject) {
// console.log('updateUserInfo', param); // param为 null 时从云端获取数据更新,为UTSJSONObject时直接根据传入的值来更新
console.log('updateUserInfo', param); // param为 null 时从云端获取数据更新,为UTSJSONObject时直接根据传入的值来更新
function afterUpdateUserInfo() {
// console.log('afterUpdateUserInfo', state.userInfo);
uni.setStorageSync('uni-id-pages-x-userInfo', state.userInfo)
......@@ -50,7 +50,7 @@ export const mutations = {
.doc(user_id)
.field('_id,username,nickname,avatar_file,mobile')
.get()
.then<void>(res => {
.then(res => {
const uniIdCo = uniCloud.importObject('uni-id-co', {
customUI: true
})
......@@ -65,14 +65,14 @@ export const mutations = {
afterUpdateUserInfo()
})
})
.catch<void>((err: any | null) => {
.catch((err: any | null) => {
const error = err as UniCloudError
console.error(error.errMsg, '错误')
})
}
} else {
param.toMap().forEach((value, key) => {
// console.log("updateUserInfo.", key, value)
console.log("updateUserInfo.", key, value)
state.userInfo.set(key, value)
})
afterUpdateUserInfo()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册