search
HomeWeChat AppletMini Program DevelopmentSmall program development toilet radar example sharing

Small program development toilet radar example sharing

Mar 22, 2017 pm 05:11 PM
Mini program development

Emergency~ Can’t find the toilet? A bolt from the blue, a pop of pants? That’s it~~ Come and use the toilet radar~~~. As an excellent poster, Fatty, I not only wrote the code, but also thought about the number of advertisements. Wow~~~~ "The faster you find the toilet, the faster you line up."
I saw a "toilet radar" in the practice area and tried it. It was mainly to practice the "basic usage of controls" and "interaction between pages" of the mini program. CSS still gave me a headache, but it was better than last time. The demo "rock paper scissors" is much better HOHO. (PS: There are several pages. Just paste the code of the homepage first. Friends who want to see it can download it and then we can communicate with each other. Comments have been written. Oh, by the way, a new sharing function has also been added. Of course, the advertising words have been written in the sharing)
The picture is directly below:

Small program development toilet radar example sharing

Small program development toilet radar example sharing

Small program development toilet radar example sharing

Small program development toilet radar example sharing

js:

//index.js
var app = getApp()
var winHeight = 0
var winWidth = 0
Page({
  data: {
      //背景图片,现在没有
      img:'/pages/image/123.png',
      //确定左边距距离,上边距距离,厕所title,头像
      dataArr:[{'left':200,'top':100,'title':'我家厕所最好','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'}]
  },
  //进页面后获取数据
  onLoad: function () {
    console.log('onLoad')
    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function(userInfo){
              console.log(userInfo)
      //更新数据
      that.setData({
        userInfo:userInfo
      })
    })
    //获取数据
    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()
    // 调用 wx.drawCanvas,通过 canvasId 指定在哪张画布上绘制,通过 actions 指定绘制行为
    wx.drawCanvas({
      canvasId: 'radar',
      actions: context.getActions() // 获取绘图动作数组
    })
  },
  onShareAppMessage: function() {
    // 用户点击右上角分享
    return {
      title: '厕所雷达', // 分享标题
      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;
}


The above is the detailed content of Small program development toilet radar example sharing. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function