Commit fb010f39 authored by 李紫阳's avatar 李紫阳

Initial commit

parents
Pipeline #236 failed with stages
// 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/index/index"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Weixin",
"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;
}
Page({
/**
* 页面的初始数据
*/
data: {
imgSrcs: ''
// imgSrcs:['0','2_4','5_7','7_9','9_12'] 图片地址
},
setIn:null, //计时器开关
times: 0, //计算按下时间
timeStart() { //计时开始
console.log('开始');
this.setIn=setInterval(()=>this.togImg(),10)
},
timeEnd() { //松开手指
console.log('结束了');
clearInterval(this.setIn)
},
togImg() { //计时切换图片
this.times++
let times = parseInt(this.times / 100)
switch (times) {
case 1:
this.setData({imgSrcs: '2_4'});
break;
case 2:
case 3:
case 4:
this.setData({imgSrcs: '5_7'});
break;
case 5:
case 6:
this.setData({imgSrcs: '7_9'});
break;
case 7:
case 8:
case 9:
this.setData({imgSrcs: '9_12'});
break;
case 10:
this.times = 0 //当等于10秒时清空
break;
}
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<view class="container">
<image class="shaizi" bindlongpress="timeStart" bindtouchend="timeEnd" src="/images/shaizi.png"></image>
<image class="bgimg" src="/images/{{imgSrcs || '0'}}.png"></image>
</view>
\ No newline at end of file
page{
background-color: darkcyan;
}
.container{
display: flex;
align-items: center;
justify-content: center;
width: 100vw;
height: 100vh;
position: relative;
}
.shaizi{
position: absolute;
width: 300rpx;
height: 150rpx;
z-index: 100;
}
.bgimg{
position: absolute;
width: 640rpx;
height: 480rpx;
}
\ No newline at end of file
{
"description": "项目配置文件",
"packOptions": {
"ignore": []
},
"setting": {
"bundle": false,
"userConfirmedBundleSwitch": false,
"urlCheck": true,
"scopeDataCheck": false,
"coverView": true,
"es6": true,
"postcss": true,
"compileHotReLoad": false,
"preloadBackgroundData": false,
"minified": true,
"autoAudits": false,
"newFeature": false,
"uglifyFileName": false,
"uploadWithSourceMap": true,
"useIsolateContext": true,
"nodeModules": false,
"enhance": false,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"showShadowRootInWxmlPanel": true,
"packNpmManually": false,
"enableEngineNative": false,
"packNpmRelationList": [],
"minifyWXSS": true
},
"compileType": "miniprogram",
"libVersion": "2.15.0",
"appid": "wxe482d0c7523ebd35",
"projectname": "%E9%AA%B0%E5%AD%90",
"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