commit 07e6576a29be55a91f9df34ed452afbbb0239d2f Author: myr1111 <3219004937@qq.com> Date: Thu Jan 9 09:46:20 2020 +0800 car diff --git a/README.md b/README.md new file mode 100644 index 0000000..cbff3ba --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# myrcar + diff --git a/app.js b/app.js new file mode 100644 index 0000000..b545190 --- /dev/null +++ b/app.js @@ -0,0 +1,39 @@ +//app.js +App({ + onLaunch: function () { + // 展示本地存储能力 + var 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 + } +}) \ No newline at end of file diff --git a/app.json b/app.json new file mode 100644 index 0000000..3429189 --- /dev/null +++ b/app.json @@ -0,0 +1,14 @@ +{ + "pages": [ + "pages/index/index", + "pages/logs/logs" + ], + "window": { + "backgroundTextStyle": "light", + "navigationBarBackgroundColor": "#fff", + "navigationBarTitleText": "WeChat", + "navigationBarTextStyle": "black" + }, + "style": "v2", + "sitemapLocation": "sitemap.json" +} \ No newline at end of file diff --git a/app.wxss b/app.wxss new file mode 100644 index 0000000..06c6fc9 --- /dev/null +++ b/app.wxss @@ -0,0 +1,10 @@ +/**app.wxss**/ +.container { + height: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-between; + padding: 200rpx 0; + box-sizing: border-box; +} diff --git a/pages/index/index.js b/pages/index/index.js new file mode 100644 index 0000000..608a282 --- /dev/null +++ b/pages/index/index.js @@ -0,0 +1,54 @@ +//index.js +//获取应用实例 +const app = getApp() + +Page({ + data: { + motto: 'Hello World', + userInfo: {}, + hasUserInfo: false, + canIUse: wx.canIUse('button.open-type.getUserInfo') + }, + //事件处理函数 + bindViewTap: function() { + wx.navigateTo({ + url: '../logs/logs' + }) + }, + onLoad: function () { + if (app.globalData.userInfo) { + this.setData({ + userInfo: app.globalData.userInfo, + hasUserInfo: true + }) + } else if (this.data.canIUse){ + // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 + // 所以此处加入 callback 以防止这种情况 + app.userInfoReadyCallback = res => { + this.setData({ + userInfo: res.userInfo, + hasUserInfo: true + }) + } + } else { + // 在没有 open-type=getUserInfo 版本的兼容处理 + wx.getUserInfo({ + success: res => { + app.globalData.userInfo = res.userInfo + this.setData({ + userInfo: res.userInfo, + hasUserInfo: true + }) + } + }) + } + }, + getUserInfo: function(e) { + console.log(e) + app.globalData.userInfo = e.detail.userInfo + this.setData({ + userInfo: e.detail.userInfo, + hasUserInfo: true + }) + } +}) diff --git a/pages/index/index.json b/pages/index/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/index/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml new file mode 100644 index 0000000..0f794dc --- /dev/null +++ b/pages/index/index.wxml @@ -0,0 +1,27 @@ +<<<<<<< HEAD + + + + + + + + + + + + + + + + + + + +======= + + + + + +>>>>>>> c5f771a59727db7ba1c64d41699c7724f4ed2d1c diff --git a/pages/index/index.wxss b/pages/index/index.wxss new file mode 100644 index 0000000..ce30de0 --- /dev/null +++ b/pages/index/index.wxss @@ -0,0 +1,21 @@ +/**index.wxss**/ +.userinfo { + display: flex; + flex-direction: column; + align-items: center; +} + +.userinfo-avatar { + width: 128rpx; + height: 128rpx; + margin: 20rpx; + border-radius: 50%; +} + +.userinfo-nickname { + color: #aaa; +} + +.usermotto { + margin-top: 200px; +} \ No newline at end of file diff --git a/pages/logs/logs.js b/pages/logs/logs.js new file mode 100644 index 0000000..b2b967d --- /dev/null +++ b/pages/logs/logs.js @@ -0,0 +1,15 @@ +//logs.js +const util = require('../../utils/util.js') + +Page({ + data: { + logs: [] + }, + onLoad: function () { + this.setData({ + logs: (wx.getStorageSync('logs') || []).map(log => { + return util.formatTime(new Date(log)) + }) + }) + } +}) diff --git a/pages/logs/logs.json b/pages/logs/logs.json new file mode 100644 index 0000000..3ee76c1 --- /dev/null +++ b/pages/logs/logs.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText": "查看启动日志", + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/logs/logs.wxml b/pages/logs/logs.wxml new file mode 100644 index 0000000..b5a85ac --- /dev/null +++ b/pages/logs/logs.wxml @@ -0,0 +1,6 @@ + + + + {{index + 1}}. {{log}} + + diff --git a/pages/logs/logs.wxss b/pages/logs/logs.wxss new file mode 100644 index 0000000..94d4b88 --- /dev/null +++ b/pages/logs/logs.wxss @@ -0,0 +1,8 @@ +.log-list { + display: flex; + flex-direction: column; + padding: 40rpx; +} +.log-item { + margin: 10rpx; +} diff --git a/project.config.json b/project.config.json new file mode 100644 index 0000000..023eb94 --- /dev/null +++ b/project.config.json @@ -0,0 +1,48 @@ +{ + "description": "项目配置文件", + "packOptions": { + "ignore": [] + }, + "setting": { + "urlCheck": true, + "es6": true, + "postcss": true, + "minified": true, + "newFeature": true, + "autoAudits": false, + "coverView": true + }, + "compileType": "miniprogram", +<<<<<<< HEAD + "libVersion": "2.0.4", + "appid": "wxae4f3cb3357e0b55", +======= + "libVersion": "2.9.4", + "appid": "wx5766b7aac7c938b3", +>>>>>>> c5f771a59727db7ba1c64d41699c7724f4ed2d1c + "projectname": "car", + "debugOptions": { + "hidedInDevtools": [] + }, + "isGameTourist": false, + "simulatorType": "wechat", + "simulatorPluginLibVersion": {}, + "condition": { + "search": { + "current": -1, + "list": [] + }, + "conversation": { + "current": -1, + "list": [] + }, + "game": { + "currentL": -1, + "list": [] + }, + "miniprogram": { + "current": -1, + "list": [] + } + } +} \ No newline at end of file diff --git a/sitemap.json b/sitemap.json new file mode 100644 index 0000000..ca02add --- /dev/null +++ b/sitemap.json @@ -0,0 +1,7 @@ +{ + "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", + "rules": [{ + "action": "allow", + "page": "*" + }] +} \ No newline at end of file diff --git a/utils/img/a.jpeg b/utils/img/a.jpeg new file mode 100644 index 0000000..5091e44 Binary files /dev/null and b/utils/img/a.jpeg differ diff --git a/utils/img/banner.png b/utils/img/banner.png new file mode 100644 index 0000000..bd8bce0 Binary files /dev/null and b/utils/img/banner.png differ diff --git a/utils/img/e0a4120f56503d02d61d5f6e92071dda.png b/utils/img/e0a4120f56503d02d61d5f6e92071dda.png new file mode 100644 index 0000000..9e5bfe6 Binary files /dev/null and b/utils/img/e0a4120f56503d02d61d5f6e92071dda.png differ diff --git a/utils/img/万能泡沫清洗剂.png b/utils/img/万能泡沫清洗剂.png new file mode 100644 index 0000000..a0c4e30 Binary files /dev/null and b/utils/img/万能泡沫清洗剂.png differ diff --git a/utils/img/保养.png b/utils/img/保养.png new file mode 100644 index 0000000..81a16cc Binary files /dev/null and b/utils/img/保养.png differ diff --git a/utils/img/冷却系统养护.png b/utils/img/冷却系统养护.png new file mode 100644 index 0000000..3e416fc Binary files /dev/null and b/utils/img/冷却系统养护.png differ diff --git a/utils/img/发动机.png b/utils/img/发动机.png new file mode 100644 index 0000000..2d21345 Binary files /dev/null and b/utils/img/发动机.png differ diff --git a/utils/img/图层 6.png b/utils/img/图层 6.png new file mode 100644 index 0000000..b90ecae Binary files /dev/null and b/utils/img/图层 6.png differ diff --git a/utils/img/圆角矩形 2.png b/utils/img/圆角矩形 2.png new file mode 100644 index 0000000..f62ae27 Binary files /dev/null and b/utils/img/圆角矩形 2.png differ diff --git a/utils/img/广告位.png b/utils/img/广告位.png new file mode 100644 index 0000000..aaadbbf Binary files /dev/null and b/utils/img/广告位.png differ diff --git a/utils/img/形状 3.png b/utils/img/形状 3.png new file mode 100644 index 0000000..caecff6 Binary files /dev/null and b/utils/img/形状 3.png differ diff --git a/utils/img/形状 5.png b/utils/img/形状 5.png new file mode 100644 index 0000000..e744317 Binary files /dev/null and b/utils/img/形状 5.png differ diff --git a/utils/img/椭圆 6.png b/utils/img/椭圆 6.png new file mode 100644 index 0000000..ed4faf9 Binary files /dev/null and b/utils/img/椭圆 6.png differ diff --git a/utils/img/汽车空调换油保养.png b/utils/img/汽车空调换油保养.png new file mode 100644 index 0000000..c3b7b95 Binary files /dev/null and b/utils/img/汽车空调换油保养.png differ diff --git a/utils/img/矩形 19.png b/utils/img/矩形 19.png new file mode 100644 index 0000000..9f68405 Binary files /dev/null and b/utils/img/矩形 19.png differ diff --git a/utils/img/矩形 2.png b/utils/img/矩形 2.png new file mode 100644 index 0000000..61789b2 Binary files /dev/null and b/utils/img/矩形 2.png differ diff --git a/utils/img/类目 品类 分类 类别.png b/utils/img/类目 品类 分类 类别.png new file mode 100644 index 0000000..458bf86 Binary files /dev/null and b/utils/img/类目 品类 分类 类别.png differ diff --git a/utils/img/道路救援.png b/utils/img/道路救援.png new file mode 100644 index 0000000..8f15189 Binary files /dev/null and b/utils/img/道路救援.png differ diff --git a/utils/img/雨刮.png b/utils/img/雨刮.png new file mode 100644 index 0000000..8dca198 Binary files /dev/null and b/utils/img/雨刮.png differ diff --git a/utils/util.js b/utils/util.js new file mode 100644 index 0000000..dbadbb8 --- /dev/null +++ b/utils/util.js @@ -0,0 +1,19 @@ +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: formatTime +}