mirror of
https://shylinux.com/x/community
synced 2025-04-26 01:54:05 +08:00
113 lines
6.5 KiB
JavaScript
113 lines
6.5 KiB
JavaScript
var UID = "uid", PLACE_UID = "place_uid", PLACE_NAME = "place_name", PLACE_TYPE = "place_type"
|
|
Volcanos(chat.ONIMPORT, {
|
|
_init: function(can, msg) {
|
|
can.onimport.myPortal(can, msg, PLACE_UID, PLACE_NAME, "我的场所")
|
|
},
|
|
myValue: function(can, value) {
|
|
return [
|
|
{view: html.TITLE, list: [{text: value.place_name||value.place_address},
|
|
{text: [can.user.transValue(can, value, PLACE_TYPE), "", mdb.TYPE]},
|
|
value.user_place_role != "creator" && {text: [can.user.transValue(can, value, "user_place_role"), "", aaa.ROLE]},
|
|
]},
|
|
{view: html.STATUS, list: [
|
|
{text: value[PLACE_UID].slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)},
|
|
{text: value.city_name}, {text: value.street_name},
|
|
]},
|
|
]
|
|
},
|
|
myPortal: function(can, msg, PLACE_UID, PLACE_NAME, title) { can.user.isMobile && can.isCmdMode() && can.onappend.style(can, html.OUTPUT)
|
|
can.isCmdMode() && (can.db.hash = can.misc.SearchHash(can))
|
|
can.sup.current = can.sup.current||{}
|
|
if (can.Option(PLACE_UID) == "") {
|
|
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, target, [{view: html.ACTION, _init: function(target) {
|
|
msg.Option(ice.MSG_ACTION) && can.onappend._action(can, msg.Option(ice.MSG_ACTION), target)
|
|
}}])
|
|
}}])
|
|
msg.Table(function(value) { var key = "_trans.value."+PLACE_NAME.replace("_name", "_type")+".icons."
|
|
msg.Push(mdb.ICONS, can.Conf(key+value.place_type)||can.Conf(key+"office"))
|
|
})
|
|
var uid = can.onimport.myPlace(can, msg, can.ui.myplace, PLACE_UID, PLACE_NAME)
|
|
msg.Length() > 0 && can.run({}, [uid], function(msg) {
|
|
can.page.Append(can, can.ui.myindex, [{view: html.TITLE, list: [{text: can.user.trans(can, "My Index", "我的应用")}]}])
|
|
for (var i = 0; i < 1; i++) { can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID) }
|
|
can.onimport.selectIndex(can, can.sup.current)
|
|
})
|
|
can.user.agent.init(can)
|
|
} else {
|
|
can.onimport.myData(can, msg, can._output, PLACE_UID, PLACE_NAME)
|
|
}
|
|
},
|
|
myPlace: function(can, msg, target, PLACE_UID, PLACE_NAME) { var place_uid
|
|
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]), can.sup.current = value)
|
|
value._uid = value[PLACE_UID]
|
|
return can.onimport.itemcard(can, value, can.onimport.myValue(can, value), function(event) {
|
|
can.sup.current = value, can.onimport.selectIndex(can, can.sup.current)
|
|
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)
|
|
})
|
|
}))
|
|
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
|
|
},
|
|
selectIndex: function(can, value) {
|
|
can.page.Select(can, can.ui.myindex, html.DIV_ITEM, function(target) {
|
|
var list = target.className.split(" ")
|
|
if (list.indexOf(mdb.TYPE) > -1 && list.indexOf(value.place_type) == -1) {
|
|
can.onmotion.toggle(can, target, false)
|
|
} else if (list.indexOf(aaa.ROLE) > -1 && list.indexOf(value.user_place_role) == -1) {
|
|
can.onmotion.toggle(can, target, false)
|
|
} else {
|
|
can.onmotion.toggle(can, target, true)
|
|
}
|
|
})
|
|
},
|
|
myIndex: function(can, msg, target, PLACE_UID) {
|
|
var width = (can.ConfWidth()-40)/parseInt((can.ConfWidth()-40)/100), height = width+20; can.user.isMobile && !can.user.isLandscape() && (width = (can.ConfWidth()-40)/4, height = width+20)
|
|
can.page.Append(can, target||can._output, msg.Table(function(value) {
|
|
if (value.enable != ice.TRUE) {
|
|
return
|
|
}
|
|
return {view: [[html.ITEM, ctx.INDEX].concat(
|
|
value.type? ["type"]: [], can.core.Split(value.type||""),
|
|
value.role? ["role"]: [], can.core.Split(value.role||""),
|
|
)], style: {height: height, width: width}, list: [
|
|
{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()
|
|
}}
|
|
}))
|
|
},
|
|
myData: function(can, msg, target, PLACE_UID, PLACE_NAME) {
|
|
msg.Table(function(value) { function back() {} function refresh() {}
|
|
var list = [can.page.button(can, can.user.trans(can, "goback", "返回"), function(event) { back() }), can.page.button(can, can.user.trans(can, "reload", "刷新"), function(event) { refresh() })]
|
|
var ui = can.page.Append(can, can._output, [{view: html.ACTION}])
|
|
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.onexport.title(can, value.help, can.user.trans(can, msg.Option("place_type"), null, "value.place_type"), msg.Option("place_name"))
|
|
can.onexport.title(can, value.help, msg.Option(PLACE_NAME))
|
|
can.onappend.plugin(can, value, function(sub) { refresh = function() { sub.Update() }
|
|
sub.Conf(PLACE_NAME, msg.Option(PLACE_NAME))
|
|
sub.onexport.output = function(_sub, msg) { 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))
|
|
can.user.agent.init(can, msg.Option("_share_content")||value.help, msg.Option("_share_icons")||value.icons)
|
|
back = function() {
|
|
if (sub.Option(UID)) {
|
|
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()
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
})
|