Index.php 3.2 KB

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