add apply

This commit is contained in:
jingganjiaoyu 2024-07-29 22:49:29 +08:00
parent ad2bba6611
commit 8292672921
16 changed files with 412 additions and 110 deletions

89
src/gonganxitong/apply.go Normal file
View File

@ -0,0 +1,89 @@
package gonganxitong
import (
"shylinux.com/x/ice"
kit "shylinux.com/x/toolkits"
"shylinux.com/x/community/src/gonganxitong/model"
)
type ApplyStatus int
const (
ApplyCreate ApplyStatus = iota
)
var ApplyStatusList = map[ApplyStatus]string{
ApplyCreate: "create",
}
func (s ApplyStatus) String() string {
return ApplyStatusList[s]
}
type apply struct {
Table
user user
userPlace userPlace
place place
street street
create string `name:"create place_uid* user_place_role* begin_time@date end_time@date"`
portal string `data:"true"`
list string `name:"list place_uid uid auto"`
}
func (s apply) Inputs(m *ice.Message, arg ...string) {
switch arg[0] {
case model.PLACE_UID:
m.Cmdy(s.userPlace, s.userPlace.MyPlace, s.user.UserUID(m))
m.Cut(model.PLACE_UID, model.PLACE_NAME).RenameAppend(model.PLACE_NAME, model.NAME)
m.DisplayInputKeyNameIconTitle()
case model.USER_PLACE_ROLE:
for k, v := range UserPlaceRoleList {
m.Push(arg[0], k).Push(model.NAME, v)
}
m.SortInt(arg[0])
m.DisplayInputKeyNameIconTitle()
default:
s.Table.Inputs(m, arg...)
}
}
func (s apply) Create(m *ice.Message, arg ...string) {
arg = kit.TransArgKeys(arg, model.USER_PLACE_ROLE, model.ROLE)
arg = kit.TransArgValueTime(arg, model.BEGIN_TIME, model.END_TIME)
s.Table.Create(m, kit.Simple(arg, model.STATUS, ApplyCreate, model.USER_UID, s.user.UserUID(m))...)
}
func (s apply) Cancel(m *ice.Message, arg ...string) {
}
func (s apply) List(m *ice.Message, arg ...string) {
if len(arg) == 0 {
s.Table.List(m, arg...)
} else if len(arg) == 1 {
userUID := s.user.UserUID(m)
s.Tables(m, s.place, s.street).Fields(m,
"applies.uid", "begin_time", "end_time",
"applies.status AS apply_status",
model.PLACE_NAME, model.TYPE, "role AS user_place_role",
model.STREET_NAME, "places.address as place_address", model.PLACE_UID, model.STREET_UID)
s.Table.Select(m, model.USER_UID, userUID, model.PLACE_UID, arg[0]).Action(s.Create)
} else {
s.Table.Select(m.FieldsSetDetail(), model.UID, arg[1])
m.RenameAppend(model.ROLE, model.USER_PLACE_ROLE)
}
m.Table(func(value ice.Maps) {
switch ApplyStatus(kit.Int(value[model.APPLY_STATUS])) {
case ApplyCreate:
m.PushButton(s.Cancel)
default:
m.PushButton()
}
})
m.RewriteAppend(func(value, key string, index int) string {
kit.If(key == model.APPLY_STATUS, func() { value = ApplyStatus(kit.Int(value)).String() })
kit.If(key == model.USER_PLACE_ROLE, func() { value = UserPlaceRole(kit.Int(value)).String() })
return value
})
m.Display("")
}
func init() { ice.Cmd(prefixKey(), apply{}) }

11
src/gonganxitong/apply.js Normal file
View File

@ -0,0 +1,11 @@
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { if (msg.IsDetail()) { return msg.Dump(can) }
can.page.Append(can, can._output, msg.Table(function(value) {
return can.page.itemcard(can, value, [
{view: html.TITLE, list: [{text: value.place_name}, {text: value.type}, {text: [value.user_place_role, "", aaa.ROLE]}]},
{view: html.STATUS, list: [{text: value.street_name}, {text: value.place_address}]},
{view: html.STATUS, list: [{text: value.begin_time.split(" ")[0]}, {text: value.end_time.split(" ")[0]}]},
], function() { can.Option("uid", value.uid), can.Update() })
}))
},
})

View File

