有個(ge)別同學會需(xu)(xu)要怎么(me)在(zai)下載附(fu)件的時候 跳轉到確認頁,小秋(qiu)今天抽空修改下內置(zhi)源碼(ma)。并將方法做(zuo)了分享和記錄,當然是否更新到版本當中,取決于需(xu)(xu)求量,由于目前只是個(ge)人需(xu)(xu)求,暫時不(bu)做(zuo)考慮嵌入在(zai)內置(zhi)里(li)面(所以只是粗(cu)粗(cu)的寫下代碼(ma),請(qing)老師勿見笑),有需(xu)(xu)要的朋友(you)自行(xing)修改。
PS:開啟前端(duan)點擊(ji)下載后,可跳轉確認頁再下載的目的功能。
其二(er) 增加后(hou)臺開關,實現如果(guo)不需要(yao)關閉即可,前端點擊下載按鈕則恢(hui)復(fu)系(xi)統直接下載模式(shi)無需再進確認頁!
開關控(kong)制在:功能地(di)圖-頻道模(mo)型-下載模(mo)型-點編輯里(li)面
效果圖:

首先(xian)打開:\application\home\controller\View.php
找到488行上面這段:【 public function downfile() 函數(shu)里(li)】
if ($users['level_value'] < $file_level['level_value']) {
$msg = '文件為【' . $file_level['level_name'] . '】可下(xia)載,您(nin)當前(qian)為【' . $users['level_name'] . '】,請(qing)先升(sheng)級!';
$this->error($msg, null, ['url' => url('user/Level/level_centre')]);
exit;
}
/*--end*/
}
}
}
下面將
// 下載次數限制
!empty($result['arc_level_id']) && $this->down_num_access($result['aid']);
//判斷外部鏈(lian)接的拓展名是(shi)(shi)否是(shi)(shi)圖片(pian)或者txt
if (is_http_url($result['file_url'])){
$url_arr = explode('.',$result['file_url']);
$count = count($url_arr);
$ext = $url_arr[$count - 1];
$image_ext_arr = explode(',', config('global.image_ext'));
$image_ext_arr = array_merge($image_ext_arr, ['txt']);
if (in_array($ext, $image_ext_arr)){
//保存到本地
$result['file_url'] = remote_file_to_local($result['file_url']);
$result['is_remote'] = 0;
$result['remote_to_local'] = 1;
}
}
替換以下代碼::
//小秋
if (!empty($channelData['is_download_cofirm'])){
// 下(xia)載次數限制
!empty($result['arc_level_id']) && $this->down_num_access($result['aid']);
//判斷外部鏈(lian)接的拓展(zhan)名是否是圖片或者txt
if (is_http_url($result['file_url'])){
$url_arr = explode('.',$result['file_url']);
$count = count($url_arr);
$ext = $url_arr[$count - 1];
$image_ext_arr = explode(',', config('global.image_ext'));
$image_ext_arr = array_merge($image_ext_arr, ['txt']);
if (in_array($ext, $image_ext_arr)){
//保存到本(ben)地
$result['file_url'] = remote_file_to_local($result['file_url']);
$result['is_remote'] = 0;
$result['remote_to_local'] = 1;
}
}
// 記錄下載次數
$this->download_log($result['file_id'], $result['aid']);
$uhash_mch = mchStrCode($uhash);
// 跳轉到確(que)認(ren)頁面
$confirm_url = url('home/View/download_confirm', ['file_id' => $file_id, 'uhash' => $uhash_mch]);
if (IS_AJAX) {
$this->success('請確認下(xia)載……', $confirm_url);
} else {
$this->redirect($confirm_url);
exit;
}
}else{
// 下(xia)載次數限制
!empty($result['arc_level_id']) && $this->down_num_access($result['aid']);
//判斷(duan)外(wai)部鏈接的拓(tuo)展名(ming)是(shi)否是(shi)圖(tu)片或(huo)者txt
if (is_http_url($result['file_url'])){
$url_arr = explode('.',$result['file_url']);
$count = count($url_arr);
$ext = $url_arr[$count - 1];
$image_ext_arr = explode(',', config('global.image_ext'));
$image_ext_arr = array_merge($image_ext_arr, ['txt']);
if (in_array($ext, $image_ext_arr)){
//保存(cun)到本(ben)地
$result['file_url'] = remote_file_to_local($result['file_url']);
$result['is_remote'] = 0;
$result['remote_to_local'] = 1;
}
}
繼續找到 :
/**
* 本地附件下載
*/
public function download_file()
上面(mian)添加一個
}
符(fu)號即可 【public function downfile()函數(shu)的(de)結尾】。
完整的public function downfile()代碼如下:
/**
* 下載文件(jian)
*/
public function downfile()
{
$file_id = input('param.id/d', 0);
$uhash = input('param.uhash/s', '');
if (empty($file_id) || empty($uhash)) {
$this->error('下載(zai)地址(zhi)出錯!');
exit;
}
clearstatcache();
// 查(cha)詢信息
$map = array(
'a.file_id' => $file_id,
'a.uhash' => $uhash,
);
$result = Db::name('download_file')
->alias('a')
->field('a.*,b.arc_level_id,b.restric_type,b.users_price,b.no_vip_pay')
->join('__ARCHIVES__ b', 'a.aid = b.aid', 'LEFT')
->where($map)
->find();
$file_url_gbk = iconv("utf-8", "gb2312//IGNORE", $result['file_url']);
$file_url_gbk = preg_replace('#^(/[/\w\-]+)?(/public/upload/soft/|/uploads/soft/)#i', '$2', $file_url_gbk);
if (empty($result) || (!is_http_url($result['file_url']) && !file_exists('.' . $file_url_gbk))) {
$this->error('下(xia)載文件不存在(zai)!');
exit;
}
//安裝下(xia)載模(mo)型付費插件 走新(xin)邏輯 大黃
$channelData = Db::name('channeltype')->where(['nid'=>'download','status'=>1])->value('data');
if (!empty($channelData)) $channelData = json_decode($channelData,true);
if (!empty($channelData['is_download_pay'])){
if ($result['restric_type'] > 0) {
$UsersData = session('users');
if (empty($UsersData['users_id'])) {
$this->error('請登錄(lu)后下載!', null, ['is_login' => 0, 'url' => url('user/Users/login')]);
exit;
}
}
if ($result['restric_type'] == 1) {// 付費
$order = Db::name('download_order')->where(['users_id' => $UsersData['users_id'], 'order_status' => 1, 'product_id' => $result['aid']])->find();
if (empty($order)) {
$msg = '文件(jian)購(gou)買(mai)后可下載,請先購(gou)買(mai)!';
$this->error($msg, null, ['url' => url('user/Download/buy'), 'need_buy' => 1, 'aid' => $result['aid']]);
exit;
}
} elseif ($result['restric_type'] == 2) {//會員專(zhuan)享
// 查詢會員信息
$users = Db::name('users')
->alias('a')
->field('a.users_id,b.level_value,b.level_name')
->join('__USERS_LEVEL__ b', 'a.level = b.level_id', 'LEFT')
->where(['a.users_id' => $UsersData['users_id']])
->find();
// 查詢下載所需等級值(zhi)
$file_level = Db::name('archives')
->alias('a')
->field('b.level_value,b.level_name')
->join('__USERS_LEVEL__ b', 'a.arc_level_id = b.level_id', 'LEFT')
->where(['a.aid' => $result['aid']])
->find();
if ($users['level_value'] < $file_level['level_value']) {//未達到會員級別
if ($result['no_vip_pay'] == 1){ //會員(yuan)專享(xiang) 開啟 非會員(yuan)付(fu)費下載
$order = Db::name('download_order')->where(['users_id' => $UsersData['users_id'], 'order_status' => 1, 'product_id' => $result['aid']])->find();
if (empty($order)) {
$msg = '文件為(wei)【' . $file_level['level_name'] . '】免費(fei)(fei)下載,您當(dang)前(qian)為(wei)【' . $users['level_name'] . '】,可付(fu)費(fei)(fei)購買!';
$this->error($msg, null, ['url' => url('user/Download/buy'), 'need_buy' => 1, 'aid' => $result['aid']]);
exit;
}
}else{
$msg = '文件為【' . $file_level['level_name'] . '】可下載,您(nin)當前為【' . $users['level_name'] . '】,請先(xian)升級!';
$this->error($msg, null, ['url' => url('user/Level/level_centre')]);
exit;
}
}
} elseif ($result['restric_type'] == 3) {//會員付費
// 查詢會(hui)員信息
$users = Db::name('users')
->alias('a')
->field('a.users_id,b.level_value,b.level_name')
->join('__USERS_LEVEL__ b', 'a.level = b.level_id', 'LEFT')
->where(['a.users_id' => $UsersData['users_id']])
->find();
// 查詢下(xia)載所(suo)需等(deng)級值
$file_level = Db::name('archives')
->alias('a')
->field('b.level_value,b.level_name')
->join('__USERS_LEVEL__ b', 'a.arc_level_id = b.level_id', 'LEFT')
->where(['a.aid' => $result['aid']])
->find();
if ($users['level_value'] < $file_level['level_value']) {
$msg = '文件(jian)為【' . $file_level['level_name'] . '】購買可下載,您當前為【' . $users['level_name'] . '】,請(qing)先升級后購買!';
$this->error($msg, null, ['url' => url('user/Level/level_centre')]);
exit;
}
$order = Db::name('download_order')->where(['users_id' => $UsersData['users_id'], 'order_status' => 1, 'product_id' => $result['aid']])->find();
if (empty($order)) {
$msg = '文件為【' . $file_level['level_name'] . '】購(gou)(gou)買(mai)(mai)可下載(zai),您當前為【' . $users['level_name'] . '】,請先購(gou)(gou)買(mai)(mai)!';
$this->error($msg, null, ['url' => url('user/Level/level_centre'), 'need_buy' => 1, 'aid' => $result['aid']]);
exit;
}
}
}else{
// 判斷會員信息
if (0 < intval($result['arc_level_id'])) {
//走下(xia)載模型(xing)會員(yuan)限制下(xia)載舊版邏輯
$UsersData = session('users');
if (empty($UsersData['users_id'])) {
$this->error('請(qing)登錄后下載(zai)!', null, ['is_login' => 0, 'url' => url('user/Users/login')]);
exit;
} else {
/*判斷(duan)會(hui)員是(shi)否(fou)可下載該(gai)文件(jian)--2019-06-21 陳風任添加*/
// 查詢會員信息
$users = Db::name('users')
->alias('a')
->field('a.users_id,b.level_value,b.level_name')
->join('__USERS_LEVEL__ b', 'a.level = b.level_id', 'LEFT')
->where(['a.users_id' => $UsersData['users_id']])
->find();
// 查詢下載(zai)所(suo)需等級值
$file_level = Db::name('archives')
->alias('a')
->field('b.level_value,b.level_name')
->join('__USERS_LEVEL__ b', 'a.arc_level_id = b.level_id', 'LEFT')
->where(['a.aid' => $result['aid']])
->find();
if ($users['level_value'] < $file_level['level_value']) {
$msg = '文件為(wei)(wei)【' . $file_level['level_name'] . '】可下載,您當前為(wei)(wei)【' . $users['level_name'] . '】,請先(xian)升級!';
$this->error($msg, null, ['url' => url('user/Level/level_centre')]);
exit;
}
/*--end*/
}
}
}
//小秋(qiu)
if (!empty($channelData['is_download_cofirm'])){
// 下載(zai)次(ci)數限制
!empty($result['arc_level_id']) && $this->down_num_access($result['aid']);
//判(pan)斷外部鏈接的拓展(zhan)名(ming)是(shi)否是(shi)圖(tu)片或者txt
if (is_http_url($result['file_url'])){
$url_arr = explode('.',$result['file_url']);
$count = count($url_arr);
$ext = $url_arr[$count - 1];
$image_ext_arr = explode(',', config('global.image_ext'));
$image_ext_arr = array_merge($image_ext_arr, ['txt']);
if (in_array($ext, $image_ext_arr)){
//保(bao)存到本地
$result['file_url'] = remote_file_to_local($result['file_url']);
$result['is_remote'] = 0;
$result['remote_to_local'] = 1;
}
}
// 記錄下載(zai)次數
$this->download_log($result['file_id'], $result['aid']);
$uhash_mch = mchStrCode($uhash);
// 跳(tiao)轉到(dao)確認頁面(mian)
$confirm_url = url('home/View/download_confirm', ['file_id' => $file_id, 'uhash' => $uhash_mch]);
if (IS_AJAX) {
$this->success('請(qing)確認下載……', $confirm_url);
} else {
$this->redirect($confirm_url);
exit;
}
}else{
// 下載次數限制(zhi)
!empty($result['arc_level_id']) && $this->down_num_access($result['aid']);
//判(pan)斷外部(bu)鏈接的拓展名是否是圖(tu)片或者txt
if (is_http_url($result['file_url'])){
$url_arr = explode('.',$result['file_url']);
$count = count($url_arr);
$ext = $url_arr[$count - 1];
$image_ext_arr = explode(',', config('global.image_ext'));
$image_ext_arr = array_merge($image_ext_arr, ['txt']);
if (in_array($ext, $image_ext_arr)){
//保存(cun)到本地
$result['file_url'] = remote_file_to_local($result['file_url']);
$result['is_remote'] = 0;
$result['remote_to_local'] = 1;
}
}
// 外部下(xia)載鏈接
if (is_http_url($result['file_url']) || !empty($result['is_remote'])) {
if ($result['uhash'] != md5($result['file_url'])) {
$this->error('下載(zai)地址(zhi)出(chu)錯!');
}
// 記錄(lu)下(xia)載次數(限制會員(yuan)級別下(xia)載的(de)文件(jian)才記錄(lu)下(xia)載次數)
// if (0 < intval($result['arc_level_id'])) {
// $this->download_log($result['file_id'], $result['aid']);
// }
//20220816修(xiu)改為不限級(ji)別都更(geng)新次數
$this->download_log($result['file_id'], $result['aid']);
$result['file_url'] = htmlspecialchars_decode($result['file_url']);
$result['file_url'] = handle_subdir_pic($result['file_url'], 'soft');
if (IS_AJAX) {
$this->success('正在跳轉中……', $result['file_url'], $result);
} else {
$this->redirect($result['file_url']);
exit;
}
}
// 本站鏈(lian)接
else
{
//如果(guo)是遠程轉換(huan)到本地的不做(zuo)這個(ge)判斷
if (md5_file('.' . $file_url_gbk) != $result['md5file'] && empty($result['remote_to_local'])) {
$this->error('下載(zai)文件(jian)包已(yi)損壞!');
}
// 記錄下(xia)載(zai)次數(shu)(限制會員級別下(xia)載(zai)的文件(jian)才記錄下(xia)載(zai)次數(shu))
// if (0 < intval($result['arc_level_id'])) {
// $this->download_log($result['file_id'], $result['aid']);
// }
// 記錄(lu)下載次數(shu)
$this->download_log($result['file_id'], $result['aid']);
$uhash_mch = mchStrCode($uhash);
$url = $this->root_dir . "/index.php?m=home&c=View&a=download_file&file_id={$file_id}&uhash={$uhash_mch}";
cookie($file_id.$uhash_mch, 1);
if (IS_AJAX) {
$this->success('開始(shi)下載中……', $url);
} else {
$url = $this->request->domain() . $url;
$this->redirect($url);
exit;
}
}
}
}
第二步:
繼續找到:
/**
* 本地(di)附件下載
*/
public function download_file()
這代(dai)(dai)碼上面添加以(yi)下代(dai)(dai)碼:
/**
* 確認下載頁面
*/
public function download_confirm()
{
$file_id = input('param.file_id/d', 0);
$uhash_mch = input('param.uhash/s', '');
if (empty($file_id) || empty($uhash_mch)) {
$this->error('下(xia)載地址出(chu)錯(cuo)!');
exit;
}
// 查詢文(wen)件信息
$result = Db::name('download_file')
->alias('a')
->field('a.*,b.arc_level_id,b.restric_type,b.users_price,b.no_vip_pay')
->join('__ARCHIVES__ b', 'a.aid = b.aid', 'LEFT')
->where(['a.file_id' => $file_id, 'a.uhash' => mchStrCode($uhash_mch, 'DECODE')])
->find();
if (empty($result)) {
$this->error('下載文件不存在!');
exit;
}
// 顯示(shi)確(que)認頁面
$this->assign('file_info', $result);
return $this->fetch('system/download_confirm');
}
/**
* 執行下(xia)載
*/
public function do_download()
{
// 獲(huo)取文件(jian) ID 和哈希值
$file_id = input('param.file_id/d', 0);
$uhash_mch = input('param.uhash/s', '');
// 檢查文件 ID 和哈希值(zhi)是否(fou)為空
if (empty($file_id) || empty($uhash_mch)) {
$this->error('下載(zai)地址出(chu)錯!');
exit;
}
// 查詢文件(jian)信息
$result = Db::name('download_file')
->alias('a')
->field('a.*,b.arc_level_id,b.restric_type,b.users_price,b.no_vip_pay')
->join('__ARCHIVES__ b', 'a.aid = b.aid', 'LEFT')
->where(['a.file_id' => $file_id, 'a.uhash' => mchStrCode($uhash_mch, 'DECODE')])
->find();
// 檢查查詢結果是否為空(kong)
if (empty($result)) {
$this->error('下載文(wen)件(jian)不存在(zai)!');
exit;
}
// 將文件(jian) URL 轉換為 GB2312 編(bian)碼并處理路徑(jing)
$file_url_gbk = iconv("utf-8", "gb2312//IGNORE", $result['file_url']);
$file_url_gbk = preg_replace('#^(/[/\w\-]+)?(/public/upload/soft/|/uploads/soft/)#i', '$2', $file_url_gbk);
// 處理(li)外(wai)部下載鏈接
if (is_http_url($result['file_url']) || !empty($result['is_remote'])) {
// 檢查(cha)哈(ha)希值是否匹配
if ($result['uhash'] != md5($result['file_url'])) {
$this->error('下載地址出錯!');
exit;
}
// 記錄下載次數
$this->download_log($result['file_id'], $result['aid']);
// 解碼(ma)并處理文件 URL
$result['file_url'] = htmlspecialchars_decode($result['file_url']);
$result['file_url'] = handle_subdir_pic($result['file_url'], 'soft');
// 根據(ju)請求(qiu)類型進行處(chu)理
if (IS_AJAX) {
$this->success('正在跳轉中……', $result['file_url'], $result);
} else {
$this->redirect($result['file_url']);
exit;
}
} else {
// 檢查文件是否損(sun)壞(非遠(yuan)程轉換(huan)到本地(di)的情況(kuang))
if (md5_file('.' . $file_url_gbk) != $result['md5file'] && empty($result['remote_to_local'])) {
$this->error('下(xia)載文件包已(yi)損壞!');
exit;
}
// 記錄(lu)下載次(ci)數
$this->download_log($result['file_id'], $result['aid']);
// 生成下載(zai)鏈接(jie)
$url = $this->root_dir . "/index.php?m=home&c=View&a=download_file&file_id={$file_id}&uhash={$uhash_mch}";
// 設置 cookie
cookie($file_id.$uhash_mch, 1);
// 根據請(qing)求(qiu)類型(xing)進行處理
if (IS_AJAX) {
$this->success('開始下載中……', $url);
} else {
$url = $this->request->domain() . $url;
$this->redirect($url);
exit;
}
}
}
本頁PHP完成
第三步:
打開\application\admin\controller
Channeltype.php文件;
找到以下代碼:
if ($post['nid'] == 'download'){
Db::name('arctype')->where([
'channeltype' => $post['id'],
])->update([
'is_release' => !empty($post['is_release']) ? $post['is_release'] : 0,
'update_time' => getTime(),
]);
if (!empty($post['data']['is_download_pay'])){
//開(kai)啟下載付費(fei)兼容舊(jiu)數據 舊(jiu)數據開(kai)始了會員限制的(de)restric_type改為2
Db::name('archives')->where(['channel'=>$post['id'],'restric_type'=>0])->where('arc_level_id','>',0)->update(['restric_type'=>2,'update_time'=>getTime()]);
}
大概在284行左(zuo)右(you)。
在下面添加(jia)以下代(dai)碼:
// 設置下載確認相關的配置參數
if (isset($post['is_download_cofirm'])) {
$paramData = [
'is_download_cofirm' => intval($post['is_download_cofirm'])
];
tpSetting('download_cofirm', $paramData);
}
再次打開:\application\admin\template\channeltype
edit.htm文件(jian):
找到:
{eq name="$field.nid" value="download"}
<dl class="row">
<dt class="tit">
<label>開啟下(xia)載付費(fei)</label>
</dt>
<dd class="opt">
<label class="curpoin"><input id="is_download_pay1" name="data[is_download_pay]" value="1" type="radio" on-click="article_pay(this,'download');" {if condition="!empty($field.data.is_download_pay)"} checked="checked"{/if}>是(shi)</label>
<label class="curpoin"><input id="is_download_pay0" name="data[is_download_pay]" value="0" type="radio" on-click="article_pay(this,'download');" {if condition="empty($field.data.is_download_pay)"} checked="checked"{/if}>否</label>
<a href="javascript:void(0);" class="{if condition='empty($field.data.is_download_pay)'}none{/if}" id="a_downloadpay" on-click="click_to_eyou_1575506523('//www.jinyoudianli.com/plus/view.php?aid=28561&origin_eycms=1','downloadpay 下載模型付費(fei)標(biao)簽')" style="font-size: 12px;padding-top: 3px;position: absolute;margin-left: 10px;">標(biao)簽教程(cheng)</a>
<p class="notic"></p>
</dd>
</dl>
{/eq}
大概186行:
添加以下代碼:
{eq name="$field.nid" value="download"}
<dl class="row">
<dt class="tit">
<label>開啟下載確認(ren)頁</label>
</dt>
<dd class="opt">
<label class="curpoin"><input id="is_download_cofirm1" name="data[is_download_cofirm]" value="1" type="radio" on-click="download_cofirm(this,'download');" {if condition="!empty($field.data.is_download_cofirm)"} checked="checked"{/if}>是(shi)</label>
<label class="curpoin"><input id="is_download_cofirm0" name="data[is_download_cofirm]" value="0" type="radio" on-click="download_cofirm(this,'download');" {if condition="empty($field.data.is_download_cofirm)"} checked="checked"{/if}>否(fou)</label>
<p class="notic"></p>
</dd>
</dl>
{/eq}
繼續查找 JS部分
找(zhao)到下面代(dai)碼
<script type="text/javascript">
function article_pay(obj,nid)
{
var value = $(obj).val();
if (1 == value) {
$('#a_'+nid+'pay').removeClass('none');
if ('article' == nid) {
var php_servicemeal = {$php_servicemeal|default=0};
var system_is_article_pay = {$system_is_article_pay|default=0};
if (php_servicemeal < 2 && system_is_article_pay == 0) {
$('input[name="data[is_article_pay]"]').eq(1).prop('checked', true);
var alert1 = layer.alert('付'+'費'+'功'+'能'+'只'+'限(xian)'+'于'+'專'+'業(ye)'+'授'+'權'+'域(yu)'+'名'+'!', {
icon: 4,
shade: layer_shade,
title:false,
btn: ['購買授權']
}, function(){
window.open('//www.jinyoudianli.com/buy');
layer.close(alert1);
});
return false;
}
var a = '<a href="javascript:void(0);" on-click="openPage(this);" data-url="//www.jinyoudianli.com/index.php?m=home&c=View&a=index&aid=11810&origin_eycms=1" data-title="articlepay 文章模型付費(fei)閱讀標簽(qian)">標簽(qian)教程</a>';
layer.alert('開(kai)啟文(wen)章付(fu)費需添加相關標簽,請查看(kan)'+ a +'修改', {
shade: layer_shade,
move: false,
title: '提示(shi)',
btnAlign:'r',
closeBtn: 3,
success: function () {
$(".layui-layer-content").css('text-align', 'left');
}
});
} else if ('download' == nid) {
var a = '<a href="javascript:void(0);" on-click="openPage(this);" data-url="//www.jinyoudianli.com/index.php?m=home&c=View&a=index&aid=28561&origin_eycms=1" data-title="downloadpay 下載(zai)模型付費標簽(qian)">標簽(qian)教程</a>';
layer.alert('開(kai)啟下載付費需添加相(xiang)關標簽,請查看(kan)'+ a +'修改', {
shade: layer_shade,
move: false,
title: '提示(shi)',
btnAlign:'r',
closeBtn: 3,
success: function () {
$(".layui-layer-content").css('text-align', 'left');
}
});
}
} else {
$('#a_'+nid+'pay').addClass('none');
}
}
下面添加以下代碼:
function download_cofirm(obj, nid) {
var value = $(obj).val();
if (1 == value) {
$('#a_' + nid + 'cofirm').removeClass('none');
if ('download' == nid) {
}
} else {
$('#a_' + nid + 'cofirm').addClass('none');
}
}
做到這里(li)核心部分就已經完成。
剩下的是模(mo)板文件和代(dai)碼添(tian)加:
新建download_confirm.htm模(mo)板(ban)文件 放在(zai):\template\pc\system目錄里面(mian)
代碼如下:
<style>
.downlf {
width: 400px; /* 假設寬度為 400px,你(ni)可(ke)以根據實際情況調整(zheng) */
margin: 0 auto; /* 上(shang)下 margin 為(wei) 0,左右(you) margin 為(wei) auto 實現水平居中 */
}
</style>
<div class="downlf">
<h1>確認下載(zai)</h1>
<p>文件名稱:{$file_info.file_name}</p>
<p>文件大小:{$file_info.file_size}</p>
<p>文(wen)件描述:{$file_info.file_des}</p>
<form action="{:url('home/View/do_download')}" method="post">
<input type="hidden" name="file_id" value="{$file_info.file_id}">
<input type="hidden" name="uhash" value="{:input('param.uhash/s')}">
<button type="submit">確(que)認下載</button>
</form>
樣式這里將(jiang)不在介紹 自(zi)己套用(yong)自(zi)己現有的(de)模板即可(ke)!
舉例:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>確認下載 - {$fife_infoarc_title}</title>
<link rel="stylesheet" href="/static/css/common.css">
<style>
.confirm-box {max-width: 800px; margin: 50px auto; padding: 20px; border: 1px solid #eee; border-radius: 8px;}
.file-info {margin: 20px 0; padding: 15px; background: #f9f9f9; border-radius: 4px;}
.info-item {margin: 10px 0;}
.btn-group {margin-top: 30px;}
.btn {display: inline-block; padding: 10px 20px; text-decoration: none; border-radius: 4px;}
.btn-confirm {background: #007bff; color: #fff; margin-right: 15px;}
.btn-cancel {background: #6c757d; color: #fff;}
.notice {margin-top: 20px; padding: 10px; background: #fff3cd; border-left: 4px solid #ffc107;}
</style>
</head>
<body>
<div>
<h2>確(que)認下載(zai)文(wen)件(jian)</h2>
<div>
<div class="info-item"><strong>文件名(ming)稱:</strong>{$file_info.title}</div>
<div class="info-item"><strong>附(fu)件名稱:</strong>{$file_info.file_name}</div>
<div class="info-item"><strong>文件大小:</strong>{$file_info.file_size}kb</div>
<div class="info-item"><strong>文件格(ge)式(shi):</strong>{$file_info.file_ext|strtoupper}</div>
<div class="info-item"><strong>發布(bu)時間:</strong>{$file_info.add_time|MyDate='Y-m-d H:i:s',###}</div>
<div class="info-item"><strong>文件描(miao)(miao)述:</strong>{$file_info.description|default='無描(miao)(miao)述'}</div>
</div>
<div>
<p>?? 下載須(xu)知:</p>
<p>1. 請確認該文件符合您的(de)需求,下載后將計入下載次數(shu)</p>
<p>2. 若文件格式(shi)為壓(ya)縮包,建議(yi)下載后(hou)驗證文件完(wan)整性</p>
<p>3. 如需幫助(zhu),請(qing)聯系客服熱線:400-xxx-xxxx</p>
</div>
<div>
下載第一種
<a href="{$file_info.file_url}" class="btn btn-confirm">確(que)認下載</a>
<a href="javascript:history.back()" class="btn btn-cancel">返(fan)回(hui)上一頁</a>
</div>
</div>
下載第二種
<form action="{:url('home/View/do_download')}" method="post">
<input type="hidden" name="file_id" value="{$file_info.file_id}">
<input type="hidden" name="uhash" value="{:input('param.uhash/s')}">
<button type="submit">確認下載(zai)</button>
</form>
</body>
</html>
標簽說明:
與下載標簽字典一樣,只不過標簽ID頭要以:file_info 為準【ID="file_info】"。
例子:文(wen)件名稱:{$file_info.file_name} 【非field】
