Browse Source

fix:版本

super-yimizi 3 weeks ago
parent
commit
a51221d7b5
2 changed files with 24 additions and 2 deletions
  1. 1 1
      application/admin/view/version/edit.html
  2. 23 1
      application/api/controller/Version.php

+ 1 - 1
application/admin/view/version/edit.html

@@ -13,7 +13,7 @@
             <div class="channel-list">
                 {foreach name="platformList" item="vo" key="key"}
                 <label class="radio-inline">
-                    <input type="radio" name="row[platform]" value="{$key}" data-rule="checked" data-rule-message="请至少选择一个活动渠道" {if condition="is_array($row.platform) && in_array($key, $row.platform)"}checked{/if}> 
+                    <input type="radio" name="row[platform]" value="{$key}" data-rule="checked" data-rule-message="请至少选择一个活动渠道" {if condition="$row.platform && $row.platform == $key"}checked{/if}> 
                     {$vo}
                 </label>
                 {/foreach}

+ 23 - 1
application/api/controller/Version.php

@@ -25,7 +25,29 @@ class Version extends Base
         $this->success('返回成功', $this->request->param());
     }
 
-    
+    /**
+     * 获取指定平台的最新版本
+     * @ApiTitle    (获取最新版本信息)
+     * @ApiSummary  (根据请求头platform参数返回最新版本)
+     * @ApiMethod   (GET)
+     * @ApiHeader   (name="platform", type="string", required=true, description="平台标识,如android/ios/h5等")
+     */
+    public function getLatestVersion()
+    {
+        $platform = $this->request->header('platform', '');
+        if (!$platform) {
+            $this->error('缺少platform参数');
+        }
+        $version = \think\Db::name('version')
+            ->where('platform', $platform)
+            ->where('status', 'normal')
+            ->order('weigh desc, id desc')
+            ->find();
+        if (!$version) {
+            $this->success('获取成功', null);
+        }
+        $this->success('获取成功', $version);
+    }
 
    
 }