@ -1,6 +1,8 @@
package gonganxitong
import (
"shylinux.com/x/ice"
"shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits"
"shylinux.com/x/mysql-story/src/db"
@ -8,4 +10,8 @@ import (
type Table struct{ db.Table }
func (s Table) Init(m *ice.Message, arg ...string) {
kit.If(m.Config(web.PORTAL) == ice.TRUE, func() { m.GoSleep("30ms", func() { portal{}.Show(m) }) })
}
func prefixKey() string { return kit.Keys("web.team", kit.PathName(-1), kit.FileName(-1)) }

View File

@ -1,23 +1,51 @@
package gonganxitong
import (
"strings"
"shylinux.com/x/ice"
"shylinux.com/x/icebergs/base/aaa"
kit "shylinux.com/x/toolkits"
"shylinux.com/x/community/src/gonganxitong/model"
emails "shylinux.com/x/golang-story/src/project/email"
)
type email struct {
user user
portal portal
list string `name:"list auto" help:"邮箱配置"`
Creds emails.Creds
list string `name:"list auto"`
apply string `name:"apply username* password*"`
reset string `name:"reset password*" help:"重置密码"`
}
func (s email) Init(m *ice.Message, arg ...string) {
m.GoSleep("30ms", func() { s.portal.Show(m) })
}
func (s email) List(m *ice.Message, arg ...string) {
m.FieldsSetDetail()
m.Cmdy(s.user, s.user.Select, model.UID, s.user.UserUID(m))
if msg := m.Cmd(s.user, s.user.Select, model.UID, s.user.UserUID(m)); len(msg.Append(model.EMAIL)) < 10 {
m.EchoInfoButton(m.Trans("please apply email", "请申请邮箱"), s.Apply)
} else {
m.EchoInfoButton(msg.Append(model.EMAIL), s.Reset)
}
}
func (s email) Apply(m *ice.Message, arg ...string) {
msg := m.Cmd(s.user, s.user.Select, model.UID, s.user.UserUID(m))
if m.Warn(msg.Append(model.EMAIL) != "", m.Trans("email already exists", "邮箱已存在")) {
return
}
if !strings.Contains(m.Option(aaa.USERNAME), "@") {
m.Option(aaa.USERNAME, m.Option(aaa.USERNAME)+"@"+m.UserWeb().Hostname())
}
m.Cmdy(s.Creds, s.Creds.Create, m.Option(aaa.USERNAME), m.Option(aaa.PASSWORD))
kit.If(!m.IsErr(), func() { m.Cmdy(s.user, s.user.Email, m.Option(aaa.USERNAME)) })
kit.If(!m.IsErr(), func() { m.ToastSuccess() })
}
func (s email) Reset(m *ice.Message, arg ...string) {
msg := m.Cmd(s.user, s.user.Select, model.UID, s.user.UserUID(m))
m.Cmdy(s.Creds, s.Creds.Password, msg.Append(model.EMAIL), m.Option(aaa.PASSWORD))
kit.If(!m.IsErr(), func() { m.ToastSuccess() })
}
func init() { ice.Cmd(prefixKey(), email{}) }

14
src/gonganxitong/event.go Normal file
View File

@ -0,0 +1,14 @@
package gonganxitong
import "shylinux.com/x/ice"
type event struct {
Table
portal string `data:"true"`
}
func (s event) List(m *ice.Message, arg ...string) {
s.Table.List(m, arg...)
}
func init() { ice.Cmd(prefixKey(), event{}) }

View File

@ -1,23 +1,35 @@
package model
import (
"time"
"shylinux.com/x/ice"
"shylinux.com/x/mysql-story/src/db"
)
const (
UID = "uid"
NAME = "name"
AVATAR = "avatar"
OPENID = "openid"
OPEN_ID = "open_id"
ADDRESS = "address"
USER_UID = "user_uid"
USER_NAME = "user_name"
PLACE_UID = "place_uid"
PLACE_ADDRESS = "place_address"
STREET_UID = "street_uid"
STREET_NAME = "street_name"
UID = "uid"
NAME = "name"
TYPE = "type"
ROLE = "role"
EMAIL = "email"
AVATAR = "avatar"
STATUS = "status"
OPENID = "openid"
OPEN_ID = "open_id"
ADDRESS = "address"
USER_UID = "user_uid"
USER_NAME = "user_name"
USER_PLACE_ROLE = "user_place_role"
PLACE_UID = "place_uid"
PLACE_TYPE = "place_type"
PLACE_NAME = "place_name"
PLACE_ADDRESS = "place_address"
STREET_UID = "street_uid"
STREET_NAME = "street_name"
APPLY_STATUS = "apply_status"
BEGIN_TIME = "begin_time"
END_TIME = "end_time"
)
type Sess struct {
@ -29,29 +41,56 @@ type Sess struct {
type User struct {
db.ModelWithUID
OpenID string `gorm:"type:char(32)";index`
Avatar string `gorm:"size:char(256)"`
Name string `gorm:"type:char(32)"`
Email string `gorm:"type:char(32)"`
Name string `gorm:"type:char(32)"`
Avatar string `gorm:"size:256"`
}
type UserPlace struct {
db.Model
UserUID string `gorm:"type:char(32);index"`
PlaceUID string `gorm:"type:char(32)"`
UserUID string `gorm:"type:char(32);index"`
PlaceUID string `gorm:"type:char(32)"`
Role uint8
BeginTime time.Time
EndTime time.Time
}
type Place struct {
db.ModelWithUID
StreetUID string `gorm:"type:char(32)"`
Address string `gorm:"size:char(256)"`
Type uint8
Name string `gorm:"type:char(32)"`
Address string `gorm:"size:256"`
}
type Street struct {
db.ModelWithUID
Name string `gorm:"type:char(32)"`
}
type Event struct {
db.ModelWithUID
UserUID string `gorm:"type:char(32);index"`
Index string `gorm:"type:char(32)"`
args string `gorm:"type:char(32)"`
}
type Apply struct {
db.ModelWithUID
UserUID string `gorm:"type:char(32);index"`
PlaceUID string `gorm:"type:char(32)"`
Status uint8
Role uint8
BeginTime time.Time
EndTime time.Time
}
type Order struct {
db.ModelWithUID
UserUID string `gorm:"type:char(32);index"`
ApplyUID string `gorm:"type:char(32)"`
Status uint8
}
type models struct{ db.Models }
func (s models) Init(m *ice.Message, arg ...string) {
s.Models.Register(m, "gonganxitong", &Sess{}, &User{}, &UserPlace{}, &Place{}, &Street{})
s.Models.Register(m, "gonganxitong", &Sess{}, &User{}, &UserPlace{}, &Place{}, &Street{}, Event{}, Apply{}, Order{})
}
func init() { ice.Cmd("web.team.community.gonganxitong.models", models{}) }

14
src/gonganxitong/order.go Normal file
View File

@ -0,0 +1,14 @@
package gonganxitong
import "shylinux.com/x/ice"
type order struct {
Table
portal string `data:"true"`
}
func (s order) List(m *ice.Message, arg ...string) {
s.Table.List(m, arg...)
}
func init() { ice.Cmd(prefixKey(), order{}) }

View File

@ -1,10 +1,55 @@
package gonganxitong
import "shylinux.com/x/ice"
import (
"shylinux.com/x/ice"
"shylinux.com/x/community/src/gonganxitong/model"
)
type PlaceType int
const (
PlaceHouse PlaceType = iota
PlaceHotel
PlacePublic
PlaceSchool
PlaceOffice
PlaceFactory
)
var PlaceTypeList = map[PlaceType]string{
PlaceHouse: "house",
PlaceHotel: "hotel",
PlacePublic: "public",
PlaceOffice: "office",
PlaceFactory: "factory",
}
func (s PlaceType) String() string {
return PlaceTypeList[s]
}
type place struct {
Table
create string `name:"create street_uid* address*"`
}
func (s place) Inputs(m *ice.Message, arg ...string) {
switch arg[0] {
case model.PLACE_TYPE:
for k, v := range PlaceTypeList {
m.Push(arg[0], k).Push(model.NAME, v)
}
m.SortInt(arg[0])
m.DisplayInputKeyNameIconTitle()
default:
s.Table.Inputs(m, arg...)
}
}
func (s place) List(m *ice.Message, arg ...string) {
if s.Table.List(m, arg...); len(arg) == 1 {
m.EchoQRCode(m.Append(model.UID))
}
}
func init() { ice.Cmd(prefixKey(), place{}) }

View File

@ -2,24 +2,15 @@ $output { background-color:var(--plugin-bg-color); }
$output>div.list { border-radius:10px; background-color:var(--output-bg-color); padding:10px; margin:10px; overflow-x:hidden; position:relative; }
$output>div.list>div.title { font-weight:bold; display:flex; align-items:center; }
$output>div.list>div.title div.action div.item.button.icons input { display:none; }
$output>div.list>div.title div.action div.item { margin-right:5px; }
$output>div.list>div.title span:first-child { flex-grow:1; }
$output>div.list>div.item.card { position:relative; display:flex; align-items:center; }
$output>div.list>div.item.card div.action { position:absolute; right:0; }
$output>div.list>div.item.card div.output { padding:10px 0; width:100%; display:flex; transition:left .2s; }
$output>div.list>div.item.card div.output { background-color:var(--output-bg-color); }
$output>div.list>div.item.card.select div.output { transition:left .5s; }
$output>div.list>div.item.card.select div.title { font-weight:bold; }
$output>div.list>div.item.card img { height:36px; }
$output>div.list>div.item.card div.title { font-size:16px; }
$output>div.list>div.item.card div.title span { margin-right:5px; }
$output>div.list>div.item.card div.status { color:var(--disable-fg-color); font-size:12px; color:gray; }
$output>div.list>div.item.card div.status span { margin-right:5px; }
$output>div.list>div.item.card div.info { width:100%; }
$output>div.list>div.item.index { padding:10px; display:flex; flex-direction:column; align-items:center; float:left; }
$output>div.list>div.item.index img { width:100%; }
$output>div.list>div.action { display:flex; justify-content:center; }
$output>div.list>div.action input[type=button] { color:var(--notice-bg-color); }
$output>div.list>div.action input[type=button] { color:var(--notice-bg-color); border:none; }
$output>div.list>div.action div.item { margin-right:5px; }
$output>div.list>div.action i { display:none; }
$output>div.action div.item.button { margin-right:5px; }
$output>div.action div.item.button input { border:none; color:var(--notice-bg-color); min-width:80px; float:left; }
$output>div.action div.item.button span { display:none; }
$output>fieldset.qrcode table.content td { text-align:center; }

View File

@ -19,12 +19,14 @@ type portal struct {
user user
userPlace userPlace
place place
street street
export string `data:"true"`
short string `data:"index"`
field string `data:"time,name,icons,index,order,enable"`
list string `name:"list place_uid index uid auto" role:"void"`
placeCreate string `name:"placeCreate street_uid* address*" role:"void"`
placeCreate string `name:"placeCreate street_uid* place_type* name* address*" role:"void"`
placeRemove string `name:"placeRemove place_uid*" role:"void"`
scanQRCode string `name:"scanQRCode type text" role:"void"`
}
func (s portal) Inputs(m *ice.Message, arg ...string) {
@ -32,7 +34,7 @@ func (s portal) Inputs(m *ice.Message, arg ...string) {
}
func (s portal) List(m *ice.Message, arg ...string) {
if len(arg) == 0 {
m.Cmdy(s.userPlace, s.userPlace.MyPlace, s.user.UserUID(m)).Action(s.PlaceCreate).PushAction(s.PlaceRemove)
m.Cmdy(s.userPlace, s.userPlace.MyPlace, s.user.UserUID(m)).Action(s.PlaceCreate, s.ScanQRCode).PushAction(s.PlaceRemove)
kit.If(m.Length() == 0, func() { m.EchoInfoButton(m.Trans("Please Create Your Place", "请添加场所"), s.PlaceCreate) })
} else if len(arg) == 1 {
s.Hash.List(m, arg[1:]...).SortInt(mdb.ORDER)
@ -43,28 +45,41 @@ func (s portal) List(m *ice.Message, arg ...string) {
}
m.Display("").DisplayCSS("")
}
func (s portal) PlaceCreate(m *ice.Message, arg ...string) {
m.ToastProcess()
msg := m.Cmd(s.place, s.place.Select, model.UID, m.Option(model.STREET_UID))
if !m.WarnNotFound(msg.Length() == 0, "street") {
if !m.Cmdy(s.place, s.place.Create, arg).IsErr() {
args := kit.Simple(model.USER_UID, s.user.UserUID(m), model.PLACE_UID, m.Result())
m.Cmdy(s.userPlace, s.userPlace.Create, args)
m.Event(EVENT_PLACE_CREATE, args, model.PLACE_ADDRESS, m.Option(model.ADDRESS))
m.ProcessRefresh().ToastSuccess()
}
func (s portal) ScanQRCode(m *ice.Message, arg ...string) {
defer m.ToastProcess()()
if m.Option(mdb.TYPE) == mdb.TEXT {
args := kit.Simple(model.USER_UID, s.user.UserUID(m), model.PLACE_UID, m.Option(mdb.TEXT))
m.Cmdy(s.userPlace, s.userPlace.Create, args, model.ROLE, UserPlaceVisitor)
}
}
func (s portal) PlaceCreate(m *ice.Message, arg ...string) {
defer m.ToastProcess()()
if m.WarnNotFound(m.Cmd(s.street, s.street.Select, model.UID, m.Option(model.STREET_UID)).Length() == 0, "street") {
return
}
arg = kit.TransArgKeys(arg, model.PLACE_TYPE, model.TYPE)
if m.Cmdy(s.place, s.place.Create, arg).IsErr() {
return
}
args := kit.Simple(model.USER_UID, s.user.UserUID(m), model.PLACE_UID, m.Result(), model.ROLE, UserPlaceCreator)
m.Cmdy(s.userPlace, s.userPlace.Create, args)
m.Event(EVENT_PLACE_CREATE, args, model.PLACE_ADDRESS, m.Option(model.ADDRESS))
m.ProcessRefresh()
}
func (s portal) PlaceRemove(m *ice.Message, arg ...string) {
m.ToastProcess()
defer m.ToastProcess()()
args := kit.Simple(model.USER_UID, s.user.UserUID(m), model.PLACE_UID, m.Option(model.PLACE_UID))
msg := m.Cmd(s.userPlace, s.userPlace.Select, args)
if !m.WarnNotFound(msg.Length() == 0, "place") {
m.Cmdy(s.userPlace, s.userPlace.Delete, args)
m.Cmdy(s.place, s.place.Delete, model.UID, m.Option(model.PLACE_UID))
m.Event(EVENT_PLACE_REMOVE, args)
m.ProcessRefresh().ToastSuccess()
if m.WarnNotFound(msg.Length() == 0, "place") {
return
}
m.Cmdy(s.userPlace, s.userPlace.Delete, args)
if kit.Int(msg.Append(model.ROLE)) == kit.Int(UserPlaceCreator) {
m.Cmdy(s.place, s.place.Delete, model.UID, m.Option(model.PLACE_UID))
}
m.Event(EVENT_PLACE_REMOVE, args)
m.ProcessRefresh()
}
func init() { ice.Cmd(prefixKey(), portal{}) }
@ -80,5 +95,6 @@ func init() { ice.Cmd(prefixKey(), Portal{}) }
func (s portal) Show(m *ice.Message, arg ...string) {
cmd := m.GetCommand()
m.Cmd(s, s.Create, mdb.NAME, cmd.Help, mdb.ICONS, cmd.Icon, ctx.INDEX, m.PrefixKey())
icon := kit.Select(cmd.Icon, kit.Value(cmd.Meta, kit.Keys(ice.CTX_ICONS, m.CommandKey())))
m.Cmd(s, s.Create, mdb.NAME, cmd.Help, mdb.ICONS, icon, ctx.INDEX, m.PrefixKey())
}

View File

@ -1,12 +1,15 @@
var UID = "uid", PLACE_UID = "place_uid", PLACE_NAME = "place_name"
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) {
can.onimport.myPortal(can, msg, PLACE_UID, PLACE_NAME, "我的场所")
can.onimport.myPortal(can, msg, PLACE_UID, "place_address", "我的场所")
},
myValue: function(can, value) {
return [
{view: html.TITLE, list: [{text: value.place_address}]},
{view: html.STATUS, list: [{text: value[PLACE_UID].slice(0, 8)}, {text: value.street_name}]},
{view: html.TITLE, list: [{text: value.place_address},
{text: [can.user.trans(can, value.type, null, "value.place_type"), "", mdb.TYPE]},
value.role != "creator" && {text: [can.user.trans(can, value.role, null, "value.user_place_role"), "", aaa.ROLE]},
]},
{view: html.STATUS, list: [{text: value[PLACE_UID].slice(0, 8)}, {text: value.street_name}, {text: can.base.TimeTrim(value.created_at)}]},
]
},
myPortal: function(can, msg, PLACE_UID, PLACE_NAME, title) { can.user.isMobile && can.isCmdMode() && can.onappend.style(can, html.OUTPUT)
@ -14,22 +17,14 @@ Volcanos(chat.ONIMPORT, {
if (can.db.hash.length > 1 && can.db.hash[0]) { return can.Option(PLACE_UID, can.db.hash[0]), can.Option(ctx.INDEX, can.db.hash[1]), can.Update() }
can.db.hash[0] && can.onexport.session(can, PLACE_UID, can.db.hash[0])
can.ui = can.page.Append(can, can._output, ["myplace.list", "myindex.list"])
can.page.Append(can, can.ui.myplace, [{view: html.TITLE, list: [
{text: can.user.trans(can, "My Place", title)}
], _init: function(target) {
can.page.Append(can, can.ui.myplace, [{view: html.TITLE, list: [{text: can.user.trans(can, "My Place", title)}], _init: function(target) {
can.page.Append(can, target, [{view: html.ACTION, _init: function(target) {
msg.Option(ice.MSG_ACTION) && can.onappend._action(can, msg.Option(ice.MSG_ACTION), target)
}}])
}}])
can.run({}, [can.onimport.myPlace(can, msg, can.ui.myplace, PLACE_UID, PLACE_NAME)], function(msg) {
can.page.Append(can, can.ui.myindex, [{view: html.TITLE, list: [{text: can.user.trans(can, "My Index", "我的应用")}]}])
can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID)
can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID)
can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID)
can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID)
can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID)
can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID)
can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID)
for (var i = 0; i < 7; i++) { can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID) }
})
} else {
can.onimport.myData(can, msg, can._output, PLACE_UID)
@ -39,40 +34,20 @@ Volcanos(chat.ONIMPORT, {
can.page.Append(can, target||can._output, msg.Table(function(value) {
place_uid = place_uid||value[PLACE_UID], can.base.isIn(value[PLACE_UID], can.onexport.session(can, PLACE_UID)||"", can.db.hash[0]||"") && (place_uid = value[PLACE_UID])
place_uid == value[PLACE_UID] && can.onexport.title(can, value[PLACE_NAME])
return {view: [[html.ITEM_CARD, "uid-"+value[PLACE_UID]]], list: [
{view: html.ACTION, _init: function(target) { target.innerHTML = value.action
can.page.Select(can, target, html.INPUT_BUTTON, function(target) {
var style = can.Conf("_style."+target.name); style && can.onappend.style(can, style, target)
target.onclick = function(event) { can.Update(can.request(event, value), [ctx.ACTION, target.name]) }
})
}},
{view: html.OUTPUT, list: [
{img: can.misc.ResourceIcons(can, value.icon)},
{view: ice.INFO, list: can.onimport.myValue(can, value)},
], _init: function(target) {
can.onmotion.slideAction(can, target)
}},
], onclick: function(event) {
can.onmotion.select(can, target, html.DIV_ITEM, event.currentTarget)
can.onexport.hash(can, value[PLACE_UID]), can.onexport.session(can, PLACE_UID, value[PLACE_UID])
can.onexport.title(can, value[PLACE_NAME])
// can.user.toastSuccess(can, "switch")
return can.page.itemcard(can, value, can.onimport.myValue(can, value), function(event) {
can.onexport.hash(can, value[PLACE_UID]), can.onexport.session(can, PLACE_UID, value[PLACE_UID]), can.onexport.title(can, value[PLACE_NAME])
can.user.agent.init(can, can.user.info.titles)
}, _init: function(target) {}}
})
}))
can.page.Select(can, target, "div.item.card.uid-"+place_uid, function(_target) {
can.onmotion.select(can, target, html.DIV_ITEM, _target)
})
can.page.Append(can, target, [{view: html.ACTION, _init: function(target) {
msg.Option(ice.MSG_ACTION) && can.onappend._action(can, msg.Option(ice.MSG_ACTION), target)
}}])
can.page.Select(can, target, "div.item.card.uid-"+place_uid, function(_target) { can.onmotion.select(can, target, html.DIV_ITEM, _target) })
can.page.Append(can, target, [{view: html.ACTION, _init: function(target) { msg.Option(ice.MSG_ACTION) && can.onappend._action(can, msg.Option(ice.MSG_ACTION), target) }}])
can.onexport.hash(can, place_uid), can.onexport.session(can, PLACE_UID, place_uid); return place_uid
},
myIndex: function(can, msg, target, PLACE_UID) {
can.page.Append(can, target||can._output, msg.Table(function(value) {
var width; can.user.isMobile && !can.user.isLandscape() && (width = (can.ConfWidth()-40)/4)
return {view: [[html.ITEM, ctx.INDEX]], style: {width: width}, list: [
{img: can.misc.ResourceIcons(can, value.icon)}, {text: can.user.trans(can, value.index.split(".").pop(), value.name)},
{img: can.misc.ResourceIcons(can, value.icons)}, {text: can.user.trans(can, value.index.split(".").pop(), value.name)},
], onclick: function(event) {
can.Option(PLACE_UID, can.onexport.session(can, PLACE_UID)), can.Option(ctx.INDEX, value.index), can.Update()
}}
@ -85,16 +60,14 @@ Volcanos(chat.ONIMPORT, {
if (can.db.hash.length > 2 && can.db.hash[0] && can.db.hash[2]) { value.args = [can.db.hash[0], can.db.hash[2]] }
value.style = html.OUTPUT, value.height = can.ConfHeight()-html.ACTION_HEIGHT
can.onappend.plugin(can, value, function(sub) { refresh = function() { sub.Update() }
sub.onexport.output = function(_sub, msg) { can.user.toastSuccess(can, "load", "", 1000)
sub.onexport.output = function(_sub, msg) { can.user.toastSuccess(can, "load", "", 1000), can.onappend.style(sub, html.OUTPUT)
can.page.Appends(can, ui.action, list), msg.Option(ice.MSG_ACTION) && can.onappend._action(sub, msg.Option(ice.MSG_ACTION), ui.action, null, true)
can.onexport.hash(can, can.Option(PLACE_UID), value.index, sub.Option(UID))
back = function() {
if (sub.Option(UID)) {
can.onexport.hash(can, can.Option(PLACE_UID), can.Option(ctx.INDEX))
sub.Option(UID, ""), sub.Update()
can.onexport.hash(can, can.Option(PLACE_UID), can.Option(ctx.INDEX)), sub.Option(UID, ""), sub.Update()
} else {
can.onexport.hash(can, "")
can.Option(PLACE_UID, ""), can.Option(ctx.INDEX, ""), can.Update()
can.onexport.hash(can, ""), can.Option(PLACE_UID, ""), can.Option(ctx.INDEX, ""), can.Update()
}
}
}

View File

@ -2,23 +2,52 @@
"user": "用户",
"place": "场所",
"street": "街道",
"portal": "用户场所",
"scanQRCode": "扫码添加",
"placeCreate": "添加场所",
"placeRemove": "删除场所",
"portal": "公安系统",
"email": "邮箱配置",
"qrcode": "场所码",
"event": "事件流",
"apply": "申请单",
"order": "审批单",
"icons": {
"email": "usr/icons/Mail.png",
"qrcode": "usr/icons/Chess.png",
"scanQRCode": "bi bi-qr-code-scan",
"placeCreate": "bi bi-plus-square-dotted"
},
"style": {
"placeRemove": "danger"
},
"input": {
"address": "地址",
"open_id": "外键",
"user_uid": "用户",
"user_name": "用户名",
"user_place_role": "用户角色",
"begin_time": "起始时间",
"end_time": "结束时间",
"place_uid": "场所",
"place_type": "场所类型",
"place_address": "场所地址",
"street_uid": "街道",
"street_name": "街道名称"
},
"value": {
"user_place_role": {
"creator": "创建人",
"admin": "管理员",
"landlord": "房东",
"tenant": "租客",
"visitor": "访客"
},
"place_type": {
"house": "住宅",
"hotel": "宾馆",
"public": "公共",
"office": "办公",
"factory": "工厂"
}
}
}

View File

@ -0,0 +1,21 @@
package gonganxitong
import (
"shylinux.com/x/ice"
"shylinux.com/x/community/src/gonganxitong/model"
)
type qrcode struct {
portal portal
}
func (s qrcode) Init(m *ice.Message, arg ...string) {
m.GoSleep("30ms", func() { s.portal.Show(m) })
}
func (s qrcode) List(m *ice.Message, arg ...string) {
m.Push(model.PLACE_UID, arg[0])
m.EchoQRCode(arg[0])
}
func init() { ice.Cmd(prefixKey(), qrcode{}) }

View File

@ -14,7 +14,7 @@ type user struct {
Table
template string `data:"4b-Z_r8dZmm1pHdd2h4A10VVYX4OIHvemlLjsHKBj2s"`
create string `name:"create openid*"`
find string `name:"find uid*"`
email string `name:"email email*"`
}
func (s user) Create(m *ice.Message, arg ...string) {
@ -25,22 +25,19 @@ func (s user) Create(m *ice.Message, arg ...string) {
m.Option(model.USER_UID, m.Append(model.UID))
}
}
func (s user) Find(m *ice.Message, arg ...string) {
s.Select(m, arg...)
}
func (s user) List(m *ice.Message, arg ...string) {
s.Table.List(m, arg...).Action(s.Create, s.Find)
func (s user) Email(m *ice.Message, arg ...string) {
s.Table.Update(m, kit.Dict(model.EMAIL, m.Option(model.EMAIL)), model.UID, s.UserUID(m))
}
func init() { ice.Cmd(prefixKey(), user{}) }
func (s user) UserUID(m *ice.Message) string {
msg := m.Cmd(s, s.Select, model.UID, m.Option(ice.MSG_USERNAME))
m.Options(ice.MSG_USERNICK, msg.Append(mdb.NAME), model.OPEN_ID, msg.Append(model.OPEN_ID))
m.Options(ice.MSG_AVATAR, msg.Append(model.AVATAR), ice.MSG_USERNICK, msg.Append(mdb.NAME), model.OPEN_ID, msg.Append(model.OPEN_ID))
return m.Option(model.USER_UID, msg.Append(model.UID))
}
func (s user) SendTemplate(m *ice.Message, arg ...string) { // url type name hash
m.Cmd("web.chat.wx.template", "", m.Config("template"), m.Option(model.OPEN_ID), kit.Select("", arg, 0),
m.Cmdy("web.chat.wx.template", "", m.Config("template"), m.Option(model.OPEN_ID), kit.Select("", arg, 0),
"thing7", kit.Select("", arg, 1), "thing12", kit.Select("", arg, 2), "character_string2", kit.Select("", arg, 3),
"time11", time.Now().Format("2006年01月02日 15:04"), "thing18", m.Option(ice.MSG_USERNICK),
)

View File

@ -2,10 +2,33 @@ package gonganxitong
import (
"shylinux.com/x/ice"
kit "shylinux.com/x/toolkits"
"shylinux.com/x/community/src/gonganxitong/model"
)
type UserPlaceRole int
const (
UserPlaceCreator UserPlaceRole = iota
UserPlaceAdmin
UserPlaceLandlord
UserPlaceTenant
UserPlaceVisitor
)
var UserPlaceRoleList = map[UserPlaceRole]string{
UserPlaceCreator: "creator",
UserPlaceAdmin: "admin",
UserPlaceLandlord: "landlord",
UserPlaceTenant: "tenant",
UserPlaceVisitor: "visitor",
}
func (s UserPlaceRole) String() string {
return UserPlaceRoleList[s]
}
type userPlace struct {
Table
place place
@ -13,8 +36,14 @@ type userPlace struct {
}
func (s userPlace) MyPlace(m *ice.Message, arg ...string) {
s.Fields(m, "places.created_at", model.STREET_NAME, "places.address as place_address", model.PLACE_UID, model.STREET_UID).Tables(m, s.place, s.street)
s.Select(m, model.USER_UID, arg[0])
s.Tables(m, s.place, s.street).Fields(m, "places.created_at", model.STREET_NAME, model.PLACE_NAME, model.TYPE, model.ROLE,
"places.address as place_address", model.PLACE_UID, model.STREET_UID)
s.Orders(m, "role desc", "created_at desc").Select(m, model.USER_UID, arg[0])
m.RewriteAppend(func(value, key string, index int) string {
kit.If(key == model.ROLE, func() { value = UserPlaceRole(kit.Int(value)).String() })
kit.If(key == model.TYPE, func() { value = PlaceType(kit.Int(value)).String() })
return value
})
}
func init() { ice.Cmd(prefixKey(), userPlace{}) }

View File

@ -8,4 +8,4 @@ import (
func main() { print(ice.Run()) }
func init() { ice.Info.Titles = "云社区" }
func init() { ice.Info.Titles = "云社区" }