緊急情況~ 找不到廁所? 晴天霹靂 褲衩一聲? 完嘍~~快來用廁所雷達(dá)吧~~~。作為一個(gè)優(yōu)秀的樓主,胖子我不僅寫了代碼,連廣告次都想好了,哇咔咔咔~~~~??“廁所找的快,排的才痛快”。
練習(xí)區(qū)里看到一個(gè)“廁所雷達(dá)”就來做了下,主要還是為了練習(xí)小程序“控件的基本用法”和“頁面間的交互”,css依舊讓我感到頭疼,不過比上次的demo“石頭剪刀布”好了很多了hoho。(ps:頁面有好幾個(gè),就先貼上首頁的代碼吧,想看的小伙伴就下載一下然后咱們互相交流哦,注釋都寫好了的說。哦對(duì)了,新的分享功能也加進(jìn)去了,當(dāng)然廣告詞已經(jīng)寫在分享里了。)
下面直接上圖:
js:
//index.js
var app = getapp()
var winheight = 0
var winwidth = 0
page({
data: {
//背景圖片,現(xiàn)在沒有
img:'/pages/image/123.png',
//確定左邊距距離,上邊距距離,廁所title,頭像
dataarr:[{'left':200,'top':100,'title':'我家?guī)詈?#39;,'img':'/pages/image/1.png'},
{'left':20,'top':400,'title':'amis的小屋','img':'/pages/image/2.png'},
{'left':540,'top':440,'title':'老丁的寶盆','img':'/pages/image/3.png'},
{'left':240,'top':800,'title':'雪姐專用坑','img':'/pages/image/4.png'}]
},
//進(jìn)頁面后獲取數(shù)據(jù)
onload: function () {
console.log('onload')
var that = this
//調(diào)用應(yīng)用實(shí)例的方法獲取全局?jǐn)?shù)據(jù)
app.getuserinfo(function(userinfo){
console.log(userinfo)
//更新數(shù)據(jù)
that.setdata({
userinfo:userinfo
})
})
//獲取數(shù)據(jù)
wx.getsysteminfo({
success: function(res) {
console.log(res)
winheight = res.windowheight;
winwidth = res.windowwidth;
}
})
// 使用 wx.createcontext 獲取繪圖上下文 context
var context = wx.createcontext()
context.arc(winwidth/2, winheight/2, 50, 0, 2 * math.pi, true)
context.arc(winwidth/2, winheight/2, 100, 0, 2 * math.pi, true)
context.arc(winwidth/2, winheight/2, 150, 0, 2 * math.pi, true)
context.arc(winwidth/2, winheight/2, 200, 0, 2 * math.pi, true)
context.arc(winwidth/2, winheight/2, 250, 0, 2 * math.pi, true)
context.arc(winwidth/2, winheight/2, 300, 0, 2 * math.pi, true)
context.setstrokestyle('red')
context.setlinewidth(1)
context.stroke()
// 調(diào)用 wx.drawcanvas,通過 canvasid 指定在哪張畫布上繪制,通過 actions 指定繪制行為
wx.drawcanvas({
canvasid: 'radar',
actions: context.getactions() // 獲取繪圖動(dòng)作數(shù)組
})
},
onshareappmessage: function() {
// 用戶點(diǎn)擊右上角分享
return {
title: '廁所雷達(dá)', // 分享標(biāo)題
desc: '廁所找的快,排的才痛快', // 分享描述
path: 'path' // 分享路徑
}
}
})
wxml:
<!--index.wxml-->
<canvas canvas-id="radar">
<image class="userinfo" src="{{userinfo.avatarurl}}"></image>
<block wx:for="{{dataarr}}">
<navigator url="../logs/logs?title={{item.title}}&img={{item.img}}">
<view class="toiletview" style="left:{{item.left}}rpx;top:{{item.top}}rpx" bindtap="toiletdetails" id="{{index}}">
<image class="toiletview-image" src="{{item.img}}"></image>
<text class="toiletview-text">{{item.title}}</text>
</view>
</navigator>
</block>
</canvas>
wxss:
/**index.wxss**/
page{
background: black;
height: 100%;
}
canvas{
width: 100%;
height: 100%;
}
.userinfo {
position:absolute;
top: 561rpx;
left:311rpx;
width: 128rpx;
height: 128rpx;
border-radius: 50%;
}
.toiletview{
position:absolute;
width: 180rpx;
height: 180rpx;
}
.toiletview-image{
position:absolute;
left: 13px;
top: 0px;
width: 128rpx;
height: 128rpx;
border-radius: 50%;
}
.toiletview-text{
position:absolute;
bottom: 10rpx;
font-size: 30rpx;
color: orangered;
width: 180rpx;
text-align: center;
}
以上就是小程序開發(fā)廁所雷達(dá)實(shí)例分享的詳細(xì)內(nèi)容。
疏通下水道有哪些方式技巧西馬馬桶噴嘴堵塞原因(馬桶噴水孔堵塞)地漏防臭、堵塞、滲水、下水慢?精維教你地漏疏通清理方法恒潔馬桶如何清潔-馬桶清洗小竅門究竟地漏什么牌子好 地漏如何選購沙子把下水道彎脖堵了怎么辦科勒馬桶傳感器故障分析(科勒智能馬桶角閥)手搖伸縮通下水道的管道疏通機(jī)使用方法