ShareController.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * ShareController.php UTF-8
  4. * 分享控制器
  5. *
  6. * @date : 2018/8/17 15:45
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HuoMp 1.0
  11. */
  12. namespace mini\sdk\controller;
  13. use huomp\controller\share\QrCodeOut;
  14. use huomp\controller\share\ShareOut;
  15. use mini\common\controller\V2ApiBaseController;
  16. use think\Log;
  17. class ShareController extends V2ApiBaseController {
  18. public function _initialize() {
  19. parent::_initialize();
  20. // Log::write(
  21. // $this->request->scheme().'://'.$this->request->server('HTTP_HOST').$this->request->server('REQUEST_URI').'?'
  22. // .$this->request->getContent(),
  23. // Log::LOG
  24. // );
  25. }
  26. /**
  27. * 获取分享内容
  28. * http://doc.1tsdk.com/159?page_id=4467
  29. * 【域名】/mp/share/detail
  30. */
  31. public function getInfo() {
  32. $this->checkLogin();
  33. $_game_rq = $this->setGameData();
  34. $_device_rq = $this->setDeviceData();
  35. $_path = $this->request->param('path/s', '');
  36. $_rdata = (new ShareOut())->getShareInfo($this->mem_id, $_game_rq->getHAppId(), $_path, $_device_rq);
  37. $this->returnData($_rdata);
  38. }
  39. /**
  40. * 分享上报
  41. * http://doc.1tsdk.com/159?page_id=4468
  42. * 【域名】/mp/share/add
  43. */
  44. public function add() {
  45. $_share_id = get_val($this->rq_data, 'share_id', 0);
  46. $_to_target = get_val($this->rq_data, 'to_target', '');
  47. $_more = get_val($this->rq_data, 'more', '');
  48. $_rdata = (new ShareOut())->upShare($_share_id, $_to_target, $_more);
  49. $this->returnData($_rdata);
  50. }
  51. /**
  52. * 获取二维码
  53. * http://doc.1tsdk.com/159?page_id=4471
  54. * 【域名】/mp/share/qrcode
  55. */
  56. public function getQrCode() {
  57. $_game_rq = $this->setGameData();
  58. $_path = get_val($this->rq_data, 'path', '');
  59. $_width = get_val($this->rq_data, 'width', 430);
  60. $_a_color = get_val($this->rq_data, 'auto_color', 1);
  61. $_line_color = get_val($this->rq_data, 'line_color', '{"r":"0","g":"0","b":"0"}');
  62. $_hyaline = get_val($this->rq_data, 'is_hyaline', 1);
  63. $_auto_color = false;
  64. $_is_hyaline = false;
  65. if (2 == $_a_color) {
  66. $_auto_color = true;
  67. }
  68. if (2 == $_hyaline) {
  69. $_is_hyaline = true;
  70. }
  71. $_rdata = (new QrCodeOut())->getQrCode(
  72. $this->mem_id, $_game_rq->getHAppId(), $_path, $_width, $_auto_color, $_line_color, $_is_hyaline
  73. );
  74. $this->returnData($_rdata);
  75. }
  76. }