微信小程序个人中心、我的界面(示例四)

微信小程序个人中心、我的界面,九宫格简单布局(示例四)

微信小程序个人中心、我的界面,超简洁的九宫格界面布局,代码粘贴即用。更多微信小程序界面示例,请进入我的主页哦!

1、js代码

javascript 复制代码
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgPath: '',
    menuList: [
      [{
          'title': '功能一',
          'icon': 'success',
          'iconColor': '#dd6161'
        },
        {
          'title': '功能二',
          'icon': 'success_no_circle',
          'iconColor': 'orange'
        },
        {
          'title': '功能三',
          'icon': 'info',
          'iconColor': '#19be6b'
        }
      ],
      [{
          'title': '功能四',
          'icon': 'warn',
          'iconColor': '#f29100'
        },
        {
          'title': '功能五',
          'icon': 'waiting',
          'iconColor': '#909399'
        },
        {
          'title': '功能六',
          'icon': 'cancel',
          'iconColor': '#606266'
        }
      ],
      [{
          'title': '功能七',
          'icon': 'download',
          'iconColor': 'purple'
        },
        {
          'title': '功能八',
          'icon': 'search',
          'iconColor': '#18b566'
        },
        {
          'title': '功能九',
          'icon': 'clear',
          'iconColor': '#f29100'
        },
      ],
    ],
  },
  // 功能监听
  clickBtn(e) {
    let tag = e.currentTarget.dataset.id;
    console.log('点击信息', tag)
  },
  // 菜单监听
  menuClick(e) {
    let tab = e.currentTarget.dataset.item;
    console.log('点击信息', tab)
  },
  // 头像切换
  avatarClick(e) {
    this.setData({
      imgPath: e.detail.avatarUrl
    })
    console.log('点击信息',e.detail.avatarUrl)
  }
})

2、wxml代码

xml 复制代码
<view class="top-box">
  <block wx:if="{{imgPath==''}}">
    <button class="avatar center" bindchooseavatar="avatarClick" open-type="chooseAvatar">头像</button>
  </block>
  <block wx:else>
    <view class="center">
      <image class="avatar" src="{{imgPath}}" mode="widthFix" />
    </view>
  </block>
  <view class="nick center">三脚猫的喵</view>
</view>
<view class="center-box center">
  <text bind:tap="clickBtn" data-id="0">功能一</text>
  <text>|</text>
  <text bind:tap="clickBtn" data-id="1">功能二</text>
</view>
<!-- 菜单 -->
<view>
  <block wx:for="{{menuList}}" wx:key="itemA" wx:for-item="itemA" wx:for-index="indexA">
    <view class="row-list">
      <block wx:for="{{itemA}}" wx:key="item" wx:for-item="item" wx:for-index="index">
        <view class="tab-col {{(index==1 || index==4 || index==7)?'border':''}}" bind:tap="menuClick" data-item="{{item}}">
          <icon class="icon-item" type="{{item.icon}}" size="30" color="{{item.iconColor}}"></icon>
          <text>{{item.title}}</text>
        </view>
      </block>
    </view>
  </block>
</view>

3、wxss代码

css 复制代码
page {
  font-size: 32rpx;
  background-color: #F1F1F1;
}

.avatar {
  width: 140rpx;
  height: 140rpx;
  border-radius: 120rpx;
  padding: 0;
  font-size: 32rpx;
}

.top-box {
  background-color: #44ADFB;
  padding-bottom: 60rpx;
  border-radius: 0 0 30% 30%;
}

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

.nick {
  margin: 20rpx 0;
  font-size: 34rpx;
  color: white;
}

.center-box {
  margin-top: -40rpx;
  color: #525151;
}

.center-box text {
  background-color: white;
  padding: 20rpx 25rpx;
  text-align: center;
}

.center-box text:nth-child(1) {
  border-radius: 50rpx 0 0 50rpx;
}

.center-box text:nth-child(2) {
  color: #44ADFB;
}

.center-box text:nth-child(3) {
  border-radius: 0 50rpx 50rpx 0;
}

.row-list {
  display: flex;
  flex-direction: row;
  text-align: center;
}

.tab-col {
  width: 33.33%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30rpx 0;
  border-bottom: 1rpx solid #FFFFFF;
  color: #525151;
}

.icon-item {
  margin-bottom: 15rpx;
}

.border {
  border-left: 1rpx solid #FFFFFF;
  border-right: 1rpx solid #FFFFFF;
}

4、json代码

javascript 复制代码
{
  "usingComponents": {},
  "navigationBarTitleText": "我的界面",
  "navigationBarBackgroundColor": "#44ADFB"
}

更多微信小程序示例的分享,请进入我的主页查看哦。。。

相关推荐
崔庆才丨静觅5 小时前
hCaptcha 验证码图像识别 API 对接教程
前端
passerby60616 小时前
完成前端时间处理的另一块版图
前端·github·web components
掘了6 小时前
「2025 年终总结」在所有失去的人中,我最怀念我自己
前端·后端·年终总结
崔庆才丨静觅6 小时前
实用免费的 Short URL 短链接 API 对接说明
前端
崔庆才丨静觅6 小时前
5分钟快速搭建 AI 平台并用它赚钱!
前端
崔庆才丨静觅7 小时前
比官方便宜一半以上!Midjourney API 申请及使用
前端
Moment7 小时前
富文本编辑器在 AI 时代为什么这么受欢迎
前端·javascript·后端
崔庆才丨静觅7 小时前
刷屏全网的“nano-banana”API接入指南!0.1元/张量产高清创意图,开发者必藏
前端
剪刀石头布啊7 小时前
jwt介绍
前端
爱敲代码的小鱼7 小时前
AJAX(异步交互的技术来实现从服务端中获取数据):
前端·javascript·ajax