lizhen 2 dienas atpakaļ
vecāks
revīzija
2e53ba8fdf

+ 13 - 1
application/admin/controller/Zhengcejiedu.php

@@ -3,7 +3,7 @@
 namespace app\admin\controller;
 
 use app\common\controller\Backend;
-
+use think\Db;
 /**
  * 政策解读
  *
@@ -33,5 +33,17 @@ class Zhengcejiedu extends Backend
      * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
      */
 
+    /**
+     * 预览
+     */
+    public function yulan($id){
+        $info = Db::name('zhengcejiedu')->where('id',$id)->find();
+        $this->assign('info',$info);
+
+        $this->layout = false;
+
+        return $this->fetch();
+    }
+
 
 }

+ 1 - 1
application/admin/lang/zh-cn/laorenguanhuaicategory.php

@@ -2,7 +2,7 @@
 
 return [
     'Id'       => 'ID',
-    'Name'     => '商家联盟分类',
+    'Name'     => '健康状况',
     'Status'   => '状态',
     'Status 1' => '显示',
     'Set status to 1'=> '设为显示',

+ 1 - 0
application/admin/view/zhengcejiedu/index.html

@@ -36,6 +36,7 @@
                     <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
                            data-operate-edit="{:$auth->check('zhengcejiedu/edit')}"
                            data-operate-del="{:$auth->check('zhengcejiedu/del')}"
+                           data-operate-yulan="{:$auth->check('zhengcejiedu/yulan')}"
                            width="100%">
                     </table>
                 </div>

+ 75 - 0
application/admin/view/zhengcejiedu/yulan.html

@@ -0,0 +1,75 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>政策解读</title>
+    <style>
+        html, body, div, span, applet, object, iframe,
+        h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+        a, abbr, acronym, address, big, cite, code,
+        del, dfn, em, img, ins, kbd, q, s, samp,
+        small, strike, strong, sub, sup, tt, var,
+        b, u, i, center,
+        dl, dt, dd, ol, ul, li,
+        fieldset, form, label, legend,
+        table, caption, tbody, tfoot, thead, tr, th, td,
+        article, aside, canvas, details, embed, 
+        figure, figcaption, footer, header, hgroup, 
+        menu, nav, output, ruby, section, summary,
+        time, mark, audio, video {
+            margin: 0;
+            padding: 0;
+            border: 0;
+            font-size: 100%;
+            font: inherit;
+            vertical-align: baseline;
+            box-sizing: border-box;
+            font-family: Source Han Sans CN;
+        }
+        .page{
+            padding: 15px;
+            font-size: 14px;
+            line-height: 16px;
+            color:#333;
+        }
+    </style>
+</head>
+<body>
+    {$info.title}
+
+    {$info.updatetime|date="Y-m-d H:i:s",###}
+
+    <?php if(!empty($info['video_file'])){ ?>
+    <video width="100" height="100" controls><source src="{$info.video_file}" type="video/ogg"></video>
+    <?php } ?>
+
+    <?php if(!empty($info['audio_file'])){ ?>
+    <audio controls="controls" src="{$info.audio_file}" /></audio>
+    <?php } ?>
+
+    <div class="page">
+        {$info.content}
+    </div>
+</body>
+</html>
+<script src="/assets/js/jquery-3.1.1.min.js"></script>
+<script>
+
+    function replaceDetail(){
+        var details = $('.page').html();
+	   //newContent仅是details替换后内容;
+        let newContent = details.replace(/<img[^>]*>/gi, function (match, capture) { //去除三标签
+            match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
+            match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
+            match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
+            return match;
+        });
+        newContent = newContent.replace(/<br[^>]*\/>/gi, '');
+        newContent = newContent.replace(/<img/gi, '<img style="max-width:100%;height:auto;display:block;margin:0 auto;"');
+        $('.page').html('');
+        $('.page').html(newContent);
+    }
+    replaceDetail();
+</script>

+ 3 - 3
application/api/controller/Jiankangdata.php

@@ -24,9 +24,9 @@ class Jiankangdata extends Api
         //新写入
         $data = [
             'user_id' => $this->auth->id,
-            'xueya_low'  => $this->request->post('xueya_low'),
-            'xueya_high' => $this->request->post('xueya_high'),
-            'xuetang' => $this->request->post('xuetang'),
+            'xueya_low'  => $this->request->post('xueya_low',0),
+            'xueya_high' => $this->request->post('xueya_high',0),
+            'xuetang' => $this->request->post('xuetang',0),
             'createtime' => time(),
             'updatetime' => time(),
             'createdate' => date('Y-m-d'),

+ 13 - 1
public/assets/js/backend/zhengcejiedu.js

@@ -40,7 +40,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
                         {field: 'weigh', title: __('Weigh'), operate: false},
-                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                        {field: 'operate', title: __('Operate'), table: table,
+                            buttons:[
+                                {
+                                    name:'yulan',
+                                    text:'预览',
+                                    title:'预览',
+                                    icon:'fa fa-exclamation-circle',
+                                    classname:'btn btn-xs btn-info btn-orderpro btn-dialog',
+                                    url:'zhengcejiedu/yulan/id/{ids}?dialog=1',
+                                    target:'_self',
+                                },
+                            ],
+                            events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]
             });