chengkun
2025-05-26 8f3df543230cd4403368b39b9bbe5726d11a0284
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
<?php
 
class wxapp_model extends model{
    
    public function setConfig($data = array())
    {
        $config  =  $this -> select_all('app_config',array(),'`name`');
        
        foreach($config as $v){
            
            $allList[]  =  $v['name'];
            
        }
        
        foreach($data as $key=>$v){
            
            if(in_array($key,$allList)){
                
                $this->update_once('app_config',array('config'=>$v),array('name'=>$key));
                
            }else{
                
                $this->insert_into('app_config',array('name'=>$key,'config'=>$v));
            }
        }
        $this->makeConfig();
    }
    /**
     * 生成appp配置缓存
     */
    public function makeConfig()
    {
        $config  =  $this -> select_all('app_config',array());
       
        if(is_array($config)){
            foreach($config as $v){
                $configarr[$v['name']]    =    $v['config'];
            }
        }
        if(!empty($configarr)){
            made_web(DATA_PATH.'api/wxapp/app.config.php',ArrayToString($configarr),'appconfig');
        }
    }
    /**
     * 移动端自定义设置保存
     */
    public function saveTplApp($data){
        
        if(!empty($data)){
            
            $tList    =    $this->select_all("tplapp",array('type'=>'index'),'`name`');
            
            foreach($tList as $k=>$v){
                
                $nameList[$v['name']]    =    1;
            }
        }
        foreach ($data as $key=>$val){
            
            if(isset($nameList[$key]) && $nameList[$key]==1){
                
                $this->update_once("tplapp",array('config'=>$val),array('name'=>$key));
                
            }else{
                
                $this->insert_into("tplapp",array('name'=>$key,'config'=>$val,'type'=>'index'));
            }
        }
    }
    
    /**
     *
     */
    public function sortTplApp($data){
        
        if(!empty($data)){
            
            $num        =        $this->select_num("tplapp",array('name'=>'sort'));
            
            $sort        =        implode(',', $data);
            
            if($num){
                
                $nid    =        $this->update_once("tplapp",array('config'=>$sort),array('name'=>'sort'));
                
            }else{
                
                $nid    =        $this->insert_into("tplapp",array('name'=>'sort','config'=>$sort,'type'=>'index'));
                
            }
        }
        return    $nid;
    }
    /**
     *
     */
    public function getTplAppList($whereData){
        
        $List            =    array();
        
        if($whereData){
            
            $List        =    $this -> select_all('tplapp',$whereData);
        }
        return    $List;
    }
    /**
     *
     */
    public function getTplApp($whereData){
        
        $row  =  $this->select_once('tplapp',$whereData);
        return    $row;
    }
    /**
     *
     */
    public function delTplApp($type,$post){
        
        $tpltype         =     $this->getTplAppList(array('type'=>$type));
        
        foreach($tpltype as $k=>$v){
            
            if(!in_array($v['id'], $post)){
                $nid        =    $this->delete_all('tplapp',array('id'=>$v['id']));
            }
        }
        return    $nid;
    }
    
