1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
-
-
- namespace app\common\model;
-
- use think\Db;
- use think\Model;
-
-
- class Weapp extends Model
- {
-
- protected function initialize()
- {
-
- parent::initialize();
- }
-
-
-
- public function getWeappList($code = '')
- {
- $result = cache('common_weapp_getWeappList');
- if (empty($result)) {
- $result = Db::name('weapp')->getAllWithIndex('code');
- foreach ($result as $key => &$value) {
- try {
- if (!empty($value['data']) && $value['data']!="[]") {
- if (preg_match('/^{.*}$/', $value['data'])) {
- $value['data'] = json_decode($value['data'], true);
- } else {
- $value['data'] = unserialize($value['data']);
- }
- }
- if (!empty($value['config'])) {
- $value['config'] = json_decode($value['config'], true);
- }
- } catch (\Exception $e) {}
- }
- cache('common_weapp_getWeappList', $result, null, 'weapp');
- }
-
- if (!empty($code)) {
- $result = !empty($result[$code]) ? $result[$code] : [];
- }
-
- return $result;
- }
- }
|