Site.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. namespace App\Client;
  3. class Site
  4. {
  5. protected $site;
  6. public function __construct()
  7. {
  8. $this->site = app()->make('siteData');
  9. }
  10. /**
  11. * 获取用户id
  12. *
  13. * @return mixed
  14. */
  15. public function getUid()
  16. {
  17. return (int)getProp($this->site, 'uid');
  18. }
  19. /**
  20. * 获取用户channel_id
  21. *
  22. * @return mixed
  23. */
  24. public function getChannelId()
  25. {
  26. return (int)getProp($this->site, 'channel_id');
  27. }
  28. /**
  29. * 获取站点类型
  30. *
  31. * @return mixed
  32. */
  33. public function getChannelType()
  34. {
  35. return (string)getProp($this->site, 'channel_type');
  36. }
  37. /**
  38. * 获取站点充值模板id
  39. *
  40. * @return mixed
  41. */
  42. public function getChannelPayId()
  43. {
  44. return (int)getProp($this->site, 'channel_pay_id');
  45. }
  46. /**
  47. * 获取用户send_order_id
  48. *
  49. * @return mixed
  50. */
  51. public function getSendOrderId()
  52. {
  53. return (int)getProp($this->site, 'send_order_id');
  54. }
  55. /**
  56. * 获取用户from_uid
  57. *
  58. * @return mixed
  59. */
  60. public function getFromUid()
  61. {
  62. return (int)getProp($this->site, 'from_uid');
  63. }
  64. /**
  65. * 获取用户token
  66. *
  67. * @return mixed
  68. */
  69. public function getToken()
  70. {
  71. return (string)getProp($this->site, 'token');
  72. }
  73. /**
  74. * 获取用户account
  75. *
  76. * @return mixed
  77. */
  78. public function getAccount()
  79. {
  80. return (string)getProp($this->site, 'account');
  81. }
  82. /**
  83. * 获取用户phone
  84. *
  85. * @return mixed
  86. */
  87. public function getPhone()
  88. {
  89. return (string)getProp($this->site, 'phone');
  90. }
  91. /**
  92. * 获取用户阅读记录
  93. *
  94. * @return array
  95. */
  96. public function getRecentBooks()
  97. {
  98. return (array)getProp($this->site, 'recent_books');
  99. }
  100. /**
  101. * 获取当前阅读章节
  102. *
  103. * @return array
  104. */
  105. public function getCurrentChapter()
  106. {
  107. return (array)getProp($this->site, 'current_chapter');
  108. }
  109. /**
  110. * 获取当前阅读章节
  111. *
  112. * @return int
  113. */
  114. public function getRecentBid()
  115. {
  116. return (int)getProp($this->site, 'recent_bid');
  117. }
  118. /**
  119. * @return int
  120. */
  121. public function getCurrentChannelId()
  122. {
  123. return (int)getProp($this->site, 'current_channel_id');
  124. }
  125. /**
  126. * @return string
  127. */
  128. public function getCurrentChannelName()
  129. {
  130. return getProp($this->site, 'current_channel_name');
  131. }
  132. /**
  133. * 设置全局返回报错数据
  134. *
  135. * @param $data
  136. */
  137. public function setErrorResponseData($data)
  138. {
  139. $this->site->errorResponseData = $data;
  140. }
  141. /**
  142. * 获取全局返回报错数据
  143. *
  144. * @return mixed|string
  145. */
  146. public function getErrorResponseData()
  147. {
  148. return getProp($this->site, 'errorResponseData', []);
  149. }
  150. }