    /**
     *
     */
    public function saveAllTplApp($whereData,$data){
        
        if($data['name']!='' && $data['url']!=''){
            
            $value    =    array(
                'name'    =>    $data['name'],
                'url'    =>    $data['url'],
                'type'    =>    $data['type']
            );
            
            if ($data['display']){
                $value['display']  =  $data['display'];
            }
            if ($data['navsort']){
                $value['navsort']  =  $data['navsort'];
            }
            if ($data['desc']){
                $value['desc']       =  $data['desc'];
            }
            if($data['pic']){
                $value['pic']       =  $data['pic'];
            }
            if($whereData['id'] != ''){
                
                $nid  =     $this -> update_once('tplapp',$value,$whereData);
                
            }else{
                
                $nid  =     $this -> insert_into('tplapp',$value);
            }
        }
        return    $nid;
    }
    /**
     * 生成tplapp缓存
     */
    public function tplappCache($type = ''){
        // 清除生成缓存标记
        $this->delete_all('tplapp', array('name'=>'isnew'));
        
        $tplApp =   $this->getTplAppList(array('id' => array('>', 0)));
        
        if (is_array($tplApp)) {
            $index = $nav = $foot = array();
            foreach ($tplApp as $k => $v) {
                if ($v['type'] == 'index') {
                    if ($v['name'] == 'sort' && stripos($v['config'], 'login') == false) {
                        
                        $index[$v['name']]  =   'search,member,nav,navbig,notice,login,hotcom,ad,job,zph,article,jobclass,connect,foot';
                    } else {
                        
                        $index[$v['name']]  =   $v['config'];
                    }
                }
                if ($v['type'] == 'nav') {
                    
                    $nav[$k]['id']      =   $v['id'];
                    $nav[$k]['name']    =   $v['name'];
                    $nav[$k]['pic']     =   $v['pic'];
                    $nav[$k]['type']    =   $v['type'];
                    $nav[$k]['url']     =   $v['url'];
                    $nav[$k]['display'] =   $v['display'];
                    $nav[$k]['navsort'] =   $v['navsort'];
                }
                if ($v['type'] == 'navbig') {
                    
                    $navbig[$k]['id']       =   $v['id'];
                    $navbig[$k]['name']     =   $v['name'];
                    $navbig[$k]['desc']     =   $v['desc'];
                    $navbig[$k]['pic']      =   $v['pic'];
                    $navbig[$k]['type']     =   $v['type'];
                    $navbig[$k]['url']      =   $v['url'];
                    $navbig[$k]['display']  =   $v['display'];
                    $navbig[$k]['navsort']  =   $v['navsort'];
                }
                if ($v['type'] == 'foot') {
                    $foot[$k]['id']     =   $v['id'];
                    $foot[$k]['name']   =   $v['name'];
                    $foot[$k]['pic']    =   $v['pic'];
                    $foot[$k]['type']   =   $v['type'];
                    $foot[$k]['url']    =   $v['url'];
                }
            }
            if ($type == 'foot') {
                $index['footRand']  =   time();//如果更新的是uniapp底部导航,则生成时间戳缓存
            }
            
            $data['tplapp']     =   ArrayToString($index);
            $data['nav']        =   ArrayToString($nav);
            $data['navbig']     =   ArrayToString($navbig);
            $data['footnav']    =   ArrayToString($foot);
            made_web_array(DATA_PATH.'api/wxapp/tplapp.cache.php', $data);
        }
    }
    public function makeCache()
    {
        $config  =  array();
        include(DATA_PATH.'api/wxapp/app.config.php');
        if (empty($appconfig['sy_push_appid'])){
            if (!empty($this->config['sy_push_appid'])){
                
                $config['sy_push_appid']         =  $this->config['sy_push_appid'];
                $config['sy_push_appsecret']     =  $this->config['sy_push_appsecret'];
                $config['sy_push_appkey']        =  $this->config['sy_push_appkey'];
                $config['sy_push_masterSecret']  =  $this->config['sy_push_masterSecret'];
            }
        }
        include(DATA_PATH.'api/wxapp/app.config.php');
        if (empty($appconfig['apptitle'])){
            if (!empty($this->config['apptitle'])){
                
                $config['iosversion']      =  $this->config['iosversion'];
                $config['iosurl']          =  $this->config['iosurl'];
                $config['androidversion']  =  $this->config['androidversion'];
                $config['androidurl']      =  $this->config['androidurl'];
                $config['apptitle']        =  $this->config['apptitle'];
                $config['appcontent']      =  $this->config['appcontent'];
            }
        }
        if (!empty($config)){
            
            $this->setConfig($config);
        }
    }
    /**
     * 生成百度小程序所需缓存
     */
    public function makeBaiduCache(){
        
        if (!empty($this->config['sy_dealId']) && !empty($this->config['sy_appKey'])){
            // 生成百度小程序缓存
            $baidu  =  array(
                'sy_weburl'     =>  $this->config['sy_weburl'],
                'sy_appKey'     =>  $this->config['sy_appKey'],
                'sy_dealId'     =>  $this->config['sy_dealId'],
                'sy_privateKey' =>  $this->config['sy_privateKey'],
                'sy_publicKey'  =>  $this->config['sy_publicKey'],
                'sy_bdlogin_appKey'=> $this->config['sy_bdlogin_appKey'],
                'sy_bdlogin_appSecret'=>$this->config['sy_bdlogin_appSecret']
            );
            
            made_web(DATA_PATH.'api/baidu/baidu_data.php',ArrayToString($baidu),'baiduData');
        }
    }
 
