对接登录接口、社区列表、村
parent
3a7ea01f18
commit
c4eee5d1af
2
App.vue
2
App.vue
|
@ -4,7 +4,7 @@
|
|||
projectname:'', // 项目名称
|
||||
lat:'', // 公司地址维度
|
||||
lng:'' ,// 公司地址经度
|
||||
hostapi:'https://www.baidu.com' // 域名配置
|
||||
hostapi:'https://minyitong.scdxtc.cn/api/' // 域名配置
|
||||
},
|
||||
// 优先于show方法
|
||||
onLaunch: function() {
|
||||
|
|
|
@ -28,91 +28,50 @@
|
|||
methods: {
|
||||
// 前往登录页
|
||||
goLogin(){
|
||||
uni.navigateTo({
|
||||
url:'/pagesA/login/login'
|
||||
})
|
||||
// 群众入口
|
||||
// uni.navigateTo({
|
||||
// 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);
|
||||
},
|
||||
});
|
||||
this.$toolAll.tools.showToast('正在登录...','none',10000)
|
||||
uni.login({
|
||||
provider: 'weixin',
|
||||
success: (rescode)=> {
|
||||
this.updateUserInfo(rescode.code);
|
||||
},
|
||||
complete: () => {
|
||||
this.ifFlag = false;
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
},
|
||||
//调用登录接口
|
||||
updateUserInfo(code) {
|
||||
var params = {
|
||||
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
|
||||
code:code
|
||||
}
|
||||
this.$requst.post('user/login',params).then(res => {
|
||||
if(res.data.token!=''){
|
||||
if(uni.getStorageSync('urlparams')) {
|
||||
uni.reLaunch({ // 重新进入当前页面
|
||||
url:uni.getStorageSync('urlparams')
|
||||
})
|
||||
} else {
|
||||
uni.reLaunch({
|
||||
url:'/pages/tabbar/pagehome/pagehome'
|
||||
})
|
||||
}
|
||||
uni.hideToast();
|
||||
if(res.code==0){
|
||||
let dataObj = res.data;
|
||||
uni.setStorageSync('token',dataObj.token);
|
||||
this.$toolAll.tools.showToast('登录成功');
|
||||
setTimeout(()=>{
|
||||
if(dataObj.utype=='def'){
|
||||
// 前往群众对应的列表页
|
||||
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 => {})
|
||||
}
|
||||
|
|
|
@ -52,10 +52,7 @@
|
|||
uni.login({
|
||||
provider: 'weixin',
|
||||
success: (rescode)=> {
|
||||
uni.reLaunch({
|
||||
url:'/pagesA/my-opinion-list/my-opinion-list'
|
||||
})
|
||||
// this.updateUserInfo(rescode.code);
|
||||
this.updateUserInfo(rescode.code);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
@ -72,23 +69,34 @@
|
|||
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 => {
|
||||
if(res.data.token!=''){
|
||||
if(uni.getStorageSync('urlparams')) {
|
||||
uni.reLaunch({ // 重新进入当前页面
|
||||
url:uni.getStorageSync('urlparams')
|
||||
})
|
||||
} else {
|
||||
if(res.code==0){
|
||||
// utype:['def' => '普通用户', 'community_worker' => '社区工作人员', 'community_secretary' => '社区书记', 'area_leader' => '片区领导', 'app_manager' => '小程序端管理员']
|
||||
// this.$store.commit('setRule',res.data.utype);
|
||||
let dataObj = res.data;
|
||||
uni.setStorageSync('token',dataObj.token);
|
||||
if(dataObj.utype=='def'){
|
||||
// 前往群众对应的列表页
|
||||
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'
|
||||
})
|
||||
}
|
||||
}
|
||||
},error => {})
|
||||
}
|
||||
|
|
|
@ -51,12 +51,13 @@
|
|||
methods: {
|
||||
// 切换事件
|
||||
switchEv(index){
|
||||
console.log(index);
|
||||
this.switchIndex = index;
|
||||
},
|
||||
// 前往提交页面
|
||||
goOpinionSubmit(){
|
||||
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="请填写手机号码">
|
||||
</view>
|
||||
</view>
|
||||
<view class="disjbac fon30 bbot pad-sx30">
|
||||
<view class="colb bold flexs">社区</view>
|
||||
<view class="disac col9 width100 fe">
|
||||
<view class="mar-y10">请选择社区</view>
|
||||
<i class="icon icon-next fon24" style="margin-top: 6rpx;"></i>
|
||||
<picker mode="selector" :range="communityList" :value="communityIndex" @change="changeCommunity" :range-key="'name'">
|
||||
<view class="disjbac fon30 bbot pad-sx30">
|
||||
<view class="colb bold flexs">社区</view>
|
||||
<view class="disac col9 width100 fe">
|
||||
<view class="mar-y10">{{communityText}}</view>
|
||||
<i class="icon icon-next fon24" style="margin-top: 6rpx;"></i>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="disjbac fon30 bbot pad-sx30">
|
||||
<view class="colb bold flexs">村</view>
|
||||
<view class="disac col9 width100 fe">
|
||||
<view class="mar-y10">请选择村</view>
|
||||
<i class="icon icon-next fon24" style="margin-top: 6rpx;"></i>
|
||||
</picker>
|
||||
<picker mode="selector" :range="villageList" :value="villageIndex" @change="changeVillage" :range-key="'name'">
|
||||
<view class="disjbac fon30 bbot pad-sx30">
|
||||
<view class="colb bold flexs">村</view>
|
||||
<view class="disac col9 width100 fe">
|
||||
<view class="mar-y10">{{villageText}}</view>
|
||||
<i class="icon icon-next fon24" style="margin-top: 6rpx;"></i>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</picker>
|
||||
<view class="dis fon30 bbot pad-sx30">
|
||||
<view class="colb bold flexs">图片上传</view>
|
||||
<view class="disac col9 width100 fe fw">
|
||||
|
@ -98,11 +102,20 @@
|
|||
return {
|
||||
imgArr:[],
|
||||
vedioArr:[],
|
||||
audioText:''
|
||||
audioText:'',
|
||||
communityList:[],//社区列表
|
||||
communityIndex:0,//当前选中的社区
|
||||
communityId:'',//社区id
|
||||
communityText:'请选择社区',
|
||||
villageList:[],//村列表
|
||||
villageIndex:0,//当前选中的村
|
||||
villageText:'请选择村',
|
||||
villageId:'',//村id
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
|
||||
// 调用查询社区列表事件
|
||||
this.getCommunityList();
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
|
@ -110,10 +123,44 @@
|
|||
})
|
||||
},
|
||||
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(){
|
||||
uni.reLaunch({
|
||||
url:'/pagesA/my-opinion-list/my-opinion-list'
|
||||
url:'/pagesA/passageway/passageway'
|
||||
})
|
||||
},
|
||||
// 图片选择
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
passagewayModeEv(index){
|
||||
this.$store.commit('setAnonymous',[false,true][index])
|
||||
uni.navigateTo({
|
||||
url:`/pagesA/opinion-submit/opinion-submit?flag=${index==1}`
|
||||
url:`/pagesA/opinion-submit/opinion-submit`
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue