为了账号安全,请及时绑定邮箱和手机立即绑定

【金秋打卡】第6天 全新升级,基于Vue3新标准,打造后台综合解决方案 第六讲

标签:
Vue.js

课程章节: vue3 + element plus 综合实现解决方案与个人中心页面实现

主讲老师: Sunday

课程内容:

今天学习的内容包括:

开发个人中心页面

课程收获:

6.1 心得:

// pages/userHome/userHome.js

var config = require("../../utils/config.js");
var app = getApp();
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
    userInfo: {},
		isLogin: false
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function (options) {

	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function () {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function () {
    this.loadData();
	},
  loadData: function () {
    var that = this;
    app.getOpenId(function (openid) {
      if (openid) {
        config.httpGet(app.getUrl('api/BiddMemberCenter/GetUser'), {
          openId: openid,
          userkey: ""
        }, function (res) {
          if (res.result) {
            res.data.Photo = app.globalData.wxUserInfo.headImage ? app.globalData.wxUserInfo.headImage : res.data.Photo;
            that.setData({
              isLogin: true,
              userInfo: res.data
            });
            wx.setStorageSync('userInfo', res.data);
          }
        });


      } else {
        that.setData({
          isLogin: false
        });
      }
    }, "userhome");

  },
	bindUserTap: function (e) {
		var url = e.currentTarget.dataset.url;
		if (!this.data.isLogin) {
		  url = '../login/login';
		}
		wx.navigateTo({
		  url: url
		})
	},

	  goLogin: function () {
		wx.navigateTo({
		  url: '../login/login'
		})
	  },

	  exitLoginout: function () {
		var that = this;
		wx.showModal({
		  title: '提示',
		  content: '确定退出登录吗?',
		  success: function (res) {
			if (res.confirm) {
			  wx.removeStorageSync('wxOpenId');
			  wx.removeStorageSync("userInfo");
			  app.globalData.wxUserInfo = null;
			  app.globalData.openId = "";
			  that.setData({
				isLogin: false
			  });
			}
		  }
		})
	  },
	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function () {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function () {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function () {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function () {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function () {

	}
})
/* pages/userHome/userHome.wxss */

.user_info {
	display: flex;
	align-items: center;
	width: 686rpx;
	margin: 0 auto 47rpx auto;
	line-height: 1;
}

.user_info image {
	width: 120rpx;
	height: 120rpx;
	border-radius: 50%;
	margin-right: 26rpx;
}

.login,
.user_name {
	color: #2E2E2E;
	font-size: 44rpx;
	margin-bottom: 21rpx;
}

.welcome {
	font-size: 24rpx;
	color: #C4C4C4;
}

.coupon {
	width: 686rpx;
	height: 240rpx;
	background: #FFFFFF;
	border: 2rpx solid #C8C8C8;
	border-radius: 12rpx;
	margin: 0 auto;
}

.coupon_title {
	display: flex;
	justify-content: space-between;
	margin: 30rpx 52rpx 16rpx 30rpx;
}

.coupon_package {
	font-size: 30rpx;
	color: #2E2E2E;
}

.view_all {
	font-size: 26rpx;
	color: #C4C4C4;
}

.coupon_list {
	display: flex;
	justify-content: space-around;
}

.coupon_detail {
	text-align: center;
	font-size: 26rpx;
	color: #C4C4C4;
	line-height: 1;
}

.coupon_detail image {
	width: 88rpx;
	height: 88rpx;
	margin-bottom: 12rpx;
}

.list{
	width: 686rpx;
	height: 88rpx;
	background: #FFFFFF;
	border: 2rpx solid #C8C8C8;
	border-radius: 12rpx;
	margin: 16rpx auto 0 auto;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.contact {
	width: 686rpx;
	padding: 0;
	height: 88rpx;
	background: #FFFFFF;
	border: 2rpx solid #C8C8C8;
	border-radius: 12rpx;
	margin: 16rpx auto 0 auto;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.list {
	width: 686rpx;
	height: 88rpx;
	background: #FFFFFF;
	border: 2rpx solid #C8C8C8;
	border-radius: 12rpx;
	margin: 16rpx auto 0 auto;
	display: flex;
	justify-content: space-between;
	align-items: center;
}


.list_left {
	display: flex;
	align-items: center;
	margin-left: 30rpx;
	font-size: 30rpx;
	color: #2E2E2E;
	line-height: 1;
}

.list_icon {
	width: 30rpx;
	height: 30rpx;
	margin-right: 18rpx;
}

.jump {
	width: 14rpx;
	height: 26rpx;
	margin-right: 30rpx;
}

图片描述

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消