示例#1
0
 /**
  * 检测新版本
  * @param $version
  * @param $platform
  */
 public function actionVersion($version, $platform)
 {
     try {
         if ($platform == 'android') {
             $versionInfo = AppVersion::findLatestVersion(1);
         } else {
             $versionInfo = AppVersion::findLatestVersion(2);
         }
         if (!$versionInfo) {
             echo json_encode([], JSON_FORCE_OBJECT);
             exit;
         }
         $latestVersion = $versionInfo['version'];
         $latestVersionNumber = str_replace('.', '', $latestVersion);
         $versionNumber = str_replace('.', '', $version);
         if ($latestVersionNumber <= $versionNumber) {
             echo json_encode([], JSON_FORCE_OBJECT);
             exit;
         }
         $this->code(200, 'ok', ['latest_version' => $latestVersion, 'description' => $versionInfo['description'], 'updated_at' => $versionInfo['created_at'] * 1000, 'download_url' => 'http://fir.im/huoshi']);
     } catch (Exception $e) {
         $this->code(500, $e->getMessage());
     }
 }