第四章作业

1.使用canvas组件实现"五色圈"的绘制
运行代码:

<!--.wxml-->
<canvas canvas-id="myCanvas"></canvas>
//.js
Page({
    onLoad:function(){
    const ctx = wx.createCanvasContext('myCanvas');
    const width = 300; // 画布宽度
    const height = 300; // 画布高度
    ctx.canvas.width = width;
    ctx.canvas.height = height;
 
    // 绘制蓝色圆环
ctx.beginPath();
ctx.arc(width / 2, height / 2, 100, 0, 2 * Math.PI);
ctx.setFillStyle('#0000FF');
ctx.fill();
ctx.closePath();
 
// 绘制黄色圆环
ctx.beginPath();
ctx.arc(width / 2 + 120, height / 2, 100, 0, 2 * Math.PI);
ctx.setFillStyle('#FFFF00');
ctx.fill();
ctx.closePath();
 
// 绘制黑色圆环
ctx.beginPath();
ctx.arc(width / 2 + 240, height / 2, 100, 0, 2 * Math.PI);
ctx.setFillStyle('#000000');
ctx.fill();
ctx.closePath();
 
// 绘制绿色圆环
ctx.beginPath();
ctx.arc(width / 2 + 60, height / 2 + 100, 100, 0, 2 * Math.PI);
ctx.setFillStyle('#00FF00');
ctx.fill();
ctx.closePath();
 
// 绘制红色圆环
ctx.beginPath();
ctx.arc(width / 2 + 180, height / 2 + 100, 100, 0, 2 * Math.PI);
ctx.setFillStyle('#FF0000');
ctx.fill();
ctx.closePath();
}
})

2.所有相应组件,完成书单页面
运行代码:

<!--.wxml-->
<view >
<image src="pages/box/1.png" mode=""class="SD"/>
<view class="A">
<image src="pages/box/2.jpg" mode="" class="AA"/>
<view class="AAA">
<view class="A1">金字塔原理</view>
<view class="A2">芭芭拉.明托(Barbara Minto)</view>
<view class="A3">金字塔原理是一种重点突出。逻辑清晰、主次分明的逻辑思路、表达方式和规范动作....</view>
</view>
</view>
<view class="B">
<image src="pages/box/3.jpg" mode="" class="BB"/>
<view class="BBB">
<view class="B1">基业长青</view>
<view class="B2">[英]古梅.柯林斯.杰里.波勒斯</view>
<view class="B3">(基业长青(珍藏版))打破了旧有神话,提供了新颖的见解,并为那些有志于建立经得....</view>
</view>
</view>
</view>
 
/*.wxss */
.SD{
    width: 100%;
    height: 150px;
  }
  .A{
    width: 450px;
    height: 130px;
    display: flex;
    margin-left: 5px;
    margin-top: 5px;
  }
  .AA{
    width: 55px;
    height: 80px;
    padding-top: 5px;
  }
  .AAA{
    padding-left: 10px;
    font-family: "微软雅黑";
  }
  .AAA .A1{
  font-weight: bold;
  font-size: 17px;
  }
  .AAA .A2{
    font-weight: bold;
    font-size: 13px;
    line-height: 30px;
  }
  .AAA .A3{
    width: 250px;
  font-size: 13px;
  }
  .B{
    width: 450px;
    height: 130px;
    display: flex;
    margin-left: 5px;
    margin-top: 5px;
  }
  .BB{
    width: 55px;
    height: 80px;
    padding-top: 5px;
  }
  .BBB{
    padding-left: 10px;
    font-family: "微软雅黑";
  }
  .BBB .B1{
    font-weight: bold;
    font-size: 17px;
     
    }
    .BBB .B2{
      font-weight: bold;
      font-size: 13px;
      line-height: 30px;
    }
    .BBB .B3{
      width: 250px;
    font-size: 13px;
    }

代码运行结果

3.使用相应组件,完成西安找拼车页面
运行代码:

<!--.wxml-->
<view class="lxfs">
联系方式(手机和微信至少填一项)</view>
<view class="box">
<view class="zi">称呼*</view>
<input type="text" placeholder="请输入称呼" style="margin-top: 12px;margin-left: 83px;"/>
</view>
<view class="box">
<view class="zi">手机号*</view>
<input type="text" placeholder="请输入手机号" style="margin-top: 12px;margin-left: 65px;"/>
</view>
<view style="display: flex; line-height: 50px;border-bottom: 1px solid #ccc;">
<view class="zi">微信号*</view>
<input type="text" placeholder="请输入微信号" style="margin-top: 12px;margin-left: 65px;"/>
</view>
<view class="lxfs">拼车信息</view>
<view class="box">
<view class="zi">出发地点*</view>
<input type="text" placeholder="限7个字" style="margin-top: 12px;margin-left: 50px;"/>
</view>
<view class="box">
<view class="zi">目的地*</view>
<input type="text" placeholder="限7个字" style="margin-top: 12px;margin-left: 65px;"/>
</view>
<view style="display: flex; line-height: 50px;border-bottom: 1px solid #ccc;">
    <view class="zi">目的地*</view>
<input type="text" placeholder="限7个字" style="margin-top: 12px;margin-left: 65px;"/>
</view>
 
/**.wxss**/
.lxfs{
    background-color: #F5F5F5;
    line-height: 30px;
    color: #B1AFB0;
    border-bottom: 1px solid #ccc;
    padding-left: 10px;
  }
.box{
    padding-top: 10px;
  display: flex;
  line-height: 30px;
}
.zi{
  font-size: 15px; 
  font-weight: bold;
  margin-left:20px 
}

代码运行结果:

4.人生进程小程序
运行代码:

<!--.wxml-->
<view style="text-align: center;">中国现阶段人均寿命900个月</view>
<form bindsubmit="bind" style="line-height: 60px;">
<view style="display: flex; font-size: 20px;">
<input type="text" name="time" placeholder="请输入时间" class="shijian"/>至今:{{people}}个月</view>
<view style="display: flex;">
<button formType="submit" class="riqi">换个日期</button>
<button formType="reset" style="width: 150px;font-size: 13px;">清除记录</button>
</view>
</form>
<view >
<image src="pages/1.jpg" class="tupian"/>
</view>
<view style="width: 350px;">
  <text bindtap="changeText1">{{ text1 }}</text>
</view>
 
/**.wxss**/
.shijian{
    width: 110px;
    padding-top: 18px;
    padding-left: 30px;
  }
  .riqi{
    padding-right: 10px;
    width: 100px;
    font-size: 15px;
    font-weight: bold;
  }
  .tupian{
    width: 200px;
    height: 250px;
    margin-left: 65px;
  }
 
//.js
Page({ 
    data:{  
     text1: '能把在前面行走的机会抓住的人,十有八九都会成功。',
         people:new Date().toLocaleDateString()
       },
       bind:function(e){
         var time = new Date().toLocaleDateString()
         var year = time.substring(0,time.indexOf("/"))
         var mo = time.substring(time.indexOf("/")+1,time.lastIndexOf("/")) 
         
         var value = e.detail.value.time
         var year2 = value.substring(0,time.indexOf("/"))
         var mo2 = value.substring(time.indexOf("/")+1,time.lastIndexOf("/"))
     
         var m1 = (year - year2 -1)*12+12-(mo2-mo)
         this.setData({
           people : m1
         })
       }
 })

代码运行结果:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值