Commit 41a09a4f authored by clone's avatar clone

资源文件

parent cbd1bd50
.idea
composer.lock
*.log
public/resource/lib/Attachments
<?php
namespace app\api\controller;
use app\api\extend\Basic;
use app\model\AppVersion;
use think\Request;
/**
* Created by PhpStorm.
* User : zw
* Date : 2017/12/26
* Time : 13:57
* Intro:
*/
class Version extends Basic
{
protected $appVersion;
public function __construct($request = null)
{
parent::__construct($request);
$this->appVersion = new AppVersion();
}
public function index()
{
return view("version/index");
}
/**
* 获取最近版本号
* @return \think\Response
*/
public function getVersionNo()
{
$type = $this->params["type"];
if(isset($type)){
$this->response("101","请求的设备类型不能为空");
}
$versionResult = $this->appVersion->getVersion($type);
return $this->response("200", "request success", $versionResult);
}
}
\ No newline at end of file
<?php
namespace app\index\controller;
use app\index\extend\Basic;
use app\model\AppVersion;
use think\Request;
/**
* Created by PhpStorm.
* User : zw
* Date : 2017/12/26
* Time : 13:57
* Intro:
*/
class Version extends Basic
{
protected $appVersion;
public function __construct($request = null)
{
parent::__construct($request);
$this->appVersion = new AppVersion();
}
public function index()
{
return view("version/index");
}
/**
* 获取最近版本号
* @return \think\Response
*/
public function getVersionNo()
{
$type = $_POST["type"];
$versionResult = $this->appVersion->getVersion($type);
return $this->response("200", "request success", $versionResult);
}
/**
* 获取版本历史记录
* @return \think\Response
*/
public function getVersionList()
{
return $this->response("200", "request success", $this->appVersion->getVersionList());
}
public function addVersion()
{
$param["version_no"] = $_POST["version_no"];
$param["intro"] = $_POST["intro"];
$param["type"] = $_POST["type"];
$param["app_path"] = $_POST["app_path"];
if (!isset($param["version_no"]) || !isset($param["type"])) {
$this->response("101", "版本号或app类型不能为空");
}
if ($param["type"] == 'android' && isset($param["app_path"])) {
$this->response("101", "安卓请上传安装包");
}
$param["create_time"] = date("Y-m-d H:i:s", time());
$param["update_time"] = date("Y-m-d H:i:s", time());
$result = $this->appVersion->addVersion($param);
if ($result['code'] == 200) {
return $this->response("200", "上传成功", $result["msg"]);
} else {
return $this->response("101", $result["msg"]);
}
}
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="http://www.zhangxinxu.com/jq/pagination_zh/lib/pagination.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="http://www.zhangxinxu.com/jq/pagination_zh/lib/jquery.min.js"></script>
<script type="text/javascript" src="http://www.zhangxinxu.com/jq/pagination_zh/lib/jquery.pagination.js"></script>
</head>
<body>
<input type="text" id="phone"/>
<button type="button" id="button" >button</button>
<div id="Searchresult">分页初始化完成后这里的内容会被替换。</div>
<div id="Pagination" class="pagination"><!-- 这里显示分页 --></div>
<div id="pageNum">${par}</div>
<table>
<tbody id="sublet_list"></tbody>
</table>
<script type="text/javascript">
var pageIndex = 0; //页面索引初始值
var pageSize = 1; //每页显示条数初始化,修改显示条数,修改这里即可
$ (function () {
InitTable (0);
/*InitTable (0); //Load事件,初始化表格数据,页面索引为0(第一页)
//分页,PageCount是总条目数,这是必选参数,其它参数都是可选
$ ("#Pagination").pagination (0, {
callback: PageCallback,
prev_text: '上一页', //上一页按钮里text
next_text: '下一页', //下一页按钮里text
items_per_page: pageSize, //显示条数
num_display_entries: 6,
current_page: pageIndex, //当前页索引
num_edge_entries: 2 //两侧首尾分页条目数
});*/
//翻页调用
function PageCallback (index, jq) {
// InitTable (index);
}
$("#button").click(function(){
InitTable (0);
});
//请求数据
function InitTable (pageIndex) {
var params = {};
params.phone = $ ("#phone").val ();
params.pageNo = pageIndex + 1;
params.pageSize = pageSize;
$.ajax ({
url: '/index/get_transfer',
type: 'GET',
async: true,
data: params,
dataType: 'json',
success: function (data) {
console.log (data.data.total);
$ ("#Pagination").pagination (data.data.total, {
callback: PageCallback,
prev_text: '上一页', //上一页按钮里text
next_text: '下一页', //下一页按钮里text
items_per_page: pageSize, //显示条数
num_display_entries: 6,
current_page: pageIndex, //当前页索引
num_edge_entries: 2 //两侧首尾分页条目数
});
}
});
}
});
</script>
</body>
</html>
\ No newline at end of file
{layout name="global/frame_tpl" /}
<input type="hidden" class="page-load" id="version"/>
<!--导航star-->
<!-- Sidebar -->
<!-- /#sidebar-wrapper -->
<!-- Page Content -->
<div id="page-content-wrapper">
<div class="container">
<div class="row">
<div class="col-lg-10 col-lg-offset-0">
<div class="panel panel-default">
<div class="panel-heading breadcrumb">
<li><a href="#">app版本管理</a></li>
<li class="active">新增版本</li>
</div>
<div class="panel-body">
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-3 control-label" style="text-align: right">选择类型:</label>
<div class="col-sm-9">
<div class="radio" style="display: inline-block">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios1" value="android"
checked>android
</label>
</div>
<div class="radio" style="display: inline-block">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios2"
value="ios">ios
</label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" style="text-align: right">当前版本号:</label>
<div class="col-sm-9">
<label class=" control-label" id="now_version">---</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" style="text-align: right">版本编号:</label>
<div class="col-sm-9">
<input type="text" class="form-control btn6" name="title" id="version_no"
style="width: 220px;"
placeholder="请输入版本编号">
</div>
</div>
<div class="form-group show_select_page">
<label class="col-sm-3 control-label" style="text-align: right">上传包:</label>
<div class="col-sm-9">
<input readonly="readonly" type="text" name="cover_image" class="form-control"
style="width: 150px !important;display: inline-block"
id="cover_image" class="require" placeholder="请选择包"/>
<button class="banner_img btn btn-default" type="button">选择包</button>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" style="text-align: right">版本简述:</label>
<div class="col-sm-9">
<input type="text" class="form-control btn6" name="title" id="intro"
style="width: 220px;"
placeholder="请简述此次发布的内容">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" style="text-align: right">&nbsp;</label>
<div class="col-sm-9" style="text-align: left;">
<button type="button" class="btn btn-primary" id="save">保存修改</button>
</div>
</div>
</form>
<h5><span style="">发布历史:</span></h5>
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover table-condensed">
<thead>
<tr>
<th class="text-center" style="width:15%;">发布时间</th>
<th class="text-center" style="width:8%;">app类型</th>
<th class="text-center" style="width:8%;">版本号</th>
<th class="text-center" style="width:14%;">下载地址</th>
<th class="text-center" style="width:55%;">发布简述</th>
</tr>
</thead>
<tbody id="sublet_list" class="text-center">
<tr>
<td colspan="7" style="text-align:center;"> 加载中...</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
namespace app\model;
use Think\Db;
use think\Model;
class AppVersion extends Model
{
protected $table = 'u_app_version';
/**
* 获取最近版本号
*
* @param string $type
* @return mixed
*/
public function getVersion($type = 'android')
{
$type = $type == 'android' ? 1 : 0;
$param["type"] = $type;
$param["is_del"] = 0;
return $this->field("id,version_no,type,create_time,intro")
->where($param)
->order("id desc")
->limit(1)
->select()[0];
}
/**
* 获取版本历史
* @return false|\PDOStatement|string|\think\Collection
*/
public function getVersionList()
{
$param["is_del"] = 0;
return $this->field("id,version_no,IF(type = 0,'ios','android') as type ,create_time,intro,app_path")
->where($param)
->order("id desc")
->select();
}
/**
* 添加版本号
* @param $param
* @return array
*/
public function addVersion($param)
{
Db::startTrans();
try {
$id = $this->save($param);
Db::commit();
return [ "code" => "200", "msg" => $id ];
} catch (\Exception $e) {
Db::rollback();
return [ "code" => "101", "msg" => "失败,数据异常" ];
}
}
}
......@@ -91,6 +91,9 @@ Route::group('index', [
//版本管理
'version' => ['index/version/index',['method'=>'get']],
'getVersionNo' => ['index/version/getVersionNo',['method'=>'post']],
'getVersionList' => ['index/version/getVersionList',['method'=>'post']],
'addVersion' => ['index/version/addVersion',['method'=>'post']],
]);
......@@ -146,6 +149,12 @@ Route::group('api', [
'addSublet' => [ 'api/Sublet/addSublet', [ 'method' => 'post|get' ] ],
//Version
'getVersionNo' => [ 'api/Version/getVersionNo', [ 'method' => 'post' ] ],
]);
//Route::miss('api/index/miss');//处理错误的url
\ No newline at end of file
request body = <TemplateSMS>
<to>18205625020</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>4102</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=A2ADF4843FE864771BEA6A3995FD1C0F
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>17602179207</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>7868</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=8268642EDFA575155C07EF14398A7011
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
/**
* Created by zw on 2017/12/15.
*/
define (['doT', 'text!temp/version_template_tpl.html', 'ckfinder', 'ckfinderStart', 'css!style/home.css'], function (doT, template) {
var Version = {
init: function () {
//初始化dot
$ ("body").append (template);
Version.getVersion ();
Version.getVersionList ();
Version.event ();
},
event: function () {
/*上传图片控件*/
$ (".banner_img").click (function () {
BrowseServer ('cover_image');
});
$ ("#save").click (function () {
var params = {};
params.type = $ ("input[name = optionsRadios]:checked").val ();
params.version_no = $ ("#version_no").val ();
params.app_path = $ ("#cover_image").val ();
params.intro = $ ("#intro").val ();
if (!params.type || params.type == null) {
alert ("类型不能为空");
return false;
}
if (!params.version_no || params.version_no == null) {
alert ("版本号不能为空");
return false;
}
if (params.type === "android" && params.app_path == null || !params.version_no) {
alert ("上传的包路径不能为空");
return false;
}
Version.addVersion (params);
});
$ ("input[name=optionsRadios]").click (function () {
if ($ ("input[name = optionsRadios]:checked").val () === 'ios') {
$ (".show_select_page").hide ();
}else{
$ (".show_select_page").show ();
}
Version.getVersion ();
});
},
getVersion: function () {
var param = {};
param.type = $ ("input[name = optionsRadios]:checked").val ();
$.ajax ({
url: '/admin.php/index/getVersionNo',
type: 'POST',
async: true,
data: param,
dataType: 'json',
success: function (data) {
console.log (data);
if (data.data) {
$ ("#now_version").html (data.data['version_no']);
} else {
$ ("#now_version").html ("暂未获取到最新版本号");
}
}
});
},
getVersionList: function (pageNo) {
$.ajax ({
url: '/admin.php/index/getVersionList',
type: 'POST',
async: true,
data: {},
dataType: 'json',
success: function (data) {
console.log (data.data);
var temp = document.getElementById ('version_list_tpl').innerHTML;
var doTtmpl = doT.template (temp);
$ ("#sublet_list").html (doTtmpl (data.data));
}
});
},
addVersion: function (params) {
$.ajax ({
url: '/admin.php/index/addVersion',
type: 'POST',
async: true,
data: params,
dataType: 'json',
success: function (data) {
if (data.code == "101") {
alert (data.msg);
return false;
}else{
window.location.reload(true);
}
}
});
},
deleteBanner: function (params) {
$.ajax ({
url: '/admin.php/index/upIsShow',
type: 'POST',
async: true,
data: params,
dataType: 'json',
success: function (data) {
$ ("#modal-delete").modal ('hide');
if (data.code == "101") {
alert (data.msg);
return false;
}
banner.getBannerList (banner.pageNo);
}
});
}
};
return Version;
});
......@@ -241,7 +241,7 @@ $config['ResourceType'][] = Array(
'url' => $baseUrl . 'images',
'directory' => $baseDir . 'images',
'maxSize' => 0,
'allowedExtensions' => 'bmp,gif,jpeg,jpg,png,txt',
'allowedExtensions' => 'bmp,gif,jpeg,jpg,png,txt,apk',
'deniedExtensions' => '');
/*$config['ResourceType'][] = Array(
......
This source diff could not be displayed because it is too large. You can view the blob instead.
<script id="version_list_tpl" type="text/template">
[% if( it ) { %]
[% for(var item in it){ %]
<tr >
<td>[%= it[item]['create_time'] %]</td>
<td>[%= it[item]["type"] %]</td>
<td>[%= it[item]["version_no"] %] </td>
<td>[%= it[item]["app_path"] || '---' %]</td>
<td>[%= it[item]["intro"] %]</td>
</tr>
[% } %]
[% }else{ %]
<tr>
<td colspan="7" style="text-align:center;"> 暂无数据</td>
</tr>
[% } %]
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment