1. 使用canvas组件实现“奥运五环”的绘制
//.js
Page({
onReady() {
const ctx = wx.createCanvasContext('olympic-rings');
// 绘制蓝色圆环
ctx.beginPath();
ctx.arc(60, 60, 40, 0, 2 * Math.PI);
ctx.setStrokeStyle('#0072bb');
ctx.stroke();
// 绘制黑色圆环
ctx.beginPath();
ctx.arc(135, 100, 40, 0, 2 * Math.PI);
ctx.setStrokeStyle('#000000');
ctx.stroke();
// 绘制红色圆环
ctx.beginPath();
ctx.arc(85, 100, 40, 0, 2 * Math.PI);
ctx.setStrokeStyle('#ff6319');
ctx.stroke();
// 绘制黄色圆环
ctx.beginPath();
ctx.arc(110, 60, 40, 0, 2 * Math.PI);
ctx.setStrokeStyle('#f4d942');
ctx.stroke();
// 绘制绿色圆环
ctx.beginPath();
ctx.arc(160, 60, 40, 0, 2 * Math.PI);
ctx.setStrokeStyle('#009e52');
ctx.stroke();
ctx.draw();
}
})
//.wxml
<canvas canvas-id="olympic-rings" style="width: 300px; height: 200px;margin: auto;"></canvas>
2.使用相应组件,完成“书单页面”
<view style="font-size: 30px;position: absolute;top: 100px;top: 25px;"> ⬅书单</view>
<view>
<view class="h1">
<image src="/image/wx.jpg" mode="pu1" class="tou"style="position:absolute;top:60px"/>
</view></view>
<view>
<view style="position: absolute;top:90px;color: grey;left: 40px;font-size: 25px;">培养商业意识,走出生活,职场和事业的困境。</view>
<view style="position: absolute;top: 85px;color: grey;left: 15px;top: 170px;font-size: 18px;">创新者是如何思考问题的?本书单包括了互联网,思维方式,商业,文案,市场,营销等方方面面,是在思维方式上的创新,略去传统商学院的教条</view>
</view>
<view class="er">
<view class="er1">金字塔原理</view>
<view class="er2">芭芭拉.明托</view>
<view class="er3">金字塔原理是一种重点突出,逻辑清晰,主次分明的逻辑思路,表达方式和规范动作</view>
</view>
<view class="hh">
<view class="hh"><image src="/images/wx2.jpg" mode=""class="tu1"/></view></view>
<view class="hh1" style="border-bottom: 1px solid darkgrey;padding: 10px;"></view>
<view class="kk">
<view><image src="/images/jycq.jpg" mode=""class="tu2"/></view></view>
<view class="pp">
<view class="qq">基业长青</view>
<view class="mm">吉姆·柯林斯、杰里·波拉斯</view>
<view class="jj">《基业长青》表达的是一种普遍规律,是一种管理理念、组织结构和行为方式,书中富于创造性地打破了关于企业管理与运作的种种旧有神话</view>
</view>
.tou{
float: left;
margin-top: 8px;
width: 450px;
height: 220px;
}
.pu1{
margin: 0 auto;
float: left;
display: block;
width: 180px;
height: 160px;
}
.er{
margin-top: 10px;
}
.hh {
position: absolute;
}
.kk{
margin-top: 30px;
position: absolute;
}
.er{
margin-top: 5px;
float: right;
}
.pp{
margin-top: 5px;
float: right;
}
.tu2{
margin: 0 auto;
float: left;
display: block;
width: 180px;
height: 160px;
margin-top: 60px;
}
.er1{
margin: 0 auto;
display: block;
font-size: 30px;
float: none;
display: block;
margin-left: 200px;
margin-top: 310px;
}
.qq{
position: absolute;
left: 195px;
top: 500px;
font-size: 30px;
}
.mm{
color: black;
position: absolute;
left: 200px;
top:540px;
font-size: 10px;
}
.jj{
position: absolute;
left: 200px;
top:570px;
font-size: 10px;
color: gray;
}
.er2{
display: block;
font-size: 15px;
float: none;
display: block;
margin-left: 200px;
margin-top: 10px;
}
.er3{
display: block;
font-size: 10px;
float: right;
display: block;
margin-left: 200px;
margin-top: 10px;
color: grey;
}
3.使用相应组件,完成“西安找拼车” 小程序部分界面
<!--index.wxml-->
<view style="background-color: black;height: 60px;"><view style="color: white;padding-top: 20px;">×西安找拼车</view>
</view>
<view style="color:grey;padding-top: 10px;background-color: darkgray;height: 35px;">
联系方式(手机号和微信至少填一项)</view>
<view class="fo" style="border-bottom: 1px solid darkgrey;padding: 0px;"></view>
<view>
<view style="font-size: 20px;position: absolute;top: 115px;">称呼*</view>
<view style="font-size: 20px;color: grey;position: absolute;left: 140px;top:115px">请输入称呼</view>
</view>
<view class="fo" style="border-bottom: 1px solid darkgrey;padding: 20px;"></view>
<view>
<view style="font-size: 20px;position: absolute;top:150px">手机号</view>
<view style="font-size: 20px;color: grey;position: absolute;left: 140px;top:150px">请输入手机号</view>
</view>
<view class="fo" style="border-bottom: 1px solid darkgrey;padding: 20px;"></view>
<view>
<view style="font-size: 20px;position: absolute;top: 195px;">微信号</view>
<view style="font-size: 20px;color: grey;position: absolute;left: 140px;top:195px">请输入微信号</view>
</view>
<view class="fo" style="border-bottom: 1px solid darkgrey;padding: 23px;"></view>
<view style="color:grey;padding-top: 10px;background-color: darkgray;height: 35px;">
拼车信息</view>
<view class="fo" style="border-bottom: 1px solid darkgrey;padding: 0px;">
</view>
<view>
<view style="font-size: 20px;position: absolute;top: 290px;">出发地点*</view>
<view style="font-size: 20px;color: grey;position: absolute;left: 140px;top:290px">限7个字</view>
</view>
<view class="fo" style="border-bottom: 1px solid darkgrey;padding: 25px;"></view>
<view>
<view style="font-size: 20px;position: absolute;top: 340px;">目的地*</view>
<view style="font-size: 20px;color: grey;position: absolute;left: 140px;top:340px">限7个字</view>
</view>
<view class="fo" style="border-bottom: 1px solid darkgrey;padding: 25px;"></view>
<view>
<view style="font-size: 20px;position: absolute;top: 390px;">空座位*</view>
<view style="font-size: 20px;color: grey;position: absolute;left: 140px;top:390px">请输入空座位</view>
</view>
<view class="fo" style="border-bottom: 1px solid darkgrey;padding: 25px;"></view>
4.“人生进程”是一款极简的小程序,它只有一个功能:就是计算一个人从出生到现在已经度过了多少个月,请编写程序完成此功能。
.f1{
text-align: center;
}
.rq{
text-align: center;font-weight: bold;margin-top: 10px;
}
picker{
float: left;
}
.dd{
margin: 25px 0 0 40px;
}
image{
width: 200px;
height: 380px; margin-left: 85px;
}
.wz{
font-size: 16px;margin: 0 15px;font-weight: bold;
}
wxml:
<view class="f1">中国现阶段人均寿命900个月</view>
<view class="rq">{{n}}年{{y}}月{{r}}日至今{{e}}个月</view>
<view class="dd">
<picker mode="date" start="{{startdate}}" end="{{enddate}}" value="{{date}}" bindchange="changedate">
<button style="width: 140px;"> 换一个日期</button>
</picker>
<button class="b" style="width: 120px;" bind:tap="clean">清除记录</button>
</view>
<image src="/images/tp6.png" mode=""/>
<view class="wz">能把在前面行走的机会抓住的人,十有八九都会成功。</view>
js:
Page({
data: {
startdate:2000,
enddate:2050,
date:'2004',
n:"2004",
y:"10",
r:"24",
e:"233"
},
changedate(e){
this.setData({date:e.detail.value});
console.log(e.detail.value);
let date = new Date(e.detail.value);
let sjc=new Date()
let newyear = sjc.getFullYear();
let newmonth = sjc.getMonth() + 1;
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
let yue=(newyear-year-1)*12+12-(month-newmonth)
console.log(yue);
this.setData({n:year,y:month,r:day});
this.setData({e:yue});
console.log("年: " + year + ", 月: " + month + ", 日: " + day);
},
clean(){
this.setData({
n:"",
y:"",
r:"",
e:""
})
},
onLoad(options) {
},
onReady() {
},
onShow() {
},
onHide() {
},
onUnload() {
},
onPullDownRefresh() {
},
onReachBottom() {
},
onShareAppMessage() {
}
})