众所周知,DT它的商家发布商品本身是不能选择地区来进行商品上架的。只能上架商家所对应的的地区进行上架。但是其实通过查看源代码和相应的分析,上架的商品
其实都应该是北京的。这点不敢确定,但是了也是不符合需求的。所以了,我就行了以下的一点修改而已:
module\mall\admin\template\edit.tpl.php
<?php
defined('DT_ADMIN') or exit('Access Denied');
include tpl('header');
show_menu($menus);
?>
<form method="post" action="?" id="dform" onsubmit="return check();">
<input type="hidden" name="moduleid" value="<?php echo $moduleid;?>"/>
<input type="hidden" name="file" value="<?php echo $file;?>"/>
<input type="hidden" name="action" value="<?php echo $action;?>"/>
<input type="hidden" name="itemid" value="<?php echo $itemid;?>"/>
<input type="hidden" name="forward" value="<?php echo $forward;?>"/>
<input type="hidden" name="post[mycatid]" value="<?php echo $mycatid;?>"/>
<div class="tt"><?php echo $action == 'add' ? '添加' : '修改';?>商品</div>
<table cellpadding="2" cellspacing="1" class="tb">
<tr>
<td class="tl"><span class="f_red">*</span> 商品分类</td>
<td><div id="catesch"></div><?php echo ajax_category_select('post[catid]', '选择分类', $catid, $moduleid, 'size="2" style="height:120px;width:180px;"');?>
<br/><input type="button" value="搜索分类" onclick="schcate(<?php echo $moduleid;?>);" class="btn"/> <span id="dcatid" class="f_red"></span></td>
</tr>
<tr>
<td class="tl"><span class="f_red">*</span> 商品名称</td>
<td><input name="post[title]" type="text" id="title" size="60" value="<?php echo $title;?>"/> <?php echo level_select('post[level]', '级别', $level);?> <?php echo dstyle('post[style]', $style);?> <br/><span id="dtitle" class="f_red"></span></td>
</tr>
<tr>
<td class="tl"><span class="f_hid">*</span> 所在地区</td>
<td><?php echo ajax_area_select('post[areaid]', '请选择', $areaid);?></td>
</tr>
<tr>
<td class="tl"><span class="f_red">*</span> 商品价格</td>
<td>
<table cellpadding="4" cellspacing="1" bgcolor="#FFFFFF">
<tr bgcolor="#EFF5FB" align="center">
<td width="90">数量</td>
<td width="90">价格</td>
<td width="90"></td>
<td width="120">数量</td>
<td width="120">价格</td>
</tr>
<tr bgcolor="#FFFFFF" align="center">
<td><input name="post[step][a1]" type="text" size="10" value="<?php echo $a1;?>" id="a1"/></td>
<td><input name="post[step][p1]" type="text" size="10" value="<?php echo $p1;?>" id="p1" onblur="Dstep();"/></td>
<td></td>
<td id="p_a_1"></td>
<td id="p_p_1"></td>
</tr>
<tr bgcolor="#FFFFFF" align="center">
<td><input name="post[step][a2]" type="text" size="10" value="<?php echo $a2;?>" id="a2"/></td>
<td><input name="post[step][p2]" type="text" size="10" value="<?php echo $p2;?>" id="p2" onblur="Dstep();"/></td>
<td class="jt" onclick="Dstep()">点击预览</td>
<td id="p_a_2"></td>
<td id="p_p_2"></td>
</tr>
<tr bgcolor="#FFFFFF" align="center">
<td><input name="post[step][a3]" type="text" size="10" value="<?php echo $a3;?>" id="a3"/></td>
<td><input name="post[step][p3]" type="text" size="10" value="<?php echo $p3;?>" id="p3" onblur="Dstep();"/></td>
<td></td>
<td id="p_a_3"></td>
<td id="p_p_3"></td>
</tr>
</table>
<span class="f_gray"> 填写示例:<span class="c_p" title="点击观看" onclick="Dd('a1').value=1;Dd('p1').value=1000;Dd('a2').value=100;Dd('p2').value=900;Dd('a3').value=500;Dd('p3').value=800;Dstep();">阶梯价格</span> / <span class="c_p" title="点击观看" onclick="Dd('a1').value=1;Dd('p1').value=1000;Dd('a2').value=Dd('p2').value=Dd('a3').value=Dd('p3').value='';Dstep();">非阶梯价格</span></span>
</td>
</tr>
<tr>
<td class="tl"><span class="f_red">*</span> 商品库存</td>
<td><input name="post[amount]" type="text" size="10" value="999" id="amount"/> <input name="post[unit]" type="text" size="2" value="<?php echo $unit;?>" id="unit" title="计量单位"/> <span id="damount" class="f_red"></span></td>
</tr>
<tr>
<td class="tl"><span class="f_hid">*</span> 商品品牌</td>
<td><input name="post[brand]" type="text" size="30" value="<?php echo $brand;?>"/></td>
</tr>
<?php if($CP) { ?>
<script type="text/javascript">
var property_catid = <?php echo $catid;?>;
var property_itemid = <?php echo $itemid;?>;
var property_admin = 1;
</script>
<script type="text/javascript" src="<?php echo DT_PATH;?>file/script/property.js"></script>
<tbody id="load_property" style="display:none;">
<tr><td></td><td></td></tr>
</tbody>
<?php } ?>
<?php echo $FD ? fields_html('<td class="tl">', '<td>', $item) : '';?>
<tr>
<td class="tl"><span class="f_red">*</span> 商品图片</td>
<td>
<input type="hidden" name="post[thumb]" id="thumb" value="<?php echo $thumb;?>"/>
<input type="hidden" name="post[thumb1]" id="thumb1" value="<?php echo $thumb1;?>"/>
<input type="hidden" name="post[thumb2]" id="thumb2" value="<?php echo $thumb2;?>"/>
<table width="360">
<tr align="center" height="120" class="c_p">
<td width="120"><img src="<?php echo $thumb ? $thumb : DT_SKIN.'image/waitpic.gif';?>" width="100" height="100" id="showthumb" title="预览图片" alt="" onclick="if(this.src.indexOf('waitpic.gif') == -1){_preview(Dd('showthumb').src, 1);}else{Dalbum('',<?php echo $moduleid;?>,<?php echo $MOD['thumb_width'];?>,<?php echo $MOD['thumb_height'];?>, Dd('thumb').value, true);}"/></td>
<td width="120"><img src="<?php echo $thumb1 ? $thumb1 : DT_SKIN.'image/waitpic.gif';?>" width="100" height="100" id="showthumb1" title="预览图片" alt="" onclick="if(this.src.indexOf('waitpic.gif') == -1){_preview(Dd('showthumb1').src, 1);}else{Dalbum(1,<?php echo $moduleid;?>,<?php echo $MOD['thumb_width'];?>,<?php echo $MOD['thumb_height'];?>, Dd('thumb1').value, true);}"/></td>
<td width="120"><img src="<?php echo $thumb2 ? $thumb2 : DT_SKIN.'image/waitpic.gif';?>" width="100" height="100" id="showthumb2" title="预览图片" alt="" onclick="if(this.src.indexOf('waitpic.gif') == -1){_preview(Dd('showthumb2').src, 1);}else{Dalbum(2,<?php echo $moduleid;?>,<?php echo $MOD['thumb_width'];?>,<?php echo $MOD['thumb_height'];?>, Dd('thumb2').value, true);}"/></td>
</tr>
<tr align="center" class="c_p">
<td><span onclick="Dalbum('',<?php echo $moduleid;?>,<?php echo $MOD['thumb_width'];?>,<?php echo $MOD['thumb_height'];?>, Dd('thumb').value, true);" class="jt"><img src="<?php echo $MODULE[2]['linkurl'];?>image/img_upload.gif" width="12" height="12" title="上传"/></span> <img src="<?php echo $MODULE[2]['linkurl'];?>image/img_select.gif" width="12" height="12" title="选择" onclick="selAlbum('');"/> <span onclick="delAlbum('', 'wait');" class="jt"><img src="<?php echo $MODULE[2]['linkurl'];?>image/img_delete.gif" width="12" height="12" title="删除"/></span></td>
<td><span onclick="Dalbum(1,<?php echo $moduleid;?>,<?php echo $MOD['thumb_width'];?>,<?php echo $MOD['thumb_height'];?>, Dd('thumb1').value, true);" class="jt"><img src="<?php echo $MODULE[2]['linkurl'];?>image/img_upload.gif" width="12" height="12" title="上传"/></span> <img src="<?php echo $MODULE[2]['linkurl'];?>image/img_select.gif" width="12" height="12" title="选择" onclick="selAlbum(1);"/> <span onclick="delAlbum(1, 'wait');" class="jt"><img src="<?php echo $MODULE[2]['linkurl'];?>image/img_delete.gif" width="12" height="12" title="删除"/></span></td>
<td><span onclick="Dalbum(2,<?php echo $moduleid;?>,<?php echo $MOD['thumb_width'];?>,<?php echo $MOD['thumb_height'];?>, Dd('thumb2').value, true);" class="jt"><img src="<?php echo $MODULE[2]['linkurl'];?>image/img_upload.gif" width="12" height="12" title="上传"/></span> <img src="<?php echo $MODULE[2]['linkurl'];?>image/img_select.gif" width="12" height="12" title="选择" onclick="selAlbum(2);"/> <span onclick="delAlbum(2, 'wait');" class="jt"><img src="<?php echo $MODULE[2]['linkurl'];?>image/img_delete.gif" width="12" height="12" title="删除"/></span></td>
</tr>
</table>
<span id="dthumb" class="f_red"></span>
</td>
</tr>
<tr>
<td class="tl"><span class="f_red">*</span> 商品详情</td>
<td><textarea name="post[content]" id="content" class="dsn"><?php echo $content;?></textarea>
<?php echo deditor($moduleid, 'content', $MOD['editor'], '100%', 350);?><br/><span id="dcontent" class="f_red"></span>
</td>
</tr>
<?php
if($MOD['swfu'] && DT_EDITOR == 'fckeditor') {
include DT_ROOT.'/api/swfupload/editor.inc.php';
}
?>
<tr>
<td class="tl"><span class="f_hid">*</span> 可选属性</td>
<td>
<table cellpadding="4" cellspacing="1" bgcolor="#FFFFFF">
<tr bgcolor="#EFF5FB" align="center">
<td>属性名称</td>
<td>属性值</td>
</tr>
<tr bgcolor="#FFFFFF" align="center">
<td><input name="post[n1]" type="text" size="10" value="<?php echo $n1;?>" id="n1"/></td>
<td><input name="post[v1]" type="text" size="40" value="<?php echo $v1;?>" id="v1"/></td>
</tr>
<tr bgcolor="#FFFFFF" align="center">
<td><input name="post[n2]" type="text" size="10" value="<?php echo $n2;?>" id="n2"/></td>
<td><input name="post[v2]" type="text" size="40" value="<?php echo $v2;?>" id="v2"/></td>
</tr>
<tr bgcolor="#FFFFFF" align="center">
<td><input name="post[n3]" type="text" size="10" value="<?php echo $n3;?>" id="n3"/></td>
<td><input name="post[v3]" type="text" size="40" value="<?php echo $v3;?>" id="v3"/></td>
</tr>
<tr bgcolor="#FFFFFF" align="center">
<td class="f_gray">例如:颜色</td>
<td class="f_gray">例如:红色|蓝色|黑色|白色 多个属性用|分隔</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="tl"><span class="f_hid">*</span> 运费设置</td>
<td>
<table cellpadding="4" cellspacing="1" bgcolor="#FFFFFF">
<tr bgcolor="#EFF5FB" align="center">
<td>快递</td>
<td>默认运费</td>
<td>增加一件商品增加</td>
<td>选择模板 | <a href="<?php echo $MODULE[2]['linkurl'];?>express.php" class="t" target="_blank">管理模板</a></td>
</tr>
<tr bgcolor="#FFFFFF" align="center">
<td><input name="post[express_name_1]" type="text" id="express_name_1" size="10" value="<?php echo $express_name_1;?>" /></td>
<td><input name="post[fee_start_1]" type="text" id="fee_start_1" size="5" value="<?php echo $fee_start_1;?>" /></td>
<td><input name="post[fee_step_1]" type="text" id="fee_step_1" size="5" value="<?php echo $fee_step_1;?>" /></td>
<td>
<select name="post[express_1]" id="express_1" onchange="Dexpress(1, this.options[selectedIndex].innerHTML);">
<option value="0">选择模板</option>
<?php if(is_array($EXP)) { foreach($EXP as $v) { ?>
<option value="<?php echo $v['itemid'];?>"<?php if($express_1==$v['itemid']) { ?> selected<?php } ?>
><?php echo $v['title'];?>[<?php echo $v['express'];?>,<?php echo $v['fee_start'];?>,<?php echo $v['fee_step'];?>,<?php echo $v['note'];?>]</option>
<?php } } ?>
</select>
</td>
</tr>
<tr bgcolor="#FFFFFF" align="center">
<td><input name="post[express_name_2]" type="text" id="express_name_2" size="10" value="<?php echo $express_name_2;?>" /></td>
<td><input name="post[fee_start_2]" type="text" id="fee_start_2" size="5" value="<?php echo $fee_start_2;?>" /></td>
<td><input name="post[fee_step_2]" type="text" id="fee_step_2" size="5" value="<?php echo $fee_step_2;?>" /></td>
<td>
<select name="post[express_2]" id="express_2" onchange="Dexpress(2, this.options[selectedIndex].innerHTML);">
<option value="0">选择模板</option>
<?php if(is_array($EXP)) { foreach($EXP as $v) { ?>
<option value="<?php echo $v['itemid'];?>"<?php if($express_2==$v['itemid']) { ?> selected<?php } ?>
><?php echo $v['title'];?>[<?php echo $v['express'];?>,<?php echo $v['fee_start'];?>,<?php echo $v['fee_step'];?>,<?php echo $v['note'];?>]</option>
<?php } } ?>
</select>
</td>
</tr>
<tr bgcolor="#FFFFFF" align="center">
<td><input name="post[express_name_3]" type="text" id="express_name_3" size="10" value="<?php echo $express_name_3;?>" /></td>
<td><input name="post[fee_start_3]" type="text" id="fee_start_3" size="5" value="<?php echo $fee_start_3;?>" /></td>
<td><input name="post[fee_step_3]" type="text" id="fee_step_3" size="5" value="<?php echo $fee_step_3;?>" /></td>
<td>
<select name="post[express_3]" id="express_3" onchange="Dexpress(3, this.options[selectedIndex].innerHTML);">
<option value="0">选择模板</option>
<?php if(is_array($EXP)) { foreach($EXP as $v) { ?>
<option value="<?php echo $v['itemid'];?>"<?php if($express_3==$v['itemid']) { ?> selected<?php } ?>
><?php echo $v['title'];?>[<?php echo $v['express'];?>,<?php echo $v['fee_start'];?>,<?php echo $v['fee_step'];?>,<?php echo $v['note'];?>]</option>
<?php } } ?>
</select>
</td>
</tr>
</table>
<span class="f_gray"> 填写示例:<span class="c_p" title="点击观看" onclick="Nexpress('0.00', '包邮');">包邮</span> / <span class="c_p" title="点击观看" onclick="Nexpress('500.00', '包邮');">满500包邮</span> / <span class="c_p" title="点击观看" onclick="Nexpress('10.00', '快递');">快递10元</span> / <span class="c_p" title="点击观看" onclick="Nexpress('500.00', '包邮');Dd('express_name_2').value = '快递';Dd('fee_start_2').value = '10.00';">快递10元,满500包邮</span></span>
</td>
</tr>
<tr>
<td class="tl"><span class="f_hid">*</span> 货到付款</td>
<td>
<select name="post[cod]" id="cod">
<option value="0"<?php if($cod == 0) echo ' selected';?>>不支持货到付款</option>
<option value="1"<?php if($cod == 1) echo ' selected';?>>支持货到付款,不支持在线支付</option>
<option value="2"<?php if($cod == 2) echo ' selected';?>>支持货到付款,支持在线支付</option>
</select>
</td>
</tr>
<tr>
<td class="tl"><span class="f_red">*</span> 会员名</td>
<td><input name="post[username]" type="text" size="20" value="<?php echo $username;?>" id="username"/> <a href="javascript:_user(Dd('username').value);" class="t">[资料]</a> <span id="dusername" class="f_red"></span></td>
</tr>
<tr>
<td class="tl"><span class="f_hid">*</span> 会员推荐产品</td>
<td>
<input type="radio" name="post[elite]" value="1" <?php if($elite == 1) echo 'checked';?>/> 是
<input type="radio" name="post[elite]" value="0" <?php if($elite == 0) echo 'checked';?>/> 否
</td>
</tr>
<tr>
<td class="tl"><span class="f_hid">*</span> 信息状态</td>
<td>
<input type="radio" name="post[status]" value="3" <?php if($status == 3) echo 'checked';?>/> 通过
<input type="radio" name="post[status]" value="2" <?php if($status == 2) echo 'checked';?>/> 待审
<input type="radio" name="post[status]" value="1" <?php if($status == 1) echo 'checked';?> onclick="if(this.checked) Dd('note').style.display='';"/> 拒绝
<input type="radio" name="post[status]" value="4" <?php if($status == 4) echo 'checked';?>/> 下架
<input type="radio" name="post[status]" value="0" <?php if($status == 0) echo 'checked';?>/> 删除
</td>
</tr>
<tr id="note" style="display:<?php echo $status==1 ? '' : 'none';?>">
<td class="tl"><span class="f_red">*</span> 拒绝理由</td>
<td><input name="post[note]" type="text" size="40" value="<?php echo $note;?>"/></td>
</tr>
<tr>
<td class="tl"><span class="f_hid">*</span> 添加时间</td>
<td><input type="text" size="22" name="post[addtime]" value="<?php echo $addtime;?>"/></td>
</tr>
<tr>
<td class="tl"><span class="f_hid">*</span> 浏览次数</td>
<td><input name="post[hits]" type="text" size="10" value="<?php echo $hits;?>"/></td>
</tr>
<tr>
<td class="tl"><span class="f_hid">*</span> 内容收费</td>
<td><input name="post[fee]" type="text" size="5" value="<?php echo $fee;?>"/><?php tips('不填或填0表示继承模块设置价格,-1表示不收费<br/>大于0的数字表示具体收费价格');?>
</td>
</tr>
<tr>
<td class="tl"><span class="f_hid">*</span> 内容模板</td>
<td><?php echo tpl_select('show', $module, 'post[template]', '默认模板', $template, 'id="template"');?><?php tips('如果没有特殊需要,一般不需要选择<br/>系统会自动继承分类或模块设置');?></td>
</tr>
<?php if($MOD['show_html']) { ?>
<tr>
<td class="tl"><span class="f_hid">*</span> 自定义文件路径</td>
<td><input type="text" size="50" name="post[filepath]" value="<?php echo $filepath;?>" id="filepath"/> <input type="button" value="重名检测" onclick="ckpath(<?php echo $moduleid;?>, <?php echo $itemid;?>);" class="btn"/> <?php tips('可以包含目录和文件 例如 destoon/b2b.html<br/>请确保目录和文件名合法且可写入,否则可能生成失败');?> <span id="dfilepath" class="f_red"></span></td>
</tr>
<?php } ?>
</table>
<div class="sbt"><input type="submit" name="submit" value=" 确 定 " class="btn"/> <input type="reset" name="reset" value=" 重 置 " class="btn"/></div>
</form>
<?php load('clear.js'); ?>
<?php if($action == 'add') { ?>
<form method="post" action="?">
<input type="hidden" name="moduleid" value="<?php echo $moduleid;?>"/>
<input type="hidden" name="file" value="<?php echo $file;?>"/>
<input type="hidden" name="action" value="<?php echo $action;?>"/>
<div class="tt">单页采编</div>
<table cellpadding="2" cellspacing="1" class="tb">
<tr>
<td class="tl"><span class="f_hid">*</span> 目标网址</td>
<td><input name="url" type="text" size="80" value="<?php echo $url;?>"/> <input type="submit" value=" 获 取 " class="btn"/> <input type="button" value=" 管理规则 " class="btn" onclick="Dwidget('?file=fetch', '管理规则');"/></td>
</tr>
</table>
</form>
<?php } ?>
<script type="text/javascript">
function _p() {
if(Dd('tag').value) {
Ds('reccate');
}
}
function check() {
var l;
var f;
f = 'catid_1';
if(Dd(f).value == 0) {
Dmsg('请选择商品分类', 'catid', 1);
return false;
}
f = 'title';
l = Dd(f).value.length;
if(l < 2) {
Dmsg('商品名称最少2字,当前已输入'+l+'字', f);
return false;
}
f = 'amount';
l = Dd(f).value;
if(l < 1) {
Dmsg('请填写库存', f);
return false;
}
f = 'thumb';
l = Dd(f).value.length;
if(l < 5) {
Dmsg('请上传第一张商品图片', f, 1);
return false;
}
f = 'content';
l = FCKLen();
if(l < 5) {
Dmsg('详细说明最少5字,当前已输入'+l+'字', f);
return false;
}
f = 'username';
l = Dd(f).value.length;
if(l < 2) {
Dmsg('请填写会员名', f);
return false;
}
if(Dd('v1').value) {
if(!Dd('n1').value) {
alert('请填写属性名称');
Dd('n1').focus();
return false;
}
if(Dd('v1').value.indexOf('|') == -1) {
alert(Dd('n1').value+'至少需要两个属性');
Dd('v1').focus();
return false;
}
}
if(Dd('v2').value) {
if(!Dd('n2').value) {
alert('请填写属性名称');
Dd('n2').focus();
return false;
}
if(Dd('v2').value.indexOf('|') == -1) {
alert(Dd('n2').value+'至少需要两个属性');
Dd('v2').focus();
return false;
}
}
if(Dd('v3').value) {
if(!Dd('n3').value) {
alert('请填写属性名称');
Dd('n3').focus();
return false;
}
if(Dd('v3').value.indexOf('|') == -1) {
alert(Dd('n3').value+'至少需要两个属性');
Dd('v3').focus();
return false;
}
}
if(Dd('n1').value && (Dd('n1').value == Dd('n2').value || Dd('n1').value == Dd('n3').value)) {
alert('属性名称不能重复');
return false;
}
if(Dd('n2').value && (Dd('n2').value == Dd('n1').value || Dd('n2').value == Dd('n3').value)) {
alert('属性名称不能重复');
return false;
}
if(Dd('n3').value && (Dd('n3').value == Dd('n1').value || Dd('n3').value == Dd('n2').value)) {
alert('属性名称不能重复');
return false;
}
if(Dd('express_name_1').value && (Dd('express_name_1').value == Dd('express_name_2').value || Dd('express_name_1').value == Dd('express_name_3').value)) {
alert('快递名称不能重复');
return false;
}
if(Dd('express_name_2').value && (Dd('express_name_2').value == Dd('express_name_1').value || Dd('express_name_2').value == Dd('express_name_3').value)) {
alert('快递名称不能重复');
return false;
}
if(Dd('express_name_3').value && (Dd('express_name_3').value == Dd('express_name_1').value || Dd('express_name_3').value == Dd('express_name_2').value)) {
alert('快递名称不能重复');
return false;
}
<?php echo $FD ? fields_js() : '';?>
<?php echo $CP ? property_js() : '';?>
return Dstep();
}
function Dexpress(i, s) {
if(Dd('express_'+i).value > 0) {
var t1 = s.split('[');
var t2 = t1[1].split(',');
Dd('express_name_'+i).value = t2[0];
Dd('fee_start_'+i).value = t2[1];
Dd('fee_step_'+i).value = t2[2];
} else {
Dd('express_name_'+i).value = '';
Dd('fee_start_'+i).value = '';
Dd('fee_step_'+i).value = '';
}
}
function Nexpress(i, s) {
Dd('express_name_1').value = s;
Dd('fee_start_1').value = i;
Dd('fee_step_1').value = '0.00';
$('#express_1').val(0);
Dd('express_name_2').value = '';
Dd('fee_start_2').value = '0.00';
Dd('fee_step_2').value = '0.00';
$('#express_2').val(0);
Dd('express_name_3').value = '';
Dd('fee_start_3').value = '0.00';
Dd('fee_step_3').value = '0.00';
$('#express_3').val(0);
}
function Dstep() {
Dd('p_a_1').innerHTML=Dd('p_p_1').innerHTML=Dd('p_a_2').innerHTML=Dd('p_p_2').innerHTML=Dd('p_a_3').innerHTML=Dd('p_p_3').innerHTML='';
var a1 = parseInt(Dd('a1').value);
var p1 = parseFloat(Dd('p1').value);
var a2 = parseInt(Dd('a2').value);
var p2 = parseFloat(Dd('p2').value);
var a3 = parseInt(Dd('a3').value);
var p3 = parseFloat(Dd('p3').value);
var u = Dd('unit').value;
if(u.length < 1) Dd('unit').value = u = '件';
var m = '<?php echo $DT['money_unit'];?>';
if(!a1 || a1 < 1) {
alert('起订量必须大于0');
Dd('a1').value = '1';
Dd('a1').focus();
return false;
}
if(!p1 || p1 < 0.1) {
alert('请填写商品价格');
Dd('p1').value = '';
Dd('p1').focus();
return false;
}
Dd('p_a_1').innerHTML = a1+u+'以上';
Dd('p_p_1').innerHTML = p1+m+'/'+u;
if(a2 > 1 && p2 > 0.01) {
if(a2 <= a1) {
alert('数量必须大于'+a1);
Dd('a2').value = '';
Dd('a2').focus();
return false;
}
if(p2 >= p1) {
alert('价格必须小于'+p1);
Dd('p2').value = '';
Dd('p2').focus();
return false;
}
Dd('p_a_1').innerHTML = a1+'-'+a2+u;
Dd('p_p_1').innerHTML = p1+m+'/'+u;
Dd('p_a_2').innerHTML = '>'+a2+u;
Dd('p_p_2').innerHTML = p2+m+'/'+u;
}
if(a3 > 1 && p3 > 0.01) {
if(a3 <= a2) {
alert('数量必须大于'+a2);
Dd('a3').value = '';
Dd('a3').focus();
return false;
}
if(p3 >= p2) {
alert('价格必须小于'+p2);
Dd('p3').value = '';
Dd('p3').focus();
return false;
}
Dd('p_a_2').innerHTML = (a2+1)+'-'+a3+u;
Dd('p_p_2').innerHTML = p2+m+'/'+u;
Dd('p_a_3').innerHTML = '>'+a3+u;
Dd('p_p_3').innerHTML = p3+m+'/'+u;
}
return true;
}
</script>
<script type="text/javascript">Menuon(<?php echo $menuid;?>);</script>
<?php include tpl('footer');?>
以上代码只是增加:
<tr>
<td class="tl"><span class="f_hid">*</span> 所在地区</td>
<td><?php echo ajax_area_select('post[areaid]', '请选择', $areaid);?></td>
</tr>
而已。哈哈,接下来就是处理保存商品数据的操作:
module\mall\mall.class.php
<?php
defined('IN_DESTOON') or exit('Access Denied');
class mall {
var $moduleid;
var $itemid;
var $db;
var $table;
var $table_data;
var $split;
var $errmsg = errmsg;
function mall($moduleid) {
global $db, $table, $table_data, $MOD;
$this->moduleid = $moduleid;
$this->table = $table;
$this->table_data = $table_data;
$this->split = $MOD['split'];
$this->db = &$db;
$this->fields = array('catid','mycatid','areaid','level','title','style','fee','introduce','brand','price','step','amount','unit','thumb','thumb1','thumb2','tag','status','hits','username','editor','addtime','adddate','edittime','editdate','ip','template','linkurl','filepath','elite','note','company','truename','telephone','mobile','address','email','msn','qq','ali','skype','n1','n2','n3','v1','v2','v3','express_1','express_name_1','fee_start_1','fee_step_1','express_2','express_name_2','fee_start_2','fee_step_2','express_3','express_name_3','fee_start_3','fee_step_3','cod');
}
function pass($post) {
global $DT_TIME, $MOD;
if(!is_array($post)) return false;
if(!$post['catid']) return $this->_(lang('message->pass_cate'));
if(strlen($post['title']) < 3) return $this->_(lang('message->pass_title'));
if(dround($post['step']['p1']) < 0.1) return $this->_(lang('message->pass_mall_price'));
if(intval($post['amount']) < 1) return $this->_(lang('message->pass_mall_amount'));
if(!is_url($post['thumb'])) return $this->_(lang('message->pass_thumb'));
if(!$post['content']) return $this->_(lang('message->pass_content'));
if(DT_MAX_LEN && strlen($post['content']) > DT_MAX_LEN) return $this->_(lang('message->pass_max'));
return true;
}
function set($post) {
global $MOD, $DT_TIME, $DT_IP, $_username, $_userid;
is_url($post['thumb']) or $post['thumb'] = '';
is_url($post['thumb1']) or $post['thumb1'] = '';
is_url($post['thumb2']) or $post['thumb2'] = '';
$post['filepath'] = (isset($post['filepath']) && is_filepath($post['filepath'])) ? file_vname($post['filepath']) : '';
$post['editor'] = $_username;
$post['addtime'] = (isset($post['addtime']) && $post['addtime']) ? strtotime($post['addtime']) : $DT_TIME;
$post['adddate'] = timetodate($post['addtime'], 3);
$post['edittime'] = $DT_TIME;
$post['editdate'] = timetodate($post['edittime'], 3);
$post['fee'] = dround($post['fee']);
$post['step']['a1'] = intval($post['step']['a1']);
$post['step']['p1'] = dround($post['step']['p1'], 2, 1);
$post['step']['a2'] = intval($post['step']['a2']);
$post['step']['p2'] = dround($post['step']['p2'], 2, 1);
$post['step']['a3'] = intval($post['step']['a3']);
$post['step']['p3'] = dround($post['step']['p3'], 2, 1);
$post['price'] = $post['step']['p1'];
if(($post['step']['a2'] && $post['step']['a2'] <= $post['step']['a1']) || ($post['step']['p2'] && $post['step']['p2'] >= $post['step']['p1'])) $post['step']['a2'] = $post['step']['a3'] = $post['step']['p2'] = $post['step']['p3'] = 0;
if(($post['step']['a3'] && $post['step']['a3'] <= $post['step']['a2']) || ($post['step']['p3'] && $post['step']['p3'] >= $post['step']['p2'])) $post['step']['a3'] = $post['step']['p3'] = 0;
$post['step']['is'] = $post['step']['a2'] ? 'Y' : 'N';
count($post['step'] == 7) or exit;
$post['amount'] = intval($post['amount']);
$post['mycatid'] = intval($post['mycatid']);
$post['elite'] = $post['elite'] ? 1 : 0;
if(strpos($post['v1'], '|') === false) $post['n1'] = $post['v1'] = '';
if(strpos($post['v2'], '|') === false) $post['n2'] = $post['v2'] = '';
if(strpos($post['v3'], '|') === false) $post['n3'] = $post['v3'] = '';
$post['express_1'] = intval($post['express_1']);
$post['fee_start_1'] = dround($post['fee_start_1']);
$post['fee_step_1'] = dround($post['fee_step_1']);
$post['express_2'] = intval($post['express_2']);
$post['fee_start_2'] = dround($post['fee_start_2']);
$post['fee_step_2'] = dround($post['fee_step_2']);
$post['express_3'] = intval($post['express_3']);
$post['fee_start_3'] = dround($post['fee_start_3']);
$post['fee_step_3'] = dround($post['fee_step_3']);
$post['cod'] = intval($post['cod']);
$post['content'] = stripslashes($post['content']);
$post['content'] = save_local($post['content']);
if($MOD['clear_link']) $post['content'] = clear_link($post['content']);
if($MOD['save_remotepic']) $post['content'] = save_remote($post['content']);
if($MOD['introduce_length']) $post['introduce'] = addslashes(get_intro($post['content'], $MOD['introduce_length']));
if($this->itemid) {
$new = $post['content'];
if($post['thumb']) $new .= '<img src="'.$post['thumb'].'"/>';
if($post['thumb1']) $new .= '<img src="'.$post['thumb1'].'"/>';
if($post['thumb2']) $new .= '<img src="'.$post['thumb2'].'"/>';
$r = $this->get_one();
$old = $r['content'];
if($r['thumb']) $old .= '<img src="'.$r['thumb'].'"/>';
if($r['thumb1']) $old .= '<img src="'.$r['thumb1'].'"/>';
if($r['thumb2']) $old .= '<img src="'.$r['thumb2'].'"/>';
delete_diff($new, $old);
} else {
$post['ip'] = $DT_IP;
}
$content = $post['content'];
unset($post['content']);
$post = dhtmlspecialchars($post);
$post['step'] = serialize($post['step']);
$post['content'] = addslashes(dsafe($content));
return array_map("trim", $post);
}
function get_one() {
$r = $this->db->get_one("SELECT * FROM {$this->table} WHERE itemid=$this->itemid");
if($r) {
$content_table = content_table($this->moduleid, $this->itemid, $this->split, $this->table_data);
$t = $this->db->get_one("SELECT content FROM {$content_table} WHERE itemid=$this->itemid");
$r['content'] = $t ? $t['content'] : '';
return $r;
} else {
return array();
}
}
function get_list($condition = 'status=3', $order = 'edittime DESC', $cache = '') {
global $MOD, $pages, $page, $pagesize, $offset, $items, $sum;
if($page > 1 && $sum) {
$items = $sum;
} else {
$r = $this->db->get_one("SELECT COUNT(*) AS num FROM {$this->table} WHERE $condition", $cache);
$items = $r['num'];
}
$pages = defined('CATID') ? listpages(1, CATID, $items, $page, $pagesize, 10, $MOD['linkurl']) : pages($items, $page, $pagesize);
if($items < 1) return array();
$lists = $catids = $CATS = array();
$result = $this->db->query("SELECT * FROM {$this->table} WHERE $condition ORDER BY $order LIMIT $offset,$pagesize", $cache);
while($r = $this->db->fetch_array($result)) {
$r['alt'] = $r['title'];
$r['title'] = set_style($r['title'], $r['style']);
$r['userurl'] = userurl($r['username']);
$r['linkurl'] = $MOD['linkurl'].$r['linkurl'];
$catids[$r['catid']] = $r['catid'];
$lists[] = $r;
}
if($catids) {
$result = $this->db->query("SELECT catid,catname,linkurl FROM {$this->db->pre}category WHERE catid IN (".implode(',', $catids).")");
while($r = $this->db->fetch_array($result)) {
$CATS[$r['catid']] = $r;
}
if($CATS) {
foreach($lists as $k=>$v) {
$lists[$k]['catname'] = $v['catid'] ? $CATS[$v['catid']]['catname'] : '';
$lists[$k]['caturl'] = $v['catid'] ? $MOD['linkurl'].$CATS[$v['catid']]['linkurl'] : '';
}
}
}
return $lists;
}
function add($post) {
global $MOD;
$post = $this->set($post);
$sqlk = $sqlv = '';
foreach($post as $k=>$v) {
if(in_array($k, $this->fields)) { $sqlk .= ','.$k; $sqlv .= ",'$v'"; }
}
$sqlk = substr($sqlk, 1);
$sqlv = substr($sqlv, 1);
$this->db->query("INSERT INTO {$this->table} ($sqlk) VALUES ($sqlv)");
$this->itemid = $this->db->insert_id();
$content_table = content_table($this->moduleid, $this->itemid, $this->split, $this->table_data);
$this->db->query("REPLACE INTO {$content_table} (itemid,content) VALUES ('$this->itemid', '$post[content]')");
$this->update($this->itemid);
if($post['status'] == 3 && $post['username'] && $MOD['credit_add']) {
credit_add($post['username'], $MOD['credit_add']);
credit_record($post['username'], $MOD['credit_add'], 'system', lang('my->credit_record_add', array($MOD['name'])), 'ID:'.$this->itemid);
}
clear_upload($post['content'].$post['thumb'].$post['thumb1'].$post['thumb2'], $this->itemid);
return $this->itemid;
}
function edit($post) {
$this->delete($this->itemid, false);
$post = $this->set($post);
$sql = '';
foreach($post as $k=>$v) {
if(in_array($k, $this->fields)) $sql .= ",$k='$v'";
}
$sql = substr($sql, 1);
$this->db->query("UPDATE {$this->table} SET $sql WHERE itemid=$this->itemid");
$content_table = content_table($this->moduleid, $this->itemid, $this->split, $this->table_data);
$this->db->query("REPLACE INTO {$content_table} (itemid,content) VALUES ('$this->itemid', '$post[content]')");
$this->update($this->itemid);
clear_upload($post['content'].$post['thumb'].$post['thumb1'].$post['thumb2'], $this->itemid);
if($post['status'] > 2) $this->tohtml($this->itemid, $post['catid']);
return true;
}
function tohtml($itemid = 0, $catid = 0) {
global $module, $MOD;
if($MOD['show_html'] && $itemid) tohtml('show', $module, "itemid=$itemid");
}
function update($itemid) {
$item = $this->db->get_one("SELECT * FROM {$this->table} WHERE itemid=$itemid");
$update = '';
$keyword = $item['title'].','.($item['brand'] ? $item['brand'].',' : '').strip_tags(cat_pos(get_cat($item['catid']), ','));
if($keyword != $item['keyword']) {
$keyword = str_replace("//", '', addslashes($keyword));
$update .= ",keyword='$keyword'";
}
$item['itemid'] = $itemid;
$linkurl = itemurl($item);
if($linkurl != $item['linkurl']) $update .= ",linkurl='$linkurl'";
$member = $item['username'] ? userinfo($item['username']) : array();
//if($member) $update .= update_user($member, $item);
if($update) $this->db->query("UPDATE {$this->table} SET ".(substr($update, 1))." WHERE itemid=$itemid");
}
function recycle($itemid) {
if(is_array($itemid)) {
foreach($itemid as $v) { $this->recycle($v); }
} else {
$this->db->query("UPDATE {$this->table} SET status=0 WHERE itemid=$itemid");
$this->delete($itemid, false);
return true;
}
}
function restore($itemid) {
global $module, $MOD;
if(is_array($itemid)) {
foreach($itemid as $v) { $this->restore($v); }
} else {
$this->db->query("UPDATE {$this->table} SET status=3 WHERE itemid=$itemid");
if($MOD['show_html']) tohtml('show', $module, "itemid=$itemid");
return true;
}
}
function delete($itemid, $all = true) {
global $MOD;
if(is_array($itemid)) {
foreach($itemid as $v) {
$this->delete($v, $all);
}
} else {
$this->itemid = $itemid;
$r = $this->get_one();
if($MOD['show_html']) {
$_file = DT_ROOT.'/'.$MOD['moduledir'].'/'.$r['linkurl'];
if(is_file($_file)) unlink($_file);
}
if($all) {
$userid = get_user($r['username']);
if($r['thumb']) delete_upload($r['thumb'], $userid);
if($r['thumb1']) delete_upload($r['thumb1'], $userid);
if($r['thumb2']) delete_upload($r['thumb2'], $userid);
if($r['content']) delete_local($r['content'], $userid);
$this->db->query("DELETE FROM {$this->table} WHERE itemid=$itemid");
$content_table = content_table($this->moduleid, $this->itemid, $this->split, $this->table_data);
$this->db->query("DELETE FROM {$content_table} WHERE itemid=$itemid");
if($MOD['cat_property']) $this->db->query("DELETE FROM {$this->db->pre}category_value WHERE moduleid=$this->moduleid AND itemid=$itemid");
if($r['username'] && $MOD['credit_del']) {
credit_add($r['username'], -$MOD['credit_del']);
credit_record($r['username'], -$MOD['credit_del'], 'system', lang('my->credit_record_del', array($MOD['name'])), 'ID:'.$this->itemid);
}
}
}
}
function check($itemid) {
global $_username, $DT_TIME, $MOD;
if(is_array($itemid)) {
foreach($itemid as $v) { $this->check($v); }
} else {
$this->itemid = $itemid;
$item = $this->get_one();
if($MOD['credit_add'] && $item['username'] && $item['hits'] < 1) {
credit_add($item['username'], $MOD['credit_add']);
credit_record($item['username'], $MOD['credit_add'], 'system', lang('my->credit_record_add', array($MOD['name'])), 'ID:'.$this->itemid);
}
$editdate = timetodate($DT_TIME, 3);
$this->db->query("UPDATE {$this->table} SET status=3,hits=hits+1,editor='$_username',edittime=$DT_TIME,editdate='$editdate' WHERE itemid=$itemid");
$this->tohtml($itemid);
return true;
}
}
function reject($itemid) {
global $_username, $DT_TIME;
if(is_array($itemid)) {
foreach($itemid as $v) { $this->reject($v); }
} else {
$this->db->query("UPDATE {$this->table} SET status=1,editor='$_username' WHERE itemid=$itemid");
return true;
}
}
function unsale($itemid) {
global $_username, $DT_TIME;
if(is_array($itemid)) {
foreach($itemid as $v) { $this->unsale($v); }
} else {
$this->db->query("UPDATE {$this->table} SET status=4,editor='$_username' WHERE itemid=$itemid");
return true;
}
}
function onsale($itemid) {
global $_username, $DT_TIME;
if(is_array($itemid)) {
foreach($itemid as $v) { $this->onsale($v); }
} else {
$this->db->query("UPDATE {$this->table} SET status=3,editor='$_username' WHERE itemid=$itemid");
return true;
}
}
function clear($condition = 'status=0') {
$result = $this->db->query("SELECT itemid FROM {$this->table} WHERE $condition");
while($r = $this->db->fetch_array($result)) {
$this->delete($r['itemid']);
}
}
function level($itemid, $level) {
$itemids = is_array($itemid) ? implode(',', $itemid) : $itemid;
$this->db->query("UPDATE {$this->table} SET level=$level WHERE itemid IN ($itemids)");
}
function type($itemid, $typeid) {
$itemids = is_array($itemid) ? implode(',', $itemid) : $itemid;
$this->db->query("UPDATE {$this->table} SET typeid=$typeid WHERE itemid IN ($itemids)");
}
function refresh($itemid) {
global $DT_TIME;
$editdate = timetodate($DT_TIME, 3);
$itemids = is_array($itemid) ? implode(',', $itemid) : $itemid;
$this->db->query("UPDATE {$this->table} SET edittime='$DT_TIME',editdate='$editdate' WHERE itemid IN ($itemids)");
}
function relate_add($M, $A, $N) {
if($M['relate_id']) {
$itemids = $M['relate_id'];
if(strpos(','.$M['relate_id'].',', ','.$A['itemid'].',') === false) {
$itemids = $M['relate_id'].','.$A['itemid'];
}
} else {
$itemids = $M['itemid'].','.$A['itemid'];
}
$this->db->query("UPDATE {$this->table} SET relate_id='$itemids',relate_name='$N' WHERE itemid IN ($itemids)");
}
function relate_del($M, $A) {
if($M['relate_id'] == $A['relate_id']) {
$ids = explode(',', $M['relate_id']);
foreach($ids as $k=>$v) {
if($v == $A['itemid']) unset($ids[$k]);
}
$this->db->query("UPDATE {$this->table} SET relate_id='',relate_name='',relate_title='' WHERE itemid=$A[itemid]");
$itemids = implode(',', $ids);
if(is_numeric($itemids)) {
$this->db->query("UPDATE {$this->table} SET relate_id='',relate_name='',relate_title='' WHERE itemid=$itemids");
} else {
$this->db->query("UPDATE {$this->table} SET relate_id='$itemids' WHERE itemid IN ($itemids)");
}
}
}
function relate($M, $P, $N) {
$S = $I = array();
foreach($P as $k=>$v) {
$S[$k] = intval($v['listorder']);
}
asort($S);
foreach($S as $k=>$v) {
$I[] = $k;
}
$itemids = implode(',', $I);
foreach($P as $k=>$v) {
$T = dhtmlspecialchars(trim($v['relate_title']));
$this->db->query("UPDATE {$this->table} SET relate_id='$itemids',relate_name='$N',relate_title='$T' WHERE itemid=$k");
}
}
function relate_list($M) {
if($M['relate_id']) {
$ids = $M['relate_id'];
$lists = $tags = array();
$result = $this->db->query("SELECT * FROM {$this->table} WHERE itemid IN ($ids)");
while($r = $this->db->fetch_array($result)) {
$tags[$r['itemid']] = $r;
}
foreach(explode(',', $ids) as $v) {
$lists[] = $tags[$v];
}
return $lists;
} else {
return array(0 => $M);
}
}
function _($e) {
$this->errmsg = $e;
return false;
}
}
?>
以上代码注释:
//if($member) $update .= update_user($member, $item);
其实每次在查询商品时,destoon都会对商品设置地区为默认地区的。代码如下:
\module\mall\show.inc.php
<?php
defined('IN_DESTOON') or exit('Access Denied');
$itemid or dheader($MOD['linkurl']);
if(!check_group($_groupid, $MOD['group_show'])) include load('403.inc');
require DT_ROOT.'/module/'.$module.'/common.inc.php';
$item = $db->get_one("SELECT * FROM {$table} WHERE itemid=$itemid");
if($item['groupid'] == 2) include load('404.inc');
if($item && $item['status'] > 2) {
if($MOD['show_html'] && is_file(DT_ROOT.'/'.$MOD['moduledir'].'/'.$item['linkurl'])) d301($MOD['linkurl'].$item['linkurl']);
extract($item);
} else {
include load('404.inc');
}
$CAT = get_cat($catid);
if(!check_group($_groupid, $CAT['group_show'])) include load('403.inc');
$content_table = content_table($moduleid, $itemid, $MOD['split'], $table_data);
$t = $db->get_one("SELECT content FROM {$content_table} WHERE itemid=$itemid");
$content = $t['content'];
if($lazy) $content = img_lazy($content);
if($MOD['keylink']) $content = keylink($content, $moduleid);
$CP = $MOD['cat_property'] && $CAT['property'];
if($CP) {
require DT_ROOT.'/include/property.func.php';
$options = property_option($catid);
$values = property_value($moduleid, $itemid);
}
$RL = $relate_id ? get_relate($item) : array();
$P1 = get_nv($n1, $v1);
$P2 = get_nv($n2, $v2);
$P3 = get_nv($n3, $v3);
if($step) {
extract(unserialize($step));
} else {
$a1 = 1;
$p1 = $item['price'];
$a2 = $a3 = $p2 = $p3 = '';
}
$unit or $unit = $L['unit'];
$adddate = timetodate($addtime, 3);
$editdate = timetodate($edittime, 3);
$linkurl = $MOD['linkurl'].$linkurl;
$thumbs = get_albums($item);
$albums = get_albums($item, 1);
$amount = number_format($amount, 0, '.', '');
$fee = get_fee($item['fee'], $MOD['fee_view']);
$update = '';
if(check_group($_groupid, $MOD['group_contact'])) {
if($fee) {
$user_status = 4;
$destoon_task = "moduleid=$moduleid&html=show&itemid=$itemid";
} else {
$user_status = 3;
$member = $item['username'] ? userinfo($item['username']) : array();
if($member) {
$update_user = update_user($member, $item);
//if($update_user) $db->query("UPDATE {$table} SET ".substr($update_user, 1)." WHERE username='$username'");
}
}
} else {
$user_status = $_userid ? 1 : 0;
if($_username && $item['username'] == $_username) {
$member = userinfo($item['username']);
$user_status = 3;
}
}
include DT_ROOT.'/include/update.inc.php';
$seo_file = 'show';
include DT_ROOT.'/include/seo.inc.php';
if($EXT['mobile_enable']) $head_mobile = $EXT['mobile_url'].mobileurl($moduleid, 0, $itemid, $page);
$template = $item['template'] ? $item['template'] : ($CAT['show_template'] ? $CAT['show_template'] : 'show');
include template($template, $module);
?>
以上注释代码:
//if($update_user) $db->query("UPDATE {$table} SET ".substr($update_user, 1)." WHERE username='$username'");
完成相应操作。可以设置地区了