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

  1. wxml

<view>
    <!-- 顶部图片 -->
    <view>
        <image class="indeximage" src="/images/person.jpg" mode="widthFix"></image>
    </view>
    <!-- 用户登录 -->
    <view>
        <block>
            <!-- 未登录 -->
            <view wx:if="{{!isLogined}}" class="no-login-title">
                <text>您尚未登录,</text>
                <text class="btn-login">点我登录</text>
            </view>
            <!-- 已登录 -->
            <view wx:else class="no-login-title">
                <button type="primary" class="btn-exit">退出登录</button>
            </view>
        </block>
    </view>
    <!-- 用户背景 -->
    <view class="user-info">
        <!-- 未登录 -->
        <view wx:if="{{!isLogined}}" class="user-info-bg">
            <view class="user-info-wrap">
                <image src="/images/nologin.jpg"></image>
                <view class="user-nickname">匿名用户</view>
            </view>
        </view>
        <!-- 已登录 -->
        <view class="user-info-bg">
            <view class="user-info-wrap">
                <image src="{{userInfo.avatarUrl}}"></image>
                <view class="user-nickname">{{userInfo.nickName}}</view>
            </view>
        </view>
    </view>

    <!-- 操作信息 -->
    <view class="usermenu">
        <view class="address" bindtap="handleaddress">收货地址</view>
        <view class="infocontact" bindtap="contactus">
            <text>联系我们</text>
            <text class="inforight">></text>
        </view>
        <view class="infocontact">
            <text>意见反馈</text>
            <text class="inforight">010-83050808</text>
        </view>
    </view>

</view>
  1. wxss

page {
    background-color: #f6f6f6;
}

/* 顶部图片 */
.indeximage {
    width: 100%;
    height: 100%;
}

/* 登录样式 */
.no-login-title {
    text-align: center;
    font-weight: 600;
    margin: 10rpx 0;
    font-size: 16px;
}

.no-login-title .btn-login {
    color: darkorange;
}

/* 用户背景 */
.user-info {
    width: 100%;
    display: flex;
}

.user-info .user-info-bg {
    position: relative;
    height: 34vh;
}

.user-info .user-info-bg .user-info-wrap {
    position: relative;
    top: 30%;
    text-align: center;
    margin-left: 120px;
}

.user-info .user-info-bg .user-info-wrap image {
    width: 150rpx;
    height: 150rpx;
    border-radius: 50%;
    margin-top: -70rpx;
}

.user-info .user-info-bg .user-info-wrap .user-nickname {
    color: red;
    font-weight: 600;
    font-size: 36rpx;
}

/* 用户菜单样式 */
.usermenu {
    margin-top: 11rpx;
}

.usermenu .address {
    margin: 15rpx;
    background-color: white;
    padding-left: 35rpx;
    padding: 20rpx;
}

.usermenu .infocontact {
    background-color: white;
    margin: 15rpx;
    padding-left: 35rpx;
    padding: 20rpx;
}

.usermenu .infocontact .inforight {
    float: right;
}
  1. js

// pages/personal/personal.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        isLogined: false,//登录标志,默认未登录
        userInfo: {},//用户信息
    },
    //收货地址
    handleaddress() {
        wx.chooseAddress({
            success: (result) => {

            }
        });
    },
    //联系我们
    contactus() {
        wx.navigateTo({
            url: '/pages/we/we',
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {

    },

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

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

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

    },

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

    },

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

    },

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

    }
})
  1. 效果

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
微信小程序是一种基于微信平台的应用的开发模式,可以快速的开发出符合用户需求的小程序。在小程序开发中,组件是一个非常重要的概念,通过组件可以实现复用性和模块化编程思想。 组件应用是小程序开发的基础。通过组件可以将某一模块化并封装起来,使得组件可以在不同的页面间得到复用,大大提升了开发效率并减少了代码冗余。微信小程序提供了丰富的自带组件,包括文本、图片、按钮、输入框等等,开发者也可以自己开发组件来满足自己的需求。实际开发中,通过组件可以快速搭建页面框架和业务逻辑。 Demo是一个演示小程序的示例程序。在小程序的实际开发过程中,一个好的Demo非常重要。通过Demo,开发人员可以更深入的了解小程序开发流程、组件的应用和实际的业务开发等等。在Demo中,通常会包括小程序的一些基础操作,如页面跳转、数据绑定、组件的使用等。而在实际开发中,Demo还会包括一些复杂的业务场景,如支付、登录、数据列表展示等等。Demo不仅为开发者提供了学习和实践的机会,也方便了使用者了解该小程序的功能和特点。 总之,微信小程序组件的应用和Demo的开发都是小程序开发过程中非常重要的两个部分。良好的组件应用和精心设计的Demo,可以在极短的时间内实现小程序开发

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hqwest

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值