| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 | 
							- <?php
 
- namespace app\admin\model\weixin;
 
- use think\Model;
 
- /**
 
-  * 配置模型
 
-  */
 
- class Config extends Model
 
- {
 
-     // 表名,不含前缀
 
-     protected $name = 'weixin_config';
 
-     // 自动写入时间戳字段
 
-     protected $autoWriteTimestamp = false;
 
-     // 定义时间戳字段名
 
-     protected $createTime = false;
 
-     protected $updateTime = false;
 
-     // 追加属性
 
-     protected $append = [
 
-     ];
 
-     public function getExtendAttr($value, $data)
 
-     {
 
-         $result = preg_replace_callback("/\{([a-zA-Z]+)\}/", function ($matches) use ($data) {
 
-             if (isset($data[$matches[1]])) {
 
-                 return $data[$matches[1]];
 
-             }
 
-         }, $data['extend']);
 
-         return $result;
 
-     }
 
-     /**
 
-      * 读取分类分组列表
 
-      * @return array
 
-      */
 
-     public static function getGroupList()
 
-     {
 
-         //$groupList = json_decode('{"weixin":"公众号配置","xiaochengxu":"小程序配置(未实现)"}', true);
 
-         $groupList = json_decode('{"weixin":"公众号配置"}', true);
 
-         foreach ($groupList as $k => &$v) {
 
-             $v = __($v);
 
-         }
 
-         return $groupList;
 
-     }
 
-     public static function getArrayData($data)
 
-     {
 
-         if (!isset($data['value'])) {
 
-             $result = [];
 
-             foreach ($data as $index => $datum) {
 
-                 $result['field'][$index] = $datum['key'];
 
-                 $result['value'][$index] = $datum['value'];
 
-             }
 
-             $data = $result;
 
-         }
 
-         $fieldarr = $valuearr = [];
 
-         $field = isset($data['field']) ? $data['field'] : (isset($data['key']) ? $data['key'] : []);
 
-         $value = isset($data['value']) ? $data['value'] : [];
 
-         foreach ($field as $m => $n) {
 
-             if ($n != '') {
 
-                 $fieldarr[] = $field[$m];
 
-                 $valuearr[] = $value[$m];
 
-             }
 
-         }
 
-         return $fieldarr ? array_combine($fieldarr, $valuearr) : [];
 
-     }
 
-     /**
 
-      * 将字符串解析成键值数组
 
-      * @param string $text
 
-      * @return array
 
-      */
 
-     public static function decode($text, $split = "\r\n")
 
-     {
 
-         $content = explode($split, $text);
 
-         $arr = [];
 
-         foreach ($content as $k => $v) {
 
-             if (stripos($v, "|") !== false) {
 
-                 $item = explode('|', $v);
 
-                 $arr[$item[0]] = $item[1];
 
-             }
 
-         }
 
-         return $arr;
 
-     }
 
-     /**
 
-      * 将键值数组转换为字符串
 
-      * @param array $array
 
-      * @return string
 
-      */
 
-     public static function encode($array, $split = "\r\n")
 
-     {
 
-         $content = '';
 
-         if ($array && is_array($array)) {
 
-             $arr = [];
 
-             foreach ($array as $k => $v) {
 
-                 $arr[] = "{$k}|{$v}";
 
-             }
 
-             $content = implode($split, $arr);
 
-         }
 
-         return $content;
 
-     }
 
-     /**
 
-      * 本地上传配置信息
 
-      * @return array
 
-      */
 
-     public static function upload()
 
-     {
 
-         $uploadcfg = config('upload');
 
-         $upload = [
 
-             'cdnurl'    => $uploadcfg['cdnurl'],
 
-             'uploadurl' => $uploadcfg['uploadurl'],
 
-             'bucket'    => 'local',
 
-             'maxsize'   => $uploadcfg['maxsize'],
 
-             'mimetype'  => $uploadcfg['mimetype'],
 
-             'multipart' => [],
 
-             'multiple'  => $uploadcfg['multiple'],
 
-         ];
 
-         return $upload;
 
-     }
 
- }
 
 
  |