轻源码

  • QingYuanMa.com
  • 全球最大的互联网技术和资源下载平台
搜索
一起源码网 门户 微信小程序 查看主题

微信小程序商城 - 基于ecshop插件接口文件

发布者: sunshusunshu | 发布时间: 2018-5-15 02:29| 查看数: 4481| 评论数: 1|帖子模式

作者:lch198548,来自原文地址 
ECSHOP 小程序接口 
整个接口基于THINKPHP5开发 
部分文件目录

分类接口源码:

  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class Category extends Model
  5. {
  6. protected static $allChildrenIds = [];
  7. public function getChildrenIds($cat_id,$include = 1){
  8. if(empty($cat_id)){
  9. return [];
  10. }
  11. if(is_int($cat_id) || is_string($cat_id)){
  12. $cat_id = [$cat_id];
  13. }
  14. $cat_id = array_unique($cat_id);
  15. sort($cat_id);
  16. $cat_id_str = implode('_', $cat_id);
  17. if(isset(self::$allChildrenIds[$cat_id_str])){
  18. return self::$allChildrenIds[$cat_id_str];
  19. }
  20. $catIds = [];
  21. $childrenIds = $cat_id;
  22. if($include == 1){
  23. $catIds = $cat_id;
  24. }
  25. while($childrenIds){
  26. $childrenIds = $this->where(['parent_id' => ['in',$childrenIds]])->column('cat_id');
  27. if(!empty($childrenIds)){
  28. $catIds = array_merge($catIds,$childrenIds);
  29. }
  30. }
  31. self::$allChildrenIds[$cat_id_str] = $catIds;
  32. return $catIds;
  33. }
  34. public function getChildrenList($cat_id = 0){
  35. $categoryList = $this->field('cat_id,cat_name')->where(['parent_id' => $cat_id,'is_show' => 1])->order('sort_order desc')->select();
  36. foreach($categoryList as &$category){
  37. if($cat_id){
  38. $category['cat_url'] = $this->getUrl($category['cat_id']);
  39. }
  40. }
  41. return $categoryList;
  42. }
  43. public function getUrl($cat_id) {
  44. return '../category/goods?cat_id=' . $cat_id;
  45. }
  46. }

查看ECSHOP小程序演示(微信扫一扫) 

最新评论

zonejiang 发表于 2022-6-15 17:15
源代码链接

浏览过的版块

轻源码让程序更轻更快

QingYuanMa.com

工作时间 周一至周六 8:00-17:30

侵权处理

客服QQ点击咨询

关注抖音号

定期抽VIP

Copyright © 2016-2021 https://www.171739.xyz/ 滇ICP备13200218号

快速回复 返回顶部 返回列表