对接登录接口、社区列表、村
parent
3a7ea01f18
commit
c4eee5d1af
2
App.vue
2
App.vue
|
@ -4,7 +4,7 @@
|
||||||
projectname:'', // 项目名称
|
projectname:'', // 项目名称
|
||||||
lat:'', // 公司地址维度
|
lat:'', // 公司地址维度
|
||||||
lng:'' ,// 公司地址经度
|
lng:'' ,// 公司地址经度
|
||||||
hostapi:'https://www.baidu.com' // 域名配置
|
hostapi:'https://minyitong.scdxtc.cn/api/' // 域名配置
|
||||||
},
|
},
|
||||||
// 优先于show方法
|
// 优先于show方法
|
||||||
onLaunch: function() {
|
onLaunch: function() {
|
||||||
|
|
|
@ -28,91 +28,50 @@
|
||||||
methods: {
|
methods: {
|
||||||
// 前往登录页
|
// 前往登录页
|
||||||
goLogin(){
|
goLogin(){
|
||||||
uni.navigateTo({
|
this.$toolAll.tools.showToast('正在登录...','none',10000)
|
||||||
url:'/pagesA/login/login'
|
uni.login({
|
||||||
})
|
provider: 'weixin',
|
||||||
// 群众入口
|
success: (rescode)=> {
|
||||||
// uni.navigateTo({
|
this.updateUserInfo(rescode.code);
|
||||||
// url:'/pagesA/my-opinion-list/my-opinion-list'
|
|
||||||
// })
|
|
||||||
// 社区入口
|
|
||||||
// uni.navigateTo({
|
|
||||||
// url:'/pagesA/community/opinion-handle/opinion-handle'
|
|
||||||
// })
|
|
||||||
// 管理员
|
|
||||||
// uni.navigateTo({
|
|
||||||
// url:'/pagesA/manager/examine-list/examine-list'
|
|
||||||
// })
|
|
||||||
},
|
|
||||||
//调起登录授权
|
|
||||||
bindGetUserInfo() {
|
|
||||||
if(!this.ifFlag){
|
|
||||||
this.$toolAll.tools.showToast('正在调起授权','none',6000);
|
|
||||||
this.ifFlag = true;
|
|
||||||
wx.getSetting({
|
|
||||||
success: (result)=> {
|
|
||||||
uni.hideToast();
|
|
||||||
// 判断是否授权
|
|
||||||
if (result.authSetting['scope.userInfo']) {
|
|
||||||
// 已授权
|
|
||||||
this.getUserInfoEv();
|
|
||||||
} else {
|
|
||||||
// 未授权
|
|
||||||
this.getUserInfoEv();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 获取用户信息事件
|
|
||||||
getUserInfoEv(){
|
|
||||||
// #ifdef MP-WEIXIN
|
|
||||||
// 微信新版获取用户信息方式(也可用于授权手机号)
|
|
||||||
wx.getUserProfile({
|
|
||||||
lang:'zh_CN',
|
|
||||||
desc:'获取亲的昵称、头像及性别',
|
|
||||||
success: (resEnd)=> {
|
|
||||||
//用户已经授权过,添加用户信息
|
|
||||||
uni.login({
|
|
||||||
provider: 'weixin',
|
|
||||||
success: (rescode)=> {
|
|
||||||
uni.reLaunch({
|
|
||||||
url:'/pagesA/passageway/passageway'
|
|
||||||
})
|
|
||||||
// this.updateUserInfo(rescode.code);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
complete: () => {
|
|
||||||
this.ifFlag = false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
// #endif
|
|
||||||
},
|
},
|
||||||
//调用登录接口
|
//调用登录接口
|
||||||
updateUserInfo(code) {
|
updateUserInfo(code) {
|
||||||
var params = {
|
var params = {
|
||||||
code:code,
|
code:code
|
||||||
nickname: this.userInfo.nickName,//用户昵称
|
|
||||||
headimgurl: this.userInfo.avatarUrl,//用户头像
|
|
||||||
country: this.userInfo.country,//用户所在国家
|
|
||||||
province: this.userInfo.province,//用户所在省份
|
|
||||||
city: this.userInfo.city,//用户所在城市
|
|
||||||
gender: this.userInfo.gender,//用户性别
|
|
||||||
language:this.userInfo.language,//语言
|
|
||||||
is_active:1
|
|
||||||
}
|
}
|
||||||
this.$requst.post('user/login',params).then(res => {
|
this.$requst.post('user/login',params).then(res => {
|
||||||
if(res.data.token!=''){
|
uni.hideToast();
|
||||||
if(uni.getStorageSync('urlparams')) {
|
if(res.code==0){
|
||||||
uni.reLaunch({ // 重新进入当前页面
|
let dataObj = res.data;
|
||||||
url:uni.getStorageSync('urlparams')
|
uni.setStorageSync('token',dataObj.token);
|
||||||
})
|
this.$toolAll.tools.showToast('登录成功');
|
||||||
} else {
|
setTimeout(()=>{
|
||||||
uni.reLaunch({
|
if(dataObj.utype=='def'){
|
||||||
url:'/pages/tabbar/pagehome/pagehome'
|
// 前往群众对应的列表页
|
||||||
})
|
uni.reLaunch({
|
||||||
}
|
url:'/pagesA/my-opinion-list/my-opinion-list'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if(dataObj.utype=='community_worker'){
|
||||||
|
// 前往社区对应的列表页
|
||||||
|
uni.reLaunch({
|
||||||
|
url:'/pagesA/community/opinion-handle/opinion-handle'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if(dataObj.utype=='app_manager'){
|
||||||
|
// 前往管理员对应的列表页
|
||||||
|
uni.reLaunch({
|
||||||
|
url:'/pagesA/manager/examine-list/examine-list'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},500)
|
||||||
|
} else {
|
||||||
|
// 前往授权登录
|
||||||
|
uni.navigateTo({
|
||||||
|
url:'/pagesA/login/login'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},error => {})
|
},error => {})
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,10 +52,7 @@
|
||||||
uni.login({
|
uni.login({
|
||||||
provider: 'weixin',
|
provider: 'weixin',
|
||||||
success: (rescode)=> {
|
success: (rescode)=> {
|
||||||
uni.reLaunch({
|
this.updateUserInfo(rescode.code);
|
||||||
url:'/pagesA/my-opinion-list/my-opinion-list'
|
|
||||||
})
|
|
||||||
// this.updateUserInfo(rescode.code);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -72,23 +69,34 @@
|
||||||
nickname: this.userInfo.nickName,//用户昵称
|
nickname: this.userInfo.nickName,//用户昵称
|
||||||
headimgurl: this.userInfo.avatarUrl,//用户头像
|
headimgurl: this.userInfo.avatarUrl,//用户头像
|
||||||
country: this.userInfo.country,//用户所在国家
|
country: this.userInfo.country,//用户所在国家
|
||||||
province: this.userInfo.province,//用户所在省份
|
|
||||||
city: this.userInfo.city,//用户所在城市
|
|
||||||
gender: this.userInfo.gender,//用户性别
|
gender: this.userInfo.gender,//用户性别
|
||||||
language:this.userInfo.language,//语言
|
language:this.userInfo.language,//语言
|
||||||
is_active:1
|
is_active:1
|
||||||
}
|
}
|
||||||
this.$requst.post('user/login',params).then(res => {
|
this.$requst.post('user/login',params).then(res => {
|
||||||
if(res.data.token!=''){
|
if(res.code==0){
|
||||||
if(uni.getStorageSync('urlparams')) {
|
// utype:['def' => '普通用户', 'community_worker' => '社区工作人员', 'community_secretary' => '社区书记', 'area_leader' => '片区领导', 'app_manager' => '小程序端管理员']
|
||||||
uni.reLaunch({ // 重新进入当前页面
|
// this.$store.commit('setRule',res.data.utype);
|
||||||
url:uni.getStorageSync('urlparams')
|
let dataObj = res.data;
|
||||||
})
|
uni.setStorageSync('token',dataObj.token);
|
||||||
} else {
|
if(dataObj.utype=='def'){
|
||||||
|
// 前往群众对应的列表页
|
||||||
uni.reLaunch({
|
uni.reLaunch({
|
||||||
url:'/pagesA/my-opinion-list/my-opinion-list'
|
url:'/pagesA/my-opinion-list/my-opinion-list'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if(dataObj.utype=='community_worker'){
|
||||||
|
// 前往社区对应的列表页
|
||||||
|
uni.reLaunch({
|
||||||
|
url:'/pagesA/community/opinion-handle/opinion-handle'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if(dataObj.utype=='app_manager'){
|
||||||
|
// 前往管理员对应的列表页
|
||||||
|
uni.reLaunch({
|
||||||
|
url:'/pagesA/manager/examine-list/examine-list'
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},error => {})
|
},error => {})
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,13 @@
|
||||||
methods: {
|
methods: {
|
||||||
// 切换事件
|
// 切换事件
|
||||||
switchEv(index){
|
switchEv(index){
|
||||||
|
console.log(index);
|
||||||
this.switchIndex = index;
|
this.switchIndex = index;
|
||||||
},
|
},
|
||||||
// 前往提交页面
|
// 前往提交页面
|
||||||
goOpinionSubmit(){
|
goOpinionSubmit(){
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url:'/pagesA/passageway/passageway'
|
url:'/pagesA/opinion-submit/opinion-submit'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 前往详情页
|
// 前往详情页
|
||||||
|
|
|
@ -11,20 +11,24 @@
|
||||||
<input class="fon30 col9 tright width100" type="text" maxlength="11" placeholder="请填写手机号码">
|
<input class="fon30 col9 tright width100" type="text" maxlength="11" placeholder="请填写手机号码">
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="disjbac fon30 bbot pad-sx30">
|
<picker mode="selector" :range="communityList" :value="communityIndex" @change="changeCommunity" :range-key="'name'">
|
||||||
<view class="colb bold flexs">社区</view>
|
<view class="disjbac fon30 bbot pad-sx30">
|
||||||
<view class="disac col9 width100 fe">
|
<view class="colb bold flexs">社区</view>
|
||||||
<view class="mar-y10">请选择社区</view>
|
<view class="disac col9 width100 fe">
|
||||||
<i class="icon icon-next fon24" style="margin-top: 6rpx;"></i>
|
<view class="mar-y10">{{communityText}}</view>
|
||||||
|
<i class="icon icon-next fon24" style="margin-top: 6rpx;"></i>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</picker>
|
||||||
<view class="disjbac fon30 bbot pad-sx30">
|
<picker mode="selector" :range="villageList" :value="villageIndex" @change="changeVillage" :range-key="'name'">
|
||||||
<view class="colb bold flexs">村</view>
|
<view class="disjbac fon30 bbot pad-sx30">
|
||||||
<view class="disac col9 width100 fe">
|
<view class="colb bold flexs">村</view>
|
||||||
<view class="mar-y10">请选择村</view>
|
<view class="disac col9 width100 fe">
|
||||||
<i class="icon icon-next fon24" style="margin-top: 6rpx;"></i>
|
<view class="mar-y10">{{villageText}}</view>
|
||||||
|
<i class="icon icon-next fon24" style="margin-top: 6rpx;"></i>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</picker>
|
||||||
<view class="dis fon30 bbot pad-sx30">
|
<view class="dis fon30 bbot pad-sx30">
|
||||||
<view class="colb bold flexs">图片上传</view>
|
<view class="colb bold flexs">图片上传</view>
|
||||||
<view class="disac col9 width100 fe fw">
|
<view class="disac col9 width100 fe fw">
|
||||||
|
@ -98,11 +102,20 @@
|
||||||
return {
|
return {
|
||||||
imgArr:[],
|
imgArr:[],
|
||||||
vedioArr:[],
|
vedioArr:[],
|
||||||
audioText:''
|
audioText:'',
|
||||||
|
communityList:[],//社区列表
|
||||||
|
communityIndex:0,//当前选中的社区
|
||||||
|
communityId:'',//社区id
|
||||||
|
communityText:'请选择社区',
|
||||||
|
villageList:[],//村列表
|
||||||
|
villageIndex:0,//当前选中的村
|
||||||
|
villageText:'请选择村',
|
||||||
|
villageId:'',//村id
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
|
// 调用查询社区列表事件
|
||||||
|
this.getCommunityList();
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
|
@ -110,10 +123,44 @@
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 选择社区
|
||||||
|
changeCommunity(e){
|
||||||
|
this.communityIndex = e.detail.value;
|
||||||
|
this.communityId = this.communityList[this.communityIndex].id;
|
||||||
|
this.communityText = this.communityList[this.communityIndex].name;
|
||||||
|
// 调用查询村列表事件
|
||||||
|
this.getVillageList(this.communityId);
|
||||||
|
},
|
||||||
|
// 社区查询
|
||||||
|
getCommunityList(){
|
||||||
|
this.$requst.get('common/communityList').then(res=>{
|
||||||
|
if(res.code==0){
|
||||||
|
this.communityList = res.data.list;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 选择村
|
||||||
|
changeVillage(e){
|
||||||
|
this.villageIndex = e.detail.value;
|
||||||
|
this.villageId = this.villageList[this.villageIndex].id;
|
||||||
|
this.villageText = this.villageList[this.villageIndex].name;
|
||||||
|
},
|
||||||
|
// 村查询
|
||||||
|
getVillageList(id){
|
||||||
|
this.$requst.get('common/villageList',{community_id:id}).then(res=>{
|
||||||
|
if(res.code==0){
|
||||||
|
this.villageList = res.data.list;
|
||||||
|
if(this.villageList.length){
|
||||||
|
this.villageId = this.villageList[0].id;
|
||||||
|
this.villageText = this.villageList[0].name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
// 提交事件
|
// 提交事件
|
||||||
submitEv(){
|
submitEv(){
|
||||||
uni.reLaunch({
|
uni.reLaunch({
|
||||||
url:'/pagesA/my-opinion-list/my-opinion-list'
|
url:'/pagesA/passageway/passageway'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 图片选择
|
// 图片选择
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
passagewayModeEv(index){
|
passagewayModeEv(index){
|
||||||
this.$store.commit('setAnonymous',[false,true][index])
|
this.$store.commit('setAnonymous',[false,true][index])
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url:`/pagesA/opinion-submit/opinion-submit?flag=${index==1}`
|
url:`/pagesA/opinion-submit/opinion-submit`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue