DiypageController.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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. $vo['list'] = Goods::getGoodsBycat($vo['base']['auto']['category'], $vo['base']['auto']['showNum'], $vo['base']['auto']['goodsSort'], $vo['base']['auto']['ptype'], $ocid);
  100. } else {
  101. foreach ($vo['list'] as &$vvo1) {
  102. $gdata = Goods::where(['weid' => weid()])->where('status', 1)->where('id', $vvo1['cm']['id'])->select()->toArray()[0];
  103. if (empty($gdata)) {
  104. $vvo1 = [];
  105. } else {
  106. $vvo1 = $gdata;
  107. }
  108. }
  109. $vo['list'] = Goods::setGoodslist($vo['list']);
  110. }
  111. }
  112. if ($vo['type'] == 'tuan') {
  113. $vo = Author()::setdiymodulecolumn($vo, $pagestyleconfig);
  114. if ($vo['base']['source'] == 'auto') {
  115. $vo['list'] = TuanGoods::where(['weid' => weid()])->where('status', 1)->limit($vo['base']['auto']['showNum'])->select()->toArray();
  116. } else {
  117. foreach ($vo['list'] as &$vvo1) {
  118. $gdata = TuanGoods::where(['weid' => weid()])->where('status', 1)->where('id', $vvo1['cm']['id'])->select()->toArray()[0];
  119. if (empty($gdata)) {
  120. $vvo1 = [];
  121. } else {
  122. $vvo1 = $gdata;
  123. }
  124. }
  125. }
  126. $vo['list'] = TuanGoods::setGoodslist($vo['list']);
  127. }
  128. if ($vo['type'] == 'miaosha') {
  129. $vo = Author()::setdiymodulecolumn($vo, $pagestyleconfig);
  130. if ($vo['base']['source'] == 'auto') {
  131. $vo['list'] = MiaoshaGoods::where(['weid' => weid()])->where('status', 1)->limit($vo['base']['auto']['showNum'])->select()->toArray();
  132. } else {
  133. foreach ($vo['list'] as &$vvo1) {
  134. $gdata = MiaoshaGoods::where(['weid' => weid()])->where('status', 1)->where('id', $vvo1['cm']['id'])->select()->toArray()[0];
  135. if (empty($gdata)) {
  136. $vvo1 = [];
  137. } else {
  138. $vvo1 = $gdata;
  139. }
  140. }
  141. }
  142. $vo['list'] = MiaoshaGoods::setGoodslist($vo['list']);
  143. }
  144. if ($vo['type'] == 'membergoods') {
  145. $vo = Author()::setdiymodulecolumn($vo, $pagestyleconfig);
  146. $tzid = tzid();
  147. if ($tzid) {
  148. $sid = Store::getidbytzid($tzid);
  149. if (!empty($sid)) {
  150. $vo['list'] = Goods::where(['weid' => weid(), 'is_mg' => 1, 'sid' => $sid])->where('status', 1)->limit($vo['base']['auto']['showNum'])->select()->toArray();
  151. $vo['list'] = Goods::setGoodslist($vo['list']);
  152. }
  153. }
  154. }
  155. if ($vo['type'] == 'technical') {
  156. $vo = Author()::setdiymoduletechcolumn($vo, $pagestyleconfig);
  157. if ($vo['base']['source'] == 'auto') {
  158. $vo['list'] = Technical::getdiy_bycat($vo['base']['auto']['category'], $vo['base']['auto']['showNum'], $vo['base']['auto']['goodsSort']);
  159. } else {
  160. foreach ($vo['list'] as &$vvo1) {
  161. $gdata = Technical::where(['weid' => weid()])->where('status', 1)->where('id', $vvo1['cm']['id'])->select()->toArray()[0];
  162. if (empty($gdata)) {
  163. $vvo1 = [];
  164. } else {
  165. $vvo1 = $gdata;
  166. }
  167. }
  168. }
  169. foreach ($vo['list'] as &$vvo) {
  170. if ($vvo['touxiang']) {
  171. $vvo['touxiang'] = toimg($vvo['touxiang']);
  172. }
  173. }
  174. }
  175. if ($vo['type'] == 'search') {
  176. if (!empty($vo['params']['hotkey'])) {
  177. $vo['params']['hotkey'] = explode(" ", $vo['params']['hotkey']);
  178. }
  179. if ($data['items']['page']['style']['titleBackgroundColor'] == '#ffffff') {
  180. $vo['style']['background'] = '#f7f7f7';
  181. $vo['style']['hotkeytxtColor'] = '#666666';
  182. } else {
  183. $vo['style']['background'] = $data['items']['page']['style']['titleBackgroundColor'];
  184. $vo['style']['hotkeytxtColor'] = '#ffffff';
  185. }
  186. }
  187. if ($vo['base']['paddingTop']) {
  188. $vo['base']['bgstyle'] .= 'padding-top:' . $vo['base']['paddingTop'] . 'px;';
  189. }
  190. if ($vo['base']['paddingBottom']) {
  191. $vo['base']['bgstyle'] .= 'padding-bottom:' . $vo['base']['paddingBottom'] . 'px;';
  192. }
  193. if ($vo['base']['paddingLeft']) {
  194. $vo['base']['bgstyle'] .= 'padding-left:' . $vo['base']['paddingLeft'] . 'px;' . 'padding-right:' . $vo['base']['paddingLeft'] . 'px;';
  195. }
  196. if ($vo['base']['marginTop']) {
  197. $vo['base']['bgstyle'] .= 'margin-top:' . $vo['base']['marginTop'] . 'px;';
  198. }
  199. if ($vo['base']['marginBottom']) {
  200. $vo['base']['bgstyle'] .= 'margin-bottom:' . $vo['base']['marginBottom'] . 'px;';
  201. }
  202. if ($vo['type'] == 'coupon') {
  203. $coupondata = Coupon::where(['weid' => weid(), 'ptype' => 1])
  204. ->limit($vo['max'])
  205. ->select()
  206. ->toArray();
  207. foreach ($coupondata as $cvo) {
  208. $cdata[$cvo['id']]['coupon_id'] = $cvo['id'];
  209. $cdata[$cvo['id']]['color'] = $cvo['color'];
  210. $cdata[$cvo['id']]['coupon_type'] = $cvo['coupon_type'];
  211. $cdata[$cvo['id']]['discount'] = $cvo['discount'];
  212. $cdata[$cvo['id']]['reduce_price'] = $cvo['reduce_price'];
  213. $cdata[$cvo['id']]['min_price'] = $cvo['min_price'];
  214. $cdata[$cvo['id']]['state'] = CouponReceive::getReceiveState($cvo['id'], $uid);
  215. }
  216. $vo['list'] = $cdata;
  217. }
  218. if (!empty($vo['list'])) {
  219. foreach ($vo['list'] as &$vvo1) {
  220. if (!empty($vvo1['link'])) {
  221. $vvo1['link'] = DiyPageLink::setlink($vvo1['link']);
  222. }
  223. }
  224. }
  225. if (!empty($vo['link'])) {
  226. $vo['link'] = DiyPageLink::setlink($vo['link']);
  227. }
  228. }
  229. }
  230. $Configdata['SITE_ICON'] = toimg($data['SITE_ICON']);
  231. $Configdata['poster'] = toimg($data['poster']);
  232. $Configdata['applypic'] = toimg($data['applypic']);
  233. $data['config'] = $Configdata;
  234. return $this->json(['data' => $data]);
  235. }
  236. }