Commit a6e6435b authored by miusix's avatar miusix

提交

parents
Pipeline #234 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",
"pages/logs/logs"
],
"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;
}
// index.js
// 获取应用实例
const app = getApp()
Page({
data: {
active: 0,
},
time: 0,
timer: null,
// 事件处理函数
bindViewTap() {
},
onReady() {
},
ts() {
this.timer = setInterval(() => {
this.time += 1
if (this.time == 1) {
this.setData({
active: 1
})
} else if (this.time >= 2 && this.time <= 4) {
this.setData({
active: 2
})
} else if (this.time >= 5 && this.time <= 6){
this.setData({
active: 3
})
} else if (this.time >= 7 && this.time <= 9) {
this.setData({
active: 4
})
} else if (this.time >= 10 && this.time <= 12) {
this.setData({
active: 1
})
if (this.time === 12) {
this.time = 2
}
}
}, 1000);
},
te() {
clearInterval(this.timer)
}
})
{
"usingComponents": {}
}
\ No newline at end of file
<!--index.wxml-->
<view class="container">
<view></view>
<view class="down">
<view class="imgs">
<view class="back">
<image class="base {{active==0?'show':''}} " src="../../img/运行 拷贝 2.png" mode="aspectFill"/>
<image class="base {{active===1?'show':''}}" src="../../img/运行 拷贝.png" mode="aspectFill"/>
<image class="base {{active===2?'show':''}}" src="../../img/运行.png" mode="aspectFill"/>
<image class="base {{active===3?'show':''}}" src="../../img/运行 拷贝 3.png" mode="aspectFill"/>
<image class="base {{active===4?'show':''}}" src="../../img/运行 拷贝 4.png" mode="aspectFill"/>
<image class="touzi" bind:touchstart="ts" bind:touchend="te" src="../../img/<编组>.png" alt="" id='touzi'/>
</view>
</view>
</view>
</view>
.down {
/* display: flex;
justify-content: center;
align-items: center; */
height: 240px;
width: 750rpx;
}
.down .imgs {
margin: 0 auto;
height: 240px;
width: 750rpx;
}
.back {
position: relative;
width: 750rpx;
display: flex;
justify-content: center;
align-items: center;
}
.touzi {
width: 100px;
height: 100px;
position: absolute;
top: 50%;
left: 50%;
z-index: 9;
transform: translate(-50%, -50%);
}
.base {
display: none;
}
.show {
display: block;
}
// logs.js
const util = require('../../utils/util.js')
Page({
data: {
logs: []
},
onLoad() {
this.setData({
logs: (wx.getStorageSync('logs') || []).map(log => {
return util.formatTime(new Date(log))
})
})
}
})
{
"navigationBarTitleText": "查看启动日志",
"usingComponents": {}
}
\ No newline at end of file
<!--logs.wxml-->
<view class="container log-list">
<block wx:for="{{logs}}" wx:for-item="log">
<text class="log-item">{{index + 1}}. {{log}}</text>
</block>
</view>
.log-list {
display: flex;
flex-direction: column;
padding: 40rpx;
}
.log-item {
margin: 10rpx;
}
{
"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": false,
"useApiHook": true,
"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.14.1",
"appid": "wxd36e1970769958f7",
"projectname": "toolBox",
"debugOptions": {
"hidedInDevtools": []
},
"scripts": {},
"isGameTourist": false,
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"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