小程序提交HR

parent c4794b1b
{
"pages": [
"page/component/index",
"page/component/navigation-pages/controller/controller",
"page/component/navigation-pages/form/form",
"page/component/navigation-pages/media/media",
"page/component/navigation-pages/view/view",
"page/component/component-pages/wx-action-sheet/wx-action-sheet",
"page/component/component-pages/wx-audio/wx-audio",
"page/component/component-pages/wx-button/wx-button",
"page/component/component-pages/wx-checkbox/wx-checkbox",
"page/component/component-pages/wx-form/wx-form",
"page/component/component-pages/wx-icon/wx-icon",
"page/component/component-pages/wx-image/wx-image",
"page/component/component-pages/wx-input/wx-input",
"page/component/component-pages/wx-mask/wx-mask",
"page/component/component-pages/wx-modal/wx-modal",
"page/component/component-pages/wx-navigator/wx-navigator",
"page/component/component-pages/wx-progress/wx-progress",
"page/component/component-pages/wx-radio/wx-radio",
"page/component/component-pages/wx-scroll-view/wx-scroll-view",
"page/component/component-pages/wx-slider/wx-slider",
"page/component/component-pages/wx-switch/wx-switch",
"page/component/component-pages/wx-text/wx-text",
"page/component/component-pages/wx-toast/wx-toast",
"page/component/component-pages/wx-video/wx-video",
"page/component/component-pages/wx-view/wx-view",
"page/component/component-pages/wx-swiper/wx-swiper",
"page/component/component-pages/wx-slide-tab/wx-slide-tab",
"page/component/component-pages/wx-label/wx-label",
"page/component/component-pages/wx-navigator/navigate",
"page/component/component-pages/wx-navigator/redirect",
"page/component/component-pages/wx-picker/wx-picker",
"page/API/index/index",
"page/API/storage/storage",
"page/API/login/login",
"page/API/get-user-info/get-user-info",
"page/API/request-payment/request-payment",
"page/API/set-navigation-bar-title/set-navigation-bar-title",
"page/API/navigation-bar-loading/navigation-bar-loading",
"page/API/navigator/navigator",
"page/API/pull-down-refresh/pull-down-refresh",
"page/API/animation/animation",
"page/API/get-network-type/get-network-type",
"page/API/get-system-info/get-system-info",
"page/API/on-compass-change/on-compass-change",
"page/API/request/request",
"page/API/web-socket/web-socket",
"page/API/upload-file/upload-file",
"page/API/download-file/download-file",
"page/API/image/image",
"page/API/voice/voice",
"page/API/file/file",
"page/API/on-accelerometer-change/on-accelerometer-change",
"page/API/canvas/canvas",
"page/API/background-audio/background-audio",
"page/API/get-location/get-location",
"page/API/open-location/open-location",
"page/resume/resume",
"page/resumeOnline/resumeOnline",
"page/my/my",
"page/job/job"
"page/job/job",
"page/hr/hr"
],
"window": {
"navigationBarTextStyle": "black",
......
Page({
onReady: function () {
this.animation = wx.createAnimation()
},
rotate: function () {
this.animation.rotate(Math.random() * 720 - 360).step()
this.setData({ animation: this.animation.export() })
},
scale: function () {
this.animation.scale(Math.random() * 2).step()
this.setData({ animation: this.animation.export() })
},
translate: function () {
this.animation.translate(Math.random() * 100 - 50, Math.random() * 100 - 50).step()
this.setData({ animation: this.animation.export() })
},
skew: function () {
this.animation.skew(Math.random() * 90, Math.random() * 90).step()
this.setData({ animation: this.animation.export() })
},
rotateAndScale: function () {
this.animation.rotate(Math.random() * 720 - 360)
.scale(Math.random() * 2)
.step()
this.setData({ animation: this.animation.export() })
},
rotateThenScale: function () {
this.animation.rotate(Math.random() * 720 - 360).step()
.scale(Math.random() * 2).step()
this.setData({ animation: this.animation.export() })
},
all: function () {
this.animation.rotate(Math.random() * 720 - 360)
.scale(Math.random() * 2)
.translate(Math.random() * 100 - 50, Math.random() * 100 - 50)
.skew(Math.random() * 90, Math.random() * 90)
.step()
this.setData({ animation: this.animation.export() })
},
allInQueue: function () {
this.animation.rotate(Math.random() * 720 - 360).step()
.scale(Math.random() * 2).step()
.translate(Math.random() * 100 - 50, Math.random() * 100 - 50).step()
.skew(Math.random() * 90, Math.random() * 90).step()
this.setData({ animation: this.animation.export() })
},
reset: function () {
this.animation.rotate(0, 0)
.scale(1)
.translate(0, 0)
.skew(0, 0)
.step({ duration: 0 })
this.setData({ animation: this.animation.export() })
}
})
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'createAnimation'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<view class="animation-element-wrapper">
<view class="animation-element" animation="{{animation}}"></view>
</view>
<view class="animation-buttons" scroll-y="true">
<button class="animation-button" bindtap="rotate">旋转</button>
<button class="animation-button" bindtap="scale"> 缩放</button>
<button class="animation-button" bindtap="translate">移动</button>
<button class="animation-button" bindtap="skew">倾斜</button>
<button class="animation-button" bindtap="rotateAndScale">旋转并缩放</button>
<button class="animation-button" bindtap="rotateThenScale">旋转后缩放</button>
<button class="animation-button" bindtap="all">同时展示全部</button>
<button class="animation-button" bindtap="allInQueue">顺序展示全部</button>
<button class="animation-button-reset" bindtap="reset">还原</button>
</view>
</view>
</view>
<template is="footer" />
</view>
.page-body-wrapper {
flex-grow: 1;
}
.animation-element-wrapper {
display: block;
margin-bottom: 100rpx;
}
.animation-element {
width: 200rpx;
height: 200rpx;
background-color: #1AAD19;
}
.animation-buttons {
padding: 50rpx 50rpx 10rpx;
border-top: 1px solid #ccc;
display: flex;
flex-grow: 1;
overflow-y: scroll;
flex-direction: row;
flex-wrap: wrap;
width: 100%;
height: 400rpx;
box-sizing: border-box;
}
.animation-button {
width: 290rpx;
margin: 20rpx auto;
}
.animation-button-reset {
width: 610rpx;
margin: 20rpx auto;
}
var util = require('../../../util/util.js')
var dataUrl = 'http://ws.stream.qqmusic.qq.com/C100001wmp4t06stlC.m4a?fromtag=38'
Page({
onLoad: function () {
var that = this
wx.onBackgroundAudioStop(function () {
that.setData({
playing: false,
playTime: 0,
formatedPlayTime: '00:00:00'
})
})
},
data: {
playing: false,
playTime: 0,
formatedPlayTime: '00:00:00'
},
play: function (res) {
var that = this
wx.playBackgroundAudio({
dataUrl: dataUrl,
title: 'Lost Stars',
coverImgUrl: 'http://y.gtimg.cn/music/photo_new/T002R150x150M000000Jhxf24CFL06.jpg?max_age=2592000',
complete: function (res) {
that.setData({
playing: true
})
}
})
this._enableInterval()
},
seek: function (e) {
clearInterval(this.updateInterval)
var that = this
wx.seekBackgroundAudio({
position: e.detail.value,
complete: function () {
// 实际会延迟两秒左右才跳过去
setTimeout(function () {
that._enableInterval()
}, 2000)
}
})
},
pause: function () {
var that = this
wx.pauseBackgroundAudio({
success: function () {
that.setData({
playing: false
})
}
})
},
stop: function () {
var that = this
wx.stopBackgroundAudio({
success: function (res) {
that.setData({
playing: false,
playTime: 0,
formatedPlayTime: util.formatTime(0)
})
}
})
},
_enableInterval: function () {
var that = this
update()
this.updateInterval = setInterval(update, 500)
function update() {
wx.getBackgroundAudioPlayerState({
success: function (res) {
that.setData({
playTime: res.currentPosition,
formatedPlayTime: util.formatTime(res.currentPosition + 1)
})
}
})
}
},
onUnload: function () {
clearInterval(this.updateInterval)
}
})
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'backgroundAudio'}}"/>
<view class="page-body-wrapper">
<view class="page-body-info">
<text class="time-big">{{formatedPlayTime}}</text>
<slider class="slider" min="0" max="269" step="1" value="{{playTime}}" bindchange="seek"></slider>
<view class="play-time">
<text>00:00</text>
<text>04:29</text>
</view>
</view>
<text class="page-body-text">离开应用后音乐也可保持播放</text>
<view class="page-body-buttons">
<block wx:if="{{playing === true}}">
<view class="page-body-button" bindtap="stop">
<image src="/image/stop.png"></image>
</view>
<view class="page-body-button" bindtap="pause">
<image src="/image/pause.png"></image>
</view>
</block>
<block wx:if="{{playing === false}}">
<view class="page-body-button"></view>
<view class="page-body-button" bindtap="play">
<image src="/image/play.png"></image>
</view>
</block>
<view class="page-body-button"></view>
</view>
</view>
<template is="footer" />
</view>
.page-body-wrapper {
margin-top: 0;
}
.page-body-info {
padding-bottom: 50rpx;
}
.time-big {
font-size: 60rpx;
margin: 20rpx;
}
.slider {
width: 650rpx;
}
.play-time {
font-size: 28rpx;
width: 700rpx;
padding: 20rpx 0;
display: flex;
justify-content: space-between;
box-sizing: border-box;
}
.page-body-buttons {
display: flex;
justify-content: space-around;
margin-top: 100rpx;
}
.page-body-button {
width: 250rpx;
text-align: center;
}
Page({
onReady: function () {
this.position = {
x: 150,
y: 150,
vx: 2,
vy: 2
}
this.drawBall()
this.interval = setInterval(this.drawBall, 17)
},
drawBall: function () {
var p = this.position
p.x += p.vx
p.y += p.vy
if (p.x >= 300) {
p.vx = -2
}
if (p.x <= 7) {
p.vx = 2
}
if (p.y >= 300) {
p.vy = -2
}
if (p.y <= 7) {
p.vy = 2
}
var context = wx.createContext()
ball(p.x, 150)
ball(150, p.y)
ball(300 - p.x, 150)
ball(150, 300 - p.y)
ball(p.x, p.y)
ball(300 - p.x, 300 - p.y)
ball(p.x, 300 - p.y)
ball(300 - p.x, p.y)
wx.drawCanvas({
canvasId: 'canvas',
actions: context.getActions()
})
function ball(x, y) {
context.beginPath(0)
context.arc(x, y, 5, 0, Math.PI * 2)
context.setFillStyle('#1aad19')
context.setStrokeStyle('rgba(1,1,1,0)')
context.fill()
context.stroke()
}
},
onUnload: function () {
clearInterval(this.interval)
}
})
{
"navigationBarTitleText": "创建画布"
}
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'createCanvas'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<canvas canvas-id="canvas" class="canvas"></canvas>
</view>
</view>
<template is="footer" />
</view>
.canvas {
width: 305px;
height: 305px;
background-color: #fff;
}
<template name="footer">
<view class="page-footer">
微信接口功能
</view>
</template>
<template name="header">
<view class="page-header">
<text class="page-header-text">{{title}}</text>
</view>
</template>
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'downloadFile'}}"/>
<view class="page-body">
<view class="page-body-wording">
<text class="page-body-text">
搭建好自己的后台服务器后,可以将服务器上的图片视频等资源下载到手机上。
</text>
</view>
</view>
<template is="footer" />
</view>
Page({
data: {
tempFilePath: '',
savedFilePath: wx.getStorageSync('savedFilePath') || '',
dialog: {
hidden: true
}
},
chooseImage: function () {
var that = this
wx.chooseImage({
count: 1,
success: function (res) {
that.setData({
tempFilePath: res.tempFilePaths[0]
})
}
})
},
saveFile: function () {
if (this.data.tempFilePath.length > 0) {
var that = this
wx.saveFile({
tempFilePath: this.data.tempFilePath,
success: function (res) {
that.setData({
savedFilePath: res.savedFilePath
})
wx.setStorageSync('savedFilePath', res.savedFilePath)
that.setData({
dialog: {
title: '保存成功',
content: '下次进入应用时,此文件仍可用',
hidden: false
}
})
},
fail: function (res) {
that.setData({
dialog: {
title: '保存失败',
content: '应该是有 bug 吧',
hidden: false
}
})
}
})
}
},
clear: function () {
wx.setStorageSync('savedFilePath', '')
this.setData({
tempFilePath: '',
savedFilePath: ''
})
},
confirm: function () {
this.setData({
'dialog.hidden': true
})
}
})
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'saveFile'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<view class="page-body-info">
<text class="page-body-text-small">请选择图片</text>
<block wx:if="{{tempFilePath != ''}}">
<image src="{{tempFilePath}}" class="image"></image>
</block>
<block wx:if="{{tempFilePath === '' && savedFilePath != ''}}">
<image src="{{savedFilePath}}" class="image"></image>
</block>
<block wx:if="{{tempFilePath === '' && savedFilePath === ''}}">
<image src="/image/plus.png" class="image-plus" bindtap="chooseImage"></image>
</block>
</view>
<view class="page-body-buttons">
<button class="page-body-button" type="primary" bindtap="saveFile">保存文件</button>
<button class="page-body-button" bindtap="clear">删除文件</button>
</view>
</view>
</view>
<modal title="{{dialog.title}}" hidden="{{dialog.hidden}}" no-cancel bindconfirm="confirm">{{dialog.content}}</modal>
<template is="footer" />
</view>
.image {
width: 300rpx;
height: 300rpx;
}
.image-plus {
width: 150rpx;
height: 150rpx;
border: 1px solid #bbb;
}
mkdir $1
touch $1/$1.js
touch $1/$1.wxss
touch $1/$1.wxml
touch $1/$1.json
function formatLocation(longitude, latitude) {
longitude = longitude.toFixed(2)
latitude = latitude.toFixed(2)
return {
longitude: longitude.toString().split('.'),
latitude: latitude.toString().split('.')
}
}
module.exports = formatLocation
var formatLocation = require('./format-location.js')
Page({
data: {
hasLocation: false,
},
getLocation: function () {
var that = this
wx.getLocation({
success: function (res) {
console.log(res)
that.setData({
hasLocation: true,
location: formatLocation(res.longitude, res.latitude)
})
}
})
},
clear: function () {
this.setData({
hasLocation: false
})
}
})
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'getLocation'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<view class="page-body-info">
<text class="page-body-text-small">当前位置经纬度</text>
<block wx:if="{{hasLocation === false}}">
<text class="page-body-text">未获取</text>
</block>
<block wx:if="{{hasLocation === true}}">
<view class="page-body-text-location">
<text>E{{location.longitude[0]}}°{{location.longitude[1]}}′</text>
<text>N{{location.latitude[0]}}°{{location.latitude[1]}}′</text>
</view>
</block>
</view>
<view class="page-body-buttons">
<button class="page-body-button" type="primary" bindtap="getLocation">获取位置</button>
<button class="page-body-button" bindtap="clear">清空</button>
</view>
</view>
</view>
<template is="footer" />
</view>
.page-body-text-small {
font-size: 24rpx;
color: #000;
margin-bottom: 100rpx;
}
.page-body-text-location {
display: flex;
font-size: 50rpx;
}
.page-body-text-location text {
margin: 10rpx;
}
Page({
data: {
hasNetworkType: false
},
getNetworkType: function () {
var that = this
wx.getNetworkType({
success: function (res) {
console.log(res)
that.setData({
hasNetworkType: true,
networkType: res.subtype || res.networkType
})
that.update()
}
})
},
clear: function () {
this.setData({
hasNetworkType: false,
networkType: ''
})
}
})
{
"navigationBarTitleText": "获取手机网络状态"
}
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'getNetworkType'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<view class="page-body-info">
<view class="page-body-title">网络状态</view>
<block wx:if="{{hasNetworkType === false}}">
<text class="page-body-text">未获取</text>
<text class="page-body-text">点击绿色按钮可获取网络状态</text>
</block>
<block wx:if="{{hasNetworkType === true}}">
<text class="page-body-text-network-type">{{networkType}}</text>
</block>
</view>
<view class="page-body-buttons">
<button class="page-body-button" type="primary" bindtap="getNetworkType">获取手机网络状态</button>
<button class="page-body-button" bindtap="clear">清空</button>
</view>
</view>
</view>
<template is="footer" />
</view>
Page({
data: {
systemInfo: {}
},
getSystemInfo: function () {
var that = this
wx.getSystemInfo({
success: function (res) {
that.setData({
systemInfo: res
})
that.update()
}
})
}
})
{
"navigationBarTitleText": "获取手机系统信息"
}
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'getSystemInfo'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<view class="page-body-form">
<view class="page-body-form-item">
<text class="page-body-form-key">手机型号</text>
<input class="page-body-form-value" type="text" disabled="{{true}}" placeholder="未获取" value="{{systemInfo.model}}"></input>
</view>
<view class="page-body-form-item">
<text class="page-body-form-key">微信语言</text>
<input class="page-body-form-value" type="text" disabled="{{true}}" placeholder="未获取" value="{{systemInfo.language}}"></input>
</view>
<view class="page-body-form-item">
<text class="page-body-form-key">微信版本</text>
<input class="page-body-form-value" type="text" disabled="{{true}}" placeholder="未获取" value="{{systemInfo.version}}"></input>
</view>
<view class="page-body-form-item">
<text class="page-body-form-key">屏幕宽度</text>
<input class="page-body-form-value" type="text" disabled="{{true}}" placeholder="未获取" value="{{systemInfo.windowWidth}}"></input>
</view>
<view class="page-body-form-item">
<text class="page-body-form-key">屏幕高度</text>
<input class="page-body-form-value" type="text" disabled="{{true}}" placeholder="未获取" value="{{systemInfo.windowHeight}}"></input>
</view>
<view class="page-body-form-item">
<text class="page-body-form-key">DPI</text>
<input class="page-body-form-value" type="text" disabled="{{true}}" placeholder="未获取" value="{{systemInfo.pixelRatio}}"></input>
</view>
</view>
<view class="page-body-buttons">
<button class="page-body-button" type="primary" bindtap="getSystemInfo">获取手机系统信息</button>
</view>
</view>
</view>
<template is="footer" />
</view>
var app = getApp()
Page({
data: {
hasUserInfo: false
},
getUserInfo: function () {
var that = this
if (app.globalData.hasLogin === false) {
wx.login({
success: _getUserInfo
})
} else {
_getUserInfo()
}
function _getUserInfo() {
wx.getUserInfo({
success: function (res) {
that.setData({
hasUserInfo: true,
userInfo: res.userInfo
})
that.update()
}
})
}
},
clear: function () {
this.setData({
hasUserInfo: false,
userInfo: {}
})
}
})
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'getUserInfo'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<view class="page-body-info">
<view class="page-body-title">用户信息</view>
<block wx:if="{{hasUserInfo === false}}">
<text class="page-body-text">未获取</text>
<text class="page-body-text">点击绿色按钮可获取用户头像及昵称</text>
</block>
<block wx:if="{{hasUserInfo === true}}">
<image class="userinfo-avatar" src="{{userInfo.avatarUrl}}"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</block>
</view>
<view class="page-body-buttons">
<button class="page-body-button" type="primary" bindtap="getUserInfo">获取用户信息</button>
<button class="page-body-button" bindtap="clear">清空</button>
</view>
</view>
</view>
<template is="footer" />
</view>
.userinfo-avatar {
border-radius: 128rpx;
width: 128rpx;
height: 128rpx;
}
.userinfo-nickname {
margin-top: 20rpx;
font-size: 38rpx;
}
var sourceType = [ ['camera'], ['album'], ['camera', 'album'] ]
var sizeType = [ ['compressed'], ['original'], ['compressed', 'original'] ]
Page({
data: {
sourceTypeIndex: 0,
sourceType: ['拍照', '相册', '拍照或相册'],
sizeTypeIndex: 0,
sizeType: ['压缩', '原图', '压缩或原图'],
countIndex: 0,
count: [1, 2, 3, 4, 5, 6, 7, 8, 9]
},
sourceTypeChange: function (e) {
this.setData({
sourceTypeIndex: e.detail.value
})
},
sizeTypeChange: function (e) {
this.setData({
sizeTypeIndex: e.detail.value
})
},
countChange: function (e) {
this.setData({
countIndex: e.detail.value
})
},
chooseImage: function () {
var that = this
wx.chooseImage({
sourceType: sourceType[this.data.sourceTypeIndex],
sizeType: sizeType[this.data.sizeTypeIndex],
count: this.data.count[this.data.countIndex],
success: function (res) {
console.log(res)
that.setData({
imageList: res.tempFilePaths
})
}
})
},
previewImage: function (e) {
var current = e.target.dataset.src
wx.previewImage({
current: current,
urls: this.data.imageList
})
}
})
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'choose/previewImage'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<form bindsubmit="openLocation">
<view class="page-body-form">
<picker range="{{sourceType}}" bindchange="sourceTypeChange" value="{{sourceTypeIndex}}">
<view class="page-body-form-picker">
<view class="page-body-form-picker-key">图片来源</view>
<view class="page-body-form-picker-value">{{sourceType[sourceTypeIndex]}}</view>
</view>
</picker>
<picker range="{{sizeType}}" bindchange="sizeTypeChange" value="{{sizeTypeIndex}}">
<view class="page-body-form-picker">
<view class="page-body-form-picker-key">图片质量</view>
<view class="page-body-form-picker-value">{{sizeType[sizeTypeIndex]}}</view>
</view>
</picker>
<picker range="{{count}}" bindchange="countChange" value="{{countIndex}}">
<view class="page-body-form-picker" style="border-bottom: none;">
<view class="page-body-form-picker-key">数量限制</view>
<view class="page-body-form-picker-value">{{count[countIndex]}}</view>
</view>
</picker>
</view>
<view class="images-wrapper">
<text class="images-text">请选择图片</text>
<view class="images-list">
<block wx:for-items="{{imageList}}" wx:for-item="image">
<image src="{{image}}" class="images-image" data-src="{{image}}" bindtap="previewImage"></image>
</block>
<image src="/image/plus.png" class="images-image images-image-plus" bindtap="chooseImage"></image>
</view>
</view>
</form>
</view>
</view>
<template is="footer" />
</view>
.images-wrapper {
padding: 20rpx;
background-color: #fff;
margin-top: 20rpx;
}
.images-wrapper-text {
font-size: 28rpx;
}
.images-list {
display: flex;
margin-top: 20rpx;
flex-wrap: wrap;
}
.images-image {
width: 150rpx;
height: 150rpx;
margin: 10rpx;
}
.images-image-plus {
border: 1px solid #999;
}
Page({
data: {
menuList: [{
name: '基础能力',
APIList: [{
zhName: '微信登录',
enName: 'login',
url: '../login/login'
}, {
zhName: '获取用户信息',
enName: 'getUserInfo',
url: '../get-user-info/get-user-info'
}, {
zhName: '发起支付',
enName: 'RequestPayment',
url: '../request-payment/request-payment'
}],
opened: false
}, {
name: '界面跳转、监听和加载',
opened: false,
APIList: [{
zhName: '设置界面标题',
enName: 'setNavigationBarTitle',
url: '../set-navigation-bar-title/set-navigation-bar-title'
}, {
zhName: '标题栏加载动画',
enName: 'navigationBarLoading',
url: '../navigation-bar-loading/navigation-bar-loading'
}, {
zhName: '页面跳转',
enName: 'navigateTo, navigateBack, redirectTo',
url: '../navigator/navigator'
}, {
zhName: '下拉刷新',
enName: 'pullDownRefresh',
url: '../pull-down-refresh/pull-down-refresh'
}, {
zhName: '创建动画',
enName: 'createAnimation',
url: '../animation/animation'
}, {
zhName: '创建绘画',
enName: 'createContext',
url: '../canvas/canvas'
}]
}, {
name: '设备相关',
opened: false,
APIList: [{
zhName: '获取手机网络状态',
enName: 'getNetworkType',
url: '../get-network-type/get-network-type'
}, {
zhName: '获取手机系统信息',
enName: 'getSystemInfo',
url: '../get-system-info/get-system-info'
}, {
zhName: '监听重力感应数据',
enName: 'onAccelerometerChange',
url: '../on-accelerometer-change/on-accelerometer-change'
}, {
zhName: '监听罗盘数据',
enName: 'onCompassChange',
url: '../on-compass-change/on-compass-change'
}]
}, {
name: '网络相关',
opened: false,
APIList: [{
zhName: '发起一个请求',
enName: 'request',
url: '../request/request'
}, {
zhName: 'Web Socket',
enName: 'Web Socket',
url: '../web-socket/web-socket'
}, {
zhName: '上传文件',
enName: 'Upload File',
url: '../upload-file/upload-file'
}, {
zhName: '下载文件',
enName: 'Download File',
url: '../download-file/download-file'
}]
}, {
name: '多媒体',
opened: false,
APIList: [{
zhName: '图片',
enName: 'chooseImage/previewImage',
url: '../image/image'
}, {
zhName: '录音',
enName: 'start/stopRecord, play/pause/stopVoice',
url: '../voice/voice'
}, {
zhName: '背景音频',
enName: 'play/pause/stopAudio',
url: '../background-audio/background-audio'
}, {
zhName: '文件',
enName: 'saveFile',
url: '../file/file'
}]
}, {
name: '数据',
opened: false,
url: '../storage/storage'
}, {
name: '地理位置',
opened: false,
APIList: [{
zhName: '获取当前位置',
enName: 'getLocation',
url: '../get-location/get-location'
}, {
zhName: '使用原生地图查看位置',
enName: 'openLocation',
url: '../open-location/open-location'
}]
}]
},
tapMenuItem: function (e) {
var menuItem = this.data.menuList[parseInt(e.currentTarget.id)]
if (menuItem.url) {
wx.navigateTo({ url: menuItem.url })
} else {
var changeData = {}
var opened = menuItem.opened
changeData['menuList[' + e.currentTarget.id + '].opened'] = !opened
this.setData(changeData)
}
}
})
<view class="container">
<view class="header">
<view class="title">小程序接口</view>
<view class="desc">为便于开发者直观了解小程序接口能力,该小程序就当前已支持的接口能力进行演示。</view>
</view>
<view class="menu-list">
<block wx:for-items="{{menuList}}" wx:for-item="menuItem">
<view class="menu-item">
<view class="menu-item-main" id="{{index}}" bindtap="tapMenuItem">
<text class="menu-item-name">{{menuItem.name}}</text>
<image
class="menu-item-arrow {{menuItem.opened ? 'open' : 'close'}} {{menuItem.url ? 'url' : ''}}"
src="/image/arrowright.png">
</image>
</view>
<view class="menu-item-api-list {{menuItem.opened ? 'open' : 'close'}}">
<block wx:for-items="{{menuItem.APIList}}" wx:for-item="APIItem">
<navigator url="{{APIItem.url}}">
<view class="menu-item-api-item" style="{{index === 0 ? 'border-top:none;' : ''}}">
<view class="menu-item-api-item-text">
<text class="menu-item-api-item-text-zhname">{{APIItem.zhName}}</text>
<text class="menu-item-api-item-text-enname">{{APIItem.enName}}</text>
</view>
<image class="menu-item-api-item-arrow" src="/image/arrowright.png"></image>
</view>
</navigator>
</block>
</view>
</view>
</block>
</view>
</view>
.header {
padding: 40px;
}
.title {
font-size: 30px;
}
.desc {
margin-top: 5px;
color: #888888;
font-size: 14px;
line-height: 1.4;
}
.menu-list {
display: flex;
flex-direction: column;
background-color: #fbf9fe;
}
.menu-item {
color: #000000;
display: flex;
background-color: #fff;
margin: 10rpx 40rpx;
flex-direction: column;
}
.menu-item-main {
display: flex;
height: 100rpx;
padding: 20rpx;
border-radius: 10rpx;
align-items: center;
font-size: 32rpx;
justify-content: space-between;
}
.menu-item-arrow {
width: 32rpx;
height: 32rpx;
transition: 400ms;
}
.menu-item-arrow.open {
transform: rotate(-90deg);
}
.menu-item-arrow.close {
transform: rotate(90deg);
}
.menu-item-arrow.url {
transform: rotate(0deg);
}
.menu-item-api-list {
transition: 200ms;
height: auto;
border-top: 1px solid #d8d8d8;
}
.menu-item-api-list.close {
display: none;
height: 0;
}
.menu-item-api-item {
display: flex;
justify-content: space-between;
height: 80rpx;
padding: 20rpx 20rpx 20rpx 0;
margin-left: 20rpx;
align-items: center;
border-top: 1px solid #f0f0f0;
}
.menu-item-api-item-text {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
}
.menu-item-api-item-text-zhname {
font-size: 30rpx;
}
.menu-item-api-item-text-enname {
font-size: 26rpx;
color: #6b6b6b;
}
.menu-item-api-item-arrow {
width: 32rpx;
height: 32rpx;
}
var app = getApp()
Page({
onLoad: function () {
this.setData({
hasLogin: app.globalData.hasLogin
})
},
data: {},
login: function () {
var that = this
wx.login({
success: function (res) {
app.globalData.hasLogin = true
that.setData({
hasLogin: true
})
that.update()
}
})
}
})
{
"navigationBarTitleText": "微信登录"
}
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'Login'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<block wx:if="{{hasLogin === true}}">
<text class="page-body-title">已登录</text>
<text class="page-body-text">每个微信号中仅需登录 1 次,后续每次进入页面即可根据微信 id 自动拉取用户信息</text>
</block>
<block wx:if="{{hasLogin === false}}">
<text class="page-body-text">每个微信号中仅需登录一次</text>
<button class="page-body-button" type="primary" bindtap="login">微信登录</button>
</block>
</view>
</view>
<template is="footer" />
</view>
.page-body-wrapper {
margin-top: 200rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
padding: 0 50rpx;
box-sizing: border-box;
}
.page-body-title {
font-size: 60rpx;
/*TODO 使用 rpx */
line-height: 100px;
}
.page-body-text {
color: #bbb;
font-size: 28rpx;
/*TODO 使用 rpx */
line-height: 20px;
margin: 0 0 100rpx 0;
text-align: center;
}
.page-body-button {
width: 100%;
}
Page({
showNavigationBarLoading: function () {
wx.showNavigationBarLoading()
},
hideNavigationBarLoading: function () {
wx.hideNavigationBarLoading()
}
})
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'navigationBarLoading'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<view class="page-body-buttons">
<button class="page-body-button" type="primary" bindtap="showNavigationBarLoading">显示加载动画</button>
<button class="page-body-button" bindtap="hideNavigationBarLoading">隐藏加载动画</button>
</view>
</view>
</view>
<template is="footer" />
</view>
Page({
navigateTo: function () {
wx.navigateTo({ url: './navigator' })
},
navigateBack: function () {
wx.navigateBack()
},
redirectTo: function () {
wx.redirectTo({ url: './navigator' })
}
})
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'navigateTo/Back, redirectTo'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<view class="page-body-buttons">
<button class="page-body-button" bindtap="navigateTo">跳转新页面</button>
<button class="page-body-button" bindtap="navigateBack">返回上一页</button>
<button class="page-body-button" bindtap="redirectTo">在当前页面打开</button>
</view>
</view>
</view>
<template is="footer" />
</view>
Page({
onReady: function () {
this.drawBigBall()
var that = this
this.position = {
x: 151,
y: 151,
vx: 0,
vy: 0,
ax: 0,
ay: 0
}
wx.onAccelerometerChange(function (res) {
that.setData({
x: res.x.toFixed(2),
y: res.y.toFixed(2),
z: res.z.toFixed(2)
})
that.position.ax = Math.sin(res.x * Math.PI / 2)
that.position.ay = -Math.sin(res.y * Math.PI / 2)
//that.drawSmallBall()
})
this.interval = setInterval(function () {
that.drawSmallBall()
}, 17)
},
drawBigBall: function () {
var context = wx.createContext()
context.beginPath(0)
context.arc(151, 151, 140, 0, Math.PI * 2)
context.setFillStyle('#ffffff')
context.setStrokeStyle('#aaaaaa')
context.fill()
context.stroke()
wx.drawCanvas({
canvasId: 'big-ball',
actions: context.getActions()
})
},
drawSmallBall: function () {
var p = this.position
var strokeStyle = 'rgba(1,1,1,0)'
p.x = p.x + p.vx
p.y = p.y + p.vy
p.vx = p.vx + p.ax
p.vy = p.vy + p.ay
if (Math.sqrt(Math.pow(Math.abs(p.x) - 151, 2) + Math.pow(Math.abs(p.y) - 151, 2)) >= 115) {
if (p.x > 151 && p.vx > 0) {
p.vx = 0
}
if (p.x < 151 && p.vx < 0) {
p.vx = 0
}
if (p.y > 151 && p.vy > 0) {
p.vy = 0
}
if (p.y < 151 && p.vy < 0) {
p.vy = 0
}
strokeStyle = '#ff0000'
}
var context = wx.createContext()
context.beginPath(0)
context.arc(p.x, p.y, 15, 0, Math.PI * 2)
context.setFillStyle('#1aad19')
context.setStrokeStyle(strokeStyle)
context.fill()
context.stroke()
wx.drawCanvas({
canvasId: 'small-ball',
actions: context.getActions()
})
},
data: {
x: 0,
y: 0,
z: 0
},
onUnload: function () {
clearInterval(this.interval)
}
})
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'onAccelerometerChange'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<text class="page-body-text">旋转手机即可移动以下小球</text>
<view class="page-body-canvas">
<canvas class="page-body-ball" show="{{true}}" canvas-id="big-ball"></canvas>
<canvas class="page-body-ball" show="{{true}}" canvas-id="small-ball"></canvas>
</view>
<view class="page-body-xyz">
<text class="page-body-title">X: {{x}}</text>
<text class="page-body-title">Y: {{y}}</text>
<text class="page-body-title">Z: {{z}}</text>
</view>
</view>
</view>
<template is="footer" />
</view>
.page-body-xyz {
display: flex;
justify-content: space-around;
width: 700rpx;
margin-top: 50rpx;
box-sizing: border-box;
}
.page-body-canvas {
width: 302px;
height: 302px;
position: relative;
}
.page-body-ball {
position: absolute;
top: 0;
left: 0;
width: 302px;
height: 302px;
}
.page-body-title {
font-size: 50rpx;
width: 250rpx;
}
Page({
data: {
direction: 0
},
onReady: function () {
var that = this
wx.onCompassChange(function (res) {
that.setData({
direction: parseInt(res.direction)
})
})
}
})
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'onCompassChange'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<text class="page-body-text">选中手机即可获取方位信息</text>
<view class="direction">
<text class="direction-value">{{direction}}</text>
<text class="direction-degree">o</text>
</view>
</view>
</view>
<template is="footer" />
</view>
.direction {
margin-top: 100rpx;
display: flex;
}
.direction-value {
font-size: 200rpx;
}
.direction-degree {
font-size: 40rpx;
}
Page({
openLocation: function (e) {
console.log(e)
var value = e.detail.value
console.log(value)
wx.openLocation({
longitude: Number(value.longitude),
latitude: Number(value.latitude),
name: value.name,
address: value.address
})
}
})
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'openLocation'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<form bindsubmit="openLocation">
<view class="page-body-form">
<view class="page-body-form-item">
<text class="page-body-form-key">经度</text>
<input class="page-body-form-value" type="text" disabled="{{true}}" value="113.324520" name="longitude"></input>
</view>
<view class="page-body-form-item">
<text class="page-body-form-key">纬度</text>
<input class="page-body-form-value" type="text" disabled="{{true}}" value="23.099994" name="latitude"></input>
</view>
<view class="page-body-form-item">
<text class="page-body-form-key">位置名称</text>
<input class="page-body-form-value" type="text" disabled="{{true}}" value="T.I.T 创意园" name="name"></input>
</view>
<view class="page-body-form-item" style="border-bottom: none;">
<text class="page-body-form-key">详细位置</text>
<input class="page-body-form-value" type="text" disabled="{{true}}" value="广州市海珠区新港中路397号" name="address"></input>
</view>
</view>
<view class="page-body-buttons">
<button class="page-body-button" type="primary" formType="submit">查看位置</button>
</view>
</form>
</view>
</view>
<template is="footer" />
</view>
Page({
onPullDownRefresh: function () {
console.log('onPullDownRefresh', new Date())
},
stopPullDownRefresh: function () {
wx.stopPullDownRefresh({
complete: function (res) {
console.log(res, new Date())
}
})
}
})
{
"navigationBarTitleText": "下拉刷新",
"enablePullDownRefresh": true
}
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'on/stopPullDownRefresh'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<view class="page-body-info">
<text class="page-body-text">下滑页面即可刷新</text>
</view>
<view class="page-body-buttons">
<button bindtap="stopPullDownRefresh">停止刷新</button>
</view>
</view>
</view>
<template is="footer" />
</view>
.page-body-info {
background-color: transparent;
}
.page-body-buttons button {
color: #21c932;
margin: 0 100rpx;
}
.page-body-buttons button:after {
border-color: #21c932;
}
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'requestPayment'}}"/>
<view class="page-body">
<view class="page-body-wording">
<text class="page-body-text">
自主接入微信支付后,可以让用户在页面上快捷完成下单购买。
</text>
</view>
</view>
<template is="footer" />
</view>
{
"navigationBarTitleText": "网络请求"
}
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'request'}}"/>
<view class="page-body">
<view class="page-body-wording">
<text class="page-body-text">
搭建好自己的后台服务器后,可以跟服务器互通数据,为用户提供个性化服务。
</text>
</view>
</view>
<template is="footer" />
</view>
Page({
setNaivgationBarTitle: function (e) {
var title = e.detail.value.title
console.log(title)
wx.setNavigationBarTitle({
title: title
})
}
})
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'setNaivgationBarTitle'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<form bindsubmit="setNaivgationBarTitle">
<view class="page-body-form">
<view class="page-body-form-item" style="border-bottom: none;">
<text class="page-body-form-key">页面标题</text>
<input class="page-body-form-value" type="text" placeholder="请输入页面标题并点击设置即可" name="title"></input>
</view>
</view>
<view class="page-body-buttons">
<button class="page-body-button" type="primary" formType="submit">设置</button>
</view>
</form>
</view>
</view>
<template is="footer" />
</view>
Page({
data: {
toast: {
hidden: true
}
},
submitForm: function (e) {
var type = e.detail.target.id
var key = e.detail.value.key
var data = e.detail.value.data
if (key.length === 0 && type !== 'clear') {
this.setData({
key: key,
data: data,
'toast.hidden': false,
'toast.content': 'key 不能为空'
})
} else if (type === 'get' && key.length > 0) {
this.setData({
key: key,
data: wx.getStorageSync(key),
'toast.hidden': false,
'toast.content': '读取数据成功'
})
} else if (type === 'set' && key.length > 0) {
wx.setStorageSync(key, data)
this.setData({
key: key,
data: data,
'toast.hidden': false,
'toast.content': '存储数据成功'
})
} else if (type === 'clear') {
wx.clearStorageSync()
this.setData({
key: '',
data: '',
'toast.hidden': false,
'toast.content': '清除数据成功'
})
}
},
toastChange: function () {
this.setData({
'toast.hidden': true
})
}
})
{
"navigationBarTitleText": "数据存储"
}
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'get/set/clearStorage'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<form bindsubmit="submitForm" id="123">
<view class="page-body-form">
<view class="page-body-form-item" style="border-bottom: none;">
<input class="page-body-form-key" type="text" placeholder="key" name="key" value="{{key}}"></input>
<input class="page-body-form-value" type="text" placeholder="data" name="data" value="{{data}}"></input>
</view>
</view>
<view class="page-body-buttons">
<button class="page-body-button" type="primary" id="get" formType="submit">读取数据</button>
<button class="page-body-button" id="set" formType="submit">存储数据</button>
<button class="page-body-button" id="clear" formType="submit">清理数据</button>
</view>
</form>
</view>
</view>
<toast hidden="{{toast.hidden}}" bindchange="toastChange">{{toast.content}}</toast>
<template is="footer" />
</view>
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'uploadFile'}}"/>
<view class="page-body">
<view class="page-body-wording">
<text class="page-body-text">
搭建好自己的后台服务器后,可以将手机上的图片视频等资源上传到服务器上。
</text>
</view>
</view>
<template is="footer" />
</view>
var util = require('../../../util/util.js')
var playTimeInterval
Page({
data: {
recording: false,
playing: false,
hasRecord: false,
recordTime: 0,
playTime: 0,
formatedRecordTime: '00:00:00',
formatedPlayTime: '00:00:00'
},
startRecord: function () {
this.setData({ recording: true })
var that = this
var interval = setInterval(function () {
that.data.recordTime += 1
that.setData({
formatedRecordTime: util.formatTime(that.data.recordTime)
})
}, 1000)
wx.startRecord({
success: function (res) {
that.setData({
hasRecord: true,
tempFilePath: res.tempFilePath,
formatedPlayTime: util.formatTime(that.data.playTime)
})
},
complete: function () {
that.setData({ recording: false })
clearInterval(interval)
}
})
},
stopRecord: function () {
wx.stopRecord()
},
playVoice: function () {
var that = this
playTimeInterval = setInterval(function () {
that.data.playTime += 1
that.setData({
playing: true,
formatedPlayTime: util.formatTime(that.data.playTime)
})
}, 1000)
wx.playVoice({
filePath: this.data.tempFilePath,
success: function () {
clearInterval(playTimeInterval)
that.data.playTime = 0
that.setData({
playing: false,
formatedPlayTime: util.formatTime(that.data.playTime)
})
}
})
},
pauseVoice: function () {
clearInterval(playTimeInterval)
wx.pauseVoice()
this.setData({
playing: false
})
},
stopVoice: function () {
clearInterval(playTimeInterval)
this.data.playTime = 0
this.setData({
playing: false,
formatedPlayTime: util.formatTime(this.data.playTime)
})
wx.stopVoice()
},
clear: function () {
this.data.recordTime = 0
this.data.playTime = 0
this.setData({
hasRecord: false,
tempFilePath: '',
formatedRecordTime: util.formatTime(0)
})
}
})
<import src="../common/header.wxml" />
<import src="../common/footer.wxml" />
<view class="container">
<template is="header" data="{{title: 'start/stopRecord、play/pause/stopVoice'}}"/>
<view class="page-body">
<view class="page-body-wrapper">
<block wx:if="{{recording === false && playing === false && hasRecord === false}}">
<view class="page-body-time">
<text class="time-big">{{formatedRecordTime}}</text>
</view>
<view class="page-body-buttons">
<view class="page-body-button"></view>
<view class="page-body-button" bindtap="startRecord">
<image src="/image/record.png"></image>
</view>
<view class="page-body-button"></view>
</view>
</block>
<block wx:if="{{recording === true}}">
<view class="page-body-time">
<text class="time-big">{{formatedRecordTime}}</text>
</view>
<view class="page-body-buttons">
<view class="page-body-button"></view>
<view class="page-body-button" bindtap="stopRecord">
<view class="button-stop-record"></view>
</view>
<view class="page-body-button"></view>
</view>
</block>
<block wx:if="{{hasRecord === true && playing === false}}">
<view class="page-body-time">
<text class="time-big">{{formatedPlayTime}}</text>
<text class="time-small">{{formatedRecordTime}}</text>
</view>
<view class="page-body-buttons">
<view class="page-body-button"></view>
<view class="page-body-button" bindtap="playVoice">
<image src="/image/play.png"></image>
</view>
<view class="page-body-button" bindtap="clear">
<image src="/image/trash.png"></image>
</view>
</view>
</block>
<block wx:if="{{hasRecord === true && playing === true}}">
<view class="page-body-time">
<text class="time-big">{{formatedPlayTime}}</text>
<text class="time-small">{{formatedRecordTime}}</text>
</view>
<view class="page-body-buttons">
<view class="page-body-button" bindtap="stopVoice">
<image src="/image/stop.png"></image>
</view>
<view class="page-body-button" bindtap="pauseVoice">
<image src="/image/pause.png"></image>
</view>
<view class="page-body-button" bindtap="clear">
<image src="/image/trash.png"></image>
</view>
</view>
</block>
</view>
</view>
<template is="footer" />
</view>
.page-body-wrapper {
justify-content: space-between;
flex-grow: 1;
margin-bottom: 300rpx;
}
.page-body-time {
display: flex;
flex-direction: column;
align-items: center;
}
.time-big {
font-size: 60rpx;
margin: 20rpx;
}
.time-small {
font-size: 30rpx;
}
.page-body-buttons {
display: flex;
justify-content: space-around;
}
.page-body-button {
width: 250rpx;
text-align: center;
}
.button-stop-record {
width: 110rpx;
height: 110rpx;
border: 20rpx solid #fff;
background-color: #f55c23;
border-radius: 130rpx;
margin: 0 auto;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment