ShareWidget.class.php 10 KB

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