mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 16:58:06 +08:00
add mp
This commit is contained in:
parent
b73ba661fa
commit
65b3ca26f3
18
client/mp/app.js
Normal file
18
client/mp/app.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
App({
|
||||||
|
conf: {serve: "https://shylinux.com/chat/mp"},
|
||||||
|
request(cmd, data, cb) {var app = this; data.sessid = app.conf.sessid
|
||||||
|
wx.request({method: "POST", url: app.conf.serve+"/"+cmd, data: data, success: function(res) {var msg = res.data
|
||||||
|
msg.__proto__ = {
|
||||||
|
Result: function() {return msg.result && msg.result.length > 0 && msg.result.join("") || ""},
|
||||||
|
}
|
||||||
|
typeof cb == "function" && cb(msg)
|
||||||
|
}})
|
||||||
|
},
|
||||||
|
onLaunch: function () {var app = this
|
||||||
|
wx.login({success: function(res) {app.request("login", {code: res.code}, function(msg) {app.conf.sessid = msg.Result()
|
||||||
|
wx.getSetting({success: function(res) {res.authSetting['scope.userInfo'] && wx.getUserInfo({success: function(res) {
|
||||||
|
app.request("login", res.userInfo, function(msg) {app.conf.userInfo = res.userInfo})
|
||||||
|
}})}})
|
||||||
|
})}})
|
||||||
|
},
|
||||||
|
})
|
14
client/mp/app.json
Normal file
14
client/mp/app.json
Normal file
@ -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"
|
||||||
|
}
|
10
client/mp/app.wxss
Normal file
10
client/mp/app.wxss
Normal file
@ -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;
|
||||||
|
}
|
18
client/mp/pages/index/index.js
Normal file
18
client/mp/pages/index/index.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
const app = getApp()
|
||||||
|
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
motto: 'Hello World',
|
||||||
|
qrcode: 'Hello World',
|
||||||
|
userInfo: {},
|
||||||
|
hasUserInfo: false,
|
||||||
|
canIUse: wx.canIUse('button.open-type.getUserInfo')
|
||||||
|
},
|
||||||
|
onscan: function(event) {var page = this
|
||||||
|
wx.scanCode({success: function(res) {
|
||||||
|
app.request("login", {scan: res.result, type: res.scanType})
|
||||||
|
page.setData({qrcode: res.result})
|
||||||
|
}})
|
||||||
|
},
|
||||||
|
onLoad: function () {},
|
||||||
|
})
|
3
client/mp/pages/index/index.json
Normal file
3
client/mp/pages/index/index.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
15
client/mp/pages/index/index.wxml
Normal file
15
client/mp/pages/index/index.wxml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<!--index.wxml-->
|
||||||
|
<view class="container">
|
||||||
|
<view class="userinfo">
|
||||||
|
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
|
||||||
|
<block wx:else>
|
||||||
|
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
|
||||||
|
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
|
||||||
|
</block>
|
||||||
|
</view>
|
||||||
|
<button bindtap="onscan">扫一扫</button>
|
||||||
|
<view><text>{{qrcode}}</text></view>
|
||||||
|
<view class="usermotto">
|
||||||
|
<text class="user-motto">{{motto}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
21
client/mp/pages/index/index.wxss
Normal file
21
client/mp/pages/index/index.wxss
Normal file
@ -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;
|
||||||
|
}
|
15
client/mp/pages/logs/logs.js
Normal file
15
client/mp/pages/logs/logs.js
Normal file
@ -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))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
4
client/mp/pages/logs/logs.json
Normal file
4
client/mp/pages/logs/logs.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"navigationBarTitleText": "查看启动日志",
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
6
client/mp/pages/logs/logs.wxml
Normal file
6
client/mp/pages/logs/logs.wxml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<!--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>
|
8
client/mp/pages/logs/logs.wxss
Normal file
8
client/mp/pages/logs/logs.wxss
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
.log-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 40rpx;
|
||||||
|
}
|
||||||
|
.log-item {
|
||||||
|
margin: 10rpx;
|
||||||
|
}
|
45
client/mp/project.config.json
Normal file
45
client/mp/project.config.json
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"description": "项目配置文件",
|
||||||
|
"packOptions": {
|
||||||
|
"ignore": []
|
||||||
|
},
|
||||||
|
"setting": {
|
||||||
|
"urlCheck": true,
|
||||||
|
"es6": true,
|
||||||
|
"postcss": true,
|
||||||
|
"minified": true,
|
||||||
|
"newFeature": true,
|
||||||
|
"autoAudits": false,
|
||||||
|
"coverView": true,
|
||||||
|
"showShadowRootInWxmlPanel": true,
|
||||||
|
"scopeDataCheck": false
|
||||||
|
},
|
||||||
|
"compileType": "miniprogram",
|
||||||
|
"libVersion": "2.0.4",
|
||||||
|
"appid": "wxf4e5104d83476ed6",
|
||||||
|
"projectname": "%E7%BB%88%E7%AB%AF%E5%B7%A5%E5%85%B7%E9%93%BE",
|
||||||
|
"debugOptions": {
|
||||||
|
"hidedInDevtools": []
|
||||||
|
},
|
||||||
|
"isGameTourist": false,
|
||||||
|
"simulatorType": "wechat",
|
||||||
|
"simulatorPluginLibVersion": {},
|
||||||
|
"condition": {
|
||||||
|
"search": {
|
||||||
|
"current": -1,
|
||||||
|
"list": []
|
||||||
|
},
|
||||||
|
"conversation": {
|
||||||
|
"current": -1,
|
||||||
|
"list": []
|
||||||
|
},
|
||||||
|
"game": {
|
||||||
|
"currentL": -1,
|
||||||
|
"list": []
|
||||||
|
},
|
||||||
|
"miniprogram": {
|
||||||
|
"current": -1,
|
||||||
|
"list": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
client/mp/sitemap.json
Normal file
7
client/mp/sitemap.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
|
||||||
|
"rules": [{
|
||||||
|
"action": "allow",
|
||||||
|
"page": "*"
|
||||||
|
}]
|
||||||
|
}
|
19
client/mp/utils/util.js
Normal file
19
client/mp/utils/util.js
Normal file
@ -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
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user