当前位置:   article > 正文

微信小程序学习笔记(八)----用户个人中心界面_menuitems: [ { text: '个人资料', url: '#', icon: '/ima

menuitems: [ { text: '个人资料', url: '#', icon: '/images/user/user1.png', t

到了实现三个菜单里面最后一个个人中心页面的时候了,这个没有自己写,因为写到现在虽然对小程序前端有了一些了解,但是还谈不上很熟悉,所以借鉴了一个网友的文章,在他的基础上自己改了一下,因为之前的我直接用是显示不全的,不过改了之后不如之前好看,后面会附上这个网友的文章地址。

最终我实现的效果是这样的:

其实用到的东西并不多,主要还是一些前端的样式,下面是实现步骤和代码。

第一,准备图片素材

我依旧还是从阿里矢量图上找的图片,下面附上网站:

http://www.iconfont.cn/collections/detail?cid=29

找到自己需要的矢量图下载png格式就可以了

第二,目录结构

第三,实现代码

.wxml文件

  1. <!--pages/user/user.wxml-->
  2. <view class="mine-wrapper">
  3. <view class="avatar-wrapper">
  4. <view>
  5. <view class="avatar">
  6. <image style="border-radius:50%;" src="{{userinfo.avatarUrl ? userinfo.avatarUrl:'/images/user/user1.png'}}"></image>
  7. </view>
  8. <view class="text">
  9. <text wx:if="{{userinfo.nickName}}">{{userinfo.nickName}}</text>
  10. <text wx:else bindtap="toLogin">注册 / 登录</text>
  11. </view>
  12. <view class="text">
  13. <text wx:if="{{userSign==2}}">{{"您还没有填写真实信息,请填写"}}</text>
  14. <text wx:elif="{{userSign==1}}">{{"会员用户"}}</text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="list-wrapper">
  19. <view class="alllists">
  20. <block wx:for="{{menuitems}}" wx:key="menu_for">
  21. <navigator url="{{item.url}}" class="lists">
  22. <view class='content'>
  23. <view class="listimg">
  24. <image src="{{item.icon}}"></image>
  25. </view>
  26. <view class="listtext">{{item.text}}</view>
  27. <view class="listicon">{{item.tips}}</view>
  28. <view class="arrows">
  29. <image src="{{item.arrows}}"></image>
  30. </view>
  31. </view>
  32. </navigator>
  33. <!-- 分割线 -->
  34. <view class="divLine"></view>
  35. </block>
  36. </view>
  37. </view>
  38. </view>

.js文件

  1. // pages/user/user.js
  2. var _app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. menuitems: [
  9. { text: '个人资料', url: '#', icon: '/images/user/user1.png', tips: '', arrows: '/images/user/arrows.png' },
  10. { text: '邀请好友', url: '#', icon: '/images/user/user2.png', tips: '', arrows: '/images/user/arrows.png' },
  11. { text: '积分兑换', url: '#', icon: '/images/user/user3.png', tips: '', arrows: '/images/user/arrows.png' },
  12. { text: '帮助说明', url: '#', icon: '/images/user/user4.png', tips: '', arrows: '/images/user/arrows.png' }
  13. ]
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. },
  20. /**
  21. * 生命周期函数--监听页面初次渲染完成
  22. */
  23. onReady: function () {
  24. },
  25. /**
  26. * 生命周期函数--监听页面显示
  27. */
  28. onShow: function () {
  29. },
  30. /**
  31. * 生命周期函数--监听页面隐藏
  32. */
  33. onHide: function () {
  34. },
  35. /**
  36. * 生命周期函数--监听页面卸载
  37. */
  38. onUnload: function () {
  39. },
  40. /**
  41. * 页面相关事件处理函数--监听用户下拉动作
  42. */
  43. onPullDownRefresh: function () {
  44. },
  45. /**
  46. * 页面上拉触底事件的处理函数
  47. */
  48. onReachBottom: function () {
  49. },
  50. /**
  51. * 用户点击右上角分享
  52. */
  53. onShareAppMessage: function () {
  54. }
  55. })

.wxss

  1. /* pages/user/user.wxss */
  2. .avatar-wrapper {
  3. background: #1b82d1;
  4. padding: 25px 0;
  5. }
  6. .avatar-wrapper .avatar {
  7. margin: 0 auto;
  8. text-align: center;
  9. }
  10. .avatar-wrapper .avatar image {
  11. width: 100px;
  12. height: 100px;
  13. }
  14. .avatar-wrapper .text {
  15. text-align: center;
  16. color: #fff;
  17. }
  18. .listimg image {
  19. margin-right: 5px;
  20. vertical-align: middle;
  21. width: 20px;
  22. height: 20px;
  23. }
  24. .content{
  25. display: flex;
  26. margin-top: 10px;
  27. margin-bottom: 10px;
  28. }
  29. /*分割线样式*/
  30. .divLine{
  31. background: #E0E3DA;
  32. width: 100%;
  33. height: 5rpx;
  34. }
  35. .arrows image {
  36. vertical-align: middle;
  37. width: 15px;
  38. height: 15px;
  39. margin-left: 500rpx;
  40. }
  41. /* user.wxss */

最后附上借鉴的网友的文章,感谢!

https://blog.csdn.net/xbw12138/article/details/75213088

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

闽ICP备14008679号