Authored by 肖亚东

个人中心以及登录功能

@@ -3,7 +3,7 @@ import { GET, POST } from '../../libs/request'; @@ -3,7 +3,7 @@ import { GET, POST } from '../../libs/request';
3 import { API_HOST } from '../../libs/config'; 3 import { API_HOST } from '../../libs/config';
4 Component({ 4 Component({
5 5
6 - externalClasses: ['login-class'], 6 + // externalClasses: ['login-class'],
7 /** 7 /**
8 * 组件的属性列表 8 * 组件的属性列表
9 */ 9 */
@@ -6,3 +6,8 @@ @@ -6,3 +6,8 @@
6 align-items: center; 6 align-items: center;
7 justify-content: center; 7 justify-content: center;
8 } 8 }
  9 +
  10 +.login-class{
  11 + width: 100%;
  12 + height: 100%;
  13 +}
1 Page({ 1 Page({
2 data: { 2 data: {
3 - 3 + url: 'https://m.yohobuy.com',
4 }, 4 },
5 onLoad: function(options) { 5 onLoad: function(options) {
6 //Do some initialize when page load. 6 //Do some initialize when page load.
1 -<view class="container"> 1 +<!-- <view class="container">
2 <image src="../../static/images/empty_view@3x.png" mode="widthFix" class="empty"></image> 2 <image src="../../static/images/empty_view@3x.png" mode="widthFix" class="empty"></image>
3 -</view>  
  3 +</view> -->
  4 +
  5 +<web-view src="{{url}}"></web-view>
@@ -47,26 +47,26 @@ Page({ @@ -47,26 +47,26 @@ Page({
47 hasUnionID: app.globalData.WXUnion_ID !== null && app.globalData.WXUnion_ID !== '' && app.globalData.WXUnion_ID !== undefined ? true:false, 47 hasUnionID: app.globalData.WXUnion_ID !== null && app.globalData.WXUnion_ID !== '' && app.globalData.WXUnion_ID !== undefined ? true:false,
48 cur_undoneTicket 48 cur_undoneTicket
49 }) 49 })
50 - if (app.isLogin()) {  
51 - this.data.isLogin = true;  
52 - }else{  
53 - this.setData({  
54 - isLogin:false,  
55 - })  
56 - }  
57 50
58 //订阅登录完成通知 51 //订阅登录完成通知
59 listen(function (succeed) { 52 listen(function (succeed) {
60 if (succeed) { 53 if (succeed) {
61 this.showUserInfo(); 54 this.showUserInfo();
62 - this.getInfoNum();  
63 - this.fetchInviteInfo();  
64 } 55 }
65 }.bind(this)) 56 }.bind(this))
66 }, 57 },
67 onReady: function() { 58 onReady: function() {
68 //Do some when page ready. 59 //Do some when page ready.
69 - 60 + if (app.isLogin()) {
  61 + this.setData({
  62 + isLogin: true,
  63 + })
  64 + this.showUserInfo();
  65 + }else{
  66 + this.setData({
  67 + isLogin: false,
  68 + })
  69 + }
70 }, 70 },
71 onShow: function() { 71 onShow: function() {
72 //Do some when page show. 72 //Do some when page show.
1 { 1 {
2 "navigationBarTitleText": "我的", 2 "navigationBarTitleText": "我的",
  3 + "enablePullDownRefresh": true,
3 "usingComponents": { 4 "usingComponents": {
4 "section-header" : "/components/user-center/section-header/index", 5 "section-header" : "/components/user-center/section-header/index",
5 "undone-view": "/components/user-center/undone-view/index", 6 "undone-view": "/components/user-center/undone-view/index",
1 <view class="container"> 1 <view class="container">
2 - <!-- 头部用户信息 -->  
3 - <view class="user-info"> 2 + <!-- 未登录 -->
  3 + <view wx:if="{{!isLogin}}" class="not-login-view">
  4 + <image class="login-icon" src="../../static/images/userCenter_login@3x.png">
4 <login-button 5 <login-button
5 - wx:if="{{!isLogin}}"  
6 - class="login-bg"  
7 - login-class="login-btn" 6 + class="login-btn"
8 open-type="{{hasUnionID?'getPhoneNumber':'getUserInfo'}}" 7 open-type="{{hasUnionID?'getPhoneNumber':'getUserInfo'}}"
9 bindgetphonenumber="getPhoneNumber" 8 bindgetphonenumber="getPhoneNumber"
10 bindgetuserinfo='getUserInfo' 9 bindgetuserinfo='getUserInfo'
11 - bindupdateuserinfo="updateUserInfo">登录/注册 10 + bindupdateuserinfo="updateUserInfo">
12 </login-button> 11 </login-button>
  12 + </image>
  13 + </view>
  14 + <!-- 已登录 -->
13 <block wx:else> 15 <block wx:else>
14 - <image class="header-bg" src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2700915385,2771074487&fm=26&gp=0.jpg" mode="aspectFill"> 16 + <!-- 头部用户信息 -->
  17 + <view class="header-bg">
  18 + <image class="user-info" src="{{isLogin ? userInfo.avatarUrl : ''}}" mode="aspectFill">
  19 + <view class="black-cover">
15 <view class="user-info"> 20 <view class="user-info">
16 <image class="portrait" src="{{userInfo.avatarUrl}}" mode="aspectFill"></image> 21 <image class="portrait" src="{{userInfo.avatarUrl}}" mode="aspectFill"></image>
17 <view class="nick-name">{{userInfo.nickName}}</view> 22 <view class="nick-name">{{userInfo.nickName}}</view>
18 - <view class="qrcode-view" bindtap="tapMyQRCode"> 23 + <view class="qrcode-view" bindtap="tapMyQRCode" wx:if="{{isLogin}}">
19 <image class="qrcode-icon" src="../../static/images/myQRcode@3x.png"></image> 24 <image class="qrcode-icon" src="../../static/images/myQRcode@3x.png"></image>
20 <view class="qrcode-tips">我的二维码</view> 25 <view class="qrcode-tips">我的二维码</view>
21 </view> 26 </view>
22 </view> 27 </view>
  28 + </view>
23 </image> 29 </image>
24 - </block>  
25 </view> 30 </view>
26 31
27 <!-- 我的门票 --> 32 <!-- 我的门票 -->
@@ -59,6 +64,7 @@ @@ -59,6 +64,7 @@
59 </block> 64 </block>
60 </scroll-view> 65 </scroll-view>
61 </block> 66 </block>
  67 + </block>
62 68
63 </view> 69 </view>
64 <quickNavigation id="quickNavigation" isShowIndicator="{{isShowIndicator}}" isShowShopCart="{{true}}" isShowMenu="{{false}}" marginBottom="{{50}}" bind:backToTop="backToTop"></quickNavigation> 70 <quickNavigation id="quickNavigation" isShowIndicator="{{isShowIndicator}}" isShowShopCart="{{true}}" isShowMenu="{{false}}" marginBottom="{{50}}" bind:backToTop="backToTop"></quickNavigation>
@@ -2,6 +2,30 @@ @@ -2,6 +2,30 @@
2 position: relative; 2 position: relative;
3 } 3 }
4 4
  5 +.not-login-view {
  6 + width: 100%;
  7 + height: 100%;
  8 + background-color: #fff;
  9 + display: flex;
  10 + justify-content: center;
  11 +}
  12 +
  13 +.not-login-view .login-icon {
  14 + position: absolute;
  15 + width: 369rpx;
  16 + height: 277rpx;
  17 + margin-top: 45%;
  18 +}
  19 +
  20 +.not-login-view .login-icon .login-btn {
  21 + position: absolute;
  22 + bottom: 0;
  23 + left: 0;
  24 + width: 369rpx;
  25 + height: 80rpx;
  26 + opacity: 0.01;
  27 +}
  28 +
5 .header-bg { 29 .header-bg {
6 width: 750rpx; 30 width: 750rpx;
7 height: 360rpx; 31 height: 360rpx;
@@ -16,7 +40,16 @@ @@ -16,7 +40,16 @@
16 display: flex; 40 display: flex;
17 flex-direction: column; 41 flex-direction: column;
18 align-items: center; 42 align-items: center;
19 - z-index: 99; 43 +}
  44 +
  45 +.user-info .black-cover {
  46 + opacity: 0.8;
  47 + background-color: #000;
  48 + position: absolute;
  49 + top: 0;
  50 + left: 0;
  51 + width: 100%;
  52 + height: 360rpx;
20 } 53 }
21 54
22 .user-info .portrait { 55 .user-info .portrait {