SpecInfoWidget.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Name: 芸众商城系统
  5. * Author: 广州市芸众信息科技有限公司
  6. * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
  7. * Date: 2021/12/10
  8. * Time: 14:09
  9. */
  10. namespace app\backend\modules\goods\widget;
  11. use app\backend\modules\goods\models\GoodsOption;
  12. use app\common\models\goods\GoodsSpecInfo;
  13. class SpecInfoWidget extends BaseGoodsWidget
  14. {
  15. public $group = 'base';
  16. public $widget_key = 'spec_info';
  17. public $code = 'spec_info';
  18. public function pluginFileName()
  19. {
  20. return 'spec_info';
  21. }
  22. /**
  23. * 权限判断
  24. * @return boolean
  25. */
  26. public function usable()
  27. {
  28. if (in_array($this->goods->plugin_id,[0,92])) {
  29. return true;
  30. }
  31. return false;
  32. }
  33. public function getData()
  34. {
  35. $specs_info = [];
  36. $options = [];
  37. if (!is_null($this->goods)) {
  38. if ($this->goods->has_option) {
  39. $options = GoodsOption::uniacid()
  40. ->select('id','title')
  41. ->where('goods_id',$this->goods->id)
  42. ->get()->toArray();
  43. }
  44. $specs_info = GoodsSpecInfo::uniacid()
  45. ->where('goods_id',$this->goods->id)
  46. ->get()->toArray();
  47. }
  48. return [
  49. 'options'=> $options,
  50. 'specs_info'=> $specs_info,
  51. ];
  52. }
  53. public function pagePath()
  54. {
  55. return $this->getPath('resources/views/goods/assets/js/components/');
  56. }
  57. }