consume.html
4.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
{template 'common/header'}
<style>
body{background:#d2e6e9;}
.charge.panel{margin:.5em; border:none;}
.charge.panel-info>.panel-heading {background: -webkit-gradient(linear, 0 0, 100% 0, from(#ebebeb), to(#f3f9fa), color-stop(30%, #f5f9f9)); color:#666666; border:none;}
a{color:#666666;}a:hover{color: #3ebacc;}
.charge .btn.btn-primary{background: #56c6d6; color: #FFF; border: 0;}
.text-hight{color:red;font-weight: bold;font-size: 18px;}
</style>
<div class=" panel panel-info charge">
<div class="panel-heading">
<h4>会员卡消费</h4>
</div>
<div class="panel-body">
<form method="post" action="{php echo url('mc/bond/consume');}" role="form" id="form1" class="form-horizontal form">
<div class="form-group">
<div class="col-xs-12">
<select name="store_id" id="store_id" class="form-control">
{loop $stores $store}
<option value="{$store['id']}">{$store['business_name']}</option>
{/loop}
</select>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<input type="text" class="form-control" name="credit" value="" placeholder="实际消费金额"/>
<div class="help-block"><strong class="text-danger">{$tips}</strong></div>
</div>
</div>
<div class="form-group" style="display: none" id="discount">
<div class="col-xs-12">
<span>实际支付金额 <span class="text-hight" id="price"></span></span>
<input type="hidden" name="last_credit" value="0"/>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<input type="hidden" name="token" value="{$_W['token']}">
<input type="submit" name="submit" class="btn btn-primary btn-block" value="提交">
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<a href="javascript:;" data-toggle="modal" data-target="#qrcode-modal" class="btn btn-warning btn-block">生成付款二维码</a>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<a class="btn btn-default btn-block" href="javascript:history.go(-1);">返回</a>
</div>
</div>
</form>
</div>
</div>
<div class="modal fade modal-code" id="qrcode-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="code-img text-center" data-dismiss="modal">
<div class="qr">
<img style="-webkit-user-select: none" src="{php echo url('mc/bond/card_qrcode');}">
</div>
<div class="text-center tip">付款时请交给店员扫一扫。该功能只能在微信中使用</div>
</div>
</div>
<script>
require(['util'], function(u){
$(':text[name="credit"]').keyup(function(){
var credit = parseFloat($(this).val());
if(isNaN(credit)) {
return false;
}
var price = credit;
{if $setting['discount_type'] > 0 && !empty($mine_discount)}
var discount = '{php echo json_encode($mine_discount);}';
discount = $.parseJSON(discount);
var type = "{$setting['discount_type']}";
discount.condition = parseFloat(discount.condition);
discount.discount = parseFloat(discount.discount);
if(credit >= discount.condition) {
if(type == 1) {
price = credit - discount.discount;
} else {
if(!discount.discount) {
discount.discount = 1;
}
price = credit * discount.discount;
}
price = price.toFixed(2);
if(price < 0) {
price = 0;
}
}
{/if}
if(price >= 0) {
$('#price').html(price+'元');
$(':hidden[name="last_credit"]').val(price);
$('#discount').show();
}
});
$('#form1').submit(function(){
{if !empty($stores)}
var store = $('#store_id').val();
if(!store) {
u.message('请选择消费门店', '', 'error');
return false;
}
{/if}
var member_credit = parseFloat("{$_W['member']['credit2']}");
var credit = parseFloat($('#form1 :text[name="credit"]').val());
var last_credit = credit;
var last_credit = parseFloat($('#form1 :hidden[name="last_credit"]').val());
if(isNaN(credit)) {
u.message('请输入消费金额', '', 'error');
return false;
}
if(isNaN(last_credit) || !last_credit) {
u.message('实际支付金额错误', '', 'error');
return false;
}
if(member_credit < last_credit) {
u.message('余额不够,请先充值', '', 'error');
return false;
}
});
});
</script>
{template 'mc/footer'}
{template 'common/footer'}