微信小程序项目之失物招领平台-5.我的主页页面编写

1.先附上我的主页的效果图
wx_project_6
2.userMsg.js文件

 // pages/userMsg/userMsg.js
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
     tabs1: [
       {
         text: '首页',
       },
       {
         text: '发布',
       },
       {
         text: '查询',
       },
       {
         text: '我的',
       },
     ],
   },
 
   handleChange(e) {
     const index = e.detail.value;
     console.log(e);
     console.log("value: " + e.detail.value);
     switch (index) {
       case 0:
         wx.redirectTo({
           url: '/pages/lostandfound/lostandfound',
         })
         break;
       case 1:
         wx.redirectTo({
           url: '/pages/send/send',
         })
         break;
       case 2:
         wx.redirectTo({
           url: '/pages/find/find',
         })
         break;
       case 3:
         // wx.navigateTo({
         //   url: '/pages/userMsg/userMsg',
         // })
         break;
     }
   },
   handleSelected() {
     this.setData({
       index: 2,
     });
   },
   handleClick(e) {
     const { index, title } = e.detail;
     console.log('点击了tab:' + index, title);
   },
 
 /**
  * 跳转到我的发布页面
  */
   toMySend(event){
 
      wx.navigateTo({
        url: 'mySend/mySend',
      })
   },
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
 
   },
 
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady: function () {
 
   },
 
   /**
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
 
   },
 
   /**
    * 生命周期函数--监听页面隐藏
    */
   onHide: function () {
 
   },
 
   /**
    * 生命周期函数--监听页面卸载
    */
   onUnload: function () {
 
   },
 
   /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh: function () {
 
   },
 
   /**
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {
 
   },
 
   /**
    * 用户点击右上角分享
    */
   onShareAppMessage: function () {
 
   }
 })

3.userMsg.json文件

{
  "navigationBarTitleText": "我的",
  "usingComponents": {
    "w-button": "/dist/w-button/index",
    "w-tabs": "/dist/w-tabs/index",
    "w-avatar": "/dist/w-avatar/index"
  }
}

4.userMsg.wxml文件

<!--pages/userMsg/userMsg.wxml-->
<!-- 头像及用户名部分 -->
<view class='avatar-backgrond'>
     <!-- <view class="avatar"> 
        	<w-avatar src="{{item.avatar}}" size="large" >W</w-avatar>  <!--头像 -->
  <!-->   </view> -->
     <view  class='userInfo'>
       <image src="/images/photo_1.jpg" class='userinfo-avatar'> </image>
     </view>
     <view class='username'>
         <text >yxc</text>
     </view>
</view>

<view class='function' catchtap='toMySend'>
  <text>我的发布</text>
</view>

<!--分割线 -->
<view class='divLine'></view>

<!-- 导航栏-->
<view class='tabs'>
 <w-tabs bind:onChange="handleChange" currentIndex="3" options="{{ tabs1 }}" />
</view>

5.userMsg.wxss文件

/* pages/userMsg/userMsg.wxss */
.tabs{
  position: fixed;
  width: 100%;
  bottom: 0;
}

.avatar-backgrond{
  width: 100%;
  height: 350rpx;
  background-color: rgb(14, 161, 14);
}

.avatar{

     /* 居中 */
  margin-top: 100rpx;  
  display: flex;
  justify-content: center;
  overflow: hidden;
  width: 161rpx;
  height: 161rpx;
  border-radius: 50%;
}

.userinfo-avatar{
  margin-top: 50rpx;
  width: 200rpx;
  height:200rpx;
  border-radius: 50%;
  display: flex;
  overflow: hidden;
  text-align: center;
}

.userInfo{
  display: flex;
flex-direction: row;
justify-content:center;
}

.username{
  text-align: center;
  color: white;
}

/*分割线样式*/
.divLine{
 background: #E0E3DA;
 width: 100%;
 height: 5rpx;
}

.function{
  width: 100%;
  height: 90rpx;
  margin-top: 30rpx;
  margin-left: 30rpx;
}

6.其中点击我的发布跳转到的页面同首页一样

获取源码:https://github.com/yangxuechen/LostAndFound/tree/master/wx_app

  • 1
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值