第四章课后操作题

文章介绍了如何在微信小程序中利用canvas组件绘制奥运五环,并展示了书单页面和西安找拼车小程序的部分界面设计,包括日期选择器的使用。
摘要由CSDN通过智能技术生成

1:使用canvas组件实现“奥运五环”的绘制

//wxml
<canvas class="place" canvas-id="myCanvas">
 
</canvas>



//wxss
.place{
  margin: 10px;
  border: black 3px solid;
}




//js
Page({
  onLoad: function (options) {
    var maru = wx.createCanvasContext('myCanvas');
    maru.beginPath();
    maru.arc(50,50,45,0,2*Math.PI);
    maru.setStrokeStyle('blue');
    maru.stroke();
    maru.beginPath();
    maru.arc(100,50,45,0,2*Math.PI);
    maru.setStrokeStyle('black');
    maru.stroke();
    maru.beginPath();
    maru.arc(170,50,45,0,2*Math.PI);
    maru.setStrokeStyle('red');
    maru.stroke();
    maru.beginPath();
    maru.arc(80,90,45,0,2*Math.PI);
    maru.setStrokeStyle('yellow');
    maru.stroke();
    maru.beginPath();
    maru.arc(140,90,45,0,2 * Math.PI);
    maru.setStrokeStyle('green');
    maru.stroke();
    maru.draw();
  }
})

2:使用相应组件,完成书单页面

//wxss
.title{
  background-color: black;
}
.count{
  color: white;
  text-align: center;
  font-size: 25px;
  padding: 20px;
}
.count1{
  color: white;
  padding: 5px;
}
.hon{
  margin: 35px;
}
.kyori{
  margin-left: 50px;
}
.img1{
  width: 400px;
  height: 240px;
}
.img2{
  width: 400px;
  height: 240px;
}
.text1{
  font-size: 20px;
  font-weight: 700;
}
.text2{
  font-size: 25px;
  font-weight: 600;
}
.line{
  margin-top: 50px;
  border-bottom: 4px solid #ccc;
}
.kyori1{
  margin-top: 50px;
}





//js
<view class="title">
  <view class="count">培养商业意识,走出生活,职场和事业的困境</view>
  <view class="count1">创新者是如何思考问题的?本书单包括了互联网,思维方式,商业,文案,市场,营销等方方面面,是在思维方式上的创新,略去传统商学院的教条</view>
</view>
<view class="hon">
  <view style="display: flex;">
   <image class="img1" src="../image/aaa.jpg"/>
    <view class="kyori">
      <view class="text1">金字塔原理</view>
      <view class="text2">芭芭拉•明托(Barbara Minto)</view>
      <view class="text3">金字塔原理是一种重点突出、逻辑清晰、主次分明的逻辑思路、表达方式和规范动作……</view>
    </view>
  </view>
  <view class="line"></view>
  <view class="kyori1" style="display: flex;">
    <image class="img2" src="../image/bbb.jpg"/>
    <view class="kyori">
      <view class="text1">基业长青</view>
      <view class="text2">[美]吉姆•柯林斯,杰里•波勒斯</view>
      <view class="text3">《基业长青(珍藏版)》打破了旧有神话,提供了新颖的见解,并为那些有志于建立经得……</view>
    </view>
  </view>
</view>

3:使用相应组件,完成“西安找拼车”小程序部分界面

//wxml
<view class="background">联系方式(手机和微信至少填一项)</view>
<view >
<view class="nickname">
<view>称呼*</view> 
<input type="text" placeholder="请输入昵称"/>
</view>
<view class="nickname">
<view>手机号</view> <input type="text" placeholder="请输入手机号"/>
</view>
<view class="nickname">
<view>微信号</view> <input type="text" placeholder="请输入微信号"/>
</view>
</view>
 
<view class="background">拼车信息</view>
<view >
<view class="nickname">
<view>出发地点*</view> <input type="text" placeholder="限七个字"/>
</view>
<view class="nickname">
<view>目的地*</view> <input type="text" placeholder="限七个字"/>
</view>
<view class="nickname">
<view>空座数*</view> <input type="text" placeholder="请输入空座数"/>
</view>
</view>
 
 
 
 
 //wxss
.background{
  width: 400px;
  height: 40px;
  background-color: #cccccc;
  color: grey;
  line-height: 40px;
  padding-left: 15px;
  border: 1px solid grey;
}
input{
 padding-top: 14px;
}
.nickname{
  margin-left: 12px; 
  border-bottom: 1px solid grey;
  height: 50px;
}
.nickname view{
  font-weight: bold;
  float: left;
  width: 100px;
  line-height: 50px;
}

编程题

//js
Page({
  data: {
    startdate:1145,
    enddate:2077,
    date:'2024',
    year:"2024",
    month:"3",
    day:"29",
    months:"114514"
  },
  changedate(e){
this.setData({date:e.detail.value});
 var date = new Date(e.detail.value);
var data=new Date()
var newyear = data.getFullYear(); 
 var newmonth = data.getMonth() + 1;
 var year = date.getFullYear();
 var month = date.getMonth() + 1;
 var day = date.getDate();
var months=(newyear-year-1)*12+12-(month-newmonth)
 this.setData({months:months});
 console.log("年: " + year + ", 月: " + month + ", 日: " + day);
  },
  clean(){
this.setData({
  year:"",
  month:"",
  day:"",
  months:""
})
}})



//wxml
<view class="title">中国现阶段人均寿命900个月</view>
<view class="date">
{{year}}年{{month}}月{{day}}日至今{{months}}个月
</view>
<view class="position">
<picker 
mode="date" 
start="{{startdate}}" 
end="{{enddate}}" 
value="{{date}}" bindchange="changedate">
 <button 
 style="width: 145px;">
  换一个日期
</button>
</picker>
<button 
style="width: 145px;" bind:tap="clean">
清除记录
</button>
</view>
<image src="/images/3.jpg"/>
<view class="tail">
能把在前面行走的机会抓住的人,十有八九都会成功。
</view>




//wxss
.title{
  text-align: center;
}
.date{ 
  margin-top: 10px;
  text-align: center;
  font-weight: bold;
}
.position{
  margin: 25px 0 0 40px;
  }
 picker{
  float: left;
} 
 image{
  width: 200px;
  height: 380px;
  margin-left: 85px;
}
.tail{
  font-weight: bold;
  font-size: 16px;
  margin: 0 15px;
}

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值