ShareWidget.class.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <?php
  2. /**
  3. * 狮子鱼社区团购系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Home\Widget;
  15. use Think\Controller;
  16. /**
  17. * 微信分享
  18. */
  19. class ShareWidget extends Controller{
  20. public $data;
  21. public $signPackage;
  22. protected function _initialize(){
  23. $data = M('Config')->select();
  24. $config = array();
  25. if($data && is_array($data)){
  26. foreach ($data as $value) {
  27. $config[$value['name']] =$value['value'];
  28. }
  29. }
  30. $this->data = $config;
  31. $appid_info = M('config')->where( array('name' => 'APPID') )->find();
  32. $appsecret_info = M('config')->where( array('name' => 'APPSECRET') )->find();
  33. $mchid_info = M('config')->where( array('name' => 'MCHID') )->find();
  34. $weixin_config = array();
  35. $weixin_config['appid'] = $appid_info['value'];
  36. $weixin_config['appscert'] = $appsecret_info['value'];
  37. $weixin_config['mchid'] = $mchid_info['value'];
  38. $jssdk = new \Lib\Weixin\Jssdk( $weixin_config['appid'], $weixin_config['appscert']);
  39. $signPackage = $jssdk->GetSignPackage();
  40. $this->signPackage = $signPackage;
  41. }
  42. function common_special_share($special_id)
  43. {
  44. $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
  45. $member_id = is_login();
  46. $hash_member_id = $hashids->encode($member_id);
  47. $special_info = M('mb_special')->where( array('special_id' => $special_id) )->find();
  48. $this->share_logo = $this->data['SITE_URL'].'Uploads/image/'.$this->data['SITE_ICON'];
  49. if(!empty($special_info['share_image']))
  50. {
  51. $this->share_logo = $this->data['SITE_URL'].'Uploads/image/'.$special_info['share_image'];
  52. }
  53. $this->indexsharetitle = $special_info['special_desc'];
  54. if(!empty($special_info['share_title']))
  55. {
  56. $this->indexsharetitle = $special_info['share_title'];
  57. }
  58. $this->url = $this->data['SITE_URL']."/index.php?s=/Special/index/special_id/{$special_id}/rmid/{$hash_member_id}";
  59. $this->indexsharesummary = $this->data['SITE_DESCRIPTION'];
  60. if(!empty($special_info['share_descript']))
  61. {
  62. $this->indexsharesummary = $special_info['share_descript'];
  63. }
  64. $this->assign('signPackage',$this->signPackage);
  65. $this->display('Widget:share_common_weixin');
  66. }
  67. function common_bargain_share($id)
  68. {
  69. $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
  70. $member_id = is_login();
  71. $hash_member_id = $hashids->encode($member_id);
  72. $bargain_order = M('bargain_order')->where( array('id' => $id) )->find();
  73. $goods_id = $bargain_order['goods_id'];
  74. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  75. //"我正在参加拼多多官方砍价,砍到0元就可以免费拿啦,帮我砍一下吧"
  76. $desc = "我正在参加".C('SITE_NAME')."砍价,砍到0元就可以免费拿啦,帮我砍一下吧";
  77. $this->share_logo = $this->data['SITE_URL'].resize($goods_info['image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  78. if(!empty($goods_info['fan_image'])){
  79. $this->share_logo = $this->data['SITE_URL'].resize($goods_info['fan_image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  80. }else {
  81. $this->share_logo = $this->data['SITE_URL'].resize($goods_info['image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  82. }
  83. if(!empty($goods_description['water_image']))
  84. {
  85. $this->share_logo = $this->data['SITE_URL'].'/Uploads/image/'.$goods_description['water_image'];
  86. }
  87. //Subject/assist_bargain_coupon_detail/id/10.html
  88. $this->indexsharetitle = '['.C('SITE_NAME')."]我在砍价免费拿".$goods_info['name'].",帮我砍价,0元拿回家!";
  89. $this->url = $this->data['SITE_URL']."/index.php?s=/Subject/assist_bargain_coupon_detail/id/{$id}/rmid/{$hash_member_id}";
  90. $this->indexsharesummary = $desc;
  91. //goods_id
  92. $this->assign('signPackage',$this->signPackage);
  93. $this->display('Widget:share_common_weixin');
  94. }
  95. function common_bargain_index_share()
  96. {
  97. $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
  98. $member_id = is_login();
  99. $hash_member_id = $hashids->encode($member_id);
  100. $this->share_logo = $this->data['SITE_URL'].'Uploads/image/'.$this->data['SITE_ICON'];
  101. $this->indexsharetitle = '['.C('SITE_NAME')."]快来玩砍价,马上被抢完啦";
  102. $this->url = $this->data['SITE_URL']."/index.php?s=/Subject/assist_bargain_coupon/rmid/{$hash_member_id}";
  103. $this->indexsharesummary = "呼朋唤友来砍价,心仪好货免费拿回家";
  104. $this->assign('signPackage',$this->signPackage);
  105. $this->display('Widget:share_common_weixin');
  106. }
  107. function common_goods_share($goods_id)
  108. {
  109. $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
  110. $member_id = is_login();
  111. $hash_member_id = $hashids->encode($member_id);
  112. $share_model = D('Seller/Fissionsharing');
  113. $link_info = $share_model->get_sharing_type_info($member_id,'goods',$goods_id);
  114. $share_param = "goods_{$goods_id}_{$member_id}_{$link_info[share_one_id]}_{$link_info[share_two_id]}_".time();
  115. $hash_share_param = base64_encode($share_param);
  116. $goods_info = M('goods')->where( array('goods_id' => $goods_id) )->find();
  117. $goods_description = M('goods_description')->where( array('goods_id' => $goods_id) )->find();
  118. $this->share_logo = $this->data['SITE_URL'].resize($goods_info['image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  119. if(!empty($goods_info['fan_image'])){
  120. $this->share_logo = $this->data['SITE_URL'].resize($goods_info['fan_image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  121. }else {
  122. $this->share_logo = $this->data['SITE_URL'].resize($goods_info['image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  123. }
  124. if(!empty($goods_description['water_image']))
  125. {
  126. $this->share_logo = $this->data['SITE_URL'].'/Uploads/image/'.$goods_description['water_image'];
  127. }
  128. $this->indexsharetitle = $goods_info['name'];
  129. if(!empty($goods_description['share_title']))
  130. {
  131. $this->indexsharetitle = $goods_description['share_title'];
  132. }
  133. $this->url = $this->data['SITE_URL']."/index.php?s=/Goods/gshow/id/{$goods_id}/rmid/{$hash_member_id}/share_rmid/".$hash_share_param;;
  134. $str = str_replace(array("/r/n", "/r", "/n"), "", $goods_description['summary']);
  135. $qian=array("\t","\n","\r");
  136. $hou=array("","","");
  137. $goods_description['summary'] = str_replace($qian,$hou,$goods_description['summary']);
  138. $this->indexsharesummary = $goods_description['summary'];
  139. if(!empty($goods_description['share_descript']))
  140. {
  141. $this->indexsharesummary = $goods_description['share_descript'];
  142. }
  143. $this->assign('signPackage',$this->signPackage);
  144. $this->display('Widget:share_common_weixin');
  145. }
  146. function common_quan_share($voucher_id)
  147. {
  148. $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
  149. $member_id = is_login();
  150. $hash_member_id = $hashids->encode($member_id);
  151. $share_model = D('Seller/Fissionsharing');
  152. $link_info = $share_model->get_sharing_type_info($member_id,'page',0);
  153. $share_param = "page_0_{$member_id}_{$link_info[share_one_id]}_{$link_info[share_two_id]}_".time();
  154. $hash_share_param = base64_encode($share_param);
  155. $voucher_info = M('voucher')->where( array('id' => $voucher_id) )->find();
  156. $this->share_logo = $this->data['SITE_URL'].resize($voucher_info['share_logo'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  157. $this->indexsharetitle = $voucher_info['share_title'];
  158. $this->url = $this->data['SITE_URL']."/index.php?s=/Bonus/index/id/{$voucher_id}/rmid/{$hash_member_id}/share_rmid/".$hash_share_param;;
  159. $str = str_replace(array("/r/n", "/r", "/n"), "", $voucher_info['share_desc']);
  160. $qian=array("\t","\n","\r");
  161. $hou=array("","","");
  162. $voucher_info['share_desc'] = str_replace($qian,$hou,$voucher_info['share_desc']);
  163. $this->indexsharesummary = $voucher_info['share_desc'];
  164. $this->assign('signPackage',$this->signPackage);
  165. $this->display('Widget:share_common_weixin_quan');
  166. }
  167. function common_pin_share()
  168. {
  169. $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
  170. $member_id = is_login();
  171. $hash_member_id = $hashids->encode($member_id);
  172. $share_model = D('Seller/Fissionsharing');
  173. $link_info = $share_model->get_sharing_type_info($member_id,'page',0);
  174. // pingoods/index.html
  175. $share_param = "page_0_{$member_id}_{$link_info[share_one_id]}_{$link_info[share_two_id]}_".time();
  176. $hash_share_param = base64_encode($share_param);
  177. $this->share_logo = $this->data['SITE_URL'].'Uploads/image/'.$this->data['SITE_ICON'];
  178. $this->indexsharetitle = $this->data['SITE_TITLE'];
  179. $this->url = $this->data['SITE_URL']."index.php?s=/pingoods/index/rmid/{$hash_member_id}/share_rmid/".$hash_share_param;
  180. $this->indexsharesummary = $this->data['SITE_DESCRIPTION'];
  181. $this->assign('signPackage',$this->signPackage);
  182. $this->display('Widget:share_common_weixin');
  183. }
  184. function common_share(){
  185. /**
  186. oscshop_fissionsharing_link
  187. id,type(page,goods),goods_id,member_id,share_one_id,share_two_id,share_three_id,modify_time
  188. **/
  189. $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
  190. $member_id = is_login();
  191. $hash_member_id = $hashids->encode($member_id);
  192. $share_model = D('Seller/Fissionsharing');
  193. $link_info = $share_model->get_sharing_type_info($member_id,'page',0);
  194. // $share_param = "goods_{$goods_id}_{$member_id}_{$link_info[share_one_id]}_{$link_info[share_two_id]}";
  195. $share_param = "page_0_{$member_id}_{$link_info[share_one_id]}_{$link_info[share_two_id]}_".time();
  196. $hash_share_param = base64_encode($share_param);
  197. $this->share_logo = $this->data['SITE_URL'].'Uploads/image/'.$this->data['SITE_ICON'];
  198. $this->indexsharetitle = $this->data['SITE_TITLE'];
  199. $this->url = $this->data['SITE_URL']."index.php?s=/index/index/rmid/{$hash_member_id}/share_rmid/".$hash_share_param;
  200. $this->indexsharesummary = $this->data['SITE_DESCRIPTION'];
  201. $this->assign('signPackage',$this->signPackage);
  202. $this->display('Widget:share_common_weixin');
  203. }
  204. }