    /**
     * 添加小程序seo
     * @param $data
     * @return array
     */
    public function addWxSeo($data){
 
        $nid    =   $this->insert_into('wxxcx_seo', $data);
 
        if ($nid) {
            // 生成缓存
            $this->makeWxSeoCache();
 
            $return =   array(
                'id'        =>  $nid,
                'errcode'   =>  9,
                'msg'       =>  '添加成功'
            );
        } else {
 
            $return =   array(
                'errcode'   =>  8,
                'msg'       =>  '添加失败'
            );
        }
        return $return;
    }
 
    /**
     * 修改小程序seo
     * @param array $where
     * @param $data
     * @return array
     */
    public function upWxSeo($where = array(), $data){
        
        if (!empty($where)){
 
            $nid    =   $this->update_once('wxxcx_seo', $data, $where);
 
            if ($nid) {
 
                // 生成缓存
                $this->makeWxSeoCache();
 
                $return =   array(
                    'errcode'   =>  9,
                    'msg'       =>  '修改成功'
                );
            } else {
                $return =   array(
                    'errcode'   =>  8,
                    'msg'       =>  '修改失败'
                );
            }
            return $return;
        }
    }
 
    /**
     * 获取小程序seo列表
     * @param array $where
     * @return array|bool|false|string|void
     */
    public function getWxSeo($where = array()){
 
        $seo = $this->select_once('wxxcx_seo', $where);
 
        if(!empty($seo)){
            if($seo['share_pic']){
                $seo['share_pic_n'] = checkpic($seo['share_pic']);
            }
        }
        return $seo;
    }
 
    /**
     * 获取小程序seo列表
     * @param array $where
     * @return array|bool|false|string|void
     */
    public function getWxSeoList($where = array()){
 
        return $this->select_all('wxxcx_seo', $where);
    }
 
    /**
     * 删除小程序SEO
     * @param $where
     * @return array
     */
    public function delWxSeo($where)
    {
 
        $res    =   $this->delete_all('wxxcx_seo', $where);
 
        if ($res) {
            // 生成缓存
            $this->makeWxSeoCache();
            $return =   array('msg' => 'SEO删除成功', 'errcode' => 9);
        } else {
            $return =   array('msg' => 'SEO删除失败', 'errcode' => 8);
        }
        return $return;
    }
 
    /**
     * 生成小程序SEO缓存
     */
    public function makeWxSeoCache()
    {
 
        $list   =   $this->select_all('wxxcx_seo');
 
        if (!empty($list)) {
            foreach ($list as $k => $v) {
                if (!empty($v['ident']) && !empty($v['title'])) {
                    $seo_index[$v["ident"]][$k]['title']      =   $v["title"];
                    $seo_index[$v["ident"]][$k]['share_pic']  =   $v["share_pic"];
                    $seo_index[$v["ident"]][$k]['keywords']   =   $v["keywords"];
                    $seo_index[$v["ident"]][$k]['description']=   $v["description"];
                }
            }
            if (isset($seo_index)){
 
                $data['seo']    =   ArrayToString($seo_index);
                made_web_array(DATA_PATH.'api/wxapp/wxseo.cache.php', $data);
            }
        }
    }
    /**
     * 生成字节跳动小程序所需缓存
     */
    public function makettCache(){
        
        if (!empty($this->config['sy_tt_appId']) && !empty($this->config['sy_tt_salt'])){
            
            $tt  =  array(
                'sy_weburl'    =>  $this->config['sy_weburl'],
                'sy_tt_appId'  =>  $this->config['sy_tt_appId'],
                'sy_tt_salt'   =>  $this->config['sy_tt_salt']
            );
            
            made_web(DATA_PATH.'api/bytedance/tt_data.php',ArrayToString($tt),'ttData');
        }
    }
}
?>