master
fengyuexingzi 7 years ago
parent 599413c8d8
commit f9a43c8e6a

74
mini/app.js vendored

@ -5,33 +5,14 @@ var user = require('./services/user.js');
App({ App({
onLaunch: function () { onLaunch: function () {
wx.navigateTo({ wx.chooseLocation({
url: '/pages/welcome/welcome', success: data => {
console.log(data)
}
}) })
// wx.login({
// success: res =>{
// console.log(res);
// },
// fail: error => {
// console.log(error);
// }
// })
// wx.getSetting({
// success: res => {
// if(res.authSetting['scope.userInfo']){
// console.log("已授权");
// wx.getUserInfo({
// success: res => {
// console.log(res);
// }
// })
// }else{
// console.log("未授权");
// }
// }
// })
// wx.showModal({ // wx.showModal({
@ -136,7 +117,7 @@ App({
// }); // });
}, }
// globalData: { // globalData: {
// userInfo: { // userInfo: {
@ -147,28 +128,25 @@ App({
// token: '', // token: '',
// } // }
getUserInfo: function (cb) { // getUserInfo: function (cb) {
var that = this // var that = this
if (this.globalData.userInfo) { // if (this.globalData.userInfo) {
typeof cb == "function" && cb(this.globalData.userInfo) // typeof cb == "function" && cb(this.globalData.userInfo)
} else { // } else {
//调用登录接口 // //调用登录接口
wx.login({ // wx.login({
success: function () { // success: function () {
wx.getUserInfo({ // wx.getUserInfo({
success: function (res) { // success: function (res) {
console.log(res); // console.log(res);
wx.setStorageSync('isFirst', res.userInfo); // wx.setStorageSync('isFirst', res.userInfo);
that.globalData.userInfo = res.userInfo // that.globalData.userInfo = res.userInfo
typeof cb == "function" && cb(that.globalData.userInfo) // typeof cb == "function" && cb(that.globalData.userInfo)
} // }
}) // })
} // }
}) // })
} // }
}, // },
globalData: {
userInfo: null
}
}) })

@ -34,9 +34,7 @@
"pages/shopping/address/address", "pages/shopping/address/address",
"pages/shopping/addressAdd/addressAdd", "pages/shopping/addressAdd/addressAdd",
"pages/goods/goods", "pages/goods/goods",
"pages/topicDetail/topicDetail", "pages/topicDetail/topicDetail"
"pages/welcome",
"pages/welcome/welcome"
], ],
"window": { "window": {
"backgroundTextStyle": "dark", "backgroundTextStyle": "dark",

@ -43,12 +43,12 @@ Page({
//this.getIndexData(); //this.getIndexData();
var that = this var that = this
app.getUserInfo(function (userInfo) { // app.getUserInfo(function (userInfo) {
//更新数据 // //更新数据
that.setData({ // that.setData({
userInfo: userInfo // userInfo: userInfo
}) // })
}) // })
}, },
onReady: function () { onReady: function () {

@ -1,7 +1,6 @@
<!--index.wxml--> <!--index.wxml-->
<view class="container"> <view class="container">
<button id='abc' open-type="getUserInfo">登录</button>
<swiper class="banner" indicator-dots="true" autoplay="true" interval="3000" duration="1000"> <swiper class="banner" indicator-dots="true" autoplay="true" interval="3000" duration="1000">
<swiper-item wx:for="{{carouselInfo}}" wx:key="{{item.id}}"> <swiper-item wx:for="{{carouselInfo}}" wx:key="{{item.id}}">
<navigator url="{{item.businessId}}"> <navigator url="{{item.businessId}}">

@ -8,26 +8,42 @@ Page({
userInfo: {} userInfo: {}
}, },
onLoad: function(options) { onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数 var that = this
console.log(app.globalData) wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
console.log('已授权');
wx.getUserInfo({
withCredentials: true,
lang: '',
success: function(res) {
that.setData({
userInfo: res.userInfo
})
},
})
}
}
})
}, },
onReady: function() { onReady: function() {
}, },
onShow: function() { onShow: function() {
let userInfo = wx.getStorageSync('userInfo'); // let userInfo = wx.getStorageSync('userInfo');
let token = wx.getStorageSync('token'); // let token = wx.getStorageSync('token');
// 页面显示 // // 页面显示
if (userInfo && token) { // if (userInfo && token) {
app.globalData.userInfo = userInfo; // app.globalData.userInfo = userInfo;
app.globalData.token = token; // app.globalData.token = token;
} // }
this.setData({ // this.setData({
userInfo: app.globalData.userInfo, // userInfo: app.globalData.userInfo,
}); // });
}, },
onHide: function() { onHide: function() {

@ -1,9 +1,20 @@
<view class="container"> <view class="container">
<view class="profile-info" bindtap="goLogin">
<image class="avatar" src="{{userInfo.avatar}}"></image> <view wx:if="{{false}}">
<view class="avatar">
<open-data type="userAvatarUrl" ></open-data>
</view>
<text class='auth-title'>请提供以下授权,即可继续操作</text>
<text class='auth-detail'>获得你的公开信息(昵称、头像等)</text>
<button class='auth-btn' open-type='getUserInfo'>确认授权</button>
</view>
<view wx:else>
<view class="profile-info">
<image class="avatar" src="{{userInfo.avatarUrl}}"></image>
<view class="info"> <view class="info">
<text class="name">{{userInfo.nickname}}11</text> <text class="name">{{userInfo.nickName}}{{test}}</text>
<!-- <text class="level">{{userInfo.username}}</text> -->
</view> </view>
</view> </view>
@ -14,69 +25,16 @@
<text class="txt">我的订单</text> <text class="txt">我的订单</text>
</navigator> </navigator>
</view> </view>
<view class="item">
<navigator url="/pages/ucenter/coupon/coupon" class="a">
<text class="icon coupon"></text>
<text class="txt">优惠券</text>
</navigator>
</view>
<!-- <view class="item no-border">
<navigator url="url" class="a">
<text class="icon gift"></text>
<text class="txt">礼品卡</text>
</navigator>
</view> -->
<view class="item">
<navigator url="/pages/ucenter/collect/collect" class="a">
<text class="icon address"></text>
<text class="txt">我的收藏</text>
</navigator>
</view>
<view class="item">
<navigator url="/pages/ucenter/footprint/footprint" class="a">
<text class="icon security"></text>
<text class="txt">我的足迹</text>
</navigator>
</view>
<view class="item">
<navigator url="url" class="a">
<text class="icon kefu"></text>
<text class="txt">会员福利</text>
</navigator>
</view>
<view class="item"> <view class="item">
<navigator url="../address/address" class="a"> <navigator url="../address/address" class="a">
<text class="icon address"></text> <text class="icon address"></text>
<text class="txt">地址管理</text> <text class="txt">地址管理</text>
</navigator> </navigator>
</view> </view>
<!-- <view class="item">
<navigator url="url" class="a">
<text class="icon security"></text>
<text class="txt">账号安全</text>
</navigator>
</view> -->
<!-- <view class="item item-bottom">
<navigator url="url" class="a">
<text class="icon help"></text>
<text class="txt">帮助中心</text>
</navigator>
</view> -->
<view class="item item-bottom">
<navigator url="/pages/ucenter/feedback/feedback" class="a">
<text class="icon feedback"></text>
<text class="txt">意见反馈</text>
</navigator>
</view> </view>
<view class="item item-bottom">
<navigator url="url" class="a">
<text class="icon kefu"></text>
<text class="txt">联系客服</text>
</navigator>
</view>
</view> </view>
<!--<view class="logout" bindtap="exitLogin">退出登录</view>-->
</view> </view>

@ -3,6 +3,33 @@ page{
width: 100%; width: 100%;
background: #f4f4f4; background: #f4f4f4;
} }
.avatar {
width: 300rpx;
height: 300rpx;
margin:150rpx auto ;
border-radius: 150px;
overflow: hidden;
}
.auth-title {
display: block;
text-align: center;
margin: 50rpx auto;
}
.auth-detail {
display: block;
font-size: 20rpx;
text-align: center
}
.auth-btn {
background: rgb(238, 205, 16);
margin: 50rpx 100rpx;
color: white;
}
.container { .container {
background: #f4f4f4; background: #f4f4f4;
height: auto; height: auto;
@ -10,6 +37,7 @@ page{
overflow: hidden; overflow: hidden;
width: 100%; width: 100%;
} }
.profile-info { .profile-info {
width: 100%; width: 100%;
height: 280rpx; height: 280rpx;
@ -18,7 +46,7 @@ page{
align-items: center; align-items: center;
justify-content: flex-start; justify-content: flex-start;
padding: 0 30.25rpx; padding: 0 30.25rpx;
background: #333; background: rgb(177, 182, 196);
} }
.profile-info .avatar { .profile-info .avatar {
@ -63,8 +91,8 @@ page{
float: left; float: left;
width: 33.33333%; width: 33.33333%;
height: 187.5rpx; height: 187.5rpx;
border-right: 1px solid rgba(0,0,0,.15); border-right: 1px solid rgba(0, 0, 0, 0.15);
border-bottom: 1px solid rgba(0,0,0,.15); border-bottom: 1px solid rgba(0, 0, 0, 0.15);
text-align: center; text-align: center;
} }
@ -133,7 +161,6 @@ page{
background-size: 52.803rpx; background-size: 52.803rpx;
} }
.user-menu .txt { .user-menu .txt {
display: block; display: block;
height: 24rpx; height: 24rpx;

@ -1,66 +0,0 @@
// pages/welcome.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

@ -1,2 +0,0 @@
<!--pages/welcome.wxml-->
<text>pages/welcome.wxml</text>

@ -1 +0,0 @@
/* pages/welcome.wxss */

@ -1,66 +0,0 @@
// pages/welcome/welcome.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

@ -1,2 +0,0 @@
<!--pages/welcome/welcome.wxml-->
<text>pages/welcome/welcome.wxml</text>

@ -1 +0,0 @@
/* pages/welcome/welcome.wxss */

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Loading…
Cancel
Save