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

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:'', //
lat:'', //
lng:'' ,//
hostapi:'https://www.baidu.com' //
hostapi:'https://minyitong.scdxtc.cn/api/' //
},
// show
onLaunch: function() {

View File

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

View File

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

View File

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

View File

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

View File

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