mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 08:48:06 +08:00
add mp
This commit is contained in:
parent
044f44955b
commit
7e5ff58415
1
publish/client/mp/.cloudbase/container/debug.json
Normal file
1
publish/client/mp/.cloudbase/container/debug.json
Normal file
@ -0,0 +1 @@
|
||||
{"containers":[],"config":{}}
|
@ -5,7 +5,7 @@ const page = require("utils/lib/page.js")
|
||||
const user = require("utils/lib/user.js")
|
||||
|
||||
App({
|
||||
data: {}, conf: {serve: "https://2021.shylinux.com/chat"},
|
||||
data: {}, conf: {serve: "https://2021.shylinux.com"},
|
||||
base: base, core: core, misc: misc, page: page, user: user,
|
||||
onLaunch: function() { console.log("app load", this.conf) },
|
||||
})
|
||||
|
@ -1,5 +1,5 @@
|
||||
const {shy, Volcanos} = require("../../utils/proto.js")
|
||||
const {html} = require("../../utils/const.js")
|
||||
const {ice, ctx, mdb, html} = require("../../utils/const.js")
|
||||
Volcanos._page = {}
|
||||
Volcanos("onimport", {
|
||||
_init: function(can, msg) { can.db.list = []
|
||||
@ -20,6 +20,9 @@ Volcanos("onimport", {
|
||||
if (input.type == "select") {
|
||||
input.values = input.values || can.core.Split(input.value)
|
||||
}
|
||||
if (input.type == "button") {
|
||||
input.value = {"list": "查看", "back": "返回", "create": "创建"}[input.value||input.name]||input.value||input.name
|
||||
}
|
||||
input.type == "button" && input.action == "auto" && can.core.Timer(100, function() {
|
||||
can.run({}, [can.db.river, can.db.storm, value.id||value.index], function(msg) {
|
||||
value.msg = msg, can.page.setData(can, can.db.list)
|
||||
@ -41,23 +44,24 @@ Volcanos("onaction", {list: ["刷新", "扫码", "清屏"],
|
||||
can.onimport._init(can, msg)
|
||||
})
|
||||
},
|
||||
onaction: function(event, can, msg) { var name = msg.Option("name")
|
||||
onaction: function(event, can, button, data) { var name = data.name
|
||||
(can.onaction[name]||function(event) { can.run(event, [ctx.ACTION, name]) })(event, can)
|
||||
},
|
||||
onInputs: function(event, can, msg) { var order = msg.Option("order")||0, index = msg.Option("index")||0
|
||||
onInputs: function(event, can, button, data) { var order = data.order, index = data.index
|
||||
var input = can.ui.data.list[order||0].inputs[index||0]
|
||||
input.value = event.detail.value
|
||||
},
|
||||
onChange: function(event, can, msg) { var order = msg.Option("order")||0, index = msg.Option("index")||0
|
||||
onChange: function(event, can, button, data) { var order = data.order, index = data.index
|
||||
var input = can.ui.data.list[order||0].inputs[index||0]
|
||||
input.value = input.values[parseInt(event.detail.value)]
|
||||
},
|
||||
onAction: function(event, can, msg) { var order = msg.Option("order")||0, name = msg.Option("name")
|
||||
onAction: function(event, can, button, data) { var order = data.order, name = data.name
|
||||
var field = can.ui.data.list[order||0]
|
||||
if (field.feature[name]) {
|
||||
can.data.insert = {field: field, name: name, list: field.feature[name], cb: function(res) {
|
||||
debugger
|
||||
can.run(event, can.base.Simple([can.db.river, can.db.storm, field.id||field.index, ctx.ACTION, name], res), function(msg) {
|
||||
can.onaction.onAction(event, can, order)
|
||||
can.onaction.onAction(event, can, ice.LIST, {order: order, name: ice.LIST})
|
||||
})
|
||||
}}
|
||||
can.user.jumps("/pages/insert/insert", {river: can.db.river, storm: can.db.storm, index: field.id||field.index, title: field.name})
|
||||
@ -65,20 +69,16 @@ Volcanos("onaction", {list: ["刷新", "扫码", "清屏"],
|
||||
}
|
||||
field._history = field._history||[]
|
||||
switch (name) {
|
||||
case "back":
|
||||
var ls = field._history.pop()
|
||||
var ls = field._history.pop()||[]
|
||||
var i = 0
|
||||
case ice.BACK: field._history.pop()
|
||||
var ls = field._history.pop()||[], i = 0
|
||||
can.core.List(field.inputs, function(input, index) {
|
||||
if (input.type != html.BUTTON) {
|
||||
input.value = ls[i++]||""
|
||||
}
|
||||
if (input.type != html.BUTTON) { input.value = ls[i++]||"" }
|
||||
})
|
||||
can.page.setData(can)
|
||||
can.onaction.onAction(event, can, order, "list")
|
||||
can.onaction.onAction(event, can, order, ice.LIST)
|
||||
break
|
||||
case "run":
|
||||
case "list":
|
||||
case ice.LIST:
|
||||
case "refresh":
|
||||
break
|
||||
default:
|
||||
@ -96,12 +96,12 @@ Volcanos("onaction", {list: ["刷新", "扫码", "清屏"],
|
||||
for (var i = cmds.length-1; i > 0; i--) { if (cmds[i] === "") { cmds.pop() } else { break } }
|
||||
can.run(event, cmds, function(msg) { field.msg = msg, can.page.setData(can) })
|
||||
},
|
||||
onDetail: function(event, can, msg) { var order = msg.Option("order")||0, name = msg.Option("name"), value = msg.Option("value")
|
||||
onDetail: function(event, can, button, data) { var order = data.order, name = data.name, value = data.value
|
||||
var field = can.ui.data.list[order||0]
|
||||
can.core.List(field.inputs, function(input) {
|
||||
if (input.name == name) {
|
||||
input.value = value, can.page.setData(can)
|
||||
can.onaction.onAction(event, can, order, "list")
|
||||
can.onaction.onAction(event, can, order, ice.LIST)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
@ -1,56 +1,37 @@
|
||||
const app = getApp()
|
||||
var kit = {}
|
||||
const {shy, Volcanos} = require("../../utils/proto.js")
|
||||
const {mdb, html} = require("../../utils/const.js")
|
||||
Volcanos._page = {}
|
||||
Volcanos("onimport", {
|
||||
_init: function(can, msg) {},
|
||||
})
|
||||
|
||||
Page({
|
||||
name: "insert",
|
||||
data: {
|
||||
action: ["扫码"],
|
||||
list: [],
|
||||
},
|
||||
action: {
|
||||
"扫码": function(event, page) { app.scans(function(res) {
|
||||
switch (res.type) {
|
||||
case "button": res.name && page.onaction(event, res); break
|
||||
default: return false
|
||||
} return true
|
||||
}) },
|
||||
},
|
||||
onaction: function(event, data) { data = data || event.target.dataset
|
||||
console.log("action", this.name, data.name)
|
||||
this.action[data.name](event, this)
|
||||
},
|
||||
|
||||
onInput: function(event) { var page = this, data = event.target.dataset
|
||||
page.data.list[data.index].value = event.detail.value
|
||||
},
|
||||
onChange: function(event) { var page = this, data = event.target.dataset
|
||||
var input = page.data.list[data.index]
|
||||
input.value = input.values[parseInt(event.detail.value)]
|
||||
},
|
||||
onConfirm: function (event) { var page = this
|
||||
var res = {}; kit.List(page.data.list, function(item) { res[item.name] = item.value })
|
||||
app.data.insert.cb(res), wx.navigateBack()
|
||||
},
|
||||
|
||||
onLoad: function (options) {
|
||||
console.log("page", this.name, options)
|
||||
app.title(options.title)
|
||||
|
||||
kit.List(app.data.insert.list, function(input) {
|
||||
Volcanos("onaction", {list: ["刷新", "扫码"],
|
||||
"刷新": function(event, can) { can.onaction.refresh(event, can) },
|
||||
"扫码": function(event, can) { can.user.agent.scanQRCode(can) },
|
||||
refresh: function(event, can) {
|
||||
can.core.List(can.data.insert.list, function(input) {
|
||||
input.action = input.action || input.value
|
||||
input.value == "auto" && (input.value = "")
|
||||
|
||||
if (input.value && input.value.indexOf("@") == 0) {
|
||||
input.action = input.value.slice(1), input.value = ""
|
||||
}
|
||||
})
|
||||
|
||||
this.setData({list: this.data.list = app.data.insert.list})
|
||||
can.page.setData(can, can.data.insert.list)
|
||||
},
|
||||
onaction: function(event, can, button, data) { var name = data.name
|
||||
(can.onaction[name]||function(event) { can.run(event, [ctx.ACTION, name]) })(event, can)
|
||||
},
|
||||
onInputs: function(event, can, button, data) { var index = data.index
|
||||
var input = can.data.insert.list[index]
|
||||
input.value = event.detail.value
|
||||
},
|
||||
onChange: function(event, can, button, data) { var index = data.index
|
||||
var input = can.data.insert.list[index]
|
||||
input.value = input.values[parseInt(event.detail.value)]
|
||||
},
|
||||
onConfirm: function (event, can, button, data) {
|
||||
var res = {}; can.core.List(can.data.insert.list, function(item) { res[item.name] = item.value||"" })
|
||||
can.data.insert.cb(res), wx.navigateBack()
|
||||
},
|
||||
onReady: function () {},
|
||||
onShow: function () {},
|
||||
onHide: function () {},
|
||||
onUnload: function () {},
|
||||
onReachBottom: function () {},
|
||||
onPullDownRefresh: function () {},
|
||||
})
|
||||
Volcanos._init()
|
||||
|
@ -1,27 +1,21 @@
|
||||
<import src="../../app.wxml"/>
|
||||
<template is="action" data="{{action}}"></template>
|
||||
|
||||
<view class="output">
|
||||
<view class="item" wx:for="{{list}}" wx:key="index">
|
||||
<!-- 文本 -->
|
||||
<textarea wx:if="{{item.type == 'textarea'}}" placeholder="{{item.name}}" value="{{item.value}}"
|
||||
bindinput="onInput" data-index="{{index}}"></textarea>
|
||||
|
||||
<textarea wx:if="{{item.type == 'textarea'}}" placeholder="{{item.name}}" value="{{item.value}}" bindinput="onInputs" data-index="{{index}}"></textarea>
|
||||
<!-- 文本 -->
|
||||
<input wx:elif="{{item.type == 'text'}}" placeholder="{{item.name}}" value="{{item.value}}" type="text"
|
||||
bindinput="onInput" data-index="{{index}}"/>
|
||||
|
||||
<input wx:elif="{{item.type == 'text'}}" placeholder="{{item.name}}" value="{{item.value}}" type="text" bindinput="onInputs" data-index="{{index}}"/>
|
||||
<!-- 列表 -->
|
||||
<picker wx:elif="{{item.type == 'select'}}" range="{{item.values}}" value="{{item.index||0}}"
|
||||
bindchange="onChange" data-index="{{index}}">
|
||||
<picker wx:elif="{{item.type == 'select'}}" range="{{item.values}}" value="{{item.index||0}}" bindchange="onChange" data-index="{{index}}">
|
||||
<view>{{item.values[item.index||0]}}</view>
|
||||
</picker>
|
||||
|
||||
<!-- 按钮 -->
|
||||
<button wx:elif="{{item.type == 'button'}}" size="mini"
|
||||
bindtap="onClick" data-index="{{index}}">{{item.name||item.value}}</button>
|
||||
<button wx:elif="{{item.type == 'button'}}" size="mini" bindtap="onClick" data-index="{{index}}">{{item.value||item.name}}</button>
|
||||
</view>
|
||||
<button bindtap="onConfirm">提交</button>
|
||||
<button bindtap="onCancel">取消</button>
|
||||
</view>
|
||||
<view class="action">
|
||||
<view class="item"><button bindtap="onCancel">取消</button></view>
|
||||
<view class="item"><button bindtap="onConfirm">提交</button></view>
|
||||
</view>
|
||||
|
||||
|
@ -12,20 +12,20 @@ Volcanos("onaction", {list: ["刷新", "扫码", "登录"],
|
||||
can.user.userinfo(can, function() { can.onaction.refresh(event, can) })
|
||||
},
|
||||
refresh: function(event, can) { can.run(event, [], function(msg) { can.onimport._init(can, msg) }) },
|
||||
onaction: function(event, can, msg) { var name = msg.Option("name")
|
||||
onaction: function(event, can, button, data) { var name = data.name;
|
||||
(can.onaction[name]||function(event) { can.run(event, [ctx.ACTION, name]) })(event, can)
|
||||
},
|
||||
ondetail: function(event, can, msg) { var index = msg.Option("index")||"0"
|
||||
ondetail: function(event, can, button, data) { var index = data.index
|
||||
var item = can.ui.data.list[index]; item._show = !item._show
|
||||
if (item.list) { return can.page.setData(can) }
|
||||
can.run(event, [item.hash, chat.STORM], function(msg) {
|
||||
item.list = msg.Table(), can.page.setData(can)
|
||||
})
|
||||
},
|
||||
onchange: function(event, can, msg) { var index = msg.Option("index")||0, i = msg.Option("i")||0
|
||||
onchange: function(event, can, button, data) { var index = data.index, i = data.i
|
||||
var river = can.ui.data.list[index], storm = river.list[i]
|
||||
can.user.jumps(can.base.MergeURL("/pages/action/action", {river: river.hash, storm: storm.hash, title: river.name+"."+storm.name}))
|
||||
},
|
||||
_name: "river/",
|
||||
_name: "/chat/river/",
|
||||
})
|
||||
Volcanos._init()
|
||||
|
@ -11,6 +11,7 @@ var kit = {proto: function(sub, sup) { return sub.__proto__ = sup, sub },
|
||||
}
|
||||
var ice = {
|
||||
TB: "\t", SP: " ", DF: ":", EQ: "=", AT: "@", QS: "?", PS: "/", PT: ".", FS: ",", NL: "\n", LT: "<", GT: ">",
|
||||
LIST: "list", BACK: "back",
|
||||
|
||||
MSG_FIELDS: "fields", MSG_SESSID: "sessid",
|
||||
MSG_DETAIL: "detail", MSG_OPTION: "option", MSG_APPEND: "append", MSG_RESULT: "result",
|
||||
@ -22,7 +23,9 @@ var ctx = {
|
||||
}
|
||||
var mdb = {
|
||||
EQ: ice.EQ, FS: ice.FS,
|
||||
TYPE: "type", NAME: "name", TEXT: "text", ICON: "icon", ICONS: "icons",
|
||||
KEY: "key", VALUE: "value", STATUS: "status", EXPIRE: "expire", EXTRA: "extra",
|
||||
DATA: "data", VIEW: "view", ORDER: "order",
|
||||
}
|
||||
var nfs = {
|
||||
DF: ice.DF, PS: ice.PS, PT: ice.PT,
|
||||
|
@ -74,8 +74,10 @@ Volcanos("misc", {
|
||||
wx.showLoading(), can.misc.request(can, msg, cmd, data, function(msg) { wx.hideLoading(), cb && cb(msg) })
|
||||
},
|
||||
request: function(can, msg, cmd, data, cb) { data.sessid = can.conf.sessid
|
||||
wx.request({method: http.POST, url: can.conf.serve+nfs.PS+cmd, data: data, success: function(res) {
|
||||
if (res.statusCode == 401) { return can.user.login(can, function() { can.misc.request(can, msg, cmd, data, cb) }) }
|
||||
wx.request({method: http.POST, url: can.conf.serve+cmd, data: data, success: function(res) {
|
||||
if (res.statusCode == 401) {
|
||||
can.user.info = {}, can.misc.localStorage(can, ice.MSG_SESSID, can.conf.sessid = "")
|
||||
return can.user.login(can, function() { can.misc.request(can, msg, cmd, data, cb) }) }
|
||||
msg.Copy(res.data), console.log("request", cmd, data.cmds||data, msg)
|
||||
msg.Data = function(item, index) {
|
||||
var text = msg[item]&&msg[item][index]||""
|
||||
|
@ -24,13 +24,13 @@ Volcanos("user", {
|
||||
case "auth":
|
||||
can.user.userinfo(can, function() {
|
||||
can.user.modal(can, "授权登录", data.name, function(res) {
|
||||
res.confirm && can.misc.request(can, can.request(), "mp/login/action/scan", data, function(msg) {
|
||||
res.confirm && can.misc.request(can, can.request(), "/chat/wx/login/action/scan", data, function(msg) {
|
||||
can.user.toast(can, "授权成功")
|
||||
})
|
||||
})
|
||||
})
|
||||
break
|
||||
default: can.misc.request(can, can.request(), "mp/login/action/scan", data)
|
||||
default: can.misc.request(can, can.request(), "/chat/wx/login/action/scan", data)
|
||||
}
|
||||
}})
|
||||
},
|
||||
@ -50,16 +50,16 @@ Volcanos("user", {
|
||||
login: function(can, cb) {
|
||||
can.conf.sessid = can.conf.sessid||can.misc.localStorage(can, ice.MSG_SESSID)
|
||||
if (can.conf.sessid) { return cb && cb() }
|
||||
wx.login({success: function(res) { can.misc.request(can, can.request(), "mp/login/action/sess", {code: res.code}, function(msg) {
|
||||
wx.login({success: function(res) { can.misc.request(can, can.request(), "/chat/wx/login/action/sess", {code: res.code}, function(msg) {
|
||||
wx.setStorage({key: ice.MSG_SESSID, data: can.conf.sessid = msg.Result()}), cb && cb()
|
||||
}) }})
|
||||
},
|
||||
userinfo: function(can, cb) {
|
||||
can.user.info.userNick? can.misc.request(can, can.request(), "mp/login/action/user", {}, function(msg) {
|
||||
can.user.info.userNick? can.misc.request(can, can.request(), "/chat/wx/login/action/user", {}, function(msg) {
|
||||
cb && cb(can.user.info)
|
||||
}): can.user.login(can, function() { wx.getSetting({success: function(res) {
|
||||
res.authSetting['scope.userInfo'] && wx.getUserInfo({success: function(res) {
|
||||
can.misc.request(can, can.request(), "mp/login/action/user", can.user.info = res.userInfo, function(msg) {
|
||||
can.misc.request(can, can.request(), "/chat/wx/login/action/user", can.user.info = res.userInfo, function(msg) {
|
||||
cb && cb(can.user.info)
|
||||
})
|
||||
}})
|
||||
|
@ -25,7 +25,7 @@ Volcanos._init = function() {
|
||||
}); return msg
|
||||
},
|
||||
run: function(event, cmds, cb) {
|
||||
can.misc.requests(can, can.request(event), can.onaction._name||"action/", {cmds: cmds}, function(msg) {
|
||||
can.misc.requests(can, can.request(event), can.onaction._name||"/chat/action/", {cmds: cmds}, function(msg) {
|
||||
msg.Dump = function() { can.ui.setData({list: msg.Table()}) }, cb(msg)
|
||||
})
|
||||
},
|
||||
@ -33,7 +33,7 @@ Volcanos._init = function() {
|
||||
var page = {data: {action: can.onaction.list, list: []},
|
||||
onLoad: function(options) { can.ui = this, can.db = options
|
||||
console.log(can.ui.route, options)
|
||||
can.user.title(options.title||"")
|
||||
can.user.title(decodeURIComponent(options.title||""))
|
||||
can.user.login(can, function() {
|
||||
if (can.onaction.refresh) {
|
||||
can.onaction.refresh({}, can)
|
||||
@ -52,7 +52,7 @@ Volcanos._init = function() {
|
||||
}
|
||||
can.core.ItemCB(can.onaction, function(key, cb) { page[key] = function(event) {
|
||||
// can.core.CallFunc(cb, {event: event, can: can, msg: can.request(event, event.target.dataset)})
|
||||
can.core.CallFunc(cb, [event, can, can.request(event, event.target.dataset)])
|
||||
can.core.CallFunc(cb, [event, can, key, event.target.dataset])
|
||||
} }), Page(page)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user