Authored by 肖亚东

用户注册后获取个人信息等bug修改

  1 +// components/resources/pop_up/pop_up.js
  2 +
  3 +
  4 +Component({
  5 + /**
  6 + * 组件的属性列表
  7 + */
  8 + properties: {
  9 + content: {
  10 + type: String,
  11 + },
  12 + isshow: {
  13 + type: Boolean,
  14 + value: true
  15 + },
  16 + },
  17 +
  18 + /**
  19 + * 组件的初始数据
  20 + */
  21 + data: {
  22 +
  23 + },
  24 +
  25 + /**
  26 + * 组件的方法列表
  27 + */
  28 + methods: {
  29 + confirmAction: function (e) {
  30 + this.setData({
  31 + isshow: false
  32 + });
  33 + },
  34 + getUserInfo(e) {
  35 + this.triggerEvent('registerToGetUserInfo', e);
  36 + }
  37 + }
  38 +});
  1 +{
  2 + "component": true,
  3 + "usingComponents": {}
  4 +}
  1 +<!-- components/resources/pop_up/pop_up.wxml -->
  2 +<view class="pop_up {{isshow?'':'hide'}}">
  3 + <view class='pop_content'>
  4 + <view class="pop_bd">
  5 + <view class='pop_title' wx:if='{{content}}'>
  6 + <text>{{content}}</text>
  7 + </view>
  8 + <view class="linView"></view>
  9 + <view class='pop_btn'>
  10 + <button class='okBtn'
  11 + bindtap='cancelPop'
  12 + open-type="getUserInfo"
  13 + bindgetuserinfo='getUserInfo'
  14 + bindtap="confirmAction">确定
  15 + </button>
  16 + </view>
  17 + </view>
  18 + </view>
  19 +</view>
  1 +/* components/resources/pop_up/pop_up.wxss */
  2 +
  3 +.pop_up {
  4 + position: fixed;
  5 + left: 0;
  6 + top: 0;
  7 + right: 0;
  8 + bottom: 0;
  9 + background: rgba(0, 0, 0, 0.7);
  10 + display: flex;
  11 + align-items: center;
  12 + justify-content: center;
  13 + z-index: 9999;
  14 +}
  15 +
  16 +.pop_content {
  17 + width: 70%;
  18 + position: relative;
  19 +}
  20 +
  21 +
  22 +.pop_bd {
  23 + width: 100%;
  24 + background-color: #fff;
  25 + border-radius: 15rpx;
  26 + text-align: center;
  27 + box-sizing: border-box;
  28 + overflow: hidden;
  29 + padding-top: 40rpx;
  30 +}
  31 +
  32 +.linView {
  33 + margin-top: 20rpx;
  34 + background-color: #e0e0e0;
  35 + height: 2rpx;
  36 +}
  37 +.okBtn {
  38 + background-color: #fff;
  39 + margin: 0;
  40 + padding: 0;
  41 +}
  42 +.okBtn::after {
  43 + border-radius: 0;
  44 + border: 0;
  45 +}
  46 +
  47 +
  48 +.pop_title {
  49 + font-size: 36rpx;
  50 +}
  51 +.pop_btn {
  52 + text-align: center;
  53 +}
  54 +
  55 +.hide {
  56 + display: none;
  57 +}
