提交 c21bb907 编写于 作者: L linju

23

<template>
<view>
<uni-popup ref="popup" :maskClick="false" type="center">
<uni-popup-agree @cancel="cancel" @confirm="confirm"></uni-popup-agree>
</uni-popup>
</view>
</template>
<script>
export default {
name:"uni-agree",
mounted() {
if (uni.getSystemInfoSync().platform == "android") {
let iKnowAgree = uni.getStorageSync('iKnowAgree') || false;
if(!iKnowAgree){
this.$refs.popup.open();
}
}
},
methods:{
confirm(){
this.$refs.popup.close();
uni.setStorageSync('iKnowAgree', true);
},
cancel(){
plus.runtime.quit();
}
}
}
</script>
<style>
</style>
<template>
<view class="uni-popup-dialog">
<view class="uni-dialog-title">
<text class="uni-dialog-title-text" :class="['uni-popup__'+dialogType]">{{title}}</text>
</view>
<view class="uni-dialog-content">
<login-ikonw class="login-iknow" :link="link" :text="content"></login-ikonw>
</view>
<view class="uni-dialog-button-group">
<view class="uni-dialog-button" @click="close">
<text class="uni-dialog-button-text">不同意</text>
</view>
<view class="uni-dialog-button uni-border-left" @click="onOk">
<text class="uni-dialog-button-text uni-button-color">同意</text>
</view>
</view>
</view>
</template>
<script>
export default {
name: "uniPopupAgree",
props: {
/**
* 对话框主题 success/warning/info/error 默认 success
*/
type: {
type: String,
default: 'error'
},
/**
* 对话框标题
*/
title: {
type: String,
default: '使用须知'
},
/**
* 对话框内容
*/
content: {
type: String,
default: 'DCloud(以下简称我们)尊重并保护所有使用服务用户的个人权益。为了给您提供更准确、更有个性化的服务,我们会按照本隐私政策和服务协议的规定使用和披露您的个人信息。但我们将以高度的勤勉、审慎义务对待这些信息。除本隐私政策和服务协议另有规定外,在未征得您事先许可的情况下,我们不会将这些信息对外披露或向第三方提供。'
},
},
data() {
return {
dialogType: 'error',
val: "",
link: [{
text: '服务协议',
to: '/pages/ucenter/agree-list/service/service'
}, {
text: '隐私政策',
to: '/pages/ucenter/agree-list/privacy/privacy'
}],
}
},
watch: {
type(val) {
this.dialogType = val
}
},
created() {
this.dialogType = this.type
},
methods: {
/**
* 点击确认按钮
*/
onOk() {
this.$emit('confirm');
},
/**
* 点击取消按钮
*/
close() {
this.$emit('cancel');
}
}
}
</script>
<style lang="scss" scoped>
.uni-popup-dialog {
width: 300px;
border-radius: 5px;
background-color: #fff;
}
.uni-dialog-title {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: center;
padding-top: 15px;
padding-bottom: 5px;
}
.uni-dialog-title-text {
font-size: 16px;
font-weight: 500;
}
.uni-dialog-content {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: center;
align-items: center;
padding: 5px 15px 15px 15px;
}
.uni-dialog-content-text {
font-size: 14px;
color: #6e6e6e;
}
.uni-dialog-button-group {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
border-top-color: #f5f5f5;
border-top-style: solid;
border-top-width: 1px;
}
.uni-dialog-button {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex: 1;
flex-direction: row;
justify-content: center;
align-items: center;
height: 45px;
/* #ifdef H5 */
cursor: pointer;
/* #endif */
}
.uni-border-left {
border-left-color: #f0f0f0;
border-left-style: solid;
border-left-width: 1px;
}
.uni-dialog-button-text {
font-size: 14px;
}
.uni-button-color {
color: $uni-color-primary;
}
.uni-dialog-input {
flex: 1;
font-size: 14px;
}
.uni-popup__success {
color: $uni-color-success;
}
.uni-popup__warn {
color: $uni-color-warning;
}
.uni-popup__error {
color: $uni-color-error;
}
.uni-popup__info {
color: #909399;
}
.uni-popup-dialog__close {
/* #ifndef APP-NVUE */
display: block;
cursor: pointer;
/* #endif */
position: absolute;
top: 9px;
right: 17px;
}
.uni-popup-dialog__close-icon {
/* #ifndef APP-NVUE */
display: inline-block;
/* #endif */
width: 13px;
height: 1px;
background: #909399;
transform: rotate(45deg);
}
.uni-popup-dialog__close-icon::after {
/* #ifndef APP-NVUE */
content: '';
display: block;
/* #endif */
width: 13px;
height: 1px;
background: #909399;
transform: rotate(-90deg);
}
</style>
...@@ -19,12 +19,12 @@ ...@@ -19,12 +19,12 @@
} }
}, { }, {
"path": "uni_modules/uni-login-page/pages/index/index", "path": "uni_modules/uni-login-page/pages/index/index",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"app-plus": { "app-plus": {
"animationType": "none", "animationType": "none",
"popGesture": "none", "popGesture": "none",
"navigationStyle": "custom", "navigationStyle": "custom",
"backgroundColor": "transparent" "backgroundColor": "transparent"
// "titleNView": { // "titleNView": {
// "buttons": [{ // "buttons": [{
...@@ -67,17 +67,17 @@ ...@@ -67,17 +67,17 @@
"navigationStyle": "custom" "navigationStyle": "custom"
} }
}, { }, {
"path": "uni_modules/opendb-feedback/pages/opendb-feedback/list", "path": "uni_modules/uni-feedback/pages/opendb-feedback/list",
"style": { "style": {
"navigationBarTitleText": "常见问题" "navigationBarTitleText": "常见问题"
} }
}, { }, {
"path": "uni_modules/opendb-feedback/pages/opendb-feedback/add", "path": "uni_modules/uni-feedback/pages/opendb-feedback/add",
"style": { "style": {
"navigationBarTitleText": "问题反馈" "navigationBarTitleText": "问题反馈"
} }
}, { }, {
"path": "uni_modules/opendb-feedback/pages/opendb-feedback/detail", "path": "uni_modules/uni-feedback/pages/opendb-feedback/detail",
"style": { "style": {
"navigationBarTitleText": "问题反馈" "navigationBarTitleText": "问题反馈"
} }
...@@ -127,7 +127,8 @@ ...@@ -127,7 +127,8 @@
} }
}, { }, {
"path": "pages/ucenter/edit/edit", "path": "uni_modules/uni-id-users/pages/uni-id-users/edit",
// "path": "pages/ucenter/edit/edit",
"style": { "style": {
"navigationBarTitleText": "编辑资料" "navigationBarTitleText": "编辑资料"
} }
...@@ -137,49 +138,19 @@ ...@@ -137,49 +138,19 @@
"navigationStyle": "custom" "navigationStyle": "custom"
} }
}, { }, {
"path": "uni_modules/uni-login-page/pages/index/pwd-login", "path": "uni_modules/uni-login-page/pages/pwd-login/pwd-login",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": ""
"app-plus": {
// "titleNView": {
// "buttons": [{
// "text": "帮助",
// "type": "none",
// "fontSize": "16px",
// "width": "60px"
// }]
// }
}
} }
}, { }, {
"path": "uni_modules/uni-login-page/pages/index/pwd-retrieve", "path": "uni_modules/uni-login-page/pages/pwd-retrieve/pwd-retrieve",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": ""
"app-plus": {
// "titleNView": {
// "buttons": [{
// "text": "帮助",
// "type": "none",
// "fontSize": "16px",
// "width": "60px"
// }]
// }
}
} }
}, { }, {
"path": "uni_modules/uni-login-page/pages/index/phone-code", "path": "uni_modules/uni-login-page/pages/phone-code/phone-code",
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": ""
"app-plus": {
// "titleNView": {
// "buttons": [{
// "text": "帮助",
// "type": "none",
// "fontSize": "16px",
// "width": "60px"
// }]
// }
}
} }
}, { }, {
...@@ -190,24 +161,24 @@ ...@@ -190,24 +161,24 @@
} }
} }
,{ ,{
"path" : "pages/test/test", "path" : "pages/test/test",
"style" : "style" :
{ {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
} }
,{ ,{
"path" : "pages/common/webview/webview", "path" : "pages/common/webview/webview",
"style" : "style" :
{ {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
} }
], ],
"globalStyle": { "globalStyle": {
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",
...@@ -215,6 +186,7 @@ ...@@ -215,6 +186,7 @@
"navigationBarBackgroundColor": "#FFFFFF", "navigationBarBackgroundColor": "#FFFFFF",
"backgroundColor": "#F8F8F8" "backgroundColor": "#F8F8F8"
}, },
<<<<<<< HEAD
// "condition": { // "condition": {
// "list": [ // "list": [
// { // {
...@@ -229,6 +201,22 @@ ...@@ -229,6 +201,22 @@
// ], // ],
// "current":1 // "current":1
// }, // },
=======
"condition": {
"list": [
{
"path": "uni_modules/uni-login-page/pages/index/index"
},
{
"path": "pages/test/test"
},
{
"path":"pages/ucenter/settings/settings"
}
],
"current":2
},
>>>>>>> 82ef1c53dc0aebef37985e23752a43c7aab5b82e
"tabBar": { "tabBar": {
"color": "#7A7E83", "color": "#7A7E83",
"selectedColor": "#007AFF", "selectedColor": "#007AFF",
...@@ -251,4 +239,4 @@ ...@@ -251,4 +239,4 @@
"text": "我的" "text": "我的"
}] }]
} }
} }
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
DB Schema 规范:https://uniapp.dcloud.net.cn/uniCloud/schema DB Schema 规范:https://uniapp.dcloud.net.cn/uniCloud/schema
--> -->
<view class="article"> <view class="article">
<uni-nav-bar :statusBar="true" :border="false"></uni-nav-bar>
<unicloud-db v-slot:default="{data, loading, error, options}" :options="formData" :collection="collection" :field="field" <unicloud-db v-slot:default="{data, loading, error, options}" :options="formData" :collection="collection" :field="field"
:getone="true" :where="where" :manual="true" ref="detail" foreignKey="opendb-news-articles.author" @load="loadData"> :getone="true" :where="where" :manual="true" ref="detail" foreignKey="opendb-news-articles.author" @load="loadData">
<template v-if="!loading && data"> <template v-if="!loading && data">
......
<template> <template>
<view style="overflow: hidden;"> <view style="overflow: hidden;">
<!-- 页面主列表 --> <!-- 页面主列表 -->
<news-list ref="newsList" :canSearch="canSearch" :currentText="searchText"></news-list> <news-list ref="newsList" :canSearch="canSearch" :currentText="searchText"></news-list>
<uni-agree></uni-agree>
</view> </view>
</template> </template>
......
<template>
<view class="content">
<uni-list>
<uni-list-item>
<template v-slot:body>
<view class="avatar-box">
<image class="avatar-img" :src="(userInfo && userInfo.avatar) || '/static/uni-center/logo.png'" @click="chooseImg" mode="aspectFill"></image>
</view>
</template>
</uni-list-item>
<uni-list-item title="姓名" :right-text="userInfo && userInfo.name"></uni-list-item>
</uni-list>
</view>
</template>
<script>
import {
mapGetters,
mapMutations
} from 'vuex';
const db = uniCloud.database();
const userTable = db.collection('uni-id-users')
export default {
data() {
return {
}
},
computed: {
...mapGetters({
userInfo: 'user/info'
})
},
onLoad() {
if(!this.userInfo)console.error('判断登录状态,如果没有登录则没有userinfo,页面报错');
},
methods: {
...mapMutations({
login:'user/login'
}),
// 选择图片
chooseImg(){
uni.chooseImage({
count:1,
success:(res)=> {
uni.$on('uploadAvatarAfter', ({url})=>{
console.log(url);
this.uploadUserInfo({avatar:url});
})
let options = {
width:600,
height:600
}
uni.navigateTo({
url:'./uploadCutImageToUnicloud?path=' + res.tempFilePaths[0] + `&options=${JSON.stringify(options)}`,
animationType:"fade-in"
});
}
})
},
/**
* @param {Object} data 更新用户信息
* key 需要更新的用户字段
* value 更新后的用户字段值
*/
uploadUserInfo(data){
console.log(this.userInfo._id)
userTable.doc(this.userInfo._id)
.update(data)
.then(res=>{
console.log(data)
this.login(data)
})
.catch(err=>{
console.log(err);
})
}
}
}
</script>
<style>
.content{
width: 750rpx;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
/* align-items: center; */
flex: 1;
}
.avatar-box{
width: 700rpx;
height: 200rpx;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
}
.avatar-img{
width: 150rpx;
height: 150rpx;
border-radius: 75rpx;
border: #F8F8F8 solid 1px;
}
</style>
...@@ -17,15 +17,15 @@ export default { ...@@ -17,15 +17,15 @@ export default {
}, },
methods:{ methods:{
successFn(e){ successFn(e){
uni.getImageInfo({ // uni.getImageInfo({
src:e.url, // src:e.url,
complete: (e) => { // complete: (e) => {
console.log(e); // console.log(e);
} // }
}) // })
this.uploadImgToUnicloud(e.url,(url)=>{ this.uploadImgToUnicloud(e.url,(url)=>{
//console.log(url); //console.log(url);
uni.$emit('uploadAvatarAfter', {url}); this.getOpenerEventChannel().emit('uploadAvatarAfter', {url})
uni.navigateBack() uni.navigateBack()
}) })
}, },
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
}), }),
toEdit(){ toEdit(){
uni.navigateTo({ uni.navigateTo({
url: '/pages/ucenter/edit/edit' url: '/uni_modules/uni-id-users/pages/uni-id-users/edit'
}); });
}, },
changePwd(){ changePwd(){
...@@ -142,8 +142,9 @@ ...@@ -142,8 +142,9 @@
}); });
}, },
fail:(err)=> { fail:(err)=> {
console.log(`认证失败:${err.errCode}`);
uni.showToast({ uni.showToast({
title: `认证失败:${err.errCode}`, title: `认证失败`,
icon: 'none' icon: 'none'
}); });
} }
......
...@@ -72,10 +72,14 @@ ...@@ -72,10 +72,14 @@
event: 'checkVersion', event: 'checkVersion',
showBadge: true showBadge: true
}, },
{
title:'去评分',
event:'gotoMarket'
},
//#endif //#endif
{ {
title: '反馈', title: '问题与反馈',
to: '/uni_modules/opendb-feedback/pages/opendb-feedback/list' // /pages/ucenter/uni-feedback/uni-feedback uni_modules/opendb-feedback/pages/opendb-feedback/list to: '/uni_modules/uni-feedback/pages/opendb-feedback/list' // /pages/ucenter/uni-feedback/uni-feedback uni_modules/uni-feedback/pages/opendb-feedback/list
},{ },{
title: '关于', title: '关于',
to: '/pages/ucenter/about/about' to: '/pages/ucenter/about/about'
...@@ -96,11 +100,11 @@ ...@@ -96,11 +100,11 @@
methods: { methods: {
...mapMutations({ ...mapMutations({
logout: 'user/logout' logout: 'user/logout'
}), }),
toSettings(){ toSettings(){
uni.navigateTo({ uni.navigateTo({
url:"/pages/ucenter/settings/settings" url:"/pages/ucenter/settings/settings"
}) })
}, },
/** /**
* 个人中心项目列表点击事件 * 个人中心项目列表点击事件
...@@ -131,6 +135,26 @@ ...@@ -131,6 +135,26 @@
title: '你点击了,第' + (index+1) + '', title: '你点击了,第' + (index+1) + '',
icon: 'none' icon: 'none'
}); });
},
/**
* 去应用市场评分
*/
gotoMarket(){
// #ifdef APP-PLUS
if (uni.getSystemInfoSync().platform == "ios") {
// 这里填写appstore应用id
let appstoreid = 'id1417078253';
plus.runtime.openURL("itms-apps://" + 'itunes.apple.com/cn/app/wechat/'+appstoreid+'?mt=8');
}
if (uni.getSystemInfoSync().platform == "android") {
var Uri = plus.android.importClass("android.net.Uri");
var uri = Uri.parse("market://details?id=" + plus.runtime.appid );
var Intent = plus.android.importClass('android.content.Intent');
var intent = new Intent(Intent.ACTION_VIEW, uri);
var main = plus.android.runtimeMainActivity();
main.startActivity(intent);
}
// #endif
} }
} }
} }
...@@ -275,4 +299,4 @@ ...@@ -275,4 +299,4 @@
/* #endif */ /* #endif */
background-color: #DD524D; background-color: #DD524D;
} }
</style> </style>
## 0.3.1(2021-04-15)
- 修复 本地数据概率无法回显时问题
## 0.3.0(2021-04-07)
- 新增 支持云端非树形表结构数据
- 修复 根节点 parent_field 字段等于null时选择界面错乱问题
## 0.2.0(2021-03-15) ## 0.2.0(2021-03-15)
- 修复 nodeclick、popupopened、popupclosed事件无法触发的问题 - 修复 nodeclick、popupopened、popupclosed事件无法触发的问题
## 0.1.9(2021-03-09) ## 0.1.9(2021-03-09)
......
...@@ -105,7 +105,11 @@ export default { ...@@ -105,7 +105,11 @@ export default {
return this.localdata.length > 0 return this.localdata.length > 0
}, },
postField() { postField() {
return `${this.field}, ${this.parentField} as parent_value` let fields = [this.field];
if (this.parentField) {
fields.push(`${this.parentField} as parent_value`);
}
return fields.join(',');
} }
}, },
created() { created() {
...@@ -192,6 +196,23 @@ export default { ...@@ -192,6 +196,23 @@ export default {
return db return db
}, },
getNodeData(callback) {
if (this.loading) {
return
}
this.loading = true
this.getCommand({
field: this.postField,
where: this._pathWhere()
}).then((res) => {
this.loading = false
this.selected = res.result.data
callback && callback()
}).catch((err) => {
this.loading = false
this.errorMessage = err
})
},
getTreePath(callback) { getTreePath(callback) {
if (this.loading) { if (this.loading) {
return return
...@@ -280,13 +301,29 @@ export default { ...@@ -280,13 +301,29 @@ export default {
this.errorMessage = err this.errorMessage = err
}) })
}, },
_pathWhere() {
let result = []
let where_field = this._getParentNameByField();
if (where_field) {
result.push(`${where_field} == '${this.value}'`)
}
if (this.where) {
return `(${this.where}) && (${result.join(' || ')})`
}
return result.join(' || ')
},
_postWhere() { _postWhere() {
let result = [] let result = []
let selected = this.selected let selected = this.selected
result.push(`${this.parentField} == null`) let parentField = this.parentField
if (parentField) {
result.push(`${parentField} == null || ${parentField} == ""`)
}
if (selected.length) { if (selected.length) {
for (var i = 0; i < selected.length - 1; i++) { for (var i = 0; i < selected.length - 1; i++) {
result.push(`${this.parentField} == '${selected[i].value}'`) result.push(`${parentField} == '${selected[i].value}'`)
} }
} }
...@@ -309,6 +346,24 @@ export default { ...@@ -309,6 +346,24 @@ export default {
return result.join(' || ') return result.join(' || ')
}, },
_getParentNameByField() {
const fields = this.field.split(',');
let where_field = null;
for (let i = 0; i < fields.length; i++) {
const items = fields[i].split('as');
if (items.length < 2) {
continue;
}
if (items[1].trim() === 'value') {
where_field = items[0].trim();
break;
}
}
return where_field
},
_isTreeView() {
return (this.parentField && this.selfField)
},
_updateSelected() { _updateSelected() {
var dl = this.dataList var dl = this.dataList
var sl = this.selected var sl = this.selected
...@@ -388,7 +443,7 @@ export default { ...@@ -388,7 +443,7 @@ export default {
child[key] = node[key] child[key] = node[key]
} }
} }
if (parent_value !== null) { if (parent_value !== undefined) {
child.parent_value = parent_value child.parent_value = parent_value
} }
result.push(child) result.push(child)
......
...@@ -110,6 +110,11 @@ ...@@ -110,6 +110,11 @@
hasNodes hasNodes
} = this._updateBindData() } = this._updateBindData()
if (!this._isTreeView()) {
this.onSelectedChange(node, true)
return
}
if (this.isLocaldata && (!hasNodes || isleaf)) { if (this.isLocaldata && (!hasNodes || isleaf)) {
this.onSelectedChange(node, true) this.onSelectedChange(node, true)
return return
......
{ {
"id": "uni-data-picker", "id": "uni-data-picker",
"displayName": "DataPicker 数据驱动的picker选择器", "displayName": "DataPicker 数据驱动的picker选择器",
"version": "0.2.0", "version": "0.3.1",
"description": "Picker选择器", "description": "Picker选择器",
"keywords": [ "keywords": [
"", "",
......
## DataPicker 级联选择 ## DataPicker 级联选择
> **组件名:uni-data-picker**
> 代码块: `uDataPicker` > 代码块: `uDataPicker`
> 关联组件:`uni-data-pickerview`、`uni-load-more`。 > 关联组件:`uni-data-pickerview`、`uni-load-more`。
...@@ -18,6 +19,7 @@ ...@@ -18,6 +19,7 @@
在uniCloud数据表中新建表“uni-id-address”和“opendb-city-china”,这2个表的schema自带foreignKey关联。在“uni-id-address”表的表结构页面使用schema2code生成前端页面,会自动生成地址管理的维护页面,自动从“opendb-city-china”表包含的中国所有省市区信息里选择地址。 在uniCloud数据表中新建表“uni-id-address”和“opendb-city-china”,这2个表的schema自带foreignKey关联。在“uni-id-address”表的表结构页面使用schema2code生成前端页面,会自动生成地址管理的维护页面,自动从“opendb-city-china”表包含的中国所有省市区信息里选择地址。
> **注意事项**
> 为了避免错误使用,给大家带来不好的开发体验,请在使用组件前仔细阅读下面的注意事项,可以帮你避免一些错误。 > 为了避免错误使用,给大家带来不好的开发体验,请在使用组件前仔细阅读下面的注意事项,可以帮你避免一些错误。
> - 组件需要依赖 `sass` 插件 ,请自行手动安装 > - 组件需要依赖 `sass` 插件 ,请自行手动安装
> - 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839 > - 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
...@@ -50,11 +52,12 @@ ...@@ -50,11 +52,12 @@
|parent-field |String | | |分步查询时父字段名称| |parent-field |String | | |分步查询时父字段名称|
|collection |String | | |表名。支持输入多个表名,用 `,` 分割| |collection |String | | |表名。支持输入多个表名,用 `,` 分割|
|field |String | | |查询字段,多个字段用 `,` 分割| |field |String | | |查询字段,多个字段用 `,` 分割|
|where |String | | |查询条件,内容较多,另见jql文档:[详情](https://uniapp.dcloud.net.cn/uniCloud/unicloud-db?id=jsquery)| |where |String | | |查询条件,内容较多,另见jql文档:[详情](https://uniapp.dcloud.net.cn/uniCloud/uni-clientDB?id=jsquery)|
|orderby |String | | |排序字段及正序倒叙设置| |orderby |String | | |排序字段及正序倒叙设置|
|popup-title |String | | |弹出层标题| |popup-title |String | | |弹出层标题|
> ****
> `collection/where/orderby` 和 `<unicloud-db>` 的用法一致,[详情](https://uniapp.dcloud.net.cn/uniCloud/unicloud-db) > `collection/where/orderby` 和 `<unicloud-db>` 的用法一致,[详情](https://uniapp.dcloud.net.cn/uniCloud/unicloud-db)
...@@ -75,6 +78,7 @@ ...@@ -75,6 +78,7 @@
#### 云端数据 #### 云端数据
> **注意事项**
> - 云端数据需要关联服务空间 > - 云端数据需要关联服务空间
> - 下面示例中使用的表 `opendb-city-china`(中国城市省市区数据,含港澳台), 在[uniCloud控制台](https://unicloud.dcloud.net.cn/)使用opendb创建,[详情](https://gitee.com/dcloud/opendb) > - 下面示例中使用的表 `opendb-city-china`(中国城市省市区数据,含港澳台), 在[uniCloud控制台](https://unicloud.dcloud.net.cn/)使用opendb创建,[详情](https://gitee.com/dcloud/opendb)
...@@ -82,12 +86,14 @@ ...@@ -82,12 +86,14 @@
```html ```html
<template> <template>
<view> <view>
<uni-data-picker placeholder="请选择地址" popup-title="请选择城市" collection="opendb-city-china" field="code as value, name as text" orderby="value asc" :step-searh="true" :self-field="code" parent-field="parent_code" <uni-data-picker placeholder="请选择地址" popup-title="请选择城市" collection="opendb-city-china" field="code as value, name as text" orderby="value asc" :step-searh="true" self-field="code" parent-field="parent_code"
@change="onchange" @nodeclick="onnodeclick"> @change="onchange" @nodeclick="onnodeclick">
</uni-data-picker> </uni-data-picker>
</view> </view>
</template> </template>
```
```js
<script> <script>
export default { export default {
data() { data() {
...@@ -117,7 +123,9 @@ ...@@ -117,7 +123,9 @@
<uni-data-picker :localdata="items" popup-title="请选择班级" @change="onchange" @nodeclick="onnodeclick"></uni-data-picker> <uni-data-picker :localdata="items" popup-title="请选择班级" @change="onchange" @nodeclick="onnodeclick"></uni-data-picker>
</view> </view>
</template> </template>
```
```js
<script> <script>
export default { export default {
data() { data() {
...@@ -178,6 +186,7 @@ ...@@ -178,6 +186,7 @@
``` ```
> **注意事项**
> `localdata` 和 `collection` 同时配置时,`localdata` 优先 > `localdata` 和 `collection` 同时配置时,`localdata` 优先
...@@ -192,7 +201,9 @@ ...@@ -192,7 +201,9 @@
</uni-data-picker> </uni-data-picker>
</view> </view>
</template> </template>
```
```js
<script> <script>
export default { export default {
data() { data() {
......
...@@ -221,7 +221,8 @@ ...@@ -221,7 +221,8 @@
} }
.feedback-uploader { .feedback-uploader {
padding: 22rpx 20rpx; padding: 22rpx 20rpx;
padding-left: 0;
} }
.feedback-star { .feedback-star {
...@@ -251,5 +252,11 @@ ...@@ -251,5 +252,11 @@
color: #FFFFFF; color: #FFFFFF;
margin: 20rpx; margin: 20rpx;
} }
.uni-uploader-title{
text-align: right;
flex: 1;
color: #B2B2B2;
padding-right: 10rpx;
}
</style> </style>
<template> <template>
<view class="uni-container"> <view class="uni-container">
<uni-forms ref="form" :value="formData" :rules="rules" validate-trigger="submit" err-show-type="toast"> <uni-forms ref="form" :value="formData" :rules="rules" validate-trigger="submit" err-show-type="toast">
<!-- <uni-forms-item name="user_id" label=""> <uni-forms-item name="content" label="反馈内容" required>
<uni-easyinput placeholder="留言反馈用户ID/回复留言用户ID,参考uni-id-users表" v-model="formData.user_id" />
</uni-forms-item> -->
<!-- <uni-forms-item name="create_date" label="">
<uni-datetime-picker return-type="timestamp" :value="formData.create_date" />
</uni-forms-item> -->
<uni-forms-item name="content" label="反馈内容">
<uni-easyinput placeholder="请输入反馈内容" type="textarea" v-model="formData.content" trim="right" /> <uni-easyinput placeholder="请输入反馈内容" type="textarea" v-model="formData.content" trim="right" />
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="imgs" label="反馈截图"> <uni-forms-item name="imgs" label="反馈截图">
<!-- <uni-data-checkbox :multiple="true" v-model="formData.imgs" /> -->
<feedback-imgs :isChoose="true" :imgs="formData.imgs" @close="close" @chooseImg="chooseImg"></feedback-imgs> <feedback-imgs :isChoose="true" :imgs="formData.imgs" @close="close" @chooseImg="chooseImg"></feedback-imgs>
</uni-forms-item> </uni-forms-item>
<!-- <uni-forms-item name="is_reply" label=""> <uni-forms-item name="contact" label="联系人" required>
<switch @change="binddata('is_reply', $event.detail.value)" :checked="formData.is_reply" />
</uni-forms-item> -->
<!-- <uni-forms-item name="feedback_id" label="">
<uni-easyinput placeholder="被回复留言ID" v-model="formData.feedback_id" />
</uni-forms-item> -->
<uni-forms-item name="contact" label="联系人">
<uni-easyinput placeholder="请输入联系人" v-model="formData.contact" trim="both" /> <uni-easyinput placeholder="请输入联系人" v-model="formData.contact" trim="both" />
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="mobile" label="联系方式"> <uni-forms-item name="mobile" label="联系方式" required>
<uni-easyinput placeholder="请输入手机号/邮箱" v-model="formData.mobile" trim="both" /> <uni-easyinput placeholder="请输入手机号/邮箱" v-model="formData.mobile" trim="both" />
</uni-forms-item> </uni-forms-item>
<!-- <uni-forms-item name="reply_count" label="">
<uni-easyinput placeholder="被回复条数" type="number" v-model="formData.reply_count" />
</uni-forms-item> -->
<view class="uni-button-group"> <view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button> <button type="primary" class="uni-button" @click="submit">提交</button>
...@@ -122,13 +106,14 @@ ...@@ -122,13 +106,14 @@
}, },
submitForm(value) { submitForm(value) {
// 使用 clientDB 提交数据 // 使用 clientDB 提交数据
db.collection(dbCollectionName).add(value).then((res) => { db.collection(dbCollectionName).add(value).then((res) => {
uni.showToast({ uni.showModal({
icon: 'none', title: '您的反馈已经提交成功,请耐心等待。',
title: '反馈成功' showCancel: false,
}) success: res => {
this.getOpenerEventChannel().emit('refreshData') uni.navigateBack()
setTimeout(() => uni.navigateBack(), 500) },
});
}).catch((err) => { }).catch((err) => {
uni.showModal({ uni.showModal({
content: err.message || '反馈失败', content: err.message || '反馈失败',
......
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"avatar": {
"rules": [{
"format": "string"
}],
"label": "头像地址"
},
"gender": {
"rules": [{
"format": "int"
},
{
"range": [{
"text": "未知",
"value": 0
},
{
"text": "",
"value": 1
},
{
"text": "",
"value": 2
}
]
}
],
"defaultValue": 0,
"label": "性别"
},
"mobile": {
"rules": [{
"format": "string"
},
{
"pattern": "^\\+?[0-9-]{3,20}$"
}
],
"label": "手机号码"
},
"nickname": {
"rules": [{
required: true,
errorMessage: '请输入昵称',
},
{
minLength: 3,
maxLength: 10,
errorMessage: '昵称长度在 {minLength} 到 {maxLength} 个字符',
}
],
"label": "昵称"
}
}
const enumConverter = {
"gender_valuetotext": {
"0": "未知",
"1": "",
"2": ""
}
}
export {
validator,
enumConverter
}
{
"id": "uni-id-users",
"displayName": "uni-id-users",
"version": "1.0.0",
"description": "",
"keywords": [
"uni-id-users"
],
"repository": "",
"engines": {
"HBuilderX": "^3.1.0"
},
"dcloudext": {
"category": [
"uniCloud",
"Admin插件"
],
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [
"uni-dateformat",
"uni-badge",
"uni-icons",
"uni-load-more",
"uni-link",
"uni-forms",
"uni-group",
"uni-list",
"uni-fab",
"uni-datetime-picker",
"uni-data-picker",
"uni-file-picker",
"uni-easyinput",
"uni-data-checkbox"
],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"App": {
"app-vue": "y",
"app-nvue": "u"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "u",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}
\ No newline at end of file
<template>
<view class="uni-container">
<uni-forms ref="form" :value="formData" :rules="rules" validate-trigger="submit" err-show-type="toast">
<uni-list-item>
<template v-slot:body>
<view class="avatar-box">
<image class="avatar-img" :src="formData.avatar || '/static/uni-center/logo.png'" @click="chooseImg" mode="aspectFill"></image>
</view>
</template>
</uni-list-item>
<uni-forms-item name="gender" label="性别" required>
<uni-data-checkbox v-model="formData.gender" :localdata="formOptions.gender_localdata" />
</uni-forms-item>
<uni-forms-item name="mobile" label="手机号码" required>
<uni-easyinput placeholder="手机号码" :disabled="true" v-model="formData.mobile" trim="both" />
</uni-forms-item>
<uni-forms-item name="nickname" label="昵称" required>
<uni-easyinput placeholder="用户昵称" v-model="formData.nickname" trim="both" />
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">修改</button>
</view>
</uni-forms>
</view>
</template>
<script>
import {
validator
} from '../../js_sdk/validator/uni-id-users.js';
import {
mapMutations
} from 'vuex';
const db = uniCloud.database();
const dbCollectionName = 'uni-id-users';
function getValidator(fields) {
let reuslt = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
reuslt[key] = validator[key]
}
}
return reuslt
}
export default {
data() {
return {
formData: {
"avatar": "",
"gender": 1,
"mobile": "",
"nickname": ""
},
formOptions: {
"gender_localdata": [{
"text": "",
"value": 1
},
{
"text": "",
"value": 2
}
]
},
rules: {
...getValidator(["avatar", "gender", "mobile", "nickname"])
}
}
},
onLoad(e) {
let id = "60795c140983f8000192f235";
id = uni.getStorageSync('uni_id_uid');
this.formDataId = id
this.getDetail(id)
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
...mapMutations({
setUserInfo:'user/login'
}),
// 选择图片
chooseImg(){
uni.chooseImage({
count:1,
success:(res)=> {
// 头像剪裁尺寸
let options = {
width:600,
height:600
}
uni.navigateTo({
url: '/pages/ucenter/edit/uploadCutImageToUnicloud',
success: res => {},
fail: () => {},
complete: () => {}
});
// 剪裁并上传头像
uni.navigateTo({
url:'/pages/ucenter/edit/uploadCutImageToUnicloud?path=' + res.tempFilePaths[0] + `&options=${JSON.stringify(options)}`,
animationType:"fade-in",
events:{
uploadAvatarAfter:({url})=>{
this.formData.avatar = url;
this.submitForm({avatar:url});
}
}
});
}
})
},
/**
* 触发表单提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.submit().then((res) => {
console.log(res);
this.submitForm(res)
}).catch((errors) => {
uni.hideLoading()
})
},
submitForm(value) {
// 使用 clientDB 提交数据
db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => {
uni.showToast({
icon: 'none',
title: '修改成功'
})
this.setUserInfo(value);
// this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
}).finally(() => {
uni.hideLoading()
})
},
/**
* 获取表单数据
* @param {Object} id
*/
getDetail(id) {
uni.showLoading({
mask: true
})
db.collection(dbCollectionName).doc(id).field('avatar,gender,mobile,nickname').get().then((res) => {
const data = res.result.data[0]
if (data) {
this.formData = data
}
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
}).finally(() => {
uni.hideLoading()
})
}
}
}
</script>
<style>
.uni-container {
padding: 15px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
display: flex;
justify-content: center;
align-items: center;
}
.uni-button {
width: 184px;
padding: 12px 20px;
font-size: 14px;
border-radius: 4px;
line-height: 1;
margin: 0;
}
.avatar-box{
width: 700rpx;
height: 200rpx;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
}
.avatar-img{
width: 150rpx;
height: 150rpx;
border-radius: 75rpx;
border: #F8F8F8 solid 3px;
}
</style>
...@@ -370,7 +370,7 @@ $list-item-pd: $uni-spacing-col-lg $uni-spacing-row-lg; ...@@ -370,7 +370,7 @@ $list-item-pd: $uni-spacing-col-lg $uni-spacing-row-lg;
/* #endif */ /* #endif */
height: $uni-img-size-base; height: $uni-img-size-base;
width: $uni-img-size-base; width: $uni-img-size-base;
margin-right: 10px; marin-right: 10px;
} }
.uni-icon-wrapper { .uni-icon-wrapper {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册