thinkphp 3.2 省市区联动

时间:2020-12-18 09:23:47
【文件属性】:
文件名称:thinkphp 3.2 省市区联动
文件大小:215KB
文件格式:SQL
更新时间:2020-12-18 09:23:47
省市区联动 PHP代码 <?php namespace Admin\Controller; use Think\Controller; class GoodController extends Controller { public function release() { /* * 开始新的操作 * */ $data=array(); $data['productname']=$_POST['productname']; $data['introduction']=$_POST['introduction']; $data['codenumber']=$_POST['codenumber']; $data['Productunit']=I('post.Productunit'); $data['sku']=I('post.sku'); $data['province']=I('post.province'); $data['city']=I('post.city'); $data['town']=I('post.town'); $data['classification']=I('post.classification'); $data['Extendedclass']=I('post.Extendedclass'); $data['Commoditybrand']=I('post.Commoditybrand'); $data['Commoditybrand']=I('post.Commoditybrand'); $data['Shopprice']=I('post.Shopprice'); $data['Marketvalue']=I('post.Marketvalue'); $data['Capitalizedcost']=I('post.Capitalizedcost'); $data['Commission']=I('post.Commission'); $data['original_img']=I('post.original_img'); /*商品重量*/ $data['Commodityweight']=I('post.Commodityweight'); $data['mail']=I('post.mail'); /*库存数量*/ $data['Inventoryquantity']=I('post.Inventoryquantity'); /*赠送积分*/ $data['Giftpoints']=I('post.Giftpoints'); /*兑换积分*/ $data['exchange_integral']=I('post.exchange_integral'); /*商品关检词*/ $data['Keyword']=I('post.Keyword'); /*商品详情描述*/ $data['describe']=I('post.describe'); $commodity=M('commodity'); /*准备开启事物*/ $commodity->startTrans(); $result=$commodity->add($data); if(!$result){ /*回滚事物*/ $commodity->rollback(); }else{ /*提交事物*/ $commodity->commit(); } /*1导入thinkphp得我自带的auth类库 * 加锁操作。若果同个用户(判断同个用户名操作)同时加入同样的sku时, * 那么如果存在时就加不上去(数量),如果不存在时(如果不存在时的数量不一样时)就insert上去 * */ $province = M('prvices')->where ( array('pid'=>1) )->select (); $this->assign('province',$province); $this->display(); } public function getRegion(){ /* * 接收市区 * */ $Region=M("prvices"); $map['pid']=$_REQUEST["pid"]; $map['type']=$_REQUEST["type"]; $list=$Region->where($map)->select(); echo json_encode($list); } public function sku() { $this->display(); } } html: 商品所在地 function loadRegion(sel,type_id,selName,url){ jQuery("#"+selName+" option").each(function(){ jQuery(this).remove(); }); jQuery("").appendTo(jQuery("#"+selName)); if(jQuery("#"+sel).val()==0){ return; } jQuery.getJSON(url,{pid:jQuery("#"+sel).val(),type:type_id}, function(data){ if(data){ jQuery.each(data,function(idx,item){ jQuery("").appendTo(jQuery("#"+selName)); }); }else{ jQuery("").appendTo(jQuery("#"+selName)); } } ); }

网友评论