DiypageController.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <?php
  2. namespace app\index\controller;
  3. use think\exception\ValidateException;
  4. use app\model\DiyPage;
  5. use app\model\Coupon;
  6. use app\model\CouponReceive;
  7. use app\model\Config;
  8. use app\model\Goods;
  9. use app\model\TuanGoods;
  10. use app\model\MiaoshaGoods;
  11. use app\model\Technical;
  12. use app\model\Tuanzhang;
  13. use app\model\Store;
  14. use app\model\DiyPageLink;
  15. class DiypageController extends Base
  16. {
  17. public function indexv2()
  18. {
  19. $id = input('get.id', '', 'intval');
  20. $where['weid'] = weid();
  21. $where['version'] = '2';
  22. $Configdata = Config::getconfig();
  23. $Configdata['kefu'] = Config::getconfig('kefu');
  24. $Configdata['tuanzhang'] = Config::getconfig('tuanzhang');
  25. $pagestyleconfig = Config::getconfig('pagestyle');
  26. $ocid = $this->userInfo['cityinfo']['ocid'];
  27. if (\app\model\Uploadminiprogram::getaudit(input('get.v', '', 'serach_in'))) {
  28. $DiyPage = DiyPage::where($where)->order('is_submitaudit desc')->find();
  29. }
  30. if (empty($DiyPage)) {
  31. if (!empty($id)) {
  32. $where['id'] = $id;
  33. }
  34. $DiyPage = DiyPage::where($where)->order('is_index desc')->find();
  35. }
  36. if (!empty($DiyPage)) {
  37. $DiyPage = $DiyPage->toArray();
  38. $uid = UID();
  39. $data['pagebase'] = iunserializer($DiyPage['pagebase'])[0];
  40. if ($data['pagebase']['base']['Bottommenutype']) {
  41. $this->userInfo['Bottommenutype'] = $data['pagebase']['base']['Bottommenutype'];
  42. $this->setAppToken($this->userInfo, $this->getAppToken());
  43. } else {
  44. $this->userInfo['Bottommenutype'] = '';
  45. $this->setAppToken($this->userInfo, $this->getAppToken());
  46. }
  47. $data['modulelist'] = iunserializer($DiyPage['modulelist']);
  48. if ($data['pagebase']['base']['bg'] == 1) {
  49. $data['pagebase']['base']['bgstyle'] = 'background:#f7f7f7;';
  50. } elseif ($data['pagebase']['base']['bg'] == 2) {
  51. $data['pagebase']['base']['bgstyle'] = 'background:none;';
  52. } elseif ($data['pagebase']['base']['bg'] == 3) {
  53. if ($data['pagebase']['base']['bt'] == 1) {
  54. $data['pagebase']['base']['bgstyle'] = 'background:' . $data['pagebase']['base']['bc'] . ';';
  55. } else if ($data['pagebase']['base']['bt'] == 2 && $data['pagebase']['base']['bi'] != '') {
  56. $data['pagebase']['base']['bgstyle'] = 'background:url(' . $data['pagebase']['base']['bi'] . ') no-repeat 0px 0px;background-size:100%;';
  57. }
  58. }
  59. $data['pagebase']['sdv'] = Author()::getlan();
  60. if ($data['pagebase']['base']['titleBackground']['bg'] == 1) {
  61. $data['pagebase']['base']['titleBackground']['bgstyle'] = 'background:#f7f7f7;';
  62. } elseif ($data['pagebase']['base']['titleBackground']['bg'] == 2) {
  63. $data['pagebase']['base']['titleBackground']['bgstyle'] = 'background:none;';
  64. } elseif ($data['pagebase']['base']['titleBackground']['bg'] == 3) {
  65. if ($data['pagebase']['base']['titleBackground']['bt'] == 1) {
  66. $data['pagebase']['base']['titleBackground']['bgstyle'] = 'background:' . $data['pagebase']['base']['titleBackground']['bc'] . ';';
  67. } else if ($data['pagebase']['base']['titleBackground']['bt'] == 2 && $data['pagebase']['base']['titleBackground']['bi'] != '') {
  68. $data['pagebase']['base']['titleBackground']['bgstyle'] = 'background:url(' . $data['pagebase']['base']['titleBackground']['bi'] . ') no-repeat 0px 0px;background-size:100%;';
  69. }
  70. }
  71. $data['pagebase']['sdvc'] = Author()::getlan();
  72. foreach ($data['modulelist'] as &$vo) {
  73. $vo = Author()::setdiymodulebase($vo);
  74. if ($vo['type'] == 'banner') {
  75. $vo['swiperHeight'] = 123;
  76. foreach ($vo['list'] as &$vvo) {
  77. $vvo['img'] = toimg($vvo['img']);
  78. }
  79. }
  80. if ($vo['type'] == 'navBar') {
  81. foreach ($vo['list'] as &$vvo) {
  82. $vvo['icon']['custompic'] = toimg($vvo['icon']['custompic']);
  83. }
  84. }
  85. if ($vo['type'] == 'window' && $vo['style']['layout'] == '-1') {
  86. $ii = 0;
  87. foreach ($vo['list'] as $vvo) {
  88. $windowdata[$ii] = $vvo;
  89. $ii++;
  90. }
  91. $vo['list'] = $windowdata;
  92. }
  93. if ($vo['type'] == 'goods') {
  94. if (!empty($vo['title']['link'])) {
  95. $vo['title']['link'] = DiyPageLink::setlink($vo['title']['link']);
  96. }
  97. $vo = Author()::setdiymodulecolumn($vo, $pagestyleconfig);
  98. if ($vo['base']['source'] == 'auto') {
  99. if (!empty($vo['base']['is_area'])) {
  100. $goodsocid = $ocid;
  101. }
  102. $vo['list'] = Goods::getGoodsBycat([
  103. 'cat' => $vo['base']['auto']['category'],
  104. 'count' => $vo['base']['auto']['showNum'],
  105. 'goodsSort' => $vo['base']['auto']['goodsSort'],
  106. 'ptype' => $vo['base']['auto']['ptype'],
  107. 'ocid' => $goodsocid
  108. ]);
  109. } else {
  110. foreach ($vo['list'] as &$vvo1) {
  111. $gdata = Goods::where(['weid' => weid()])->where('ptype','>', 0)->where('status', 1)->where('id', $vvo1['cm']['id'])->select()->toArray()[0];
  112. if (empty($gdata)) {
  113. $vvo1 = [];
  114. } else {
  115. $vvo1 = $gdata;
  116. }
  117. }
  118. $vo['list'] = Goods::setGoodslist($vo['list']);
  119. }
  120. }
  121. if ($vo['type'] == 'tuan') {
  122. $vo = Author()::setdiymodulecolumn($vo, $pagestyleconfig);
  123. if ($vo['base']['source'] == 'auto') {
  124. if (!empty($vo['base']['is_area'])) {
  125. $tuanocid = $ocid;
  126. }
  127. $vo['list'] = TuanGoods::getDiyTuanGoods($vo['base']['auto']['showNum'], $vo['base']['auto']['goodsSort'], $tuanocid);
  128. } else {
  129. foreach ($vo['list'] as &$vvo1) {
  130. $gdata = TuanGoods::where(['weid' => weid()])->where('status', 1)->where('id', $vvo1['cm']['id'])->select()->toArray()[0];
  131. if (empty($gdata)) {
  132. $vvo1 = [];
  133. } else {
  134. $vvo1 = $gdata;
  135. }
  136. }
  137. }
  138. $vo['list'] = TuanGoods::setGoodslist($vo['list']);
  139. }
  140. if ($vo['type'] == 'miaosha') {
  141. $vo = Author()::setdiymodulecolumn($vo, $pagestyleconfig);
  142. if ($vo['base']['source'] == 'auto') {
  143. if (!empty($vo['base']['is_area'])) {
  144. $miaoshaocid = $ocid;
  145. }
  146. $vo['list'] = MiaoshaGoods::getDiyMiaoshaGoods($vo['base']['auto']['showNum'], $vo['base']['auto']['goodsSort'], $miaoshaocid);
  147. } else {
  148. foreach ($vo['list'] as &$vvo1) {
  149. $gdata = MiaoshaGoods::where(['weid' => weid()])->where('status', 1)->where('id', $vvo1['cm']['id'])->select()->toArray()[0];
  150. if (empty($gdata)) {
  151. $vvo1 = [];
  152. } else {
  153. $vvo1 = $gdata;
  154. }
  155. }
  156. }
  157. $vo['list'] = MiaoshaGoods::setGoodslist($vo['list']);
  158. }
  159. if ($vo['type'] == 'goodscard') {
  160. $vo = Author()::setdiymodulecolumn($vo, $pagestyleconfig);
  161. $tzid = tzid();
  162. if ($tzid) {
  163. $sid = Store::getidbytzid($tzid);
  164. if (!empty($sid)) {
  165. $vo['list'] = Goods::where(['weid' => weid(), 'is_times' => 3, 'sid' => $sid])->where('status', 1)->limit($vo['base']['auto']['showNum'])->select()->toArray();
  166. $vo['list'] = Goods::setGoodslist($vo['list']);
  167. }
  168. }
  169. }
  170. if ($vo['type'] == 'technical') {
  171. $vo = Author()::setdiymoduletechcolumn($vo, $pagestyleconfig);
  172. if ($vo['base']['source'] == 'auto') {
  173. if (!empty($vo['base']['is_area'])) {
  174. $technicalocid = $ocid;
  175. }
  176. $vo['list'] = Technical::getdiy_bycat($vo['base']['auto']['category'], $vo['base']['auto']['showNum'], $vo['base']['auto']['Sort'], $technicalocid);
  177. } else {
  178. foreach ($vo['list'] as &$vvo1) {
  179. $gdata = Technical::where(['weid' => weid()])->where('status', 1)->where('id', $vvo1['cm']['id'])->select()->toArray()[0];
  180. if (empty($gdata)) {
  181. $vvo1 = [];
  182. } else {
  183. $vvo1 = $gdata;
  184. }
  185. }
  186. }
  187. foreach ($vo['list'] as &$vvo) {
  188. if ($vvo['touxiang']) {
  189. $vvo['touxiang'] = toimg($vvo['touxiang']);
  190. }
  191. }
  192. }
  193. if ($vo['type'] == 'store') {
  194. $vo = Author()::setdiymoduletechcolumn($vo, $pagestyleconfig);
  195. if ($vo['base']['source'] == 'auto') {
  196. if (!empty($vo['base']['is_area'])) {
  197. $storeocid = $ocid;
  198. }
  199. $vo['list'] = Store::getdiy_bycat($vo['base']['auto']['category'], $vo['base']['auto']['showNum'], $vo['base']['auto']['Sort'], $storeocid);
  200. } else {
  201. foreach ($vo['list'] as &$vvo1) {
  202. $gdata = Store::where(['weid' => weid()])->where('status', 1)->where('id', $vvo1['cm']['id'])->select()->toArray()[0];
  203. if (empty($gdata)) {
  204. $vvo1 = [];
  205. } else {
  206. $vvo1 = $gdata;
  207. }
  208. }
  209. }
  210. foreach ($vo['list'] as &$vvo) {
  211. if ($vvo['touxiang']) {
  212. $vvo['touxiang'] = toimg($vvo['touxiang']);
  213. }
  214. }
  215. }
  216. if ($vo['type'] == 'search') {
  217. if (!empty($vo['params']['hotkey'])) {
  218. $vo['params']['hotkey'] = explode(" ", $vo['params']['hotkey']);
  219. }
  220. if ($data['items']['page']['style']['titleBackgroundColor'] == '#ffffff') {
  221. $vo['style']['background'] = '#f7f7f7';
  222. $vo['style']['hotkeytxtColor'] = '#666666';
  223. } else {
  224. $vo['style']['background'] = $data['items']['page']['style']['titleBackgroundColor'];
  225. $vo['style']['hotkeytxtColor'] = '#ffffff';
  226. }
  227. }
  228. if ($vo['base']['paddingTop']) {
  229. $vo['base']['bgstyle'] .= 'padding-top:' . $vo['base']['paddingTop'] . 'px;';
  230. }
  231. if ($vo['base']['paddingBottom']) {
  232. $vo['base']['bgstyle'] .= 'padding-bottom:' . $vo['base']['paddingBottom'] . 'px;';
  233. }
  234. if ($vo['base']['paddingLeft']) {
  235. $vo['base']['bgstyle'] .= 'padding-left:' . $vo['base']['paddingLeft'] . 'px;' . 'padding-right:' . $vo['base']['paddingLeft'] . 'px;';
  236. }
  237. if ($vo['base']['marginTop']) {
  238. $vo['base']['bgstyle'] .= 'margin-top:' . $vo['base']['marginTop'] . 'px;';
  239. }
  240. if ($vo['base']['marginBottom']) {
  241. $vo['base']['bgstyle'] .= 'margin-bottom:' . $vo['base']['marginBottom'] . 'px;';
  242. }
  243. if ($vo['type'] == 'coupon') {
  244. $coupondata = Coupon::where(['weid' => weid(), 'ptype' => 1])
  245. ->limit($vo['max'])
  246. ->select()
  247. ->toArray();
  248. foreach ($coupondata as $cvo) {
  249. $cdata[$cvo['id']]['coupon_id'] = $cvo['id'];
  250. $cdata[$cvo['id']]['color'] = $cvo['color'];
  251. $cdata[$cvo['id']]['coupon_type'] = $cvo['coupon_type'];
  252. $cdata[$cvo['id']]['discount'] = $cvo['discount'];
  253. $cdata[$cvo['id']]['reduce_price'] = $cvo['reduce_price'];
  254. $cdata[$cvo['id']]['min_price'] = $cvo['min_price'];
  255. $cdata[$cvo['id']]['state'] = CouponReceive::getReceiveState($cvo['id'], $uid);
  256. }
  257. $vo['list'] = $cdata;
  258. }
  259. if (!empty($vo['list'])) {
  260. foreach ($vo['list'] as &$vvo1) {
  261. if (!empty($vvo1['link'])) {
  262. $vvo1['link'] = DiyPageLink::setlink($vvo1['link']);
  263. }
  264. }
  265. }
  266. if (!empty($vo['link'])) {
  267. $vo['link'] = DiyPageLink::setlink($vo['link']);
  268. }
  269. }
  270. }
  271. $Configdata['SITE_ICON'] = toimg($data['SITE_ICON']);
  272. $Configdata['poster'] = toimg($data['poster']);
  273. $Configdata['applypic'] = toimg($data['applypic']);
  274. $data['config'] = $Configdata;
  275. $data['ocid'] = $ocid;
  276. return $this->json(['data' => $data]);
  277. }
  278. }