IndexController.class.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <?php
  2. namespace Mobile\Controller;
  3. class IndexController extends MobileController
  4. {
  5. protected function _initialize()
  6. {
  7. parent::_initialize();
  8. $allow_action=array("index","version","deal","history","uoption","notice","respwd","sub_respwd","tgcode","noticeinfo","readall","delall","gglist","gginfo");
  9. if(!in_array(ACTION_NAME,$allow_action)){
  10. $this->error(L("非法操作"));
  11. }
  12. }
  13. //公告列表
  14. public function gglist(){
  15. $list = M("content")->where(array('status'=>1))->select();
  16. $this->ajaxReturn(['code' => 1, 'data' => $list]);
  17. // $this->assign("list",$list);
  18. // $this->display();
  19. }
  20. //公告详情
  21. public function gginfo($id = null){
  22. $info = M("content")->where(array('id'=>$id))->find();
  23. $this->ajaxReturn(['code' => 1, 'data' => $info]);
  24. }
  25. //删除通知记录
  26. public function delall(){
  27. $uid = userid();
  28. $list = M("notice")->where(array('uid'=>$uid))->select();
  29. if(!empty($list)){
  30. foreach($list as $k=>$v){
  31. $id = $v['id'];
  32. $re = M("notice")->where(array('id'=>$id))->delete();
  33. }
  34. $this->ajaxReturn(['code'=>1,'info'=> L("删除成功")]);
  35. }else{
  36. $this->ajaxReturn(['code'=>0,'info'=> L("没有记录")]);
  37. }
  38. }
  39. //通知标记已读
  40. public function readall(){
  41. $uid = userid();
  42. $list = M("notice")->where(array('uid'=>$uid,'status'=>1))->select();
  43. if(!empty($list)){
  44. foreach($list as $k=>$v){
  45. $id = $v['id'];
  46. $re = M("notice")->where(array('id'=>$id))->save(array('status'=>2));
  47. }
  48. $this->ajaxReturn(['code'=>1,'info'=> L("标注成功")]);
  49. }else{
  50. $this->ajaxReturn(['code'=>0,'info'=> L("全部已读")]);
  51. }
  52. }
  53. //会员选项页面
  54. public function uoption(){
  55. $uid = userid();
  56. $info = M("user")->where(array('id'=>$uid))->field("id,username,invit")->find();
  57. $this->assign("info",$info);
  58. $count = M("notice")->where(array('uid'=>$uid,'status'=>1))->count();
  59. $this->assign("count",$count);
  60. $this->display();
  61. }
  62. //通知页面
  63. public function notice(){
  64. $uid = userid();
  65. if($uid <= 0){
  66. $this->redirect('Trade/tradelist');
  67. }
  68. $list = M("notice")->where(array('uid'=>$uid))->order("id desc")->select();
  69. $this->assign('list',$list);
  70. $this->display();
  71. }
  72. //通知详情
  73. public function noticeinfo($id){
  74. $info = M("notice")->where(array('id'=>$id))->find();
  75. M("notice")->where(array('id'=>$id))->save(array('status'=>2));
  76. $this->assign('info',$info);
  77. $this->display();
  78. }
  79. //修改密码
  80. public function respwd(){
  81. $this->display();
  82. }
  83. //修改密码处理
  84. public function sub_respwd($oldpwd,$newpwd){
  85. // if($_POST){
  86. if(checkstr($oldpwd) || checkstr($newpwd)){
  87. $this->ajaxReturn(['code'=>0,'info'=>L('您输入的信息有误')]);
  88. }
  89. $uid = userid();
  90. if($uid == ''){
  91. $this->ajaxReturn(['code'=>0,'info'=>L('请先登陆')]);
  92. }
  93. $info = M("user")->where(array('id'=>$uid))->field("id,username,password")->find();
  94. if(md5($oldpwd) != $info['password']){
  95. $this->ajaxReturn(['code'=>0,'info'=>L('旧密码不正确')]);
  96. }
  97. $result = M("user")->where(array('id'=>$uid))->save(array('password'=>md5($newpwd),'stoptime'=>time()));
  98. if($result){
  99. $this->ajaxReturn(['code'=>1,'info'=>L('密码修改成功')]);
  100. }else{
  101. $this->ajaxReturn(['code'=>0,'info'=>L('密码修改失败')]);
  102. }
  103. // }else{
  104. // $this->ajaxReturn(['code'=>0,'info'=>L('非法操作')]);
  105. // }
  106. }
  107. //推广页面
  108. public function tgcode(){
  109. header ( "Content-type: text/html; charset=utf-8" );
  110. $uid = userid();
  111. //三代会员统计
  112. $count1_rz = M("user")->where("invit_1 = {$uid} and rzstatus = 2")->count();
  113. if($count1_rz <= 0){
  114. $count1_rz = 0;
  115. }
  116. $count1_nrz = M("user")->where("invit_1 = {$uid} and rzstatus != 2")->count();
  117. if($count1_nrz <= 0){
  118. $count1_nrz = 0;
  119. }
  120. $count2_rz = M("user")->where("invit_2 = {$uid} and rzstatus = 2")->count();
  121. if($count2_rz <= 0){
  122. $count2_rz = 0;
  123. }
  124. $count2_nrz = M("user")->where("invit_2 = {$uid} and rzstatus != 2")->count();
  125. if($count2_nrz <= 0){
  126. $count2_nrz = 0;
  127. }
  128. $count3_rz = M("user")->where("invit_3 = {$uid} and rzstatus = 2")->count();
  129. if($count3_rz <= 0){
  130. $count3_rz = 0;
  131. }
  132. $count3_nrz = M("user")->where("invit_3 = {$uid} and rzstatus != 2")->count();
  133. if($count3_nrz <= 0){
  134. $count3_nrz = 0;
  135. }
  136. $allcount_rz = $count1_rz + $count2_rz + $count3_rz;
  137. if($allcount_rz <= 0){
  138. $allcount_rz = 0;
  139. }
  140. $allcount_nrz = $count1_nrz + $count2_nrz + $count3_nrz;
  141. if($allcount_nrz <= 0){
  142. $allcount_nrz = 0;
  143. }
  144. $carr['one'] = $count1_rz;
  145. $carr['two'] = $count2_rz;
  146. $carr['three'] = $count3_rz;
  147. $carr['onen'] = $count1_nrz;
  148. $carr['twon'] = $count2_nrz;
  149. $carr['threen'] = $count3_nrz;
  150. $carr['allrz'] = $allcount_rz;
  151. $carr['allnrz'] = $allcount_nrz;
  152. $this->assign('carr',$carr);
  153. $uinfo = M("user")->where(array('id'=>$uid))->field("id,username,invit")->find();
  154. $invit = $uinfo['invit'];
  155. $url = 'https://' . $_SERVER['HTTP_HOST'] . u('/Login/register', array('qr'=>$invit));
  156. $drpath = './Public/Static/qrcode/';
  157. $imgma = $invit . '.png';
  158. $urel = './Public/Static/qrcode/' . $imgma;
  159. Vendor('phpqrcode.phpqrcode');
  160. $object = new \QRcode();
  161. $size = 3;
  162. $errorLevel = 16;
  163. $object->png($url, $drpath . '/' . $imgma, $errorLevel, $size);
  164. $object->scerweima1($url,$urel,$url);
  165. $this->assign('invit',$invit);
  166. $this->assign('url',$url);
  167. $clist = M("config")->where(array('id'=>1))->field("webtjimgs,tgtext")->find();
  168. $this->assign('clist',$clist);
  169. $this->display();
  170. }
  171. public function index()
  172. {
  173. $this->redirect('Trade/tradelist');
  174. }
  175. public function history()
  176. {
  177. $instId = I('get.instId');
  178. $bar = I('get.bar');
  179. $limit = I('get.limit');
  180. if (!$limit) $limit = 100;
  181. if (!$bar) $bar = '1m';
  182. $after = I('get.after');
  183. // $before = strtotime(I('get.before'));
  184. $url = 'https://aws.okx.com/api/v5/market/history-candles?instId='.$instId.'&bar='.$bar.'&limit='.$limit.'&after='.$after;
  185. $oy_list = do_request($url, []);
  186. if ($oy_list->code == 0){
  187. $this->ajaxReturn(['code' => 1, 'data' => $oy_list->data]);
  188. }else{
  189. $this->ajaxReturn(['code' => 0, 'info' => '网络请求错误']);
  190. }
  191. }
  192. public function deal()
  193. {
  194. $instId = I('get.instId');
  195. $limit = I('get.limit');
  196. if (!$limit) $limit = 100;
  197. $after = I('get.after');
  198. // $before = strtotime(I('get.before'));
  199. $url = 'https://aws.okx.com/api/v5/market/history-trades?instId='.$instId.'&limit='.$limit.'&after='.$after;
  200. $oy_list = do_request($url, []);
  201. if ($oy_list->code == 0){
  202. $this->ajaxReturn(['code' => 1, 'data' => $oy_list->data]);
  203. }else{
  204. $this->ajaxReturn(['code' => 0, 'info' => '网络请求错误']);
  205. }
  206. }
  207. public function version()
  208. {
  209. $list = M('config')->where(['id' => 1])->find();
  210. $data = [
  211. 'app' => 'https://'.$_SERVER['HTTP_HOST'].$list['app'],
  212. 'version' => $list['version'],
  213. ];
  214. $this->ajaxReturn(['code' => 1, 'data' => $data]);
  215. }
  216. }