Browse Source

修复一下登录返回的数据

master
zhengshuiqi 3 years ago
parent
commit
61c812935b
  1. 46
      .hbuilderx/launch.json
  2. 2
      pages/account/deleteCount.vue
  3. 10
      pages/account/deleteOk.vue
  4. 15
      pages/account/index.vue
  5. 242
      pages/login/index.vue
  6. 1
      pages/order/confirmation.vue

46
.hbuilderx/launch.json

@ -1,24 +1,26 @@
{ // launch.json configurations app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
// launchtypelocalremote, localremote
"version": "0.0",
"configurations": [{
"app-plus" :
{
"launchtype" : "local"
},
"default" :
{
"launchtype" : "local"
},
"h5" :
{
"launchtype" : "local"
},
"mp-weixin" :
{
"launchtype" : "local"
},
"type" : "uniCloud"
}
{
// launch.json configurations app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
// launchtypelocalremote, localremote
"version" : "0.0",
"configurations" : [
{
"app-plus" : {
"launchtype" : "local"
},
"default" : {
"launchtype" : "local"
},
"h5" : {
"launchtype" : "local"
},
"mp-weixin" : {
"launchtype" : "local"
},
"type" : "uniCloud"
},
{
"playground" : "custom",
"type" : "uni-app:app-ios"
}
]
}

2
pages/account/deleteCount.vue

@ -67,7 +67,6 @@
})
},
deleteuserinfo(){
uni.showModal({
title: 'Confirm Delet?',
cancelText: "cancel", //
@ -110,7 +109,6 @@
},
onShow() {
let user = uni.getStorageInfoSync('user_info')
console.log(user)
this.getuserinfo()
}
}

10
pages/account/deleteOk.vue

@ -1,11 +1,11 @@
<template>
<view>
<view class="font">
<uni-icons type="closeempty" size="30" @click="back" color="#fff"></uni-icons>
<!-- <uni-icons type="closeempty" size="30" @click="back" color="#fff"></uni-icons> -->
<text style="margin-left: 30rpx;color: white;">Delete account</text>
</view>
<view class="icon">
<view class="icon_img"><image mode="" src="../../static/icon/deleteok.png"></image></view>
<view class="icon_img"><image mode="" src="../../static/icon/deleteok.png"></image></view>
<view class="icon_text">Delete account</view>
</view>
@ -88,10 +88,10 @@
.icon_img{
height: 120rpx;
width: 110rpx;
margin-left: 250rpx;
width: 120rpx;
margin-left: 250rpx;
image{
object-fit: cover;
height: 100%;
width: 100%;

15
pages/account/index.vue

@ -19,6 +19,7 @@
<view class="info_name" v-else>
<navigator class="info_name_a" url="/pages/account/myProfile">
Hey.{{user_info.nickname!=''?user_info.nickname:user_info.email}}.>
<!-- user_info.nickname -->
</navigator>
</view>
@ -161,7 +162,7 @@
user_info: {
isLogin: false,
},
nikname: '',
//
catQuery: {
_action: 'getgoods',
@ -330,10 +331,10 @@
if (res.error == 0) {
this.count = res.data.user_info.user_money
this.hb_num = res.data.user_bonus_list.length
this.nikname = res.data.user_info.nikname
console.log(this.hb_num)
}
})
},
getImg() {
let data = {
@ -452,6 +453,7 @@
},
},
onLoad(e) {
this.getList()
let that = this;
let s = 0;
let time = setInterval(() => {
@ -484,13 +486,15 @@
this.getIndex()
// this.getUserInfo()
this.getCatList()
this.getList()
this.getImg()
},
onShow() {
// this.getIndex()
// this.getCatList()
this.getUserInfo()
this.getImg()
this.getList()
uni.hideTabBar()
// uni.showTabBar()
this.isLogin = uni.getStorageSync('isLogin')
@ -498,6 +502,7 @@
},
onPullDownRefresh() {
this.getList()
this.getUserInfo()
this.isLogin = uni.getStorageSync('isLogin')
console.log(this.isLogin)
if (this.isLogin == 0) {

242
pages/login/index.vue

@ -39,7 +39,7 @@
<view class="cellphone-minBox" v-if="cellphone == 2" @click="apple()"> <image src="../../static/img/AppleD.png" mode=""></image></view>
<!-- v-if="cellphone == 2" -->
<view class="cellphone-minBox" @click="facebook()"><image src="../../static/img/FacebookD.png" mode=""></image></view>
<view class="cellphone-minBox" @click="google()"> <image src="../../static/img/GoogleD.png" mode=""></image></view>
<view class="cellphone-minBox" v-if="cellphone == 1" @click="google()"> <image src="../../static/img/GoogleD.png" mode=""></image></view>
<!-- v-if="cellphone == 1" -->
</view>
</view>
@ -274,22 +274,26 @@
}
appleOauth.login( function(oauth){
console.log(oauth);
uni.navigateBack({
delta: 1
});
// oauth.target.appleInfo
// const openid = JSON.parse(oauth.target.appleInfo.identityToken)
// console.log(openid);
let data = {
_action: 'loginbyapple',
ap_user_id: oauth.target.appleInfo.user,
ap_user_name: oauth.target.appleInfo.familyName+oauth.target.appleInfo.giveName,
ap_user_name: oauth.target.appleInfo.familyName,
ap_user_first_name: oauth.target.appleInfo.familyName,
ap_user_middle_name: oauth.target.appleInfo.givenName,
ap_user_last_name: oauth.target.appleInfo.familyName,
ap_user_email: oauth.target.appleInfo.email
}
uni.setStorageSync('user_info', {nickname: oauth.target.appleInfo.familyName})
uni.setStorageSync('user_info', {email: oauth.target.appleInfo.email})
defaultRequest(data).then(res => {
console.info(res)
if (res.error == 0) {
uni.navigateBack({
delta: 1
});
uni.showToast({
title:'Login is successful, please reopen the App to load information',
icon:'none',
@ -297,6 +301,18 @@
})
}
})
// defaultRequest(data).then(res => {
// console.info(res)
// console.log('====================================');
// if (res.error == 0) {
// console.log(openid);
// uni.showToast({
// title:'Login is successful, please reopen the App to load information',
// icon:'none',
// duration: 2000
// })
// }
// })
}, function(err) {
console.log(err);
@ -387,17 +403,23 @@
fb_user_last_name: '',
fb_user_email: info.userInfo.email
}
uni.setStorageSync('user_info', {nickname: info.userInfo.nickName})
uni.setStorageSync('user_info', {email: info.userInfo.email})
// uni.setStorageSync('user_info', 'info.userInfo');
defaultRequest(data).then(res => {
console.info(res)
if (res.error == 0) {
uni.showLoading({
title: '加载中'
});
uni.navigateBack({
delta: 1
});
uni.showLoading({
title: '脸书用户登录成功',
icon: 'none',
duration: 2000
})
// uni.showLoading({
// title: '',
// icon: 'none',
// duration: 2000
// })
}
})
}
@ -408,110 +430,128 @@
//
// err.code
uni.showLoading({
title: '脸书用户授权失败',
title: err.errMsg + err.errCode + err.code,
icon: 'none',
duration: 2000
})
// uni.showLoading({
// title: '',
// icon: 'none',
// duration: 2000
// })
}
});
},
//
google(){
// var googleOauth = null;
// plus.oauth.getServices(function(services) {
// for (var i in services) {
// var service = services[i];
// //
// if (service.id == 'google') {
// googleOauth = service;
// break;
// }
// }
// googleOauth.login( function(oauth){
// // googleOauth.authResult
// console.log(googleOauth.authResult);
// let data = {
// _action: 'loginbygoogle',
// fb_user_id: googleOauth.authResult.openid,
// fb_user_name: '',
// fb_user_first_name: '',
// fb_user_middle_name: '',
// fb_user_last_name: '',
// fb_user_email: googleOauth.authResult.email
// }
// defaultRequest(data).then(res => {
// console.info(res)
// if (res.error == 0) {
// uni.navigateBack({
// delta: 1
// });
// uni.showLoading({
// title: '',
// icon: 'none',
// duration: 2000
// })
// }
// })
// }, function(err) {
// console.log(err);
// uni.showLoading({
// title: '',
// icon: 'none',
// duration: 2000
// })
// //
// // err.code
// })
// }, function(err) {
// console.log(err);
// // services
// })
uni.login({
provider: 'google',
success: function (loginRes) {
//
uni.getUserInfo({
provider: 'google',
success: function(info) {
// , info.authResult
console.log(info);
let data = {
_action: 'loginbygoogle',
fb_user_id: info.authResult.openid,
fb_user_name: '',
fb_user_first_name: '',
fb_user_middle_name: '',
fb_user_last_name: '',
fb_user_email: info.authResult.email
}
defaultRequest(data).then(res => {
console.info(res)
if (res.error == 0) {
uni.navigateBack({
delta: 1
});
uni.showLoading({
title: '谷歌用户登录成功',
icon: 'none',
duration: 2000
})
}
})
}
})
},
fail: function (err) {
var googleOauth = null;
plus.oauth.getServices(function(services) {
for (var i in services) {
var service = services[i];
//
if (service.id == 'google') {
googleOauth = service;
break;
}
}
googleOauth.login( function(oauth){
// googleOauth.authResult
console.log(googleOauth.authResult);
let data = {
_action: 'loginbygoogle',
gg_user_id: googleOauth.authResult.openid,
gg_user_name: googleOauth.authResult.nickName,
gg_user_first_name: '',
gg_user_middle_name: '',
gg_user_last_name: '',
gg_user_email: googleOauth.authResult.email
}
uni.setStorageSync('user_info', {email: googleOauth.authResult.email})
uni.setStorageSync('user_info', {nickname: googleOauth.authResult.nickName})
// uni.setStorageSync('user_info.data.nickname', 'googleOauth.authResult.nickName');
defaultRequest(data).then(res => {
console.info(res)
if (res.error == 0) {
uni.navigateBack({
delta: 1
});
uni.showLoading({
title: '谷歌用户登录成功',
icon: 'none',
duration: 2000
})
}
})
}, function(err) {
console.log(err);
uni.showLoading({
title: '谷歌用户授权失败',
title: err.errMsg + err.errCode + err.code,
icon: 'none',
duration: 2000
})
//
// err.code
}
});
// uni.showLoading({
// title: '',
// icon: 'none',
// duration: 2000
// })
//
// err.code
})
}, function(err) {
console.log(err);
uni.showLoading({
title: err.errMsg + err.errCode + err.code,
icon: 'none',
duration: 2000
})
// services
})
// uni.login({
// provider: 'google',
// success: function (loginRes) {
// //
// uni.getUserInfo({
// provider: 'google',
// success: function(info) {
// // , info.authResult
// console.log(info);
// let data = {
// _action: 'loginbygoogle',
// gg_user_id: info.authResult.openid,
// gg_user_name: info.authResult.nickName,
// gg_user_first_name: '',
// gg_user_middle_name: '',
// gg_user_last_name: '',
// gg_user_email: info.authResult.email
// }
// defaultRequest(data).then(res => {
// console.info(res)
// if (res.error == 0) {
// uni.navigateBack({
// delta: 1
// });
// uni.showLoading({
// title: '',
// icon: 'none',
// duration: 2000
// })
// }
// })
// }
// })
// },
// fail: function (err) {
// console.log(err);
// uni.showLoading({
// title: err.errMsg + err.errCode + err.code,
// icon: 'none',
// duration: 20000000
// })
// //
// // err.code
// }
// });
},
//

1
pages/order/confirmation.vue

@ -708,7 +708,6 @@
if (res.error == 0) {
this.count = res.data.user_info.user_money
// this.count = 4.00
}
})
},

Loading…
Cancel
Save