提交 4b2fe29e 编写于 作者: A Anne_LXM

feat: 兼容uni-app-x web端

上级 4e094a0f
......@@ -7,8 +7,6 @@
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.uniui-back:before {
......
<template>
<view class="uni-navbar">
<view class="uni-navbar-inner" :style="navbarStyle">
<view class="left-content" @click="back">
<text class="uni-icons">{{unicode}}</text>
</view>
<view class="uni-navbar-content" :class="{'is-left':isLeft}">
<slot name="title">{{title}}</slot>
</view>
<view class="right-content">
<slot name="right"></slot>
</view>
</view>
</view>
<view class="uni-navbar">
<view class="uni-navbar-inner" :style="navbarStyle">
<view class="left-content" @click="back">
<text :style="{ color: textColor }" class="uni-icons">{{
unicode
}}</text>
</view>
<view class="uni-navbar-content" :class="{ 'is-left': isLeft }">
<text :style="{ color: textColor }">
<slot>{{ title }}</slot>
</text>
</view>
<view class="right-content">
<slot name="right"></slot>
</view>
</view>
</view>
</template>
<script>
import iconpath from './uniicons.ttf'
export default {
name: "uni-navbar",
props: {
title: {
type: String,
default: ''
},
isLeft: {
type: Boolean,
default: false
}
},
data() {
return {
statusBarHeight: 0
};
},
computed: {
navbarStyle() : string {
return `margin-top:${this.statusBarHeight}px`
},
unicode() : string {
return '\ue600'
}
},
created() {
uni.loadFontFace({
global: false,
family: 'UniIconsFontFamily',
source: iconpath,
success() { },
fail(err) {
console.log(err);
},
})
const sys = uni.getSystemInfoSync()
const statusBarHeight = sys.statusBarHeight
this.statusBarHeight = statusBarHeight
},
mounted() {
// TODO 暂时加定时器,否则不生效
setTimeout(() => {
uni.setNavigationBarColor({
frontColor: '#000000',
backgroundColor: '#ffffff'
})
}, 100)
},
methods: {
back() {
uni.navigateBack({})
}
},
}
import iconpath from "./uniicons.ttf";
export default {
name: "uni-navbar",
props: {
title: {
type: String,
default: "",
},
isLeft: {
type: Boolean,
default: false,
},
textColor: {
type: String,
default: "#000",
},
},
data() {
return {
statusBarHeight: 0,
};
},
computed: {
navbarStyle() : string {
return `margin-top:${this.statusBarHeight}px`;
},
unicode() : string {
return "\ue600";
},
},
created() {
uni.loadFontFace({
global: false,
family: "UniIconsFontFamily",
source: `url("${iconpath}")`,
success() { },
fail(err) {
console.log(err);
},
});
const sys = uni.getSystemInfoSync();
const statusBarHeight = sys.statusBarHeight;
this.statusBarHeight = statusBarHeight;
},
mounted() {
// TODO 暂时加定时器,否则不生效
setTimeout(() => {
uni.setNavigationBarColor({
frontColor: "#000000",
backgroundColor: "#ffffff",
});
}, 100);
},
methods: {
back() {
uni.navigateBack({});
},
},
};
</script>
<style>
.uni-icons {
font-family: "UniIconsFontFamily" !important;
font-size: 22px;
font-style: normal;
color: #333;
}
.uni-icons {
font-family: "UniIconsFontFamily" !important;
font-size: 22px;
font-style: normal;
color: #333;
}
.uni-navbar {
border: 1px #eee solid;
background-color: #fff;
}
.uni-navbar {
border: 1px #eee solid;
background-color: #ffffff;
}
.uni-navbar-inner {
position: relative;
display: flex;
flex-direction: row;
justify-content: space-between;
height: 45px;
}
.uni-navbar-inner {
position: relative;
flex-direction: row;
justify-content: space-between;
height: 45px;
}
.left-content,
.right-content {
display: flex;
justify-content: center;
align-items: center;
width: 45px;
height: 100%;
}
.left-content,
.right-content {
justify-content: center;
align-items: center;
width: 66px;
height: 100%;
}
.uni-navbar-content {
position: absolute;
height: 100%;
top: 0;
bottom: 0;
left: 45px;
right: 45px;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.uni-navbar-content {
position: absolute;
height: 100%;
top: 0;
bottom: 0;
left: 45px;
right: 45px;
flex-direction: row;
justify-content: center;
align-items: center;
}
.is-left {
justify-content: flex-start;
}
</style>
\ No newline at end of file
.is-left {
justify-content: flex-start;
}
</style>
<template>
<view class="uni-navbar">
<view class="uni-navbar-inner" :style="navbarStyle">
<view class="left-content" @click="back">
<text class="uni-icons uniui-back"></text>
</view>
<view class="uni-navbar-content">
<slot>{{title}}</slot>
</view>
<view class="right-content">
<slot name="right"></slot>
</view>
</view>
</view>
<view class="uni-navbar">
<view class="uni-navbar-inner" :style="navbarStyle">
<view class="left-content" @click="back">
<text class="uni-icons uniui-back"></text>
</view>
<view class="uni-navbar-content">
<slot>{{title}}</slot>
</view>
<view class="right-content">
<slot name="right"></slot>
</view>
</view>
</view>
</template>
<script>
export default {
name: "uni-navbar",
props: {
title: {
type: String,
default: ''
}
},
data() {
return {
statusBarHeight: 0
};
},
computed: {
navbarStyle() {
return `margin-top:${this.statusBarHeight}px`
},
},
created() {
const sys = uni.getSystemInfoSync()
const statusBarHeight = sys.statusBarHeight
this.statusBarHeight = statusBarHeight
},
methods: {
back() {
uni.navigateBack({})
}
},
}
export default {
name: "uni-navbar",
props: {
title: {
type: String,
default: ''
}
},
data() {
return {
statusBarHeight: 0
};
},
computed: {
navbarStyle() {
return `margin-top:${this.statusBarHeight}px`
},
},
created() {
const sys = uni.getSystemInfoSync()
const statusBarHeight = sys.statusBarHeight
this.statusBarHeight = statusBarHeight
},
methods: {
back() {
uni.navigateBack({})
}
},
}
</script>
<style>
@import './uni-icons.css';
@import './uni-icons.css';
.uni-icons {
font-family: UniIconsLight;
text-decoration: none;
text-align: center;
font-size: 22px;
font-style: normal;
color: #333;
}
.uni-icons {
font-family: UniIconsLight;
text-decoration: none;
text-align: center;
font-size: 22px;
font-style: normal;
color: #333;
}
.uni-navbar {
border: 1px #eee solid;
background-color: #fff;
}
.uni-navbar {
border: 1px #eee solid;
background-color: #fff;
}
.uni-navbar-inner {
position: relative;
display: flex;
flex-direction: row;
justify-content: space-between;
height: 45px;
}
.uni-navbar-inner {
position: relative;
flex-direction: row;
justify-content: space-between;
height: 45px;
}
.left-content,
.right-content {
display: flex;
justify-content: center;
align-items: center;
width: 45px;
height: 100%;
}
.left-content,
.right-content {
justify-content: center;
align-items: center;
width: 45px;
height: 100%;
}
.uni-navbar-content {
position: absolute;
height: 100%;
top: 0;
bottom: 0;
left: 45px;
right: 45px;
display: flex;
justify-content: center;
align-items: center;
}
</style>
\ No newline at end of file
.uni-navbar-content {
position: absolute;
height: 100%;
top: 0;
bottom: 0;
left: 45px;
right: 45px;
justify-content: center;
align-items: center;
}
</style>
......@@ -113,16 +113,12 @@
// this.setAvatarFile(avatar_file)
},
uploadAvatarImg() {
if(this.readOnly){
return
}
// #ifdef MP-WEIXIN
return // 微信小程序走 bindchooseavatar方法
// #endif
// #ifndef MP-WEIXIN
// if(!this.hasLogin){
// uni.navigateTo({
......@@ -139,21 +135,20 @@
uni.chooseImage({
count: 1,
crop,
success(res) : void {
success: (res) => {
// console.log('res', res);
let tempFiles = res.tempFiles as UTSJSONObject[];
let tempFile = tempFiles[0];
let tempFileName = tempFile.getString('name')
let tempFilePath = tempFile.getString('path')
let tempFileName = tempFile['name'] as string
let tempFilePath = tempFile['path'] as string
if (tempFileName == null) {
tempFileName = ""
}
if (tempFilePath == null) {
tempFilePath = ""
}
console.log(9527,tempFileName.length);
console.log('tempFileName',tempFileName);
console.log('tempFilePath',tempFilePath);
// console.log('tempFileName',tempFileName);
// console.log('tempFilePath',tempFilePath);
let avatar_file = {
// #ifdef WEB
extname: tempFileName.split(".")[tempFileName.split(".").length - 1],
......@@ -164,7 +159,7 @@
name: tempFileName,
url: tempFilePath
} as UTSJSONObject
console.log('avatar_file', avatar_file);
// console.log('avatar_file', avatar_file);
let filePath = res.tempFilePaths[0]
//非app端剪裁头像,app端用内置的原生裁剪
......@@ -191,12 +186,6 @@
});
})
// #endif
console.log("state",state)
console.log("state.userInfo",state.userInfo)
console.log("this.userInfo",this.userInfo)
let _id = this.userInfo["_id"] as string
console.log("id",_id)
// if(_id != null){
......@@ -204,19 +193,17 @@
// }
let cloudPath = _id + '' + Date.now()
avatar_file.name = cloudPath
uni.showLoading({
title: "更新中",
mask: true
});
// console.log('filePath', filePath);
uniCloud.uploadFile({
filePath,
cloudPath,
})
.then(function (res) {
// console.log('res777777777',res);
// console.log('res', res);
avatar_file.url = res.fileID
// console.log('avatar_file111', avatar_file);
mutations.updateUserInfo({ avatar_file } as UTSJSONObject)
......@@ -232,7 +219,7 @@
uni.hideLoading()
})
},
fail(err) : void {
fail:(err)=>{
console.error('chooseImage fail: ', err)
uni.showModal({
content: '失败,' + err.errMsg,
......
......@@ -14,7 +14,7 @@
</template>
<script>
import { state, mutations } from '@/uni_modules/uni-id-pages-x/store.uts';
import { mutations } from '@/uni_modules/uni-id-pages-x/store.uts';
export default {
data() {
return {
......@@ -44,7 +44,7 @@
},
bindMobileBySms(param : UTSJSONObject) {
// 设置(添加)验证码并重新发起
function setCaptchaRetry() {
const setCaptchaRetry = ()=> {
uni.showToast({
title: '请输入验证码',
icon: 'none',
......@@ -70,8 +70,7 @@
uni.hideLoading()
})
.then((e : UTSJSONObject) : void => {
// console.log('then');
console.log(e);
console.log(e,"-----------");
uni.showToast({
title: '绑定成功',
icon: 'none',
......@@ -107,7 +106,6 @@
})
},
popupCaptchaCancel() {
// console.log('popupCaptchaCancel');
this.smsCodeEl!.reset();
this.captcha = ""
}
......
......@@ -98,8 +98,8 @@
font-size: 14px;
border-radius: 5px;
margin-right: 15px;
background-color: #0070ff;
color: #FFF;
background-color: #0070ff !important;
color: #FFF!important;
}
.submit.disabled {
......
......@@ -20,7 +20,7 @@ function initState() {
let userInfo = uni.getStorageSync('uni-id-pages-x-userInfo')
if (userInfo instanceof UTSJSONObject) {
state.userInfo = userInfo
// console.log('init userInfo',userInfo);
console.log('init userInfo',userInfo);
}
} catch (e) {
console.error('init userInfo error', e);
......@@ -35,7 +35,7 @@ type Mutations = {
}
export const mutations = {
updateUserInfo: function (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)
......@@ -44,7 +44,7 @@ export const mutations = {
if (param == null) {
const db = uniCloud.databaseForJQL()
const user_id = uniCloud.getCurrentUserInfo().uid
// console.log('user_id', user_id);
console.log('user_id', user_id);
if (user_id != null) {
db.collection('uni-id-users')
.doc(user_id)
......@@ -72,7 +72,6 @@ export const mutations = {
}
} else {
param.toMap().forEach((value, key) => {
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.
先完成此消息的编辑!
想要评论请 注册