1.使用canvas组件实现ayhw。
代码如下:
//index.wxml
<view class="container"><canvas canvas-id="wuhuan" style="width: 300px; height: 300px;"></canvas></view>
//index.js
Page({
onReady: function () {
const ctx = wx.createCanvasContext('wuhuan');
ctx.beginPath();
ctx.arc(60, 80, 40, 0, 2 * Math.PI);
ctx.lineWidth=6;
ctx.strokeStyle='black'
ctx.stroke();
ctx.beginPath();
ctx.arc(140, 80, 40, 0, 2 * Math.PI);
ctx.lineWidth=6;
ctx.strokeStyle='black'
ctx.stroke();
ctx.beginPath();
ctx.arc(220, 80, 40, 0, 2 * Math.PI);
ctx.lineWidth=6;
ctx.strokeStyle='black'
ctx.stroke();
ctx.beginPath();
ctx.arc(100, 140, 40, 0, 2 * Math.PI);
ctx.lineWidth=6;
ctx.strokeStyle='black'
ctx.stroke();
ctx.beginPath();
ctx.arc(180, 140, 40, 0, 2 * Math.PI);
ctx.lineWidth=6;
ctx.strokeStyle='black'
ctx.stroke();
ctx.draw();
}
})
效果显示:
2.使用想对组件,完成书页页面。
//index.wxml
<view>书单</view>
<view>
<image src="../../image/t3.jpg" mode="" class="t1"/>
<view class="q1">
<image src="../../image/t4.jpg" mode="" class="t2"/>
<view class="jzt">
<view class="z1">金字塔原理</view>
<view class="z2">芭芭拉.明托(Barbara Minto)</view>
<view class="z3">金字塔原理是一种重点突出。逻辑清晰、主次分明的逻辑思路、表达方式和规范动作....</view>
</view>
</view>
<view style="border: 1px solid black;"></view>
<view class="q1">
<image src="../../image/t5.jpg" mode="" class="t3"/>
<view class="jycq">
<view class="z1">基业长青</view>
<view class="z2">[英]古梅.柯林斯.杰里.波勒斯</view>
<view class="z3">(基业长青(珍藏版))打破了旧有神话,提供了新颖的见解,并为那些有志于建立经得....</view>
</view>
</view>
</view>
//index.wxss
.t1{
width: 100%;
height: 250px;
}
.q1{
width: 400px;
height: 120px;
display: flex;
margin-left: 20px;
margin-top: 20px;
}
.t2{
width: 60px;
height: 80px;
padding-top: 6px;
}
.jzt{
padding-left: 10px;
}
.jzt .z1{
font-weight: bold;
font-size: 18px;
}
.jzt .z2{
font-weight: bold;
font-size: 12px;
line-height: 30px;
}
.jzt .z3{
width: 250px;
font-size: 12px;
}
.t3{
width: 60px;
height: 80px;
padding-top: 6px;
}
.jycq{
padding-left: 10px;
}
.jycq .z1{
font-weight: bold;
font-size: 18px;
}
.jycq .z2{
font-weight: bold;
font-size: 12px;
line-height: 30px;
}
.jycq .z3{
width: 250px;
font-size: 12px;
}
效果如下:
3. 使用想对组件,完成西安找拼车小程序部分界面。
代码如下:
//index.wxml
<view>西安找拼车</view>
<view class="lxfs">联系方式(手机和微信至少填一项)</view>
<view style="border-bottom: 1px solid #ccc;"></view>
<view class="d1">
<view class="n1">称呼*</view>
<input type="text" placeholder="请输入称呼" style="margin-top: 12px;margin-left: 75px;"/>
</view>
<view class="d1">
<view class="n1">手机号</view>
<input type="password" placeholder="请输入手机号" style="margin-top: 12px;margin-left: 65px;"/>
</view>
<view style="display: flex; line-height: 50px;border-bottom: 1px solid #ccc;">
<view class="n1">微信号</view>
<input type="text" placeholder="请输入微信号" style="margin-top: 12px;margin-left: 65px;"/>
</view>
<view style="border-bottom: 1px solid #ccc;"></view>
<view class="pcxx">拼车信息</view>
<view class="d1">
<view class="n1">出发地点*</view>
<input type="text" placeholder="限7个字" style="margin-top: 12px;margin-left: 40px;"/>
</view>
<view class="d1">
<view class="n1">目的地*</view>
<input type="text" placeholder="限7个字" style="margin-top: 12px;margin-left: 55px;"/>
</view>
<view style="display: flex; line-height: 50px;">
<view style="font-size: 18px; font-weight: bold;margin-left:20px ;">空座数*</view>
<input type="text" placeholder="请输入空座数" style="margin-top: 12px;margin-left: 50px;"/>
</view>
<view style="border-bottom: 1px solid #ccc;"></view>
//index.wxss
.lxfs{
background-color: #F5F5F5;
line-height: 50px;
color: #B1AFB0;
border-bottom: 1px solid #ccc;
padding-left: 20px;
}
.d1{
display: flex;
line-height: 50px;
}
.pcxx{
background-color: #F5F5F5;
line-height: 50px;
color: #B1AFB0;
border-bottom: 1px solid #ccc;
padding-left: 20px;
}
.n1{
font-size: 17px;
font-weight: bold;
margin-left:20px
}
效果如下:
4.人生进程是一款极简的小程序,它只有一个功能:就是计算一个人从出生到现在已经度过了多少个月,请编写程序完成此功能。
代码如下:
//index,wxml
<view style="text-align: center;">中国现阶段人均寿命900个月</view>
<form bindsubmit="bind" style="line-height: 60px;">
<view style="display: flex; font-size: 20px;">
<input class="p1" type="text" name="time" placeholder="请输入时间"/>至今{{people}}个月</view>
<view style="display: flex;">
<button class="b1" formType="submit">请输入后再点击此按钮</button>
<button class="b1" formType="reset" style="width: 150px;font-size: 13px;">清除记录</button>
</view>
</form>
<view style="margin-top:50px;"><image src="../../image/t6.jpg" class="t1" /></view>
<view style="width: 350px;"><text bindtap="changeText">{{text1}}</text></view>
//index.wxss
.p1{
width: 100px;
padding-top: 20px;
padding-left: 30px;
}
.b1{
font-weight: bold;
padding-right: 20px;
width: 175px;
font-size: 14px;
}
.t1{
width: 150px;
height: 300px;
margin-left: 100px;
}
//index.js
Page({
data:{
text1: '能把在前面行走的机会抓住的人,十有八九都会成功。',
people:new Date().toLocaleDateString()
},
changeText: function() {
this.setData({
text1: '成功了'
});
},
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)
}
})
效果如下: