Commit 01a4c8c0 authored by light's avatar light

update all

parent dfcc3ce7
// app.js
App({
onLaunch() {
// 展示本地存储能力
const logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
}
}
})
},
globalData: {
userInfo: null
}
})
{
"pages":[
"pages/home/home"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "骰子",
"navigationBarTextStyle":"black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
// pages/home/home.js
Page({
/**
* 页面的初始数据
*/
data: {
image_url: '/imgs/default.png',
// 触摸开始时间
touchStartTime: 0,
// 触摸结束时间
touchEndTime: 0,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
// 按钮触摸开始触发的事件
touchStart: function(e) {
this.touchStartTime = e.timeStamp
},
// 按钮触摸结束触发的事件
touchEnd: function(e) {
this.touchEndTime = e.timeStamp
},
longtap(e) {
var diff = this.touchEndTime - this.touchStartTime
// 1s -> 1.png
// 2-4s -> 2.png
// 5-6s -> 3.png
// 7-9s -> 4.png
// 10-12s 1.png
// image_url
var image_url = '/imgs/default.png'
if (diff <= 1000) {
image_url = '/imgs/1.png'
} else if (diff <= 4000) {
image_url = '/imgs/2.png'
} else if (diff <= 6000) {
image_url = '/imgs/3.png'
} else if (diff <= 9000) {
image_url = '/imgs/4.png'
}
this.setData({
image_url: image_url,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/home/home.wxml-->
<view class="container">
<image src="{{image_url}}" style="width: 900rpx; height:700rpx;"></image>
<image src="/imgs/shaizi.png" style="width: 200rpx; height:200rpx;" bindtap="longtap" bindtouchstart="touchStart"
bindtouchend="touchEnd"></image>
</view>
\ No newline at end of file
/* pages/home/home.wxss */
// index.js
// 获取应用实例
const app = getApp()
Page({
data: {
},
onLoad() {
},
})
{
"usingComponents": {}
}
\ No newline at end of file
<!--index.wxml-->
<view class="container">
<image src="/imgs/1.png"></image>
</view>
/**index.wxss**/
image {
widows: 100%;
height: 700rpx;
}
\ No newline at end of file
{
"description": "项目配置文件",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"enhance": false,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": false,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": false,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"bundle": false,
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true
},
"compileType": "miniprogram",
"libVersion": "2.15.0",
"appid": "wx3a6bf4289b1150d7",
"projectname": "helloworld",
"debugOptions": {
"hidedInDevtools": []
},
"scripts": {},
"isGameTourist": false,
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"game": {
"list": []
},
"plugin": {
"list": []
},
"gamePlugin": {
"list": []
},
"miniprogram": {
"list": []
}
}
}
\ No newline at end of file
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}
\ No newline at end of file
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : `0${n}`
}
module.exports = {
formatTime
}
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