1.奥运五环
代码:
wxml
<canvas canvas-id="olympic-rings" style="width: 300px; height: 200px;margin: auto;"></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(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('#000000');
ctx.stroke();
// 绘制绿色圆环
ctx.beginPath();
ctx.arc(85, 100, 40, 0, 2 * Math.PI);
ctx.setStrokeStyle('#009e52');
ctx.stroke();
// 绘制红色圆环
ctx.beginPath();
ctx.arc(135, 100, 40, 0, 2 * Math.PI);
ctx.setStrokeStyle('#ff6319');
ctx.stroke();
ctx.draw();
}
})
代码执行结果:
2.完成书单页面
代码:
<!-- wxml文件 -->
<view class="head">← 书单</view>
<!-- 上面的结构 -->
<view class="p1">
<view class="p2">培养商业意识,走出生活,职场和事业的困境</view>
<view class="p3">创新者是如何思考问题的?本书单包括了互联网,思维方式,商业,文案,市场,营销等方方面面,是在思维方式上的创新,略去传统商学院的教条</view>
</view>
<!-- 中间的结构 -->
<view class="shu">
<view class="imgone" style="display: flex;">
<image class="img1" src="/pages/tp/ea4b6f4b7dfe2b7acc2a9a8cbbbc5e1.jpg"/>
<view class="textone">
<view class="text1">活着</view>
<view class="text2">余华</view>
<view class="text3">活着》是中国当代作家余华创作的长篇虚构小说,首次发表于《收获》1992年第6期</view>
</view>
</view>
<view class="xian"></view>
<!-- 下面的结构 -->
<view class="imgtwo" style="display: flex;">
<image class="img2" src="/pages/tp/1.webp"/>
<view class="texttwo">
<view class="text1">水浒传</view>
<view class="text2">施耐庵</view>
<view class="text3">《水浒传》是元末明初编著的长篇小说(现存刊本署名大多有施耐庵或罗贯中或两人皆有),是中国历史上第一部用白话文写成的章回体长篇小说</view>
</view>
</view>
</view>
/* wxss文件 */
/* 上面的样式 */
.head{
font-size: 60rpx;
margin-top: 200rpx;
}
.p1{
background-color: black;
}
.p2{
color: aliceblue;
text-align: center;
font-size: 45rpx;
padding: 30rpx;
}
.p3{
color: aliceblue;
padding: 20rpx;
}
/* 中间的样式 */
.shu{
margin: 50rpx;
}
.textone{
margin-left: 50rpx;
}
.img1{
width: 700rpx;
height: 350rpx;
}
.img2{
width: 700rpx;
height: 350rpx;
}
.text1{
font-size: 70rpx;
font-weight: 700;
}
.text2{
font-size: 40rpx;
font-weight: 600;
}
.xian{
margin-top: 50rpx;
border-bottom: 4px solid #ccc;
}
/* 下面的样式 */
.imgtwo{
margin-top: 50rpx;
}
.texttwo{
margin-left: 50rpx;
}
代码执行结果
3.完成西安找拼车的小程序部分页面
代码:
<!-- wxml文件 -->
<view class="head">✕ 西安找拼车</view>
<!-- 联系方式 -->
<view class="one">
<view class="txw">联系方式(手机和微信至少填一项)</view>
</view>
<view class="two">
<view class="two2">称呼*</view>
<view class="two3">请输入称呼</view>
</view>
<view class="three">
<view class="three2">手机号</view>
<view class="three3">请输入手机号</view>
</view>
<view class="four">
<view class="four2">微信号</view>
<view class="four3">请输入微信号</view>
</view>
<!-- 拼车信息 -->
<view class="one">
<view class="txw">拼车信息</view>
</view>
<view class="five">
<view class="five2">出发地点*</view>
<view class="five3">限7个字</view>
</view>
<view class="six">
<view class="six2">目的地*</view>
<view class="six3">限7个字</view>
</view>
<view class="seven">
<view class="seven2">空座数*</view>
<view class="seven3">请输入空座数</view>
</view>
.head{
margin-top: 100rpx;
font-size: 70rpx;
color: aliceblue;
background-color: black;
}
/* 联系方式 js文件 */
.one{
padding: 45rpx 0 0 40rpx;
border-bottom: 4px solid #c0c0c0;
background-color: #ccc;
}
.txw{
width: auto;
height: 100rpx;
font-size: 35rpx;
}
.two{
margin-left: 30px;
padding: 20px 0 20px 0;
border-bottom: 4px solid #c0c0c0;
}
.two2{
font-size: 55rpx;
font-weight: 700;
}
.two3{
position: absolute;
left: 180px;
top: 217px;
font-size: 55rpx;
}
.three{
margin-left: 30px;
padding: 20px 0 20px 0;
border-bottom: 4px solid #c0c0c0;
}
.three2{
font-size: 55rpx;
font-weight: 700;
}
.three3{
position: absolute;
left: 180px;
top: 300px;
font-size: 55rpx;
}
.four{
padding: 20px 0 20px 30px;
border-bottom: 4px solid #c0c0c0;
}
.four2{
font-size: 55rpx;
font-weight: 700;
}
.four3{
position: absolute;
left: 180px;
top: 385px;
font-size: 55rpx;
}
/* 拼车信息 js文件 */
.five{
margin-left: 30px;
padding: 20px 0 20px 0px;
border-bottom: 4px solid #c0c0c0;
}
.five2{
font-size: 55rpx;
font-weight: 700;
}
.five3{
position: absolute;
left: 180px;
top: 555px;
font-size: 55rpx;
}
.six{
margin-left: 30px;
padding: 20px 0 20px 0px;
border-bottom: 4px solid #c0c0c0;
}
.six2{
font-size: 55rpx;
font-weight: 700;
}
.six3{
position: absolute;
left: 180px;
top: 640px;
font-size: 55rpx;
}
.seven{
padding: 20px 0 20px 30px;
border-bottom: 4px solid #c0c0c0;
}
.seven2{
font-size: 55rpx;
font-weight: 700;
}
.seven3{
position: absolute;
left: 180px;
top: 725px;
font-size: 55rpx;
}
代码执行结果:
4.完成人生进程:
代码:wxml
<view style="text-align: center;font-size: 16x;position: absolute;left: 120px;">中国阶段人均寿命900个月</view>
<view style="position: absolute;padding-top: 30px;font-size: 26px;left: 70px;">2005年8月至今155个月</view>
<view style=" border:1px solid black;width: 100px;position: absolute;height: 20px;top: 92px;left: 85px;"></view>
<view style="position: absolute;padding-top: 90px;font-size: 16px;padding-left: 188px;"></view><view style="border: 5px;color: black;position: absolute;left: 240px;top: 92px;">换一个日期</view>
<view style=" border:1px solid black;width: 100px;position: absolute;height: 20px;top: 92px;left: 230px;"></view>
<view style="position: absolute;padding-top: 90px;font-size: 16px;padding-left: 470px;"><view style="position: absolute;left: 100px;top: 92px;">清除记录</view></view>
<view><image src="/pages/tp/b.jpg" mode="" style="position: absolute;top:140px;left: 85px;height: 370px;width: 250px;"/></view>
<view style="position: absolute;top:540px;font-size: 18px;left:10px;">能把后面前行行走的机会抓住的人,十有八九都会成功</view>
app.json
{
"pages": [
"pages/index/index",
"pages/a/a",
"pages/b/b",
"pages/c/c"
],
"window": {
"backgroundColor": "#F6F6F6",
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#F6F6F6",
"navigationBarTitleText": "云开发 QuickStart",
"navigationBarTextStyle": "black"
},
"tabBar": {
"color": "#666666",
"selectedColor": "#ff0000",
"borderStyle":"black",
"backgroundColor": "#ffffff",
"list": [{
"pagePath": "pages/index/index",
"iconPath": "./pages/img/aa.jpeg",
"selectedIconPath": "./pages/img/aa.jpeg",
"text": "首页"
},
{
"pagePath": "pages/a/a",
"iconPath": "./pages/img/aa.jpeg",
"selectedIconPath": "./pages/img/aa.jpeg",
"text": "年月日"
},
{
"pagePath": "pages/b/b",
"iconPath": "./pages/img/aa.jpeg",
"selectedIconPath": "./pages/img/aa.jpeg",
"text": "静思"
},
{
"pagePath": "pages/c/c",
"iconPath": "./pages/img/aa.jpeg",
"selectedIconPath": "./pages/img/aa.jpeg",
"text": "关于"
}]
},
"style": "v2",
"componentFramework": "glass-easel",
"lazyCodeLoading": "requiredComponents"
}
a.js:
const date=new Date()
const years=[]
const months=[]
//定义年份
for(let i=1900;i<=2050;i++){
years.push(i)
}
//定义月份
for(let i=1;i<=12;i++){
months.push(i)
}
Page({
data:{
onTapButton:function(){
console.log("换一个日期")
},
onTapButton:function(){
console.log("清楚记录")
},
years:years,
months:months,
year:date.getFullYear(),
month:date.getMonth()+1,
value:[104,5],//定位到2004年6月
},
bindChange:function(e){
const val=e.detail.value
console.log(val);
this.setData({
year:this.data.years[val[0]],
month:this.data.months[val[1]]
})
},
})
a.wxml:
<view class="one">中国现阶段人均寿命900个月</view>
<view class="two">{{year}}年{{month}}月至今{{yue}}个月</view>
<view class="button">
<button class="but">换一个日期</button>
<button>清除记录</button>
</view>
<picker-view
indicator-style="height:50px;"
style="width:100%;height:300px;"
value="{{value}}"
bindchange="bindChange">
<picker-view-column>
<view
wx:for="{{years}}"
style="line-height:50px">
{{item}}年
</view>
</picker-view-column>
<picker-view-column>
<view
wx:for="{{months}}"
style="line-height:50px">
{{item}}月
</view>
</picker-view-column>
</picker-view>
<view class="three">能把在面前行走的机会抓住的人,十有八九都会成功。</view>
a.wxss:
.one{
font-size: 20px;
margin-top: 90px;
text-align: center;
}
.two{
font-size: 35px;
text-align: center;
}
.button{
padding: 20px 0 20px 0;
}
.but{
float: left;
}
.three{
font-size: 30px;
margin-top: 90px;
text-align: center;
}
代码执行结果: