后台增加协议模块 2、添加课程增加选择协议 3、在支付增加同意并阅读环节 路径:\app\app\shop\web\templates\met shop_pay_index.php 代码1: JS代码 script src = "https://cdn.bootcss.com/jquery/3.3.1/jquery.j
后台增加协议模块
2、添加课程增加选择协议
3、在支付增加同意并阅读环节
路径:\app\app\shop\web\templates\met shop_pay_index.php
代码1:
JS代码
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script><script type="text/javascript">
//勾选协议 打开协议
$("input[id='checkAgree']").click(function(){
// console.log($(this).val());
//collapseExample10
//console.log($("div[id='collapseExample"+$(this).val()+"']").prop("aria-expanded"));
if($(this).prop('checked')){
$("#collapseExample"+$(this).val()+"").attr("class","row collapse in")
$("#collapseExample"+$(this).val()+"").attr("aria-expanded",true)
}else{
$("#collapseExample"+$(this).val()+"").attr("class","row collapse")
$("#collapseExample"+$(this).val()+"").attr("aria-expanded",false)
$("#collapseExample"+$(this).val()+"").attr("style","")
}
})
//检查协议是否勾选
function checkf() {
var l1 = $("input:checkbox").length;
var l2 = $("input:checkbox:checked").length;
//return false;
if (l1!=l2) {
alert("请同意勾选阅读并接受所有协议!");
return false;
} else {
return true;
}
}
</script>
完整代码:
<?php$met_title = $_M['word']['app_shop_placeorder'];
$page_type='pay';
$paths['formvalidation']=1;
$paths['labelauty']=1;
$paths['animsition']=1;
$paths['cityselect']=1;
$paths['address']=1;
$paths[$page_type]=1;
require_once $this->template('tem/shop_head');
$form_url=$metinfo_member_name?$_M['url']['shop_pay_placeorder']:$_M['url']['shop_choose'];
echo <<<EOT
-->
<div class="page bg-pagebg1 animsition" data-plugin="animsition">
<div class="container">
<div class="page-content row">
<div class="panel m-b-0">
<div class="panel-body pay-body">
<form action="{$_M['url']['shop_pay_placeorder']}" method='post' class="pay-form met-form-validation">
<input name="cidlist" type="hidden" value="{$cidlist}">
<!--
EOT;
if($need_email){
echo <<<EOT
-->
<div class="example-wrap">
<div class="example">
<div class="form-group clearfix m-b-0">
<label class="pull-xs-left example-title control-label w-150 m-t-5 m-b-15">{$_M['word']['app_shop_receiveemail']}</label>
<div class="pull-xs-left">
<input type="text" class="form-control w-250 pull-xs-left" name="email" placeholder='{$_M['word']['app_shop_receiveemail_prompt']}' required data-fv-notempty-message="{$_M['word']['Prompt_email']}" data-fv-emailAddress="true">
</div>
</div>
</div>
</div>
<hr>
<!--
EOT;
}
if($logistic||$_M['config']['shopv2_gi']){
echo <<<EOT
-->
<div class="example-wrap">
<input name="addressid" id="addressid" type="hidden" value="{$addr_de}">
<div class="example">
<div class="form-group clearfix m-b-0">
<label class="pull-xs-left example-title control-label w-150 m-t-5 m-b-15">{$_M['word']['app_shop_address']}</label>
<div class="pull-xs-left">
<button type="button" class="btn btn-outline btn-success btn-squared addr-btn">{$_M['word']['app_shop_addto']}{$_M['word']['app_shop_address']}</button>
</div>
</div>
<div class="blocks-100 blocks-sm-2 blocks-md-3 addr-body m-b-0">
<div class="loader vertical-align-middle loader-default m-l-30"></div>
</div>
</div>
</div>
<hr>
<!--
EOT;
}
echo <<<EOT
-->
<div class="example-wrap">
<div class="example">
<div class="form-group">
<label class="pull-sm-left example-title control-label w-150 m-t-5">{$_M['word']['app_shop_paymentmod']}</label>
<div class="pull-sm-left pay-set-body">
<!--
EOT;
$checked = '';
if($_M['config']['shopv2_onlinepay']){
$checked = 'checked';
echo <<<EOT
-->
<div class="pull-xs-left">
<input type="radio" name="paytype" value="1" data-plugin="labelauty" data-labelauty="{$_M['word']['app_shop_paymentonline']}" {$checked}/>
</div>
<!--
EOT;
}
if($_M['config']['shopv2_deliverypay']){
$checked = $checked==''?'checked':'';
echo <<<EOT
-->
<div class="pull-xs-left">
<input type="radio" name="paytype" value="2" data-plugin="labelauty" data-labelauty="{$_M['word']['app_shop_paymentcod']}" {$checked}/>
</div>
<!--
EOT;
}
echo <<<EOT
-->
</div>
</div>
</div>
</div>
<hr>
<!--
EOT;
if($logistic||$_M['config']['shopv2_gi']){
echo <<<EOT
-->
<div class="example-wrap">
<div class="example">
<div class="form-group">
<label class="pull-xs-left example-title control-label w-150 m-b-0">{$_M['word']['app_shop_delivery']}</label>
<div class="pull-xs-left red-600 m-t-5">
{$freight_type_str}
</div>
</div>
</div>
</div>
<hr>
<!--
EOT;
}
// 发票
if($_M['config']['shopv2_gi']){
echo <<<EOT
-->
<input name="invoice_type" type="hidden" value="1">
<div class="example-wrap">
<div class="example">
<div class="form-group">
<label class="pull-sm-left example-title control-label w-150">{$_M['word']['app_shop_invoice']}</label>
<div class="pull-sm-left pay-set-body">
<div class="clearfix">
<div class="pull-xs-left">
<input type="radio" name="invoice_is" value="0" data-plugin="labelauty" data-labelauty="{$_M['word']['app_shop_unwanted']}" checked/>
</div>
<div class="pull-xs-left">
<input type="radio" name="invoice_is" value="1" data-plugin="labelauty" data-labelauty="{$_M['word']['app_shop_need']}" />
</div>
</div>
<div class="collapse" id="invoice-body">
<div class="well m-t-20 m-b-0">
<div class="form-group m-b-10">
<input type="text" class="form-control" name="invoice_title" required placeholder="{$_M['word']['app_shop_invoicehead']}" data-fv-notempty-message="{$_M['word']['app_shop_invoicehead']}">
</div>
<div class="form-group m-b-0">
<input type="text" class="form-control" name="invoice_credit_code" required placeholder="{$_M['word']['app_shop_creditcode']}" data-fv-notempty-message="{$_M['word']['app_shop_creditcode']}">
</div>
<!--
EOT;
if($_M['config']['shopv2_invoice']){
$invoice_c = explode(',', $_M['config']['shopv2_invoice']);
$invoice_mt=count($invoice_c)>1?' m-t-10':'';
echo <<<EOT
-->
<div class="form-group clearfix m-t-10 m-b-0">
<label class="control-label pull-xs-left m-b-0 m-r-10{$invoice_mt}">{$_M['word']['app_shop_invoicecontent']} : </label>
<div class="pull-xs-left">
<!--
EOT;
if(count($invoice_c)>1){
$invoice_html = '<select class="form-control" name="invoice_con">';
foreach($invoice_c as $key=>$val){
if($val)$invoice_html.= "<option value=\"{$val}\">{$val}</option>";
}
$invoice_html.= '</select>';
}else{
$invoice_html = $invoice_c[0];
}
echo <<<EOT
-->
{$invoice_html}
</div>
</div>
<!--
EOT;
}
echo <<<EOT
-->
</div>
</div>
</div>
</div>
</div>
</div>
<hr>
<!--
EOT;
}
echo <<<EOT
-->
<div class="example-wrap">
<h3 class="example-title">{$_M['word']['app_shop_commodity']}</h3>
<div class="example bg-blue-grey-100">
<!--
EOT;
// 订单商品
$pgoods_img_y=round(60*$met_productimg_y/$met_productimg_x);
foreach($pgoods as $val){
$val[para_str] = str_replace(","," ",$val[para_str]);
$val[img]=str_replace($_M[url][site],'',$val[img]);
//取出该课程的协议
$ag_rs=DB::get_one("SELECT ".$_M['table']['my_agreement'].".id,".$_M['table']['my_agreement'].".content FROM ".$_M['table']['product']." INNER JOIN ".$_M['table']['my_agreement']." ON ".$_M['table']['my_agreement'].".id=".$_M['table']['product'].".agreement WHERE ".$_M['table']['product'].".id = '$val[pid]'");
echo <<<EOT
-->
<div class="pay-goods-body">
<div class="row">
<div class="col-sm-6 col-xs-8">
<div class="media media-xs">
<div class="col-sm-5 red-600 text-xs-left">
<!--
EOT;
//此课程有协议才出现
if($ag_rs['id']){
echo <<<EOT
-->
<input name="checkAgree" value="{$val[id]}" id="checkAgree" type="checkbox" ><a role="button" data-toggle="collapse" href="#collapseExample{$val[id]}" >阅读并接受务协议</a>
<!--
EOT;
}
echo <<<EOT
-->
</div>
<div class="media-left">
<a href="{$val[url]}" title='{$val[name]}' target="_blank">
<img class="media-object" src="{$navurl}include/thumb.php?dir={$val[img]}&x=60&y={$pgoods_img_y}" alt="{$val[name]}">
</a>
</div>
<div class="media-body">
<h4 class="media-heading"><a href="{$val[url]}" title='{$val[name]}' target="_blank">{$val[name]}</a></h4>
{$val[para_str]}
</div>
</div>
</div>
<div class="col-sm-3 col-xs-4 text-nowrap text-xs-right">
{$val[price_str]} <span class="p-num">x {$val[amount]}</span>
</div>
<div class="col-sm-3 col-xs-4 red-600 text-xs-right">
{$val[subtotal]}
</div>
</div>
<!--
EOT;
//此课程有协议才出现
if($ag_rs['id']){
echo <<<EOT
-->
<!--协议内容-->
<div class="row collapse" id="collapseExample{$val[id]}">
<div class="well" style="background-color: #fff">
{$ag_rs['content']}
</div>
</div>
<!--
EOT;
}
echo <<<EOT
-->
<!--
EOT;
foreach($val['message'] as $key=>$msg){
$msg['required'] = $msg['required']?" required data-fv-notempty-message='{$_M['word']['MessageInfo4']}'":'';
if($msg['line']){
echo <<<EOT
-->
<div class="form-group m-t-15 m-b-0 p-message">
<textarea class="form-control" rows="3" name="msg_{$val['id']}_{$val['pid']}_{$key}" placeholder="{$msg[name]}"{$msg['required']}></textarea>
</div>
<!--
EOT;
}else{
echo <<<EOT
-->
<div class="form-group m-t-15 m-b-0 p-message">
<input placeholder="{$msg[name]}" class="form-control" name="msg_{$val['id']}_{$val['pid']}_{$key}"{$msg['required']}>
</div>
<!--
EOT;
}
}
echo <<<EOT
-->
</div>
<!--
EOT;
}
echo <<<EOT
-->
</div>
<div class="message form-group m-b-0">
<textarea class="form-control" rows="3" name="message" placeholder="{$_M['word']['app_shop_message']}"></textarea>
</div>
</div>
<hr>
<!--
EOT;
if($discounts){
echo <<<EOT
-->
<div class="example-wrap m-t-40 m-b-0">
<h3 class="example-title">{$_M['word']['app_shop_discount']}</h3>
<div class="example m-b-0 blocks-2 blocks-sm-3 blocks-lg-4 blocks-xl-5 pay-discount-body">
<input type="hidden" name='discount' value='{$discounts[0][id]}'>
<!--
EOT;
foreach ($discounts as $key=> $value) {
if($val[instructions]) $value[instructions]="{$_M['word']['app_shop_instructions']} : {$value[instructions]}";
$val[checked]=$key?'':'checked';
echo <<<EOT
-->
<li>
<input type="radio" name='discountval' value='{$value[id]}' data-plugin="labelauty" data-labelauty="
<span class='font-size-16'>{$_M['word']['app_shop_order_achieve']} {$value[r_price]} {$_M['word']['app_shop_order_reduce']} {$value[par]}</span>
<hr class='m-y-5'>
<div class='blue-grey-400'>{$_M['word']['app_shop_period_validity']}{$_M['word']['app_shop_to']} {$value[e_time_str]}
</div>
" {$val[checked]}/>
</li>
<!--
EOT;
}
echo <<<EOT
-->
<li>
<input type="radio" name='discountval' value='' data-plugin="labelauty" data-labelauty="
<div class='font-size-16' style='height:44px;padding-top:16px;padding-bottom:16px;'>{$_M['word']['app_shop_notusediscount']}</div>
"/>
</li>
</div>
</div>
<hr>
<!--
EOT;
}
echo <<<EOT
-->
<div class="pay-submit">
<div class="row">
<div class="col-xl-8 col-md-6 text-xs-right" style='line-height: 1.8;'>
{$_M['word']['app_shop_intotal']} <span id="pay-amount" class="red-600"></span> {$_M['word']['app_shop_piece']}{$_M['word']['app_shop_commodity']},{$_M['word']['app_shop_total']} : <span id="pay-total" class="red-600"></span>
</div>
<div class="col-xl-4 col-md-6 text-xs-right">
<a class="btn btn-lg btn-squared btn-default p-x-30 m-r-10" href='{$_M['url']['shop_cart']}'>{$_M['word']['app_shop_return']}{$_M['word']['app_shop_cart']}</a>
<input type="submit" οnclick="return checkf();" value='{$_M['word']['app_shop_placeorder']}' class="btn btn-lg btn-squared btn-danger p-x-30">
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
<script type="text/javascript">
//勾选协议 打开协议
$("input[id='checkAgree']").click(function(){
// console.log($(this).val());
//collapseExample10
//console.log($("div[id='collapseExample"+$(this).val()+"']").prop("aria-expanded"));
if($(this).prop('checked')){
$("#collapseExample"+$(this).val()+"").attr("class","row collapse in")
$("#collapseExample"+$(this).val()+"").attr("aria-expanded",true)
}else{
$("#collapseExample"+$(this).val()+"").attr("class","row collapse")
$("#collapseExample"+$(this).val()+"").attr("aria-expanded",false)
$("#collapseExample"+$(this).val()+"").attr("style","")
}
})
//检查协议是否勾选
function checkf() {
var l1 = $("input:checkbox").length;
var l2 = $("input:checkbox:checked").length;
//return false;
if (l1!=l2) {
alert("请同意勾选阅读并接受所有协议!");
return false;
} else {
return true;
}
}
</script>
<script>
var addrlisturl = '{$_M['url']['shop_addr_index']}',
addrdelurl = '{$_M['url']['shop_addr_del']}',
shop_ajax_total = '{$_M['url']['shop_ajax_total']}';
</script>
<!--
EOT;
require_once $this->template('tem/module/md/shop_address_modal');
require_once $this->template('tem/shop_foot');
?>