对接登录接口、社区列表、村

master
吃肉的饺子 2022-07-31 10:40:15 +08:00
parent 3a7ea01f18
commit c4eee5d1af
6 changed files with 122 additions and 107 deletions

View File

@ -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() {

View File

@ -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 => {})
} }

View File

@ -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 => {})
} }

View File

@ -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'
}) })
}, },
// //

View File

@ -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'
}) })
}, },
// //

View File

@ -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`
}) })
} }
} }