Browse Source

修复一下登录返回的数据

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

20
.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/ {
// launch.json configurations app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
// launchtypelocalremote, localremote // launchtypelocalremote, localremote
"version" : "0.0", "version" : "0.0",
"configurations": [{ "configurations" : [
"app-plus" :
{ {
"app-plus" : {
"launchtype" : "local" "launchtype" : "local"
}, },
"default" : "default" : {
{
"launchtype" : "local" "launchtype" : "local"
}, },
"h5" : "h5" : {
{
"launchtype" : "local" "launchtype" : "local"
}, },
"mp-weixin" : "mp-weixin" : {
{
"launchtype" : "local" "launchtype" : "local"
}, },
"type" : "uniCloud" "type" : "uniCloud"
},
{
"playground" : "custom",
"type" : "uni-app:app-ios"
} }
] ]
} }

2
pages/account/deleteCount.vue

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

6
pages/account/deleteOk.vue

@ -1,7 +1,7 @@
<template> <template>
<view> <view>
<view class="font"> <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> <text style="margin-left: 30rpx;color: white;">Delete account</text>
</view> </view>
<view class="icon"> <view class="icon">
@ -88,10 +88,10 @@
.icon_img{ .icon_img{
height: 120rpx; height: 120rpx;
width: 110rpx; width: 120rpx;
margin-left: 250rpx; margin-left: 250rpx;
image{ image{
object-fit: cover;
height: 100%; height: 100%;
width: 100%; width: 100%;

15
pages/account/index.vue

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

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

Loading…
Cancel
Save