Index.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 pay()
  31. {
  32. return $this->view->fetch();
  33. }
  34. public function index()
  35. {
  36. $code = input('code', '', 'trim'); //邀请码
  37. $this->view->assign('code', $code);
  38. $this->view->assign('downurl', config("site.apk_url"));
  39. $is_ios = 0;
  40. if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
  41. $is_ios = 1;
  42. }
  43. $this->view->assign('is_ios', $is_ios);
  44. return $this->view->fetch();
  45. }
  46. public function wxsharedownload(){
  47. $this->view->assign('downurl', config("site.apk_url"));
  48. return $this->view->fetch();
  49. }
  50. public function suningh5(){
  51. return $this->view->fetch();
  52. }
  53. /**
  54. * app下载页
  55. * 判断是安卓还是ios
  56. */
  57. public function appdownload() {
  58. echo 'hello wold';
  59. }
  60. /**
  61. * app下载页-新
  62. * 判断是安卓还是ios
  63. */
  64. public function downapp() {
  65. $code = input('code', '', 'trim'); //邀请码
  66. $this->view->assign('code', $code);
  67. $this->view->assign('downurl', config("site.apk_url"));
  68. return $this->view->fetch();
  69. // if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')||strpos($_SERVER['HTTP_USER_AGENT'], 'iPad')){
  70. // header("Location: https://apps.apple.com/cn/app/%E4%BC%B4%E5%A3%B0%E8%AF%AD%E9%9F%B3/id1556551099");
  71. // }else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android')){
  72. // //$host = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"];
  73. // //header("Location: ".$host."/index/index/download");
  74. // $this->view->assign('downurl', config("site.apk_url"));
  75. // return $this->view->fetch();
  76. // }else{
  77. // $this->view->assign('downurl', config("site.apk_url"));
  78. // return $this->view->fetch();
  79. // }
  80. }
  81. //基础文章网页
  82. public function basedata(){
  83. $key = input('key','');
  84. if(!$key){
  85. exit;
  86. }
  87. $content = Db::name('basedata')->where('key',$key)->find();
  88. $this->assign('content',$content['content']);
  89. return $this->fetch();
  90. }
  91. }