mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 08:48:06 +08:00
opt mp
This commit is contained in:
parent
e73b918567
commit
a64d302df6
@ -150,6 +150,7 @@ Volcanos("base", {help: "数据类型",
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
try { res = JSON.parse(str)
|
try { res = JSON.parse(str)
|
||||||
|
res.text = res.text||str
|
||||||
res.type = res.type||"json"
|
res.type = res.type||"json"
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
res = {type: "text", text: str}
|
res = {type: "text", text: str}
|
||||||
|
@ -1,40 +1,29 @@
|
|||||||
const kit = require("utils/kit.js")
|
const kit = require("utils/kit.js")
|
||||||
|
|
||||||
App({
|
App({
|
||||||
// data: {}, conf: {serve: "https://shylinux.com/chat", space: "mac"},
|
|
||||||
data: {}, conf: {serve: "https://shylinux.com/chat", space: ""},
|
data: {}, conf: {serve: "https://shylinux.com/chat", space: ""},
|
||||||
request: function(cmd, data, cb) { var app = this; data.sessid = app.conf.sessid, data.pod = app.conf.space
|
request: function(cmd, data, cb) { var app = this; data.sessid = app.conf.sessid, data.pod = app.conf.space
|
||||||
wx.request({method: "POST", url: app.conf.serve+"/"+cmd, data: data, success: function(res) { var msg = res.data
|
wx.request({method: "POST", url: app.conf.serve+"/"+cmd, data: data, success: function(res) { var msg = res.data
|
||||||
if (res.statusCode == 401) { return app.usercode(function() {app.request(cmd, data, cb)}) }
|
if (res.statusCode == 401) { return app.usercode(function() { app.request(cmd, data, cb) }) }
|
||||||
console.log("POST", cmd, msg)
|
console.log("POST", cmd, msg)
|
||||||
|
|
||||||
msg.__proto__ = {
|
msg.__proto__ = {
|
||||||
nRow: function() { return msg.append && msg.append[0] && msg[msg.append[0]].length || 0 },
|
|
||||||
Result: function() { return msg.result && msg.result.length > 0 && msg.result.join("") || "" },
|
Result: function() { return msg.result && msg.result.length > 0 && msg.result.join("") || "" },
|
||||||
Table: function(cb) { var row = 0
|
Length: function() { var max = 0; if (!msg.append) { return max }
|
||||||
for (var i = 0; i < msg.append.length; i++) {
|
for (var i = 0; i < msg.append.length; i++) {
|
||||||
row = msg[msg.append[i]].length > row? msg[msg.append[i]].length: row
|
var len = msg[msg.append[i]].length; len > max && (max = len)
|
||||||
}
|
}; return max
|
||||||
for (var i = 0; i < row; i++) { var line = {}
|
},
|
||||||
for (var k in msg.append) {
|
Table: function(cb) { var res = []
|
||||||
line[msg.append[k]] = msg[msg.append[k]][i]
|
for (var i = 0; i < msg.Length(); i++) { var line = {}
|
||||||
}
|
for (var k in msg.append) { line[msg.append[k]] = msg[msg.append[k]][i] }
|
||||||
typeof cb == "function" && cb(line, i, row)
|
typeof cb == "function" && cb(line, i, msg.Length())
|
||||||
}
|
res.push(line)
|
||||||
|
}; return res
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
var row = 0
|
|
||||||
var index = []
|
|
||||||
if (msg.append) {
|
|
||||||
for (var i = 0; i < msg.append.length; i++) {
|
|
||||||
row = msg[msg.append[i]].length > row? msg[msg.append[i]].length: row
|
|
||||||
}
|
|
||||||
for (var i = 0; i < row; i++) {
|
|
||||||
index.push(i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
msg._index = index
|
|
||||||
|
|
||||||
|
var index = []; for (var i = 0; i < msg.Length(); i++) { index.push(i) }; msg._index = index
|
||||||
typeof cb == "function" && cb(msg)
|
typeof cb == "function" && cb(msg)
|
||||||
}})
|
}})
|
||||||
},
|
},
|
||||||
@ -43,24 +32,20 @@ App({
|
|||||||
},
|
},
|
||||||
usercode: function(cb) { var app = this
|
usercode: function(cb) { var app = this
|
||||||
wx.login({success: function(res) { app.request("mp/login/sess", {code: res.code}, function(msg) {
|
wx.login({success: function(res) { app.request("mp/login/sess", {code: res.code}, function(msg) {
|
||||||
wx.setStorage({key: "sessid", data: msg.Result()})
|
wx.setStorage({key: "sessid", data: app.conf.sessid = msg.Result()})
|
||||||
app.conf.sessid = msg.Result(), typeof cb == "function" && cb()
|
typeof cb == "function" && cb()
|
||||||
})}})
|
})}})
|
||||||
},
|
},
|
||||||
userinfo: function(cb) { var app = this
|
userinfo: function(cb) { var app = this
|
||||||
if (app.conf.userInfo) {
|
app.conf.userInfo? app.request("mp/login/user", app.conf.userInfo, function(msg) {
|
||||||
app.request("mp/login/user", app.conf.userInfo, function(msg) {
|
typeof cb == "function" && cb(app.conf.userInfo)
|
||||||
typeof cb == "function" && cb(app.conf.userInfo)
|
}): app.usercode(function() { wx.getSetting({success: function(res) {
|
||||||
})
|
res.authSetting['scope.userInfo'] && wx.getUserInfo({success: function(res) {
|
||||||
return
|
app.request("mp/login/user", app.conf.userInfo = res.userInfo, function(msg) {
|
||||||
}
|
typeof cb == "function" && cb(app.conf.userInfo)
|
||||||
app.usercode(function() {
|
|
||||||
wx.getSetting({ success: function(res) { res.authSetting['scope.userInfo'] && wx.getUserInfo({success: function(res) {
|
|
||||||
app.request("mp/login/user", res.userInfo, function(msg) { app.conf.userInfo = res.userInfo
|
|
||||||
typeof cb == "function" && cb(res.userInfo)
|
|
||||||
})
|
})
|
||||||
}})}})
|
}})
|
||||||
})
|
}}) })
|
||||||
},
|
},
|
||||||
location: function(arg) { wx.chooseLocation(arg) },
|
location: function(arg) { wx.chooseLocation(arg) },
|
||||||
|
|
||||||
@ -71,58 +56,20 @@ App({
|
|||||||
console.log("jump", next), wx.navigateTo({url: next, success: cb})
|
console.log("jump", next), wx.navigateTo({url: next, success: cb})
|
||||||
},
|
},
|
||||||
scans: function(cb) { var app = this
|
scans: function(cb) { var app = this
|
||||||
wx.scanCode({success: function(res) { console.log("scan", res)
|
wx.scanCode({success: function(res) { var data = kit.parseJSON(res)
|
||||||
try {
|
if (typeof cb == "function" && cb(data)) { return }
|
||||||
var value = JSON.parse(res.result)
|
|
||||||
} catch(e) {
|
|
||||||
try {
|
|
||||||
var value = {"type": "url", "text": res.result}
|
|
||||||
var ls = res.result.split("?"); if (ls.length > 1) { ls = ls[1].split("&")
|
|
||||||
for (var i = 0; i < ls.length; i++) { var vs = ls[i].split("=")
|
|
||||||
value[vs[0]] = decodeURIComponent(vs[1])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch(e) {
|
|
||||||
typeof cb == "function" && cb({type: "", text: res.result})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (value.type) {
|
switch (data.type) {
|
||||||
case "share":
|
case "auth":
|
||||||
switch (value.name) {
|
|
||||||
case "invite":
|
|
||||||
app.userinfo(function(userInfo) {
|
|
||||||
app.modal("接受邀请", value.name, function(res) {
|
|
||||||
res.confirm && app.request("mp/login/auth", value, function(msg) {
|
|
||||||
app.toast("回执成功")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
break
|
|
||||||
}
|
|
||||||
break
|
|
||||||
|
|
||||||
case "login":
|
|
||||||
app.userinfo(function(userInfo) {
|
app.userinfo(function(userInfo) {
|
||||||
app.modal("授权登录", value.name, function(res) {
|
app.modal("授权登录", data.name, function(res) {
|
||||||
res.confirm && app.request("mp/login/auth", value, function(msg) {
|
res.confirm && app.request("mp/login/scan", data, function(msg) {
|
||||||
app.toast("授权成功")
|
app.toast("授权成功")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case "active":
|
default: app.request("mp/login/scan", res)
|
||||||
app.userinfo(function(userInfo) {
|
|
||||||
app.modal("授权登录", value.name, function(res) {
|
|
||||||
res.confirm && app.request("mp/login/auth", value, function(msg) {
|
|
||||||
app.toast("授权成功")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
typeof cb == "function" && cb(value)
|
|
||||||
}
|
}
|
||||||
}})
|
}})
|
||||||
},
|
},
|
||||||
|
@ -1,13 +1,8 @@
|
|||||||
<template name="action">
|
<template name="action">
|
||||||
<view class="action">
|
<view class="action">
|
||||||
<view class="item" wx:for="{{action}}" wx:key="name">
|
<view class="item" wx:for="{{action}}" wx:key="index">
|
||||||
<button size="mini" bindtap="onaction" data-name="{{item}}">{{item}}</button>
|
<button size="mini" bindtap="onaction" data-name="{{item}}">{{item}}</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template name="list-name">
|
|
||||||
<view class="output" wx:if="{{msg.name}}">
|
|
||||||
<view class="item" wx:for="{{msg.name}}" wx:key="name" bindtap="ondetail" data-name="{{item}}" data-index="{{index}}">{{item}}</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
@ -3,49 +3,50 @@ const app = getApp()
|
|||||||
|
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
action: ["扫码", "刷新", "清屏", "串行", "并行"],
|
|
||||||
river: "", storm: "", title: "",
|
river: "", storm: "", title: "",
|
||||||
|
action: ["刷新", "扫码", "清屏", "串行", "并行"],
|
||||||
res: [], his: {}, inputs: {},
|
res: [], his: {}, inputs: {},
|
||||||
},
|
},
|
||||||
action: {
|
action: {
|
||||||
"扫码": function(event, page, data, name) {
|
"刷新": function(event, page) { var list = []
|
||||||
// app.jumps("scans/scans")
|
app.data[page.data.river+page.data.storm] = page.data.res = list
|
||||||
app.scans(function(res) {
|
|
||||||
res["sess.river"] = page.data.river
|
|
||||||
res["sess.storm"] = page.data.storm
|
|
||||||
app.request("mp/login/scan", res)
|
|
||||||
page.onaction(event, res, res.name)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
"刷新": function(event, page, data, name) {
|
|
||||||
var list = []; app.data[page.data.river+page.data.storm] = page.data.res = list
|
|
||||||
wx.showLoading()
|
wx.showLoading()
|
||||||
app.request("action", {cmds: [page.data.river, page.data.storm]}, function(msg) {
|
app.request("action", {cmds: [page.data.river, page.data.storm]}, function(msg) { wx.hideLoading()
|
||||||
wx.hideLoading()
|
msg.Table(function(line, index) { list.push(line)
|
||||||
msg.Table(function(line, index) {
|
|
||||||
line.name = line.name.split(" ")[0]
|
|
||||||
page.data.his[index] = []
|
|
||||||
line.inputs = JSON.parse(line.list)
|
|
||||||
line.feature = JSON.parse(line.meta)
|
line.feature = JSON.parse(line.meta)
|
||||||
|
line.inputs = JSON.parse(line.list)
|
||||||
|
line.name = line.name.split(" ")[0]
|
||||||
|
|
||||||
if (!line.inputs || line.inputs.length === 0) {
|
if (!line.inputs || line.inputs.length === 0) {
|
||||||
line.inputs = [{_input: "text"}, {_input: "button", value: "执行"}]
|
line.inputs = [{_input: "text"}, {_input: "button", value: "执行"}]
|
||||||
}
|
}
|
||||||
list.push(line), line.inputs.forEach(function(input) {
|
|
||||||
input.action = input.action || input.value
|
line.inputs.forEach(function(input) { input.action = input.action || input.value
|
||||||
|
input.value = kit.Value(line, "feature.trans."+input.name) || input.value
|
||||||
input.value == "auto" && (input.value = "")
|
input.value == "auto" && (input.value = "")
|
||||||
input.value = input.value || kit.Value(line, "feature.trans."+input.name)
|
|
||||||
if (input.value && input.value.indexOf("@") == 0) {
|
if (input.value && input.value.indexOf("@") == 0) {
|
||||||
input.value = ""
|
input.action = input.value.slice(1), input.value = ""
|
||||||
}
|
}
|
||||||
if (input._input == "select") {
|
if (input._input == "select") {
|
||||||
input.values = input.values || input.value && input.value.split("|")
|
input.values = input.values || input.value && kit.Split(input.value)
|
||||||
}
|
}
|
||||||
input._input == "button" && input.action == "auto" && page.run(event, index)
|
input._input == "button" && input.action == "auto" && page.run(event, index)
|
||||||
})
|
})
|
||||||
})
|
}), page.data.his = [], page.setData({res: list})
|
||||||
page.setData({res: list})
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
"扫码": function(event, page) { app.scans(function(res) {
|
||||||
|
switch (res.type) {
|
||||||
|
case "button": res.name && page.onaction(event, res); break
|
||||||
|
default: return false
|
||||||
|
} return true
|
||||||
|
}) },
|
||||||
|
"清屏": function(event, page) {
|
||||||
|
kit.List(page.data.res, function(field, index) { delete(field.msg) })
|
||||||
|
page.setData({res: page.data.res})
|
||||||
|
},
|
||||||
"串行": function(event, page, data, name) {
|
"串行": function(event, page, data, name) {
|
||||||
function cb(i) {
|
function cb(i) {
|
||||||
page.run(event, i, null, function() {i < page.data.res.length - 1&& cb(i+1)})
|
page.run(event, i, null, function() {i < page.data.res.length - 1&& cb(i+1)})
|
||||||
@ -57,17 +58,10 @@ Page({
|
|||||||
page.run(event, index)
|
page.run(event, index)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"清屏": function(event, page, data, name) {
|
|
||||||
kit.List(page.data.res, function(field, index) {
|
|
||||||
delete(field.msg)
|
|
||||||
})
|
|
||||||
page.setData({res: page.data.res})
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
onaction: function(event, data, name) {
|
onaction: function(event, data) { data = data || event.target.dataset
|
||||||
data = data || event.target.dataset, name = name || data.name
|
console.log("action", "river", data.name)
|
||||||
console.log("action", "action", name)
|
this.action[data.name](event, this)
|
||||||
this.action[name](event, this, data)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
run: function(event, order, cmd, cb) {var page = this, field = page.data.res[order]
|
run: function(event, order, cmd, cb) {var page = this, field = page.data.res[order]
|
||||||
@ -157,7 +151,6 @@ Page({
|
|||||||
|
|
||||||
onLoad: function (options) {
|
onLoad: function (options) {
|
||||||
console.log("page", "action", options)
|
console.log("page", "action", options)
|
||||||
app.conf.sessid = options.sessid || app.conf.sessid
|
|
||||||
this.data.river = options.river
|
this.data.river = options.river
|
||||||
this.data.storm = options.storm
|
this.data.storm = options.storm
|
||||||
this.data.title = options.title
|
this.data.title = options.title
|
||||||
@ -165,20 +158,16 @@ Page({
|
|||||||
|
|
||||||
var data = app.data[options.river+options.storm]
|
var data = app.data[options.river+options.storm]
|
||||||
if (data) { return this.setData({res: this.data.res = data}) }
|
if (data) { return this.setData({res: this.data.res = data}) }
|
||||||
this.onaction({}, {}, "刷新")
|
this.onaction({}, {name: "刷新"})
|
||||||
},
|
},
|
||||||
onReady: function () {},
|
onReady: function () {},
|
||||||
onShow: function () {},
|
onShow: function () {},
|
||||||
onHide: function () {},
|
onHide: function () {},
|
||||||
onUnload: function () {},
|
onUnload: function () {},
|
||||||
onPullDownRefresh: function () {
|
|
||||||
this.onaction({}, {}, "刷新")
|
|
||||||
},
|
|
||||||
onReachBottom: function () {},
|
onReachBottom: function () {},
|
||||||
|
onPullDownRefresh: function () { this.onaction({}, {name: "刷新"}) },
|
||||||
onShareAppMessage: function (res) {
|
onShareAppMessage: function (res) {
|
||||||
console.log("action", "share", res)
|
return { title: this.data.title,
|
||||||
return {
|
|
||||||
title: this.data.title,
|
|
||||||
path: "pages/action/action?river="+this.data.river+"&storm="+this.data.storm+"&title="+this.data.title,
|
path: "pages/action/action?river="+this.data.river+"&storm="+this.data.storm+"&title="+this.data.title,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -3,82 +3,51 @@ const app = getApp()
|
|||||||
|
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
action: ["扫码", "刷新", "登录"],
|
|
||||||
river: {},
|
river: {},
|
||||||
|
action: ["刷新", "扫码", "登录"],
|
||||||
},
|
},
|
||||||
action: {
|
action: {
|
||||||
"扫码": function(event, page, data) { app.scans(function(res) {
|
"刷新": function(event, page) { wx.showLoading()
|
||||||
|
app.request("river", {}, function(msg) { wx.hideLoading()
|
||||||
|
page.setData({river: msg.Table()})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
"扫码": function(event, page) { app.scans(function(res) {
|
||||||
switch (res.type) {
|
switch (res.type) {
|
||||||
case "url":
|
case "button": res.name && page.onaction(event, res); break
|
||||||
app.request("mp/login/scan", res, function(msg) {
|
default: return false
|
||||||
page.onaction({}, {}, "刷新")
|
} return true
|
||||||
})
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
res.name && page.onaction(event, res, res.name)
|
|
||||||
}
|
|
||||||
}) },
|
}) },
|
||||||
"刷新": function(event, page, data) {
|
"登录": function(event, page) { app.conf.sessid = ""
|
||||||
wx.showLoading()
|
app.userinfo(function(res) { page.onaction(event, {name: "刷新"}) })
|
||||||
app.request("river", {}, function(msg) {
|
|
||||||
wx.hideLoading()
|
|
||||||
var river = {}; msg.Table(function(value) {
|
|
||||||
river[value.hash] = value
|
|
||||||
})
|
|
||||||
page.setData({river: river})
|
|
||||||
})
|
|
||||||
},
|
|
||||||
"登录": function(event, page, data) { app.conf.sessid = "",
|
|
||||||
app.userinfo(function(res) {
|
|
||||||
page.onaction(event, data, "刷新")
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
onaction: function(event, data, name) {
|
onaction: function(event, data) { data = data || event.target.dataset
|
||||||
data = data || event.target.dataset, name = name || data.name
|
console.log("action", "river", data.name)
|
||||||
console.log("action", "river", name)
|
this.action[data.name](event, this)
|
||||||
this.action[name](event, this, data)
|
|
||||||
},
|
},
|
||||||
ondetail: function(event, data) { var page = this
|
ondetail: function(event, data) { data = data || event.target.dataset
|
||||||
data = data || event.target.dataset.item
|
var page = this, river = page.data.river[data.index]
|
||||||
console.log("detail", "river", data)
|
river._show = !river._show; if (river.list) {
|
||||||
|
return page.setData({river: page.data.river})
|
||||||
var river = page.data.river[data.hash]
|
|
||||||
if (river.tool) {
|
|
||||||
river.hidetool = !river.hidetool
|
|
||||||
page.setData({river: page.data.river})
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wx.showLoading()
|
wx.showLoading()
|
||||||
app.request("river", {cmds: [data.hash, "tool"]}, function(msg) {
|
app.request("river", {cmds: [river.hash, "tool"]}, function(msg) { wx.hideLoading()
|
||||||
wx.hideLoading()
|
river.list = msg.Table(), page.setData({river: page.data.river})
|
||||||
river.tool = {}; msg.Table(function(value) {
|
|
||||||
river.tool[value.hash] = value
|
|
||||||
value.river = data
|
|
||||||
})
|
|
||||||
page.setData({river: page.data.river})
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onchange: function(event, data) { var page = this
|
onchange: function(event, data) { data = data || event.target.dataset
|
||||||
data = data || event.target.dataset.item
|
var river = this.data.river[data.index]; var storm = river.list[data.i]
|
||||||
app.jumps("action/action", {river: data.river.hash, storm: data.hash, title: data.river.name+"."+data.name})
|
app.jumps("action/action", {river: river.hash, storm: storm.hash, title: river.name+"."+storm.name})
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad: function (options) { var page = this
|
onLoad: function (options) { this.onaction({}, {name: "刷新"}) },
|
||||||
console.log("page", "river", options)
|
|
||||||
app.conf.sessid = options.sessid || app.conf.sessid
|
|
||||||
app.usercode(function() {
|
|
||||||
page.onaction({}, options, "刷新")
|
|
||||||
})
|
|
||||||
},
|
|
||||||
onReady: function () {},
|
onReady: function () {},
|
||||||
onShow: function () {},
|
onShow: function () {},
|
||||||
onHide: function () {},
|
onHide: function () {},
|
||||||
onUnload: function () {},
|
onUnload: function () {},
|
||||||
onPullDownRefresh: function () {
|
|
||||||
this.onaction({}, {}, "刷新")
|
|
||||||
},
|
|
||||||
onReachBottom: function () {},
|
onReachBottom: function () {},
|
||||||
|
onPullDownRefresh: function () { this.onaction({}, {name: "刷新"}) },
|
||||||
onShareAppMessage: function () {}
|
onShareAppMessage: function () {}
|
||||||
})
|
})
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
<import src="../../app.wxml"/>
|
<import src="../../app.wxml"/>
|
||||||
|
|
||||||
<template is="action" data="{{action}}"></template>
|
<template is="action" data="{{action}}"></template>
|
||||||
|
|
||||||
<view class="output">
|
<view class="output">
|
||||||
<view class="item" wx:for="{{river}}" wx:key="name">
|
<view class="item" wx:for="{{river}}" wx:key="index">
|
||||||
<view class="item" bindtap="ondetail" data-item="{{item}}">{{item.name}}</view>
|
<view class="item" bindtap="ondetail" data-index="{{index}}">{{item.name}}</view>
|
||||||
<view class="list" wx:if="{{!item.hidetool}}">
|
<view class="list" wx:if="{{item._show}}">
|
||||||
<view class="item" bindtap="onchange" wx:for="{{item.tool}}" wx:key="name" data-item="{{item}}">{{item.name}}</view>
|
<view class="item" bindtap="onchange" wx:for="{{item.list}}" wx:for-index="i" wx:key="i"
|
||||||
|
data-index="{{index}}" data-i="{{i}}">{{item.name}}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
@ -1,89 +1,108 @@
|
|||||||
{
|
{
|
||||||
"description": "项目配置文件",
|
"description": "项目配置文件",
|
||||||
"packOptions": {
|
"packOptions": {
|
||||||
"ignore": []
|
"ignore": []
|
||||||
},
|
},
|
||||||
"setting": {
|
"setting": {
|
||||||
"urlCheck": true,
|
"urlCheck": true,
|
||||||
"es6": true,
|
"es6": true,
|
||||||
"postcss": true,
|
"enhance": false,
|
||||||
"minified": true,
|
"postcss": true,
|
||||||
"newFeature": true,
|
"preloadBackgroundData": false,
|
||||||
"autoAudits": false,
|
"minified": true,
|
||||||
"coverView": true,
|
"newFeature": true,
|
||||||
"showShadowRootInWxmlPanel": true,
|
"coverView": true,
|
||||||
"scopeDataCheck": false
|
"nodeModules": false,
|
||||||
},
|
"autoAudits": false,
|
||||||
"compileType": "miniprogram",
|
"showShadowRootInWxmlPanel": true,
|
||||||
"libVersion": "2.0.4",
|
"scopeDataCheck": false,
|
||||||
"appid": "wxf4e5104d83476ed6",
|
"uglifyFileName": false,
|
||||||
"projectname": "%E7%BB%88%E7%AB%AF%E5%B7%A5%E5%85%B7%E9%93%BE",
|
"checkInvalidKey": true,
|
||||||
"debugOptions": {
|
"checkSiteMap": true,
|
||||||
"hidedInDevtools": []
|
"uploadWithSourceMap": true,
|
||||||
},
|
"compileHotReLoad": false,
|
||||||
"isGameTourist": false,
|
"useMultiFrameRuntime": false,
|
||||||
"simulatorType": "wechat",
|
"useApiHook": true,
|
||||||
"simulatorPluginLibVersion": {},
|
"babelSetting": {
|
||||||
"condition": {
|
"ignore": [],
|
||||||
"search": {
|
"disablePlugins": [],
|
||||||
"current": -1,
|
"outputPath": ""
|
||||||
"list": []
|
},
|
||||||
},
|
"enableEngineNative": false,
|
||||||
"conversation": {
|
"bundle": false,
|
||||||
"current": -1,
|
"useIsolateContext": true,
|
||||||
"list": []
|
"useCompilerModule": true,
|
||||||
},
|
"userConfirmedUseCompilerModuleSwitch": false,
|
||||||
"plugin": {
|
"userConfirmedBundleSwitch": false,
|
||||||
"current": -1,
|
"packNpmManually": false,
|
||||||
"list": []
|
"packNpmRelationList": [],
|
||||||
},
|
"minifyWXSS": true
|
||||||
"game": {
|
},
|
||||||
"currentL": -1,
|
"compileType": "miniprogram",
|
||||||
"list": []
|
"libVersion": "2.0.4",
|
||||||
},
|
"appid": "wxf4e5104d83476ed6",
|
||||||
"gamePlugin": {
|
"projectname": "%E7%BB%88%E7%AB%AF%E5%B7%A5%E5%85%B7%E9%93%BE",
|
||||||
"current": -1,
|
"debugOptions": {
|
||||||
"list": []
|
"hidedInDevtools": []
|
||||||
},
|
},
|
||||||
"miniprogram": {
|
"isGameTourist": false,
|
||||||
"current": -1,
|
"simulatorType": "wechat",
|
||||||
"list": [
|
"simulatorPluginLibVersion": {},
|
||||||
{
|
"condition": {
|
||||||
"id": 0,
|
"search": {
|
||||||
"name": "pages/action/action",
|
"list": []
|
||||||
"pathName": "pages/action/action",
|
},
|
||||||
"query": "river=c796cd&storm=9092d5",
|
"conversation": {
|
||||||
"scene": 1008
|
"list": []
|
||||||
},
|
},
|
||||||
{
|
"plugin": {
|
||||||
"id": 1,
|
"list": []
|
||||||
"name": "action",
|
},
|
||||||
"pathName": "pages/action/action",
|
"game": {
|
||||||
"query": "river=d022b3&storm= c22d21",
|
"currentL": -1,
|
||||||
"scene": null
|
"list": []
|
||||||
},
|
},
|
||||||
{
|
"gamePlugin": {
|
||||||
"id": 2,
|
"list": []
|
||||||
"name": "pages/river/river",
|
},
|
||||||
"pathName": "pages/river/river",
|
"miniprogram": {
|
||||||
"query": "river=c796cd&storm=9092d5",
|
"list": [
|
||||||
"scene": null
|
{
|
||||||
},
|
"id": 0,
|
||||||
{
|
"name": "pages/action/action",
|
||||||
"id": -1,
|
"pathName": "pages/action/action",
|
||||||
"name": "pages/scans/scans",
|
"query": "river=c796cd&storm=9092d5",
|
||||||
"pathName": "pages/scans/scans",
|
"scene": 1008
|
||||||
"query": "river=c796cd&storm=9092d5",
|
},
|
||||||
"scene": null
|
{
|
||||||
},
|
"id": 1,
|
||||||
{
|
"name": "action",
|
||||||
"id": 4,
|
"pathName": "pages/action/action",
|
||||||
"name": "pages/action/action",
|
"query": "river=d022b3&storm= c22d21",
|
||||||
"pathName": "pages/action/action",
|
"scene": null
|
||||||
"query": "river=d82c1d&storm=12d1d7&title=mac.paste",
|
},
|
||||||
"scene": null
|
{
|
||||||
}
|
"id": 2,
|
||||||
]
|
"name": "pages/river/river",
|
||||||
}
|
"pathName": "pages/river/river",
|
||||||
}
|
"query": "river=c796cd&storm=9092d5",
|
||||||
|
"scene": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": -1,
|
||||||
|
"name": "pages/scans/scans",
|
||||||
|
"pathName": "pages/scans/scans",
|
||||||
|
"query": "river=c796cd&storm=9092d5",
|
||||||
|
"scene": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"name": "pages/action/action",
|
||||||
|
"pathName": "pages/action/action",
|
||||||
|
"query": "river=d82c1d&storm=12d1d7&title=mac.paste",
|
||||||
|
"scene": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -31,12 +31,102 @@ module.exports = {
|
|||||||
cb(k, list[k])
|
cb(k, list[k])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Value: function(item, key) {
|
Value: function(data, key, value) {
|
||||||
var p = item, ls = key.split(".")
|
if (data == undefined) { return }
|
||||||
while (p && ls.length > 0) {
|
if (key == undefined) { return data }
|
||||||
|
if (typeof key == "object") { for (var k in key) {
|
||||||
|
arguments.callee.call(this, data, k, key[k])
|
||||||
|
}; return data }
|
||||||
|
|
||||||
|
if (value != undefined) { data[key] = value }
|
||||||
|
if (data[key] != undefined) { return data[key] }
|
||||||
|
|
||||||
|
var p = data, ls = key.split("."); while (p && ls.length > 0) {
|
||||||
|
if (ls[0] == "-1") { ls[0] = p.length-1 }
|
||||||
p = p[ls[0]], ls = ls.slice(1)
|
p = p[ls[0]], ls = ls.slice(1)
|
||||||
|
}; return p
|
||||||
|
},
|
||||||
|
|
||||||
|
Split: function(str) { if (!str || !str.length) { return [] }
|
||||||
|
var opt = {detail: false}, arg = []; for (var i = 1; i < arguments.length; i++) {
|
||||||
|
typeof arguments[i] == "object"? opt = arguments[i]: arg.push(arguments[i])
|
||||||
}
|
}
|
||||||
return p
|
|
||||||
|
function _list(str) { var res = {}; for (var i = 0; i < str.length; i++) { res[str[i]] = true }; return res }
|
||||||
|
// 空白符
|
||||||
|
var seps = _list(arg[0]||"\t ,\n")
|
||||||
|
// 分隔符
|
||||||
|
var sups = _list(arg[1]||"{[(.:)]}")
|
||||||
|
// 引用符
|
||||||
|
var subs = _list(arg[2]||"'\"`")
|
||||||
|
|
||||||
|
// 开始分词
|
||||||
|
var res = [], list = str
|
||||||
|
var left = "", space = true, begin = 0
|
||||||
|
for (var i = 0; i < list.length; i++) {
|
||||||
|
if (seps[list[i]]) {
|
||||||
|
// 空白符
|
||||||
|
if (left == "") {
|
||||||
|
if (!space) {
|
||||||
|
res.push(list.slice(begin, i))
|
||||||
|
}
|
||||||
|
opt.detail && res.push({text: list.slice(i, i+1), type: "space", left: left})
|
||||||
|
space = true, begin = i+1
|
||||||
|
}
|
||||||
|
} else if (subs[list[i]]) {
|
||||||
|
// 引用符
|
||||||
|
if (left == "") {
|
||||||
|
left = list[i], space = false, begin = i+1
|
||||||
|
} else if (left == list[i]) {
|
||||||
|
res.push({text: list.slice(begin, i), type: "string", left: left, right: left})
|
||||||
|
left = "", space = true, begin = i+1
|
||||||
|
}
|
||||||
|
} else if (sups[list[i]]) {
|
||||||
|
// 分隔符
|
||||||
|
if (left == "") {
|
||||||
|
if (!space) {
|
||||||
|
res.push(list.slice(begin, i))
|
||||||
|
}
|
||||||
|
res.push(list.slice(i, i+1))
|
||||||
|
space = true, begin = i+1
|
||||||
|
}
|
||||||
|
} else if (list[0] == '\\') {
|
||||||
|
// 转义符
|
||||||
|
for (var i = i; i < list.length-1; i++) {
|
||||||
|
list[i] = list[i+1]
|
||||||
|
}
|
||||||
|
list = list.slice(0, list.length-1)
|
||||||
|
space = false
|
||||||
|
} else {
|
||||||
|
space = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 末尾字符
|
||||||
|
if (left != "") {
|
||||||
|
res.push({text: list.slice(begin), type: "string", left: left, right: ""})
|
||||||
|
} else if (begin < list.length) {
|
||||||
|
res.push(list.slice(begin))
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
},
|
||||||
|
parseJSON: function(str) { var res
|
||||||
|
if (typeof str == "object") { return str }
|
||||||
|
if (str.indexOf("http") == 0) { var ls = str.split("?")
|
||||||
|
res = {type: "link", name: "", text: str}
|
||||||
|
res.name = ls[0].split("://").pop().split("/")[0]
|
||||||
|
ls[1] && ls[1].split("&").forEach(function(item) { var ls = item.split("=")
|
||||||
|
res[decodeURIComponent(ls[0])] = decodeURIComponent(ls[1])
|
||||||
|
})
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
try { res = JSON.parse(str)
|
||||||
|
res.text = res.text||str
|
||||||
|
res.type = res.type||"json"
|
||||||
|
} catch (e) {
|
||||||
|
res = {type: "text", text: str}
|
||||||
|
}
|
||||||
|
return res
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
function Number(d, n) {var res = [];
|
|
||||||
while (d > 0) {res.push(d % 10); d = parseInt(d / 10); n--}
|
|
||||||
while (n > 0) {res.push("0"); n--}
|
|
||||||
return res.reverse(), res.join("");
|
|
||||||
}
|
|
||||||
function Time(t, fmt) {var now = t? new Date(t): new Date();
|
|
||||||
fmt = fmt || "%y-%m-%d %H:%M:%S";
|
|
||||||
fmt = fmt.replace("%y", now.getFullYear())
|
|
||||||
fmt = fmt.replace("%m", Number(now.getMonth()+1, 2))
|
|
||||||
fmt = fmt.replace("%d", Number(now.getDate(), 2))
|
|
||||||
fmt = fmt.replace("%H", Number(now.getHours(), 2))
|
|
||||||
fmt = fmt.replace("%M", Number(now.getMinutes(), 2))
|
|
||||||
fmt = fmt.replace("%S", Number(now.getSeconds(), 2))
|
|
||||||
return fmt
|
|
||||||
}
|
|
||||||
function Args(url, args) {var list = []
|
|
||||||
for (var k in args) {
|
|
||||||
list.push(encodeURIComponent(k)+"="+encodeURIComponent(args[k]))
|
|
||||||
}
|
|
||||||
return url+"?"+list.join("&")
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
formatTime: formatTime,
|
|
||||||
Time: Time,
|
|
||||||
Args: Args,
|
|
||||||
List: function(list, cb) {
|
|
||||||
var res = [], val;
|
|
||||||
for (var i = 0; i < list.length; i++) {
|
|
||||||
typeof cb == "function"? (val = cb(list[i], i, list)) != undefined && res.push(val): res.push(list[i])
|
|
||||||
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
},
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user