提交 f2071bd4 编写于 作者: L linju

123

上级 c0e157ac
...@@ -7,8 +7,12 @@ ...@@ -7,8 +7,12 @@
</view> </view>
</template> </template>
<script> <script>
export default { import {
mapGetters,
mapMutations
} from 'vuex';
export default {
data() { data() {
return { return {
config: { config: {
...@@ -83,11 +87,16 @@ ...@@ -83,11 +87,16 @@
}) })
*/ */
}, },
methods: { methods: {
...mapMutations({
setUserInfo: 'user/login'
}),
login(type) { login(type) {
let oauthService = this.oauthServices.find((service) => service.id == type) let oauthService = this.oauthServices.find((service) => service.id == type)
// #ifdef APP-PLUS // #ifdef APP-PLUS
uni.showLoading({mask: true}); uni.showLoading({mask: true});
//请勿直接使用前端获取的unionid或openid直接用于登陆,前端的数据都是不可靠的
if(type=='weixin'){ if(type=='weixin'){
oauthService.authorize(({code})=>{ oauthService.authorize(({code})=>{
console.log(code); console.log(code);
...@@ -120,23 +129,35 @@ ...@@ -120,23 +129,35 @@
// #endif // #endif
}, },
quickLogin(params,type){ quickLogin(params,type){
//请勿直接使用authResult中的unionid或openid直接用于登陆,前端的数据都是不可靠的
console.log({params,type}); console.log({params,type});
uniCloud.callFunction({//联网验证登陆 uniCloud.callFunction({//联网验证登陆
"name": "user-center", "name": "user-center",
"data": { "data": {
"action": "login_by_"+type, "action": "login_by_"+type,
params params
}, },
success: (e) => { success:async (e) => {
uni.hideLoading()
console.log(e.result); console.log(e.result);
uni.showModal({ // uni.showModal({
content: JSON.stringify(e.result), // content: JSON.stringify(e.result),
showCancel: false // showCancel: false
}); // });
if(type=='univerify'){ if(e.result.code === 0){
uni.closeAuthView() uni.setStorageSync('uni_id_uid', e.result.uid)
uni.setStorageSync('uni_id_token', e.result.token)
uni.setStorageSync('uni_id_token_expired', e.result.tokenExpired)
console.log('66666=',e.result.uid,e.result.token,e.result.tokenExpired);
delete e.result.userInfo.token
this.setUserInfo(e.result.userInfo)
if(type=='univerify'){
uni.closeAuthView()
}
uni.showToast({
title: '登陆成功',
icon: 'none'
});
uni.navigateBack()
} }
}, },
fail: (err) => { fail: (err) => {
......
...@@ -3,6 +3,9 @@ const PACKAGE_INFO_KEY = '__package_info__' ...@@ -3,6 +3,9 @@ const PACKAGE_INFO_KEY = '__package_info__'
export default function() { export default function() {
// #ifdef APP-PLUS // #ifdef APP-PLUS
return '先关了'
plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) { plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
uniCloud.callFunction({ uniCloud.callFunction({
name: 'check-version', name: 'check-version',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册