@@ -37,6 +37,8 @@ Page(extend({},Toast,{ @@ -37,6 +37,8 @@ Page(extend({},Toast,{
37 isLogin: false, 37 isLogin: false,
38 userInfo: {}, 38 userInfo: {},
39 hasUnionID: '', 39 hasUnionID: '',
  40 + isShowPopup: false,
  41 + registerTips: '欢迎加入Yoho!Family!',
40 42
41 ticketData: [], 43 ticketData: [],
42 onActivityList: [],//正在进行的活动 44 onActivityList: [],//正在进行的活动
@@ -267,12 +269,22 @@ Page(extend({},Toast,{ @@ -267,12 +269,22 @@ Page(extend({},Toast,{
267 269
268 } else { 270 } else {
269 if (result.is_register){ 271 if (result.is_register){
270 - that.showZanToast({ title: '欢迎加入Yoho!Family!',success:function(){  
271 - let uid = app.globalData.userInfo.uid > 0 ? app.globalData.userInfo.uid : 0;  
272 - app.updateUid(uid)  
273 - that.setData({ uid });  
274 - that.showUserInfo();  
275 - }},1500); 272 + let uid = app.globalData.userInfo.uid > 0 ? app.globalData.userInfo.uid : 0;
  273 + that.setData({
  274 + uid,
  275 + isShowPopup: true,
  276 + });
  277 +
  278 + // that.showZanToast({ title: '欢迎加入Yoho!Family!',success:function(){
  279 + // let uid = app.globalData.userInfo.uid > 0 ? app.globalData.userInfo.uid : 0;
  280 + // app.updateUid(uid)
  281 + // that.setData({ uid });
  282 + // getUnionID(app.getWechatThirdSession(), function (response) {
  283 + // if (response.succeed === true) {
  284 + // that.showUserInfo();
  285 + // }
  286 + // })
  287 + // }}, 2000);
276 } else { 288 } else {
277 let uid = app.globalData.userInfo.uid > 0 ? app.globalData.userInfo.uid : 0; 289 let uid = app.globalData.userInfo.uid > 0 ? app.globalData.userInfo.uid : 0;
278 app.updateUid(uid) 290 app.updateUid(uid)
@@ -288,6 +300,21 @@ Page(extend({},Toast,{ @@ -288,6 +300,21 @@ Page(extend({},Toast,{
288 } 300 }
289 }, 301 },
290 302
  303 + //注册后上传并获取用户信息
  304 + registerToGetUserInfo(e) {
  305 + let that = this;
  306 + decodeUnionId(app.getWechatThirdSession(),e.detail, function (response){
  307 + if (response.isHaveUnionID){
  308 + that.setData({
  309 + hasUnionID: true,
  310 + isLogin:true
  311 + });
  312 + } else {
  313 + // console.log("没有获取到unionid");
  314 + }
  315 + });
  316 + },
  317 +
291 loginAndRegisterTapped:function() { 318 loginAndRegisterTapped:function() {
292 // console.log("loginAndRegisterTapped"); 319 // console.log("loginAndRegisterTapped");
293 let that = this; 320 let that = this;
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 "undone-view": "/components/user-center/undone-view/index", 6 "undone-view": "/components/user-center/undone-view/index",
7 "ticket-slide": "/components/user-center/ticket-slide/index", 7 "ticket-slide": "/components/user-center/ticket-slide/index",
8 "activity-item": "/components/activity-item/index", 8 "activity-item": "/components/activity-item/index",
9 - "login-button": "/components/login-button/login-button" 9 + "login-button": "/components/login-button/login-button",
  10 + "pop_up": "/components/pop_up/pop_up"
10 } 11 }
11 } 12 }
@@ -9,10 +9,12 @@ @@ -9,10 +9,12 @@
9 bindgetuserinfo='getUserInfo' 9 bindgetuserinfo='getUserInfo'
10 bindupdateuserinfo="updateUserInfo"> 10 bindupdateuserinfo="updateUserInfo">
11 </login-button> 11 </login-button>
  12 + <pop_up content="{{registerTips}}" isshow="{{isShowPopup}}" bind:registerToGetUserInfo='registerToGetUserInfo'></pop_up>
12 </image> 13 </image>
13 </view> 14 </view>
14 <!-- 已登录 --> 15 <!-- 已登录 -->
15 <block wx:else> 16 <block wx:else>
  17 +
16 <!-- 头部用户信息 --> 18 <!-- 头部用户信息 -->
17 <view class="header-bg"> 19 <view class="header-bg">
18 <image class="user-info" src="{{isLogin ? userInfo.avatarUrl : ''}}" mode="aspectFill"> 20 <image class="user-info" src="{{isLogin ? userInfo.avatarUrl : ''}}" mode="aspectFill">