mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 16:58:06 +08:00
add figure
This commit is contained in:
parent
41b45db4d4
commit
54b4f39a4d
@ -9,6 +9,7 @@ App({
|
|||||||
app.usercode(function() {app.request(cmd, data, cb)})
|
app.usercode(function() {app.request(cmd, data, cb)})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.__proto__ = {
|
msg.__proto__ = {
|
||||||
nRow: function() {return msg.append && msg.append[0] && msg[msg.append[0]].length || 0},
|
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("") || ""},
|
||||||
@ -36,6 +37,7 @@ App({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg._index = index
|
msg._index = index
|
||||||
|
|
||||||
typeof cb == "function" && cb(msg)
|
typeof cb == "function" && cb(msg)
|
||||||
}})
|
}})
|
||||||
},
|
},
|
||||||
@ -59,8 +61,8 @@ App({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
modal: function(title, cb) {wx.showModal({title: title, success: cb})},
|
modal: function(title, content, cb) {wx.showModal({title: title||"", content: content||"", success: cb})},
|
||||||
toast: function(title) {wx.showToast({title: title})},
|
toast: function(title, content) {wx.showToast({title: title, content: content||""})},
|
||||||
jumps: function(url, args, cb) {var next = "/pages/"+kit.Args(url, args)
|
jumps: function(url, args, cb) {var next = "/pages/"+kit.Args(url, args)
|
||||||
console.log("jump", next), wx.navigateTo({url: next, success: cb})
|
console.log("jump", next), wx.navigateTo({url: next, success: cb})
|
||||||
},
|
},
|
||||||
@ -71,7 +73,7 @@ App({
|
|||||||
switch (value.type) {
|
switch (value.type) {
|
||||||
case "active":
|
case "active":
|
||||||
app.userinfo(function(userInfo) {
|
app.userinfo(function(userInfo) {
|
||||||
app.modal("授权登录", function(res) {
|
app.modal("授权登录", value.name, function(res) {
|
||||||
res.confirm && app.request("mp/login/auth", {auth: value.name}, function(msg) {
|
res.confirm && app.request("mp/login/auth", {auth: value.name}, function(msg) {
|
||||||
app.toast("授权成功")
|
app.toast("授权成功")
|
||||||
})
|
})
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
const utils = require("../../utils/util.js")
|
|
||||||
const kit = require("../../utils/kit.js")
|
const kit = require("../../utils/kit.js")
|
||||||
const app = getApp()
|
const app = getApp()
|
||||||
|
|
||||||
@ -58,16 +57,109 @@ Page({
|
|||||||
this.action[name](event, this, data)
|
this.action[name](event, this, data)
|
||||||
},
|
},
|
||||||
onfigure: {
|
onfigure: {
|
||||||
key: {click: function(event, page, data, cmd, field) {
|
|
||||||
page.run(event, data.order, ["action", "input", data.item.name, data.item.value])
|
|
||||||
}},
|
|
||||||
location: {click: function(event, page, data, cmd, field) {
|
location: {click: function(event, page, data, cmd, field) {
|
||||||
wx.chooseLocation({success: function(res) {
|
wx.chooseLocation({success: function(res) {
|
||||||
field.inputs[data.index].value = res.name
|
if (data.input._input != "button") {
|
||||||
page.setData({res: page.data.res})
|
field.inputs[data.index].value = res.name
|
||||||
page.run(event, data.order, ["action", "location", res.name, res.address, res.latitude*100000, res.longitude*100000])
|
page.setData({res: page.data.res})
|
||||||
|
}
|
||||||
|
page.run(event, data.order, ["action", "device", "location", res.name, res.address, "latitude", res.latitude*100000, "longitude", res.longitude*100000])
|
||||||
}})
|
}})
|
||||||
}}
|
}},
|
||||||
|
battery: {click: function(event, page, data, cmd, field) {
|
||||||
|
wx.getBatteryInfo({success: function(res) {
|
||||||
|
if (data.input._input != "button") {
|
||||||
|
field.inputs[data.index].value = res.level
|
||||||
|
page.setData({res: page.data.res})
|
||||||
|
}
|
||||||
|
page.run(event, data.order, ["action", "device", "battery", res.level, res.isCharging])
|
||||||
|
}})
|
||||||
|
}},
|
||||||
|
paste: {click: function(event, page, data, cmd, field) {
|
||||||
|
wx.getClipboardData({success: function(res) {
|
||||||
|
if (data.input._input != "button") {
|
||||||
|
field.inputs[data.index].value = res.data
|
||||||
|
page.setData({res: page.data.res})
|
||||||
|
}
|
||||||
|
page.run(event, data.order, ["action", "device", "paste", res.data, res.data])
|
||||||
|
}})
|
||||||
|
}},
|
||||||
|
scan: {click: function(event, page, data, cmd, field) {
|
||||||
|
app.scans(function(res) {
|
||||||
|
if (data.input._input != "button") {
|
||||||
|
field.inputs[data.index].value = res.text || res.name
|
||||||
|
page.setData({res: page.data.res})
|
||||||
|
}
|
||||||
|
page.run(event, data.order, ["action", "device", res.type||"spide", res.name||"", res.text||"", JSON.stringify(res.extra||"")])
|
||||||
|
})
|
||||||
|
}},
|
||||||
|
album: {click: function(event, page, data, cmd, field) {
|
||||||
|
wx.chooseImage({success: function(res) {
|
||||||
|
console.log(res)
|
||||||
|
const tempFilePaths = res.tempFilePaths
|
||||||
|
wx.uploadFile({
|
||||||
|
url: app.conf.serve+"/mp/login/upload",
|
||||||
|
filePath: tempFilePaths[0],
|
||||||
|
name: 'upload', formData: {'user': 'test'},
|
||||||
|
success: function(msg) {
|
||||||
|
console.log(msg)
|
||||||
|
if (data.input._input != "button") {
|
||||||
|
field.inputs[data.index].value = msg.data
|
||||||
|
page.setData({res: page.data.res})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: function(res) {
|
||||||
|
console.log(res)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}})
|
||||||
|
}},
|
||||||
|
finger: {click: function(event, page, data, cmd, field) {
|
||||||
|
wx.startSoterAuthentication({
|
||||||
|
requestAuthModes: ['fingerPrint'], authContent: '请用指纹解锁',
|
||||||
|
challenge: '123456', success(res) {
|
||||||
|
console.log(res)
|
||||||
|
res = JSON.parse(res.resultJSON)
|
||||||
|
if (data.input._input != "button") {
|
||||||
|
field.inputs[data.index].value = res.cpu_id
|
||||||
|
page.setData({res: page.data.res})
|
||||||
|
}
|
||||||
|
page.run(event, data.order, ["action", "device", "finger", res.uid, res.cpu_id, "counter", res.counter, "raw", res.raw])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}},
|
||||||
|
wifi: {click: function(event, page, data, cmd, field) {
|
||||||
|
wx.getConnectedWifi({success: function(res) {
|
||||||
|
console.log(res)
|
||||||
|
if (data.input._input != "button") {
|
||||||
|
field.inputs[data.index].value = res.wifi.SSID
|
||||||
|
page.setData({res: page.data.res})
|
||||||
|
}
|
||||||
|
page.run(event, data.order, ["action", "device", "wifi", res.wifi.SSID, res.wifi.signalStrength])
|
||||||
|
}})
|
||||||
|
}},
|
||||||
|
wifiConn: {click: function(event, page, data, cmd, field) {
|
||||||
|
wx.connectWifi({
|
||||||
|
SSID: data.SSID, password: data.password,
|
||||||
|
success: function(res) {
|
||||||
|
console.log(res)
|
||||||
|
},
|
||||||
|
fail: function(res) {
|
||||||
|
console.log(res)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}},
|
||||||
|
vibrate: {click: function(event, page, data, cmd, field) {
|
||||||
|
wx.vibrateShort()
|
||||||
|
}},
|
||||||
|
key: {click: function(event, page, data, cmd, field) {
|
||||||
|
page.run(event, data.order, ["action", "input", data.input.name, data.input.value])
|
||||||
|
}},
|
||||||
|
share: {click: function(event, page, data, cmd, field) {
|
||||||
|
wx.showShareMenu({
|
||||||
|
withShareTicket: true
|
||||||
|
})
|
||||||
|
}},
|
||||||
},
|
},
|
||||||
|
|
||||||
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]
|
||||||
@ -107,11 +199,10 @@ Page({
|
|||||||
|
|
||||||
onClick: function(event) {var page = this, data = event.target.dataset
|
onClick: function(event) {var page = this, data = event.target.dataset
|
||||||
var field = page.data.res[data.order]
|
var field = page.data.res[data.order]
|
||||||
if (data && data.item && data.item._input == "text") {
|
|
||||||
// 输入补全
|
// 输入补全
|
||||||
var figure = page.onfigure[data.item.cb||data.item.figure||data.item.name]
|
var figure = data && data.input && page.onfigure[data.input.cb||data.input.figure||data.input.name]
|
||||||
figure && figure.click(event, page, data, "what", field)
|
if (figure) {
|
||||||
return
|
return figure.click(event, page, data, data.input.name, field)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (data.input.cb) {
|
switch (data.input.cb) {
|
||||||
@ -162,5 +253,14 @@ Page({
|
|||||||
this.onaction({}, {}, "刷新")
|
this.onaction({}, {}, "刷新")
|
||||||
},
|
},
|
||||||
onReachBottom: function () {},
|
onReachBottom: function () {},
|
||||||
onShareAppMessage: function () {}
|
onShareAppMessage: function (res) {
|
||||||
|
console.log(res)
|
||||||
|
return {
|
||||||
|
title: "some",
|
||||||
|
path: "pages/action/action?river="+this.data.river+"&storm="+this.data.storm,
|
||||||
|
success: function(res) {
|
||||||
|
console.log(res)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<view class="item {{item._input}}" wx:for="{{field.inputs}}" wx:key="name">
|
<view class="item {{item._input}}" wx:for="{{field.inputs}}" wx:key="name">
|
||||||
<!-- 文本 -->
|
<!-- 文本 -->
|
||||||
<input wx:if="{{item._input == 'text'}}" type="text" value="{{item.value}}" placeholder="{{item.name}}"
|
<input wx:if="{{item._input == 'text'}}" type="text" value="{{item.value}}" placeholder="{{item.name}}"
|
||||||
bindtap="onClick" bindinput="onInput" bindconfirm="onEnter" data-order="{{order}}" data-index="{{index}}" data-item="{{item}}"/>
|
bindtap="onClick" bindinput="onInput" bindconfirm="onEnter" data-order="{{order}}" data-index="{{index}}" data-input="{{item}}"/>
|
||||||
|
|
||||||
<!-- 文本 -->
|
<!-- 文本 -->
|
||||||
<textarea wx:elif="{{item._input == 'textarea'}}" value="{{item.value}}" placeholder="{{item.name}}"
|
<textarea wx:elif="{{item._input == 'textarea'}}" value="{{item.value}}" placeholder="{{item.name}}"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const utils = require("../../utils/util.js")
|
const kit = require("../../utils/kit.js")
|
||||||
const app = getApp()
|
const app = getApp()
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
|
@ -10,7 +10,7 @@ Page({
|
|||||||
action: {
|
action: {
|
||||||
"扫码": function(event, page, data, name) {
|
"扫码": function(event, page, data, name) {
|
||||||
app.scans(function(res) {
|
app.scans(function(res) {
|
||||||
app.toast()
|
app.modal(res.name, res.text)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"刷新": function(event, page, data, name) {
|
"刷新": function(event, page, data, name) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user