一、实验简介 二、实验目标
三、实验步骤
第二步: 修改 app.json 添加页面清单,修改标题栏默认属性 1. { 2. "pages":[ 3. "pages/index/index" 4. ], 5. "window":{ 6. "backgroundTextStyle":"light", 7. "navigationBarBackgroundColor": "#ffffff", 8. "navigationBarTitleText": "Hello World", 9. "navigationBarTextStyle":"black" 10. } 11. } 第三步: 修改 app.wxss 设定全局样式 1. .container { 2. height: 100%; 3. display: flex; 4. flex-direction: column; 5. align-items: center; 6. justify-content: space-between; 7. padding: 100rpx 0; 8. box-sizing: border-box; 9. }
2. 用户登录 1. var app = getApp(); 2. Page({ 3. data: { 4. hello: 'hello world', 5. userInfo: { 6. avatarUrl:'http://of2is3ok3.bkt.clouddn.com/nopic.gif', 7. nickName:'载入中..' 8. } 9. }, 10. onLoad: function () { 11. var that = this; 12. app.user.login().then(function( uinfo ){ 13. that.setData({userInfo:uinfo}); 14. }); 15. } 16. }); 第二步: 修改 pages/index/index.wxml 更新页面布局 > 1. <view class="container"> > 2. <view bindtap="bindViewTap" class="userinfo"> > 3. <image class="userinfo-avatar" src="{{userInfo.avatarUrl}}" backgro und-size="cover"></image> > 4. <text class="userinfo-nickname">{{userInfo.nickName}}</text> > 5. </view> > 6. <view class="usermotto"> > 7. <text class="user-motto">{{hello}}</text> > 8. </view> > 9. </view> 第三步: 修改 pages/index/index.wxss 微调页面样式 1. .userinfo { 2. display: flex; 3. flex-direction: column; 4. align-items: center; 5. } 6. 7. .userinfo-avatar { 8. width: 128rpx; 9. height: 128rpx; 10. margin: 20rpx; 11. border-radius: 50%; 12. } 13. 14. .userinfo-nickname { 15. color: #aaa; 16. } 17. 18. .usermotto { 19. margin-top: 120px; 20. } 第五步: 修改 pages/index/index.json 设置页面名称 1. { 2. "navigationBarTitleText": "用户登录 效果预览: 通过微信开发者工具,通过模拟器可以实时预览效果
3.2 商品列表页 1. view { 2. color:#232323; 3. font-size:32rpx; 4. } 5. 6. button[type="primary"][plain] { 7. border: 1px solid #81c7d1; 8. color: #81c7d1; 9. } 10. 11. button[type="primary"] { 12. color:#FFFFFF; 13. background-color:#81c7d1; 14. } 15. 16. .topbar{ 17. background: #f5f5f5; 18. line-height: 64rpx; 19. position: fixed; 20. width: 100%; 21. z-index: 1000; 22. border-bottom: 2rpx solid #e1e1e1; 23. } 24. ...
2. 购物车布局
1. <view class="bottombar view-row"> 2. <view style="width:88rpx;"> 3. <image mode="widthFix" src="/res/icons/shop.png"></image> 4. </view> 5. <view style="width:40%"> 6. <text style="padding-left:20rpx;"> {{cart.total}} 件商品 {{cart.show _price}} 元 </text> 7. </view> 8. <view class="text-right" style="width:50%"> 9. 10. <button 11. class="push-t-10 push-r-10" 12. type="default" size="mini" loading="{{loading}}" 13. disabled="{{disabled}}" 14. bindtap="cleanup"> 清空 </button> 15. <button 16. class="push-t-10 push-r-10" 17. type="warn" size="mini" loading="{{loading}}" 18. disabled="{{disabled}}" 19. data-link="{{order}}" bindtap="payout"> 结算 </button> 20. |