Index.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. namespace app\index\controller;
  3. use app\common\controller\Frontend;
  4. use app\utils\PayUtil;
  5. use think\Cache;
  6. use think\Db;
  7. class Index extends Frontend
  8. {
  9. protected $noNeedLogin = '*';
  10. protected $noNeedRight = '*';
  11. protected $layout = '';
  12. /**
  13. * 测试 汇付 支付
  14. */
  15. public function testPay()
  16. {
  17. $params = \request()->post();
  18. $order_no = $params['order_no'] ?? '';
  19. $wxInfo = Cache::get($params['openid'] ?? '');
  20. $openid = $wxInfo['openid'] ?? '';
  21. // $sessionKey = $wxInfo['session_key'] ?? '';
  22. $pay = new PayUtil();
  23. $order_no = !empty($order_no) ? $order_no : time() . rand(1, 200);
  24. $pay->jsPay($openid, "D0{$order_no}", '0.01', '开通会员');
  25. return json_encode([
  26. 'order_no' => $order_no,
  27. 'data' => $pay->getData()
  28. ]);
  29. }
  30. public function index()
  31. {
  32. $code = input('code', '', 'trim'); //邀请码
  33. $this->view->assign('code', $code);
  34. $this->view->assign('downurl', config("site.apk_url"));
  35. $is_ios = 0;
  36. if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
  37. $is_ios = 1;
  38. }
  39. $this->view->assign('is_ios', $is_ios);
  40. return $this->view->fetch();
  41. }
  42. public function wxsharedownload(){
  43. $this->view->assign('downurl', config("site.apk_url"));
  44. return $this->view->fetch();
  45. }
  46. public function suningh5(){
  47. return $this->view->fetch();
  48. }
  49. /**
  50. * app下载页
  51. * 判断是安卓还是ios
  52. */
  53. public function appdownload() {
  54. echo 'hello wold';
  55. }
  56. /**
  57. * app下载页-新
  58. * 判断是安卓还是ios
  59. */
  60. public function downapp() {
  61. $code = input('code', '', 'trim'); //邀请码
  62. $this->view->assign('code', $code);
  63. $this->view->assign('downurl', config("site.apk_url"));
  64. return $this->view->fetch();
  65. // if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
  66. // header("Location: https://apps.apple.com/cn/app/%E4%BC%B4%E5%A3%B0%E8%AF%AD%E9%9F%B3/id1556551099");
  67. // }else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android')){
  68. // //$host = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"];
  69. // //header("Location: ".$host."/index/index/download");
  70. // $this->view->assign('downurl', config("site.apk_url"));
  71. // return $this->view->fetch();
  72. // }else{
  73. // $this->view->assign('downurl', config("site.apk_url"));
  74. // return $this->view->fetch();
  75. // }
  76. }
  77. //基础文章网页
  78. public function basedata(){
  79. $key = input('key','');
  80. if(!$key){
  81. exit;
  82. }
  83. $content = Db::name('basedata')->where('key',$key)->find();
  84. $this->assign('content',$content['content']);
  85. return $this->fetch();
  86. }
  87. }