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.完成书单页面
代码
wxml
<view class="title">
<view class="count">培养商业意识,走出生活,职场和事业的困境</view>
<view class="count1">创新者是如何思考问题的?本书单包括了互联网,思维方式,商业,文案,市场,营销等方方面面,是在思维方式上的创新,略去传统商学院的教条</view>
</view>
<view class="hon">
<view style="display: flex;">
<image class="img1" src="/images/1.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="/images/2.jpg"/>
<view class="kyori">
<view class="text1">基业长青</view>
<view class="text2">[美]吉姆•柯林斯,杰里•波勒斯</view>
<view class="text3">《基业长青(珍藏版)》打破了旧有神话,提供了新颖的见解,并为那些有志于建立经得……</view>
</view>
</view>
</view>
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;
}
app.json
"window": {
"navigationBarBackgroundColor": "#ac5845",
"navigationBarTextStyle": "black",
"navigationBarTitleText": "← 书单",
"backgroundColor": "#eeeeee",
"backgroundTextStyle": "light",
"enablePullDownRefresh": true
}
}
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;
}
4.编程题
代码
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>
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:""
})
}})
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;
}