一、模糊查询
使用
<select id="selectByPhone" parameterType="String" resultMap="BaseResultMap">
select * from auth_user where phone like '%' #{phone} '%'
</select>
或使用
<select id="selectByPhone" parameterType="String" resultMap="BaseResultMap">
select * from auth_user where phone like %${0}%
</select>
二、页面带参数跳转
在前一个页面:
uni.redirectTo({
url:'./user_update?id='+ id
})
后一个页面:
使用onLoad接收,在页面跳转时运行
onLoad:function(res){
this.id = res.id
}
或
onLoad(options) {
options.id
}
三、如何修改中文乱码问题
在yml文件中的jdbc中url上添加&characterEncoding=utf-8&useSSL=false
url: jdbc:mysql://39.107.35.145:3306/rz_cms?serverTimezone=UTC&characterEncoding=utf-8&useSSL=false
四、用户添加
<template>
<view >
<uni-nav-bar backgroundColor="#ffffff" title="睿智法务用户添加界面" leftText="返回"
@clickLeft="clickLect" rightText="保存" @clickRight="clickRight" ></uni-nav-bar>
<view style=" margin-left: auto; margin-right: auto; margin-top: 80rpx;">
<uni-group mode="card" top="10" title="用户管理系统:用户添加">
手机号<input singleline='true' placeholder="请输入手机号" type="number" class="input_str" v-model="phone"/>
昵称<input singleline='true' placeholder="请输入昵称" type="text" class="input_str" v-model="nickName"/>
</uni-group>
<uni-popup ref="alertDialog" type="message">
<uni-popup-message :message='msg' type="warning"></uni-popup-message>
</uni-popup>
</view>
</view>
</template>
<script>
export default{
data(){
//数据
return{
msg:'',
phone:'',
pwd:'123123',
nickName:'',
sculpture:'',
}
},
methods:{
clickLect(){
uni.redirectTo({
url:'./user'
})
},
clickRight(){
uni.request({
url: 'http://localhost:8070/auth/user/regedit/'+this.phone + '/' + this.pwd + '/' + this.nickName, //仅为示例,并非真实接口地址。
success: (res) => {
if(res.data.code == 200){
uni.redirectTo({
url:'./user'
})
}else{
this.msg = res.data.message,
this.$refs.alertDialog.open()
}
}
});
},
upload(){
this.$refs.files.upload()
}
}
}
</script>
<style>
.input_str{
border: 2px solid #000000;
border-radius: 10rpx; height: 30rpx;
line-height: 30rpx;
padding: 10rpx; margin-bottom: 15rpx;
}
</style>
五、用户修改
<template>
<view>
<uni-nav-bar backgroundColor="#ffffff" title="睿智法务用户修改界面" leftText="返回"
@clickLeft="clickLect" rightText="保存" @clickRight="clickRight" ></uni-nav-bar>
<view style="margin-left: auto;
margin-right: auto; margin-top: 80rpx;">
<uni-group mode="card" top="10" title="用户管理系统:用户修改" >
手机号:<input singleline='true' placeholder="请输入手机号" type="number" class="input_str" v-model="phone"/>
昵称:<input singleline='true' placeholder="请输入昵称" type="text" class="input_str" v-model="nickname"/>
</uni-group>
<uni-popup ref="alertDialog" type="message">
<uni-popup-message :message='msg' type="warning"></uni-popup-message>
</uni-popup>
</view>
</view>
</template>
<script>
export default{
data(){
return{
id:'',
phone:'',
pwd:'',
nickname:'',
sculpture:'',
msg:''
}
},
onLoad:function(res){
this.id = res.id
uni.request({
url:'http://localhost:8070/auth/user/getUserById/'+this.id,
success: (res) => {
if(res.data.code == 200){
this.phone = res.data.data.phone,
this.pwd = res.data.data.passwd,
this.nickname = res.data.data.nickname
}else{
this.msg = res.data.message,
this.$refs.alertDialog.open()
}
}
})
},
methods:{
clickLect(){
uni.redirectTo({
url:'./user'
})
},
clickRight(){
uni.request({
url:'http://localhost:8070/auth/user/modity/'+ this.id +'/'+this.phone +'/'+this.pwd+'/'+ this.nickname,
success: (res) => {
if(res.data.code == 200){
uni.redirectTo({
url:'./user'
})
}else{
this.msg = res.data.message,
this.$refs.alertDialog.open()
}
}
})
},
}
}
</script>
<style>
.input_str{
border: 2px solid #000000;
border-radius: 10rpx; height: 30rpx;
padding: 10rpx; margin-bottom: 15rpx;
}
</style>
六、table多选回显
this.$refs.roletable.toggleRowSelection(j,true)
j:对应的行的序号
true:selected的值(true代表选中,默认值为false
七、搜索栏
<uni-search-bar @input="input" @confirm="confirm" :radius="100"
style="margin-bottom: 15rpx;" bgColor="Pink"
@cancel="cancel" @clear="clear" placeholder='请输入手机号'></uni-search-bar>
<--@input 数据输入;@confirm 回车 ;@cancel 点击取消按钮 ;@clear 点击输入框最后的x号-->
clear(){
this.getUserList()
},
cancel(){
this.getUserList()
},
input(e){
},
confirm(res) {
uni.request({
url:'http://localhost:8070/auth/user/getUser/'+res.value,
success: (res) => {
this.userList = res.data.data
this.total = res.data.rows
}
})
},