微信小程序操作题

(1)、使用canvas组件实现“奥运五环”的绘制。

代码展示:

js代码:
//。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)、使用相应组件,完成“书单”页面

代码展示:

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/image/dd.png"/>
    <view class="textone">
      <view class="text1">金字塔原理</view>
      <view class="text2">芭芭拉•明托(Barbara Minto)</view>
      <view class="text3">金字塔原理是一种重点突出、逻辑清晰、主次分明的逻辑思路、表达方式和规范动作……</view>
    </view>
  </view>
  <view class="xiamian"></view>
  <view class="imgtwo" style="display: flex;">
    <image class="img2" src="/pages/image/head.png"/>
    <view class="texttwo">
      <view class="text1">基业长青</view>
      <view class="text2">[美]吉姆•柯林斯,杰里•波勒斯</view>
      <view class="text3">《基业长青(珍藏版)》打破了旧有神话,提供了新颖的见解,并为那些有志于建立经得……</view>
    </view>
  </view>
</view>
wxss代码展示:
.head{
  text-align:"left";
  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;
}
.xiamian{
  margin-top: 50rpx;
  border-bottom: 4px solid #ccc;
}
.imgtwo{
  margin-top: 50rpx;
}
.texttwo{
  margin-left: 50rpx;
}

代码运行结果展示:

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

代码展示:

wxml:
<view class="first">联系方式(手机和微信至少填一项)</view>
 
<view >
<view class="s">
<view>称呼*</view> <input type="text" placeholder="请输入昵称"/>
</view>
<view class="s">
<view>手机号</view> <input type="text" placeholder="请输入手机号"/>
</view>
<view class="s">
<view>微信号</view> <input type="text" placeholder="请输入微信号"/>
</view>
</view>
 
 <view class="first">拼车信息</view>
<view>
<view class="s">
<view>出发地点*</view><input type="text" placeholder="限七个字"/>
</view>
</view>

<view class="s">
<view>目的地*</view> <input type="text" placeholder="限七个字"/>
</view>

<view class="s">
<view>空座数*</view> <input type="text" placeholder="请输入空座数"/>
</view>
wxss:
.first{
  width: 100%;height: 40px;background-color: #cccccc;line-height: 40px;padding-left: 15px;color: grey;border: 1px solid grey;
}
.s{
margin-left: 12px;   border-bottom: 1px solid grey;height: 50px;
}
.s view{
  float: left; width: 100px;line-height: 50px;font-weight: bold;
}
input{
 padding-top: 14px;
}

代码运行结果展示:

2、编程题

        “人生进程”是一款极简的小程序,他只有一个功能:就是计算一个人从出生到现在已经度过了多少个月,请编写此程序。

代码展示:

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() {
 
  }
})
wxss:
.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;
}

代码运行结果展示:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值