推广二维码按时间轮播

master
tping 3 years ago
parent 4b54b68866
commit 35af729ded

@ -72,7 +72,15 @@ class JumpController extends HomeController
}
// 二维码:
$qrcodePromotionList = M('qrcode_promotion_list', 'tab_')->where(['id' => $id])->find();
$qrcode = json_decode($qrcodePromotionList['qrcode_img'], true);
$qrcodeCnt = count($qrcode);
$intervalMin = $qrcodePromotionList['interval_min'];
$elapseMin = floor((time() - $qrcodePromotionList['create_time']) / 60);
$imgIndex = 0;
if ($intervalMin > 0) {
$imgIndex = floor($elapseMin / $intervalMin);
$imgIndex = $imgIndex % $qrcodeCnt;
}
// 背景图
$qrcodePromotion = M('qrcode_promotion', 'tab_')->where(['id' => $qrcodePromotionList['qp_id']])->find();
@ -80,7 +88,7 @@ class JumpController extends HomeController
'id' => $_REQUEST['id'],
'status' => 1,
'background_img' => $qrcodePromotion['background_img'],
'qrcode_img' => $qrcodePromotionList['qrcode_img']
'qrcode_img' => $qrcode[$imgIndex]
]);
}

@ -198,7 +198,8 @@ class QrCodePromotionController extends BaseController
'short_link' => '',
'create_time' => time(),
'status' => 0,
'qrcode_img' => $params['img'],
'qrcode_img' => json_encode($params['img'], JSON_FORCE_OBJECT),
'interval_min' => $params['interval_min'],
]);
if ($id > 0) {
$h5Link = ($isHttps? 'https://': 'http://').$_SERVER['HTTP_HOST']."/index.php?s=/Qrcode/Jump/jumpMp/id/{$id}";

@ -13,19 +13,25 @@
</div>
<div class="trunk-content article">
<div class="trunk-list list_normal">
<form action="{:U('Promote/linkAdd')}" novalidate="novalidate" method="post" class="base_info" id="form_reg">
<form action="{:U('Promote/linkAdd')}" novalidate="novalidate" method="post" class="base_info" id="form_link_add">
<table class="table2">
<tr>
<input id="qp_id" type="hidden" name="id" value="{$qp_id}">
<td class="l"><span class="req">*</span>推广二维码:</td>
<td class="r">
<input id="images" name="img" type="hidden" value="">
<span id="img"><img src="" width="40%" height="40%"/></span>
<span id="img"></span>
<input type="file" id="imgFile"/>
</td>
</tr>
<tr>
<td class="l"><span class="req">*</span>轮播二维码间隔时间(分钟):</td>
<td class="r">
<input id="interval_min" type="text" name="interval_min" value="0">
</td>
</tr>
<tr>
<td class="l"></td>
<td class="r">
@ -46,27 +52,41 @@
<script type="text/javascript" src="__STATIC__/uploadifive/jquery.uploadifive.min.js"></script>
<script type="text/javascript">
var imgIndex = 0;
$('#imgFile').uploadifive({
'fileObjName':'file',
'removeCompleted' : true,
'formData' : {},
'buttonText' : '上传',
'uploadScript' : '/index.php?s=/Qrcode/QrCodePromotion/uploadQrCodeBackground',
'multi' : false,
'multi' : true,
'onUploadComplete' : function(file, data) {
var res = eval('(' + data + ')');
var src = res.path;
$('#img').html('<img src=' + src + ' width="40%" height="40%"/>')
$('#images').val(res.path);
$('#img').append('<img src=' + src + ' width="40%" height="40%"/>');
$('#img').append('<input class="images" name="img['+ imgIndex +']" type="hidden" value="'+ src +'">');
imgIndex = imgIndex + 1;
// $('#img').html('<img src=' + src + ' width="40%" height="40%"/>')
// $('#images').val(arr);
}
});
function insertAfter(newElement, targentElement) {
var parent = targentElement.parentNode;
if (parent.lastChild == targentElement) {
parent.appendChild(newElement);
} else {
parent.insertBefore(newElement, targentElement.nextSibling)
}
}
$('.add-submit').on({
click: function() {
var id = $("#qp_id").val();
var img = $('#images').val();
if (!img) {
var imgs = $("#form_link_add").serialize();
if (!imgs) {
return layer.msg('二维码不能为空')
}
@ -74,12 +94,12 @@
url: '{:U("linkAdd")}',
type: 'post',
dataType: 'json',
data: { id: id, img: img },
data: imgs,
success: function(result) {
if (result.status == 1) {
layer.msg(result.message)
setTimeout(function() {
window.location.href = "{:U('QrCodePromotion/linkLists')}";
// window.location.href = "{:U('QrCodePromotion/linkLists')}";
}, 200)
} else {
layer.msg(result.message)

Loading…
Cancel
Save