Commit 438d3a35 authored by 潘永坪's avatar 潘永坪

登录优化和原组合票定位取消

parent 3f9c3e3a
...@@ -28,8 +28,7 @@ ...@@ -28,8 +28,7 @@
</template> </template>
</view> </view>
<view v-if="showDistance" class="title-right"> <view class="title-right">
距您{{ item.distance ? parseFloat((item.distance / 1000).toFixed(2)) : 0 }}km
<u-icon name="arrow-right" style="margin-left: 4rpx;" size='26' color='#B4B4B4'></u-icon> <u-icon name="arrow-right" style="margin-left: 4rpx;" size='26' color='#B4B4B4'></u-icon>
</view> </view>
</view> </view>
...@@ -229,7 +228,6 @@ export default { ...@@ -229,7 +228,6 @@ export default {
currentNum:0,//轮播图下标 currentNum:0,//轮播图下标
imgList: [], //图片列表 imgList: [], //图片列表
scenicList: [], //景区数据 scenicList: [], //景区数据
showDistance: false, //定位成功显示距离
buyKnowData: '', //购买须知数据 buyKnowData: '', //购买须知数据
chooseProduct: [], //选中的产品 chooseProduct: [], //选中的产品
showModal: false, //是否显示模态框 showModal: false, //是否显示模态框
...@@ -361,24 +359,6 @@ export default { ...@@ -361,24 +359,6 @@ export default {
let newTimestamp=uni.getStorageSync('newTimestamp')||'' let newTimestamp=uni.getStorageSync('newTimestamp')||''
let token = uni.getStorageSync('token') let token = uni.getStorageSync('token')
if (token) { if (token) {
uni.getLocation({
type: 'wgs84',
success: res => {
let latitude = res.latitude //纬度
let longitude = res.longitude //经度
this.showDistance = true
//判断时间戳,之前请求失败,必须大于缓存时间戳才进行请求
if(newTimestamp){
if(Date.now()>newTimestamp){
this.initList(latitude, longitude)
}else{
this.showTip=true
}
}else{
this.initList(latitude, longitude)
}
},
fail: res => {
let latitude = '' let latitude = ''
let longitude = '' let longitude = ''
//判断时间戳,之前请求失败,必须大于缓存时间戳才进行请求 //判断时间戳,之前请求失败,必须大于缓存时间戳才进行请求
...@@ -392,8 +372,6 @@ export default { ...@@ -392,8 +372,6 @@ export default {
this.initList(latitude, longitude) this.initList(latitude, longitude)
} }
} }
})
}
}, },
methods: { methods: {
//---商品列表 //---商品列表
......
...@@ -10,7 +10,7 @@ export default { ...@@ -10,7 +10,7 @@ export default {
} }
}, },
onLoad() { onLoad() {
this.login() this.getCodeLogin()
}, },
// 一般页面用onUnload // 一般页面用onUnload
// tabbar页面用onHide // tabbar页面用onHide
...@@ -21,8 +21,8 @@ export default { ...@@ -21,8 +21,8 @@ export default {
} }
}, },
methods:{ methods:{
//---登录 //---获取编码并登录
login(){ getCodeLogin(){
uni.getProvider({ uni.getProvider({
service: 'oauth', service: 'oauth',
success:proRes=>{ success:proRes=>{
...@@ -49,7 +49,31 @@ export default { ...@@ -49,7 +49,31 @@ export default {
let openid = res.data.openid let openid = res.data.openid
uni.setStorageSync('openid', openid) uni.setStorageSync('openid', openid)
let userId = res.data.userId || '' let userId = res.data.userId || ''
let datas = { openid, source, userId } this.login(openid,userId,source)
} else {
uni.showToast({
title: res.message,
icon: 'none'
})
}
}).catch(err => {
uni.showToast({
title: '登录失败,请退出并重新登录',
icon: 'none'
})
this.timer = setTimeout(() => {
this.getCodeLogin()
}, 2000)
})
}
}
})
}
})
},
//---登录
login(openid,userId,source){
let datas = {openid,userId,source}
this.$request('wechatUser/login/findWxUserAndLogin', datas).then(res => { this.$request('wechatUser/login/findWxUserAndLogin', datas).then(res => {
//通过openid获取token //通过openid获取token
if (res.code == '00') { if (res.code == '00') {
...@@ -88,31 +112,11 @@ export default { ...@@ -88,31 +112,11 @@ export default {
icon: 'none' icon: 'none'
}) })
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
this.login() this.login(openid,userId,source)
}, 2000)
})
} else {
uni.showToast({
title: res.message,
icon: 'none'
})
}
}).catch(err => {
uni.showToast({
title: '登录失败,请退出并重新登录',
icon: 'none'
})
this.timer = setTimeout(() => {
this.login()
}, 2000) }, 2000)
}) })
} }
} }
})
}
})
}
}
} }
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment