前段要调用的三个函数
public function flash_rcloud()
{
$data = $this->data;
if (empty($data['user_id']) || empty($data['token'])) {
return $this->returnValue(105,'尚未登录,请先登录',(object)array());
}
$user = M('user')->where('id=%d',array($data['user_id']))->field('token')->find();
if ($user['token']!=$data['token']) {
return $this->returnValue(100,'已在另一台机器上登录',(object)array());
}
$rcloud_id = M('rcloud_list')->where('user_id=%d and user_type=1',array($data['user_id']))->getField('rcloud_id');
$result = json_decode(gettalktoken($rcloud_id,$user['nickname'],$user['headimgurl']),true);
$user['rcloud_token'] = $save['rcloud_token'] = $result['token']?$result['token']:'';
M('user')->where('id=%d',array($data['user_id']))->save($save);
$content = array(
'rcloud_token' => $user['rcloud_token']
);
return $this->returnValue(0,'',$content);
}
public function chat_detail()
{
$data = $this->data;
$id = $data['rcloud_id'];
$result = M('rcloud_list')->where('rcloud_id="%s"',array($id))->field('user_id,user_type')->find();
if ($result['user_type'] == 1) {
$user = M('user')->where('id=%d',array($result['user_id']))->field('nickname,headimgurl')->find();
}
if ($result['user_type'] == 2) {
$user = M('purchasing')->where('id=%d',array($result['user_id']))->field(array('purchasing_name'=>'nickname','headimg'=>'headimgurl'))->find();
}
if ($result['user_type'] == 3) {
$user = M('admin')->where('id=%d',array($result['user_id']))->field(array('purchasing_name'=>'nickname','headimg'=>'headimgurl'))->find();
}
if (empty($user)) {
$user = (object)array();
}
return $this->returnValue(0,'',$user);
}
public function allkey()
{
$cloumn = array('JP_appid','RC_appkey','WX_appid','BD_appkey');
$where['code'] = array('in',$cloumn);
$key = M('shop_config')->where($where)->field('code,value')->select();
if (empty($key)) {
$key = (object)array();
}
else{
foreach ($key as $key => $value) {
$key = $value['code'];
$keys[$key] = $value['value']?$value['value']:'';
}
}
return $this->returnValue(0,'',$keys);
}