Vote 投票
获取投票信息
Mudu.Room.Vote.Get(function (response) {
response = JSON.parse(response)
if (response.status === 'y') {
console.log('获取成功,数据为:', response.data)
}
if (response.status === 'n') {
console.log('获取失败')
}
})
{
"status": "y",
"flag": 100,
"info": "获取成功",
"data": {
"id": 4265,
"act_id": 12146,
"uin": 9354,
"vote_name": "alkdsjf",
"end_time": "2017-09-29 14:39:07",
"vote_status": 1,
"view_enable": 1,
"vote_type": 1,
"questions": [
{
"id": 6626,
"vote_id": 4265,
"question_name": "alkdsjfaksld",
"question_multi": 1,
"max_question_num": 2,
"question_uid": 1,
"items": [
{
"id": 31205,
"vote_id": 4265,
"question_uid": 1,
"item_name": "alkdsjf",
"item_uid": 1,
"user_voted": 1,
"vote_sum": 3,
"percent": "100%",
"image": "https://xxxxx.com/afasdfasf.jpg"
},
{
"id": 31206,
"vote_id": 4265,
"question_uid": 1,
"item_name": "adslkfj",
"item_uid": 2,
"vote_sum": 0,
"percent": "0%",
"image": "https://xxxxx.com/afasdfasf.jpg"
}
]
},
{
"id": 6627,
"vote_id": 4265,
"question_name": "徕卡江森",
"question_multi": 2,
"max_question_num": 2,
"question_uid": 2,
"items": [
{
"id": 31207,
"vote_id": 4265,
"question_uid": 2,
"item_name": "二老董藩",
"item_uid": 1,
"vote_sum": 1,
"percent": "16.67%",
"image": "https://xxxxx.com/afasdfasf.jpg"
},
{
"id": 31208,
"vote_id": 4265,
"question_uid": 2,
"item_name": "二老单反",
"item_uid": 2,
"user_voted": 1,
"vote_sum": 3,
"percent": "50%",
"image": "https://xxxxx.com/afasdfasf.jpg"
},
{
"id": 31209,
"vote_id": 4265,
"question_uid": 2,
"item_name": "二老单反",
"item_uid": 3,
"user_voted": 1,
"vote_sum": 2,
"percent": "33.33%",
"image": "https://xxxxx.com/afasdfasf.jpg"
},
{
"id": 31210,
"vote_id": 4265,
"question_uid": 2,
"item_name": "adlkfj",
"item_uid": 4,
"vote_sum": 0,
"percent": "0%",
"image": "https://xxxxx.com/afasdfasf.jpg"
}
]
}
],
"voted": 1,
"vote_question": [
{
"id": 6626,
"vote_id": 4265,
"question_name": "alkdsjfaksld",
"question_multi": 1,
"max_question_num": 2,
"question_uid": 1,
"items": [
{
"id": 31205,
"vote_id": 4265,
"question_uid": 1,
"item_name": "alkdsjf",
"item_uid": 1,
"user_voted": 1,
"vote_sum": 3,
"percent": "100%",
"image": "https://xxxxx.com/afasdfasf.jpg"
},
{
"id": 31206,
"vote_id": 4265,
"question_uid": 1,
"item_name": "adslkfj",
"item_uid": 2,
"vote_sum": 0,
"percent": "0%",
"image": "https://xxxxx.com/afasdfasf.jpg"
}
]
},
{
"id": 6627,
"vote_id": 4265,
"question_name": "徕卡江森",
"question_multi": 2,
"max_question_num": 2,
"question_uid": 2,
"items": [
{
"id": 31207,
"vote_id": 4265,
"question_uid": 2,
"item_name": "二老董藩",
"item_uid": 1,
"vote_sum": 1,
"percent": "16.67%",
"image": "https://xxxxx.com/afasdfasf.jpg"
},
{
"id": 31208,
"vote_id": 4265,
"question_uid": 2,
"item_name": "二老单反",
"item_uid": 2,
"user_voted": 1,
"vote_sum": 3,
"percent": "50%",
"image": "https://xxxxx.com/afasdfasf.jpg"
},
{
"id": 31209,
"vote_id": 4265,
"question_uid": 2,
"item_name": "二老单反",
"item_uid": 3,
"user_voted": 1,
"vote_sum": 2,
"percent": "33.33%",
"image": "https://xxxxx.com/afasdfasf.jpg"
},
{
"id": 31210,
"vote_id": 4265,
"question_uid": 2,
"item_name": "adlkfj",
"item_uid": 4,
"vote_sum": 0,
"percent": "0%",
"image": "https://xxxxx.com/afasdfasf.jpg"
}
]
}
]
}
}
flag |
info |
status |
100 |
获取成功 |
y |
101 |
无投票信息 |
n |
进行投票
Mudu.Room.Vote.Vote(
[
{
"4265":"1|1"
},
{
"4265":"2|2,3"
}
],
function (response) {
response = JSON.parse(response)
if (response.status === 'y') {
console.log('投票成功')
}
if (response.status === 'n') {
console.log('投票失败')
}
}
)
{
status : 'y',
flag: 100,
info: '投票成功',
}
flag |
info |
status |
100 |
投票成功 |
y |
101 |
系统繁忙/参数错误 |
n |
102 |
该问题不是多选 |
n |
103 |
超过最大选项数 |
n |
104 |
投票还未开始 |
n |
105 |
投票已结束 |
n |
106 |
已经投过票 |
n |
107 |
保存失败 |
n |
108 |
没有登录 |
n |
Vote.Changed事件
Vote.Changed事件会在投票状态改变(一般为后台关闭或开启投票)的时候被触发
Mudu.MsgBus.On(
"Vote.Changed",
function (response) {
var response = JSON.parse(response)
console.log('投票状态改变')
})
- response与
获取投票信息
时的response格式相同