chengkun
2025-06-05 4080b5997b38ca84b3b203c7101dcadb97b76925
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
<?php
 
namespace app\admin\controller;
 
use think\facade\View;
use think\facade\Request;
 
//use app\Gateway;
use think\facade\Config;
use think\facade\Db;
use think\Validate;
use app\BaseController;
use think\facade\Log;
use think\facade\Session;
 
class Common extends BaseController
{
 
    public $Opadmin = null;
    public $admin_id = null;
    public $cinfo = null;
 
    public function __construct()
    {
        Log::record(getcurrurl());
        header('Content-Type:text/html;charset=utf-8');
        $this->Opadmin = new \app\admin\util\Opadmin();
        if (!$this->Opadmin->islogin()) {
            $this->redirect(url('/admin/login/index')->build());
        }
 
        $this->cinfo = $this->Opadmin->info;
        $this->admin_id = $this->Opadmin->info['id'];
        $menulist = $this->Opadmin->menu();
        View::assign('menulist', $menulist);
        View::assign('cinfo', $this->Opadmin->info);
        View::assign('menuitem', Request()->controller(true) . '-' . Request()->action(true));
    }
    protected function getCountrychildrenids($id)
    {
        $where['father_id'] = $id;
        $result = Db::name('country_code')->field('id as value,cate_name as label')->where($where)->cacheAlways(TRUE, 0, 'country_codes')->order('order_id asc,id asc')->select()->toArray();
        if ($result) {
            foreach ($result as &$val) {
                $val['children'] = $this->getCountrychildrenids($val['value']); ////
            }
            return $result;
        } else {
            return [];
        }
    }
    //////上传文件到cos/////////////////
    protected function uploadFileToCos($file = '')
    {
        if ($file && Config::get('qcloud.isopencos') == 1) {
            $key = getCosName($file);
            $localPath = '.' . $file;
            $cos = new \common\Uploadcos();
            $result = $cos->cosUpload($key, $localPath);
            return $result;
        }
    }
 
    //////删除cos中的文件/////////////////
    protected function deleteFileFromCos($file = '', $versionId = '')
    {
        if ($file && Config::get('qcloud.isopencos') == 1) {
            $key = getCosName($file);
            $cos = new \common\Uploadcos();
            $result = $cos->cosDelete($key, $versionId);
            return $result;
        }
    }
}