Ajax.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | A3Mall
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: xzncit <158373108@qq.com>
  8. // +----------------------------------------------------------------------
  9. namespace app\admin\controller\common;
  10. use app\admin\controller\Auth;
  11. use mall\response\Response;
  12. use think\facade\Request;
  13. use think\facade\View;
  14. use app\admin\service\users\Users as UsersService;
  15. use app\admin\service\products\Goods as GoodsService;
  16. use app\admin\service\products\Area as AreaService;
  17. use app\admin\service\products\Attribute as AttributeService;
  18. use app\admin\service\products\Model as ModelService;
  19. class Ajax extends Auth {
  20. /**
  21. * 获取未成为分销会员列表
  22. * @return string|\think\response\Json
  23. * @throws \think\db\exception\DataNotFoundException
  24. * @throws \think\db\exception\DbException
  25. * @throws \think\db\exception\ModelNotFoundException
  26. */
  27. public function get_users(){
  28. if(Request::isAjax()){
  29. $list = UsersService::getList(Request::param(),["users.is_spread"=>0]);
  30. return Response::returnArray("ok",0,$list['data'],$list['count']);
  31. }
  32. return View::fetch("common/get_users",UsersService::getSearchData());
  33. }
  34. /**
  35. * 获取商品列表
  36. * @return string|\think\response\Json
  37. * @throws \think\db\exception\DataNotFoundException
  38. * @throws \think\db\exception\DbException
  39. * @throws \think\db\exception\ModelNotFoundException
  40. */
  41. public function get_goods(){
  42. if(Request::isAjax()){
  43. $list = GoodsService::getList(Request::param(),"");
  44. return Response::returnArray("ok",0,$list["data"],$list["count"]);
  45. }
  46. return View::fetch("common/get_goods",GoodsService::getSearchData());
  47. }
  48. /**
  49. * 获取商品规格
  50. * @return \think\response\Json
  51. */
  52. public function get_goods_data(){
  53. try{
  54. return Response::returnArray("ok",1,GoodsService::getGoodsItemData(Request::param("id",0,"intval")));
  55. }catch (\Exception $ex){
  56. return Response::returnArray($ex->getMessage(),0);
  57. }
  58. }
  59. /**
  60. * 获取商品列表
  61. * @return string|\think\response\Json
  62. * @throws \think\db\exception\DataNotFoundException
  63. * @throws \think\db\exception\DbException
  64. * @throws \think\db\exception\ModelNotFoundException
  65. */
  66. public function get_goods_list(){
  67. if(Request::isAjax()){
  68. $list = GoodsService::getList(Request::param(),"");
  69. return Response::returnArray("ok",0,$list["data"],$list["count"]);
  70. }
  71. return View::fetch("common/get_goods_list",GoodsService::getSearchData());
  72. }
  73. /**
  74. * 获取商品列表
  75. * @return \think\response\Json
  76. */
  77. public function get_goods_list_data(){
  78. try{
  79. $result = GoodsService::getGoodsListData(Request::param("id", "0","trim,strip_tags"));
  80. $html = View::fetch("common/get_goods_list_data",[ "data"=>$result["data"] ]);
  81. return Response::returnArray("ok",1,[ "content"=>$html, "goods_id"=>implode(",",$result["goods_id"]) ]);
  82. }catch (\Exception $ex){
  83. return Response::returnArray($ex->getMessage(),0);
  84. }
  85. }
  86. /**
  87. * 获取省级地区列表
  88. * @return \think\response\Json
  89. * @throws \think\db\exception\DataNotFoundException
  90. * @throws \think\db\exception\DbException
  91. * @throws \think\db\exception\ModelNotFoundException
  92. */
  93. public function get_area(){
  94. return Response::returnArray('ok',1,AreaService::getArea(Request::get("id","0","intval")));
  95. }
  96. /**
  97. * 获取所有地址信息
  98. * @return string
  99. * @throws \think\db\exception\DataNotFoundException
  100. * @throws \think\db\exception\DbException
  101. * @throws \think\db\exception\ModelNotFoundException
  102. */
  103. public function get_distribution(){
  104. return View::fetch('common/get_distribution',AreaService::getDistribution());
  105. }
  106. /**
  107. * 获取规格
  108. * @return \think\response\Json
  109. */
  110. public function get_attr(){
  111. $attribute = AttributeService::getAttr(Request::param());
  112. $html = View::fetch("common/get_attr",[ "spec_checked"=>$attribute["spec_checked"],"result"=>$attribute["result"] ]);
  113. return Response::returnArray("ok",1,$html);
  114. }
  115. /**
  116. * 生成规格数据
  117. * @return \think\response\Json
  118. */
  119. public function get_attr_data(){
  120. try{
  121. $html = View::fetch("common/get_attr_data",AttributeService::getAttrData(Request::param()));
  122. return Response::returnArray("ok", 1, $html);
  123. }catch (\Exception $ex){
  124. return Response::returnArray("ok", 1,"");
  125. }
  126. }
  127. /**
  128. * 获取商品参数
  129. * @return \think\response\Json
  130. */
  131. public function get_model(){
  132. try{
  133. $html = View::fetch("common/get_model",ModelService::getModel(Request::param()));
  134. return Response::returnArray("ok",1,$html);
  135. }catch (\Exception $ex){
  136. return Response::returnArray($ex->getMessage(),0);
  137. }
  138. }
  139. /**
  140. * 获取门店核销会员
  141. * @return string|\think\response\Json
  142. * @throws \think\db\exception\DataNotFoundException
  143. * @throws \think\db\exception\DbException
  144. * @throws \think\db\exception\ModelNotFoundException
  145. */
  146. public function get_shop_users(){
  147. if(Request::isAjax()){
  148. $list = UsersService::getList(Request::param());
  149. return Response::returnArray("ok",0,$list['data'],$list['count']);
  150. }
  151. return View::fetch("common/get_shop_users",UsersService::getSearchData());
  152. }
  153. }