当前位置:   article > 正文

小白开发微信小程序43--个人中心页面布局2_微信小程序写个人中心页面

微信小程序写个人中心页面
  1. wxml

  1. <view>
  2. <!-- 顶部图片 -->
  3. <view>
  4. <image class="indeximage" src="/images/person.jpg" mode="widthFix"></image>
  5. </view>
  6. <!-- 用户登录 -->
  7. <view>
  8. <block>
  9. <!-- 未登录 -->
  10. <view wx:if="{{!isLogined}}" class="no-login-title">
  11. <text>您尚未登录,</text>
  12. <text class="btn-login">点我登录</text>
  13. </view>
  14. <!-- 已登录 -->
  15. <view wx:else class="no-login-title">
  16. <button type="primary" class="btn-exit">退出登录</button>
  17. </view>
  18. </block>
  19. </view>
  20. <!-- 用户背景 -->
  21. <view class="user-info">
  22. <!-- 未登录 -->
  23. <view wx:if="{{!isLogined}}" class="user-info-bg">
  24. <view class="user-info-wrap">
  25. <image src="/images/nologin.jpg"></image>
  26. <view class="user-nickname">匿名用户</view>
  27. </view>
  28. </view>
  29. <!-- 已登录 -->
  30. <view class="user-info-bg">
  31. <view class="user-info-wrap">
  32. <image src="{{userInfo.avatarUrl}}"></image>
  33. <view class="user-nickname">{{userInfo.nickName}}</view>
  34. </view>
  35. </view>
  36. </view>
  37. <!-- 操作信息 -->
  38. <view class="usermenu">
  39. <view class="address" bindtap="handleaddress">收货地址</view>
  40. <view class="infocontact" bindtap="contactus">
  41. <text>联系我们</text>
  42. <text class="inforight">></text>
  43. </view>
  44. <view class="infocontact">
  45. <text>意见反馈</text>
  46. <text class="inforight">010-83050808</text>
  47. </view>
  48. </view>
  49. </view>
  1. wxss

  1. page {
  2. background-color: #f6f6f6;
  3. }
  4. /* 顶部图片 */
  5. .indeximage {
  6. width: 100%;
  7. height: 100%;
  8. }
  9. /* 登录样式 */
  10. .no-login-title {
  11. text-align: center;
  12. font-weight: 600;
  13. margin: 10rpx 0;
  14. font-size: 16px;
  15. }
  16. .no-login-title .btn-login {
  17. color: darkorange;
  18. }
  19. /* 用户背景 */
  20. .user-info {
  21. width: 100%;
  22. display: flex;
  23. }
  24. .user-info .user-info-bg {
  25. position: relative;
  26. height: 34vh;
  27. }
  28. .user-info .user-info-bg .user-info-wrap {
  29. position: relative;
  30. top: 30%;
  31. text-align: center;
  32. margin-left: 120px;
  33. }
  34. .user-info .user-info-bg .user-info-wrap image {
  35. width: 150rpx;
  36. height: 150rpx;
  37. border-radius: 50%;
  38. margin-top: -70rpx;
  39. }
  40. .user-info .user-info-bg .user-info-wrap .user-nickname {
  41. color: red;
  42. font-weight: 600;
  43. font-size: 36rpx;
  44. }
  45. /* 用户菜单样式 */
  46. .usermenu {
  47. margin-top: 11rpx;
  48. }
  49. .usermenu .address {
  50. margin: 15rpx;
  51. background-color: white;
  52. padding-left: 35rpx;
  53. padding: 20rpx;
  54. }
  55. .usermenu .infocontact {
  56. background-color: white;
  57. margin: 15rpx;
  58. padding-left: 35rpx;
  59. padding: 20rpx;
  60. }
  61. .usermenu .infocontact .inforight {
  62. float: right;
  63. }
  1. js

  1. // pages/personal/personal.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. isLogined: false,//登录标志,默认未登录
  8. userInfo: {},//用户信息
  9. },
  10. //收货地址
  11. handleaddress() {
  12. wx.chooseAddress({
  13. success: (result) => {
  14. }
  15. });
  16. },
  17. //联系我们
  18. contactus() {
  19. wx.navigateTo({
  20. url: '/pages/we/we',
  21. })
  22. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad(options) {
  27. },
  28. /**
  29. * 生命周期函数--监听页面初次渲染完成
  30. */
  31. onReady() {
  32. },
  33. /**
  34. * 生命周期函数--监听页面显示
  35. */
  36. onShow() {
  37. },
  38. /**
  39. * 生命周期函数--监听页面隐藏
  40. */
  41. onHide() {
  42. },
  43. /**
  44. * 生命周期函数--监听页面卸载
  45. */
  46. onUnload() {
  47. },
  48. /**
  49. * 页面相关事件处理函数--监听用户下拉动作
  50. */
  51. onPullDownRefresh() {
  52. },
  53. /**
  54. * 页面上拉触底事件的处理函数
  55. */
  56. onReachBottom() {
  57. },
  58. /**
  59. * 用户点击右上角分享
  60. */
  61. onShareAppMessage() {
  62. }
  63. })
  1. 效果

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/279616
推荐阅读
相关标签
  

闽ICP备14008679号