123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- <?php
- namespace Mobile\Controller;
- class IndexController extends MobileController
- {
- protected function _initialize()
- {
- parent::_initialize();
- $allow_action=array("index","version","deal","history","uoption","notice","respwd","sub_respwd","tgcode","noticeinfo","readall","delall","gglist","gginfo");
- if(!in_array(ACTION_NAME,$allow_action)){
- $this->error(L("非法操作"));
- }
- }
-
-
-
- //公告列表
- public function gglist(){
- $list = M("content")->where(array('status'=>1))->select();
- $this->ajaxReturn(['code' => 1, 'data' => $list]);
- // $this->assign("list",$list);
- // $this->display();
- }
-
- //公告详情
- public function gginfo($id = null){
- $info = M("content")->where(array('id'=>$id))->find();
- $this->ajaxReturn(['code' => 1, 'data' => $info]);
- }
- //删除通知记录
- public function delall(){
- $uid = userid();
- $list = M("notice")->where(array('uid'=>$uid))->select();
- if(!empty($list)){
- foreach($list as $k=>$v){
- $id = $v['id'];
- $re = M("notice")->where(array('id'=>$id))->delete();
- }
- $this->ajaxReturn(['code'=>1,'info'=> L("删除成功")]);
- }else{
- $this->ajaxReturn(['code'=>0,'info'=> L("没有记录")]);
- }
- }
-
- //通知标记已读
- public function readall(){
- $uid = userid();
- $list = M("notice")->where(array('uid'=>$uid,'status'=>1))->select();
- if(!empty($list)){
- foreach($list as $k=>$v){
- $id = $v['id'];
- $re = M("notice")->where(array('id'=>$id))->save(array('status'=>2));
- }
- $this->ajaxReturn(['code'=>1,'info'=> L("标注成功")]);
- }else{
- $this->ajaxReturn(['code'=>0,'info'=> L("全部已读")]);
- }
- }
- //会员选项页面
- public function uoption(){
- $uid = userid();
- $info = M("user")->where(array('id'=>$uid))->field("id,username,invit")->find();
- $this->assign("info",$info);
-
- $count = M("notice")->where(array('uid'=>$uid,'status'=>1))->count();
- $this->assign("count",$count);
- $this->display();
- }
- //通知页面
- public function notice(){
- $uid = userid();
- if($uid <= 0){
- $this->redirect('Trade/tradelist');
- }
- $list = M("notice")->where(array('uid'=>$uid))->order("id desc")->select();
- $this->assign('list',$list);
- $this->display();
- }
-
- //通知详情
- public function noticeinfo($id){
- $info = M("notice")->where(array('id'=>$id))->find();
- M("notice")->where(array('id'=>$id))->save(array('status'=>2));
- $this->assign('info',$info);
- $this->display();
- }
- //修改密码
- public function respwd(){
- $this->display();
- }
- //修改密码处理
- public function sub_respwd($oldpwd,$newpwd){
- // if($_POST){
- if(checkstr($oldpwd) || checkstr($newpwd)){
- $this->ajaxReturn(['code'=>0,'info'=>L('您输入的信息有误')]);
- }
- $uid = userid();
- if($uid == ''){
- $this->ajaxReturn(['code'=>0,'info'=>L('请先登陆')]);
- }
- $info = M("user")->where(array('id'=>$uid))->field("id,username,password")->find();
- if(md5($oldpwd) != $info['password']){
- $this->ajaxReturn(['code'=>0,'info'=>L('旧密码不正确')]);
- }
- $result = M("user")->where(array('id'=>$uid))->save(array('password'=>md5($newpwd),'stoptime'=>time()));
- if($result){
- $this->ajaxReturn(['code'=>1,'info'=>L('密码修改成功')]);
- }else{
- $this->ajaxReturn(['code'=>0,'info'=>L('密码修改失败')]);
- }
- // }else{
- // $this->ajaxReturn(['code'=>0,'info'=>L('非法操作')]);
- // }
- }
- //推广页面
- public function tgcode(){
-
- header ( "Content-type: text/html; charset=utf-8" );
- $uid = userid();
-
- //三代会员统计
-
- $count1_rz = M("user")->where("invit_1 = {$uid} and rzstatus = 2")->count();
- if($count1_rz <= 0){
- $count1_rz = 0;
- }
- $count1_nrz = M("user")->where("invit_1 = {$uid} and rzstatus != 2")->count();
- if($count1_nrz <= 0){
- $count1_nrz = 0;
- }
-
-
-
- $count2_rz = M("user")->where("invit_2 = {$uid} and rzstatus = 2")->count();
- if($count2_rz <= 0){
- $count2_rz = 0;
- }
-
- $count2_nrz = M("user")->where("invit_2 = {$uid} and rzstatus != 2")->count();
- if($count2_nrz <= 0){
- $count2_nrz = 0;
- }
-
-
- $count3_rz = M("user")->where("invit_3 = {$uid} and rzstatus = 2")->count();
- if($count3_rz <= 0){
- $count3_rz = 0;
- }
-
- $count3_nrz = M("user")->where("invit_3 = {$uid} and rzstatus != 2")->count();
- if($count3_nrz <= 0){
- $count3_nrz = 0;
- }
-
-
- $allcount_rz = $count1_rz + $count2_rz + $count3_rz;
- if($allcount_rz <= 0){
- $allcount_rz = 0;
- }
-
- $allcount_nrz = $count1_nrz + $count2_nrz + $count3_nrz;
- if($allcount_nrz <= 0){
- $allcount_nrz = 0;
- }
-
-
- $carr['one'] = $count1_rz;
- $carr['two'] = $count2_rz;
- $carr['three'] = $count3_rz;
-
- $carr['onen'] = $count1_nrz;
- $carr['twon'] = $count2_nrz;
- $carr['threen'] = $count3_nrz;
-
- $carr['allrz'] = $allcount_rz;
- $carr['allnrz'] = $allcount_nrz;
-
- $this->assign('carr',$carr);
-
-
- $uinfo = M("user")->where(array('id'=>$uid))->field("id,username,invit")->find();
- $invit = $uinfo['invit'];
- $url = 'https://' . $_SERVER['HTTP_HOST'] . u('/Login/register', array('qr'=>$invit));
-
- $drpath = './Public/Static/qrcode/';
- $imgma = $invit . '.png';
- $urel = './Public/Static/qrcode/' . $imgma;
-
- Vendor('phpqrcode.phpqrcode');
- $object = new \QRcode();
- $size = 3;
- $errorLevel = 16;
- $object->png($url, $drpath . '/' . $imgma, $errorLevel, $size);
- $object->scerweima1($url,$urel,$url);
- $this->assign('invit',$invit);
- $this->assign('url',$url);
-
- $clist = M("config")->where(array('id'=>1))->field("webtjimgs,tgtext")->find();
- $this->assign('clist',$clist);
-
-
- $this->display();
- }
- public function index()
- {
-
- $this->redirect('Trade/tradelist');
- }
- public function history()
- {
- $instId = I('get.instId');
- $bar = I('get.bar');
- $limit = I('get.limit');
- if (!$limit) $limit = 100;
- if (!$bar) $bar = '1m';
- $after = I('get.after');
- // $before = strtotime(I('get.before'));
- $url = 'https://aws.okx.com/api/v5/market/history-candles?instId='.$instId.'&bar='.$bar.'&limit='.$limit.'&after='.$after;
- $oy_list = do_request($url, []);
- if ($oy_list->code == 0){
- $this->ajaxReturn(['code' => 1, 'data' => $oy_list->data]);
- }else{
- $this->ajaxReturn(['code' => 0, 'info' => '网络请求错误']);
- }
- }
- public function deal()
- {
- $instId = I('get.instId');
- $limit = I('get.limit');
- if (!$limit) $limit = 100;
- $after = I('get.after');
- // $before = strtotime(I('get.before'));
- $url = 'https://aws.okx.com/api/v5/market/history-trades?instId='.$instId.'&limit='.$limit.'&after='.$after;
- $oy_list = do_request($url, []);
- if ($oy_list->code == 0){
- $this->ajaxReturn(['code' => 1, 'data' => $oy_list->data]);
- }else{
- $this->ajaxReturn(['code' => 0, 'info' => '网络请求错误']);
- }
- }
- public function version()
- {
- $list = M('config')->where(['id' => 1])->find();
- $data = [
- 'app' => 'https://'.$_SERVER['HTTP_HOST'].$list['app'],
- 'version' => $list['version'],
- ];
- $this->ajaxReturn(['code' => 1, 'data' => $data]);
- }
- }
|