优惠券:\custom\b2c\controller\admin\sales\coupon.php 新增starbuy_weight_radio方法

 function starbuy_weight_radio()
    {

        $_POST['filter'] = json_decode($_POST['filter'],true);
         
        $this->pagedata = $_POST;
        echo $this->fetch("admin/sales/coupon/starbuy_weight_radio.html");
    }
新增\custom\b2c\view\admin\sales\coupon\starbuy_weight_radio.html

<{input type="object" name="subject[{$id}][cpns_id]" object="coupons" app="b2c" select="radio" vtype="required" textcol="cpns_name"
filter=$filter multiple="false" }>
<{input type="object" name="subject[{$key}][cpns_id]" object="coupons" app="b2c" select="radio" vtype="required" textcol="cpns_name" cols="name" 
filter=$data.map multiple="false" value=$item.cpns_id }>
$data.map为过滤的条件(数组)

$map['examine']=1;
    $map['employee_exclusive']=1;
    $data['map']=$map;
   $data['filter']= json_encode($map);

以下为整个代码:

theme_widget_cfg_employee_choice.php

<?php function theme_widget_cfg_employee_choice(){ $map['examine']=1; $map['employee_exclusive']=1; $data['map']=$map; $data['filter']= json_encode($map); return $data; } ?>

theme_widget_employee_choice.php:

<?php
function theme_widget_employee_choice(&$setting, &$smarty)
{

foreach ($setting['subject'] as $key => $val) {
$cpns_id = $val['cpns_id'];
$filter = array('cpns_id' => $cpns_id);
$data = app::get('b2c')->model('coupons')->getRow('*', $filter);
$data['cpns_title']=$val['cpns_title'];
$data['comment']=$val['comment'];
$data['cpns_pic_url']=$val['cpns_pic_url'];

$info[] = $data;
}
return $info;
}

?>

_config.html:
<
div id="tbody"> <!--大图--> <div class="tableform" style="margin-top:10px;"> <div class="widgetconfig "> <div class="tableform" style="margin-top:10px;"> <div class="widgetconfig "> <label>楼层标题:</label> <input name="title" value="<{$setting.title}>"> </div> </div> </div> </div> <div class="tableform" style="margin-top:10px;"> <{button label=$___b2c="添加"|t:'b2c' id="addsubject" app="desktop" icon="btn_add.gif"}> <span>优惠券图片尺寸应为300*150</span> </div> <{foreach from=$setting.subject item=item key=key}> <div class="tableform" style="margin-top:10px;"> <table class="widgetconfig division"> <tr> <th>优惠券大标题:</th> <td> <input name="subject[<{$key}>][cpns_title]" value="<{$item.cpns_title}>" > </td> <td style="width: 60%"> 优惠券选择:<{input type="object" name="subject[{$key}][cpns_id]" object="coupons" app="b2c" select="radio" vtype="required" textcol="cpns_name" cols="name" filter=$data.map multiple="false" value=$item.cpns_id }></td> <td><{button label=$___b2c="删除"|t:'b2c' onClick="f_remove(this);" }></td> </tr> <tr> <th>优惠券图片上标题:</th> <td> <input name="subject[<{$key}>][comment]" value="<{$item.comment}>"> </td> <td> 图片链接: <input class="imgsrc" name="subject[<{$key}>][cpns_pic_url]" id="pic" value="<{$item.cpns_pic_url}>"> <input type="button" value="<{t app="b2c"}>上传图片<{/t}>" class="uploadbtn"> </td> </tr> </table> </div> <{/foreach}> </div> <input type="hidden" id="filter" name="filter" value='<{$data.filter}>'> <script> $("addsubject").addEvents({ 'click': function () { var cur_time = new Date().getTime(); var tbody = $('tbody'); var weight = build_starbuy_weight(cur_time); var tmp = '<table class="widgetconfig division"> ' + '<tr> ' + '<th>优惠券大标题:</th>'+ '<td><input name="subject['+cur_time+'][cpns_title]" value="" ></td>'+ '<td style="width: 60%">优惠券选择:' + weight.html + '</td>' + ' <td><{button label=$___b2c="删除"|t:'b2c' onClick="f_remove(this);" }> </td>' + ' </tr> ' + '<tr>' + ' <th>优惠券图片上标题:</th>' + '<td><input name="subject['+cur_time+'][comment]" value="<{$setting.type_blck}>"></td>'+ '<td style="width: 30%">图片链接:<input name="subject['+cur_time+'][cpns_pic_url]">' + '<input type="button" value="上传图片" class="uploadbtn"></td>' + '</tr>' + '</table>'; new Element('div', {'html': tmp, 'class': 'tableform', 'style': 'margin-top:10px'}).inject(tbody); Browser.exec(weight.script); } }) $('tbody').addEvents({ 'click:relay(.uploadbtn)': function () { addPic(this.getPrevious()); } }); function addPic(el) { var url = 'index.php?app=desktop&act=alertpages&goto=' + encodeURIComponent("index.php?app=image&ctl=admin_manage&act=image_broswer&type=big"); Ex_Loader('modedialog', function () { return new imgDialog(url, { onCallback: function (image_id, image_src) { el.value = image_src; } }); }); } function f_remove(el) { el.getParent('.tableform').destroy(); } function build_starbuy_weight(id) { var __script = ''; var __result = ''; var filter =$('filter').value; new Request({ method: 'post', async: false, evalScripts: function (script, text) { __script += script }, url:'<{link app=b2c ctl=admin_sales_coupon act=starbuy_weight_radio}>', onSuccess: function (rs) { __result = rs; } }).post({id: id, filter:filter}); return {html: __result, script: __script}; } </script>

 

posted on 2018-06-08 15:45  limonyun  阅读(277)  评论(0编辑  收藏  举报