WeappShare.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\groupbuy\model\share;
  11. use app\model\share\WeappShareBase;
  12. use app\model\system\Config as ConfigModel;
  13. /**
  14. * 分享
  15. */
  16. class WeappShare extends WeappShareBase
  17. {
  18. protected $config = [
  19. [
  20. 'title' => '团购专区列表',
  21. 'config_key' => 'WEAPP_SHARE_CONFIG_GROUPBUY_LIST',
  22. 'path' => [ '/pages_promotion/groupbuy/list' ],
  23. 'method_prefix' => 'groupbuyList',
  24. ],
  25. ];
  26. protected $sort = 5;
  27. /**
  28. * 团购专区列表
  29. * @param $param
  30. * @return array
  31. */
  32. protected function groupbuyListShareData($param)
  33. {
  34. //获取和替换配置数据
  35. $config_data = $this->groupbuyListShareConfig($param);
  36. $title = $config_data[ 'value' ][ 'title' ];
  37. $image_url = $config_data[ 'value' ][ 'imageUrl' ] ? img($config_data[ 'value' ][ 'imageUrl' ]) : '';
  38. $path = $this->getSharePath($param);
  39. $data = [
  40. 'title' => $title,
  41. 'path' => $path,
  42. 'imageUrl' => $image_url,
  43. ];
  44. return [
  45. 'permission' => [
  46. 'onShareAppMessage' => true,
  47. 'onShareTimeline' => true,
  48. ],
  49. 'data' => $data,//分享内容
  50. ];
  51. }
  52. /**
  53. * 团购专区列表
  54. * @param $param
  55. * @return array
  56. */
  57. protected function groupbuyListShareConfig($param)
  58. {
  59. $site_id = $param[ 'site_id' ];
  60. $config = $param[ 'config' ];
  61. $config_model = new ConfigModel();
  62. $data = $config_model->getConfig([
  63. [ 'site_id', '=', $site_id ],
  64. [ 'app_module', '=', 'shop' ],
  65. [ 'config_key', '=', $config[ 'config_key' ] ],
  66. ])[ 'data' ];
  67. if (empty($data[ 'value' ])) {
  68. $data[ 'value' ] = [
  69. 'title' => '跟我一起来团购吧!',
  70. 'imageUrl' => '',
  71. ];
  72. }
  73. $variable = [];
  74. return [
  75. 'value' => $data[ 'value' ],
  76. 'variable' => $variable,
  77. ];
  78. }
  79. }