|
@@ -500,29 +500,32 @@
|
|
|
return this.$store.state.userInfo||{};
|
|
|
}
|
|
|
},
|
|
|
- mounted() {
|
|
|
+ onLoad(options) {
|
|
|
+ console.log(options)
|
|
|
+ if(options.invite){
|
|
|
+ uni.setStorageSync('invited',options.invite);
|
|
|
+ }
|
|
|
uni.showLoading({
|
|
|
mask:true,
|
|
|
title:'加载中'
|
|
|
})
|
|
|
+ this.$api.public.aliossCdn({}).then(cdnRes=>{
|
|
|
+ this.$store.commit('setImageCdn',cdnRes.data.pictureCdn);
|
|
|
+ this.$store.commit('setVideoCdn',cdnRes.data.videoCdn);
|
|
|
+ uni.setStorageSync('imageCdn',cdnRes.data.pictureCdn);
|
|
|
+ uni.setStorageSync('videoCdn',cdnRes.data.videoCdn);
|
|
|
+ });
|
|
|
+ this.login();
|
|
|
this.computedScollviewHeight();
|
|
|
- if(!uni.getStorageSync('token')){
|
|
|
- this.computedLocation();
|
|
|
- }
|
|
|
- else{
|
|
|
- this.computedLocation();
|
|
|
- this.getRecommendTopsMData();
|
|
|
- this.getRecommendTopsHData();
|
|
|
- setTimeout(()=>{
|
|
|
- this.imInit();
|
|
|
- },3000)
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
},
|
|
|
+ onShow() {
|
|
|
+ if(uni.getStorageSync('needFreshList')==='1'){
|
|
|
+ this.recommendRefresh();
|
|
|
+ this.nearRefresh();
|
|
|
+ uni.setStorageSync('needFreshList','0');
|
|
|
+ }
|
|
|
+ },
|
|
|
// #ifdef MP
|
|
|
onShareAppMessage(){
|
|
|
return {
|
|
@@ -532,6 +535,65 @@
|
|
|
},
|
|
|
// #endif
|
|
|
methods: {
|
|
|
+ getMineData(){
|
|
|
+ let user=JSON.parse(uni.getStorageSync('user'));
|
|
|
+ this.$api.public.mineDetail({
|
|
|
+ getAlbum:true,
|
|
|
+ completeUser:user
|
|
|
+ }).then(res=>{
|
|
|
+ this.$store.commit('setUserInfo',res.data);
|
|
|
+ uni.setStorageSync('userInfo',JSON.stringify(res.data));
|
|
|
+ if(!res.data.regDone){
|
|
|
+ uni.reLaunch({
|
|
|
+ url:'/pages/info/sex'
|
|
|
+ })
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ login(){
|
|
|
+ const that=this;
|
|
|
+ if(uni.getStorageSync('isLogin')==='yes'){
|
|
|
+ this.getMineData();
|
|
|
+ this.computedLocation();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ uni.login({//免密登录
|
|
|
+ success:(res)=>{
|
|
|
+ that.$api.login.wxLogin({
|
|
|
+ scene: "WxMPLogin",
|
|
|
+ miniProgramEncryUserInfoParam:{
|
|
|
+ jsCode:res.code
|
|
|
+ }
|
|
|
+ }).then(result=>{
|
|
|
+ if(result.status==='Succ'){
|
|
|
+ uni.setStorageSync('openId',result.data.wxLoginInfo.openId);
|
|
|
+ uni.setStorageSync('unionId',result.data.wxLoginInfo.unionId);
|
|
|
+ this.computedLocation();
|
|
|
+ this.getRecommendTopsMData();
|
|
|
+ this.getRecommendTopsHData();
|
|
|
+ uni.setStorageSync('LL_Ukn',result.data.userToken.ukn);
|
|
|
+ uni.setStorageSync('token',result.data.userToken.token);
|
|
|
+ uni.setStorageSync('userInfo',JSON.stringify(result.data));
|
|
|
+ uni.setStorageSync('user',JSON.stringify(result.data.userToken.user));
|
|
|
+ uni.setStorageSync('isLogin','yes');
|
|
|
+ this.$api.public.aliossCdn({}).then(cdnRes=>{
|
|
|
+ this.$store.commit('setImageCdn',cdnRes.data.pictureCdn);
|
|
|
+ this.$store.commit('setVideoCdn',cdnRes.data.videoCdn);
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ console.log(err)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ closePopup(){
|
|
|
+ this.$refs.popup.close();
|
|
|
+ },
|
|
|
imInit(){
|
|
|
/**
|
|
|
* IM初始化
|
|
@@ -557,7 +619,10 @@
|
|
|
uni.$TUIKit.registerPlugin({ 'tim-upload-plugin':TIMUploadPlugin });
|
|
|
},
|
|
|
resetLoginData() {
|
|
|
- let user=JSON.parse(uni.getStorageSync('userInfo'));
|
|
|
+ if(!uni.getStorageSync('userInfo')){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let user=JSON.parse(uni.getStorageSync('userInfo'));
|
|
|
this.$api.IM.loadSig({}).then(res=>{
|
|
|
this.$store.commit('setImLoadSig',res.data.sig);
|
|
|
uni.$TUIKit.login({
|
|
@@ -565,17 +630,16 @@
|
|
|
userSig:this.$store.state.IMloadSig
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
- uni.hideLoading();
|
|
|
},
|
|
|
- onTIMError() {},
|
|
|
+ onTIMError(error) {
|
|
|
+ },
|
|
|
onSDKReady({name}) {
|
|
|
const isSDKReady = name === uni.$TUIKitEvent.SDK_READY ? true : false;
|
|
|
if(isSDKReady){
|
|
|
uni.$emit('isSDKReady', {
|
|
|
isSDKReady: true
|
|
|
});
|
|
|
-
|
|
|
+ uni.hideLoading();
|
|
|
}
|
|
|
|
|
|
},
|
|
@@ -625,6 +689,7 @@
|
|
|
recommendRestore() {this.recommendTriggered = true;},
|
|
|
recommendAbort() {},
|
|
|
recommendToBottom(){
|
|
|
+ if(!uni.getStorageSync('token')){return;}
|
|
|
if(this.recommendList.length>=this.recommendTotal){return;}
|
|
|
this.recommendListOptions.page.index++;
|
|
|
this.getRecommendList();
|
|
@@ -677,14 +742,9 @@
|
|
|
* 计算列表定位距离
|
|
|
*/
|
|
|
computedLocation(){
|
|
|
- // #ifdef MP
|
|
|
uni.getFuzzyLocation({
|
|
|
type:'gcj02',
|
|
|
success:res=>{
|
|
|
- this.latitude=res.latitude;
|
|
|
- this.longitude=res.longitude;
|
|
|
- this.$store.commit('setLatitude',this.latitude);
|
|
|
- this.$store.commit('setLongitude',this.longitude);
|
|
|
wxMapSdk.reverseGeocoder({
|
|
|
location:{
|
|
|
latitude:res.latitude,
|
|
@@ -692,29 +752,28 @@
|
|
|
},
|
|
|
success:result=>{
|
|
|
this.locationCity=result.result.ad_info.city;
|
|
|
+ this.latitude=result.result.location.lat;
|
|
|
+ this.longitude=result.result.location.lng;
|
|
|
+ this.$store.commit('setLatitude',result.result.location.lat);
|
|
|
+ this.$store.commit('setLongitude',result.result.location.lng);
|
|
|
+ uni.setStorageSync('latitude',result.result.location.lat);
|
|
|
+ uni.setStorageSync('longitude',result.result.location.lng);
|
|
|
+ uni.setStorageSync('city',this.locationCity);
|
|
|
this.locationCityCode=result.result.ad_info.city_code.split(result.result.ad_info.nation_code)[1];
|
|
|
- this.getTempRecommendList();
|
|
|
if(!uni.getStorageSync('token')){
|
|
|
this.getTempRecommendList();
|
|
|
}
|
|
|
else{
|
|
|
- this.$api.public.heartBeat({
|
|
|
- city:this.locationCity,
|
|
|
- cityCode:this.locationCityCode,
|
|
|
- geo:{
|
|
|
- lat:this.latitude,
|
|
|
- lon:this.longitude,
|
|
|
- }
|
|
|
-
|
|
|
- }).then(()=>{
|
|
|
- this.getNearTopsMData();
|
|
|
- this.getNearTopsHData();
|
|
|
- this.getNearList();
|
|
|
- this.getRecommendList();
|
|
|
- this.showGetLocation=false;
|
|
|
- }).catch(err=>{
|
|
|
- this.getTempRecommendList();
|
|
|
- })
|
|
|
+ this.getNearTopsMData();
|
|
|
+ this.getNearTopsHData();
|
|
|
+ this.getRecommendTopsMData();
|
|
|
+ this.getRecommendTopsHData();
|
|
|
+ this.getNearList();
|
|
|
+ this.getRecommendList();
|
|
|
+ this.showGetLocation=false;
|
|
|
+ setTimeout(()=>{
|
|
|
+ this.imInit();
|
|
|
+ },2000)
|
|
|
}
|
|
|
|
|
|
|
|
@@ -742,58 +801,6 @@
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
- // #endif
|
|
|
- // #ifdef H5
|
|
|
- console.log('h5')
|
|
|
- uni.getLocation({
|
|
|
- type: 'wgs84',
|
|
|
- success: (res) => {
|
|
|
- console.log(res)
|
|
|
- this.latitude=res.latitude;
|
|
|
- this.longitude=res.longitude;
|
|
|
- this.$store.commit('setLatitude',this.latitude);
|
|
|
- this.$store.commit('setLongitude',this.longitude);
|
|
|
- this.$jsonp('https://apis.map.qq.com/ws/geocoder/v1',{
|
|
|
- key:'E5SBZ-T2YC3-CBL3F-YGFQQ-26PP2-ERFII',
|
|
|
- output:'jsonp',
|
|
|
- callbackName: 'QQmap',
|
|
|
- location:`${this.latitude},${this.longitude}`
|
|
|
- }).then(result=>{
|
|
|
- console.log(result)
|
|
|
- this.locationCity=result.result.ad_info.city;
|
|
|
- this.locationCityCode=result.result.ad_info.city_code.split(result.result.ad_info.nation_code)[1];
|
|
|
- this.getTempRecommendList();
|
|
|
- if(!uni.getStorageSync('token')){
|
|
|
- this.getTempRecommendList();
|
|
|
- }
|
|
|
- else{
|
|
|
- this.$api.public.heartBeat({
|
|
|
- city:this.locationCity,
|
|
|
- cityCode:this.locationCityCode,
|
|
|
- geo:{
|
|
|
- lat:this.latitude,
|
|
|
- lon:this.longitude,
|
|
|
- }
|
|
|
-
|
|
|
- }).then(()=>{
|
|
|
- this.getNearTopsMData();
|
|
|
- this.getNearTopsHData();
|
|
|
- this.getNearList();
|
|
|
- this.getRecommendList();
|
|
|
- this.showGetLocation=false;
|
|
|
- }).catch(err=>{
|
|
|
- this.getTempRecommendList();
|
|
|
- })
|
|
|
- }
|
|
|
- }).catch(err=>{
|
|
|
- console.log(err)
|
|
|
- })
|
|
|
- },
|
|
|
- fail:err=>{
|
|
|
- console.log(err);
|
|
|
- }
|
|
|
- })
|
|
|
- // #endif
|
|
|
|
|
|
},
|
|
|
toLogin(){
|
|
@@ -874,7 +881,7 @@
|
|
|
this.recommendListOptions.type='FamaleReco';
|
|
|
this.$api.public.friendsNoAuth(this.recommendListOptions).then(res=>{
|
|
|
if(res.status==='Succ'){
|
|
|
-
|
|
|
+ uni.hideLoading();
|
|
|
this.recommendTotal=res.data.page.recordCount;
|
|
|
this.recommendListOptions.page.sortValues=res.data.sortValues;
|
|
|
|
|
@@ -906,7 +913,6 @@
|
|
|
else{
|
|
|
this.recommendList=res.data.users;
|
|
|
}
|
|
|
- uni.hideLoading();
|
|
|
this.$forceUpdate();
|
|
|
}
|
|
|
|
|
@@ -957,6 +963,7 @@
|
|
|
else{
|
|
|
this.recommendList=res.data.users;
|
|
|
}
|
|
|
+ uni.hideLoading();
|
|
|
this.$forceUpdate();
|
|
|
}
|
|
|
|
|
@@ -1005,6 +1012,7 @@
|
|
|
else{
|
|
|
this.nearList=res.data.users;
|
|
|
}
|
|
|
+ uni.hideLoading()
|
|
|
this.$forceUpdate();
|
|
|
}
|
|
|
|
|
@@ -1046,7 +1054,7 @@
|
|
|
})
|
|
|
}
|
|
|
else{
|
|
|
- this.otherInfo=res.data;
|
|
|
+ uni.setStorageSync('otherInfo',JSON.stringify(res.data));
|
|
|
uni.hideLoading();
|
|
|
uni.navigateTo({
|
|
|
url:`/pages/friends/user?id=${id}`
|