-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayOrder.html
368 lines (328 loc) · 8.73 KB
/
payOrder.html
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="format-detection" content="telephone=no" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>确认订单</title>
<link rel="stylesheet" href="css/sta.css">
<link rel="stylesheet" href="css/mui.min.css">
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/mui.min.js"></script>
</head>
<style>
.select_all {
position: absolute!important;
left: 0px;
top: 10px;
margin: 0;
}
.ckid {
margin-top: 40px;
}
input[type=checkbox] {
position: relative;
width: 15px;
height: 1px;
}
input[type=checkbox]::before,
input[type=checkbox]::after {
position: absolute;
display: block;
content: '';
border-radius: 50%;
transition: .3s all esae;
}
input[type=checkbox]::before {
top: 0;
left: 0;
width: 15px;
height: 15px;
border: 2px solid #7EC420;
}
input[type=checkbox]::after {
top: 4px;
left: 4px;
width: 11px;
height: 11px;
}
input[type=checkbox]:checked::before {
border-color: 1px solid #fff;
}
input[type=checkbox]:checked::after {
background-color: #7EC420;
}
.order_top_after {
height: 80px;
background: #008CEE;
}
.order_top_after a {
width: 100%;
display: flex;
display: -webkit-flex;
}
.order_top_after_l {
-webkit-flex: 1;
flex: 1;
height: 80px;
}
.order_top_after_c {
-webkit-flex: 4;
flex: 4;
height: 80px;
}
.order_top_after_c h6,
.order_top_after_c p {
color: #fff;
}
.order_top_after_r {
-webkit-flex: 0.6;
flex: 0.6;
height: 80px;
}
.order_top_after_c h6 span {
float: right;
}
[v-cloak] {
display: none;
}
</style>
<body style="background:#F0F0F0;">
<div class="index_box" id="app" v-cloak>
<div class="nearby_top">
<h1>确认订单</h1>
<a class="index_back mui-action-back"><img src="img/back.png" alt="" width="100%" height="100%"></a>
</div>
<!-- 列表 -->
<div style="margin: 70px 0 150px 0;">
<div class="order_top" v-if="!address.id">
<a @tap="selectAddress"><img src="img/jia.png" alt="" class="order_top_l">添加联系人<img src="img/backk.png" alt="" class="order_top_r"></a>
</div>
<div class="order_top_after" v-if="address.id">
<a @tap="selectAddress">
<div class="order_top_after_l">
<img src="img/dw.png" alt="" class="order_top_l">
</div>
<div class="order_top_after_c">
<h6>联系人:{{address.name}}<span>{{address.phone}}</span></h6>
<p>{{address.province}}{{address.city}}{{address.country}}{{address.detail}}</p>
</div>
<div class="order_top_after_r">
<img src="img/backk.png" alt="" class="order_top_r">
</div>
</a>
</div>
<div class="shopcar_box">
<div class="shopcar_center" v-for="item in orderinfo.order_products">
<div class="shopcar_center2">
<img :src="getImgUrl(item.product.pics[0])" alt="">
</div>
<div class="shopcar_center3">
<h6>{{ item.product.name }}</h6>
<!-- <p>火龙果约500G/个</p> -->
<h5>¥{{ item.product.price }}<span>¥{{ item.product.now_price }}</span></h5>
</div>
<div class="shopcar_center4">
<div class="gw_num">
×{{ item.num }}
</div>
</div>
</div>
</div>
<!-- 买家留言 -->
<div class="order_ly">
<p>买家留言(选填):</p><input v-model="orderinfo.remark" type="text" placeholder="可填写您与商家达成一致的要求">
</div>
</div>
<!-- 底部-->
<div class="order_bottom">
<p>合计:<span>¥{{ orderinfo.total_price }}</span></p>
<input type="submit" @tap="goPay" value="提交订单">
</div>
<!-- 支付弹窗 -->
<div class="shop_car_zf" style="display:none;" id="coon">
<div class="shop_car_zhe"></div>
<div class="shop_car_box">
<h4>请选择支付方式<a @tap="hidePay"><img src="img/close.png" alt="" width="16" height="15"></a></h4>
<ul>
<li class="shop_car1">
<a>¥ {{ orderinfo.total_price }}元</a>
</li>
<li class="shop_car2">
<a>订单支付</a>
</li>
<li>
<a @tap="payBy('amount')" class="shop_car"><span><img src="img/yue.png" alt=""></span><b>余额支付</b></a>
</li>
<li>
<a @tap="payBy('wx')" class="shop_car"><span><img src="img/yue.png" alt=""></span><b>微信支付</b></a>
</li>
<li>
<a @tap="payBy('ali')" class="shop_car"><span><img src="img/yue.png" alt=""></span><b>支付宝支付</b></a>
</li>
<!-- <li>
<a class="shop_car"><span><img src="img/yinlian.png" alt=""></span><b>银联支付</b></a>
</li> -->
<li>
<a @tap="payBy('offline')" class="shop_car"><span><img src="img/xianxia.png" alt=""></span><b>线下支付</b></a>
</li>
</ul>
</div>
</div>
</div>
</body>
<script src="js/vue.js"></script>
<script src="js/config.js"></script>
<script src="js/common.js" type="text/javascript" charset="utf-8"></script>
<script>
window.addEventListener('selectAddress', function(event) {
var address = event.detail.address;
vm.address = address;
});
var wxChannel = null; // 微信支付
var aliChannel = null; // 支付宝支付
mui.plusReady(function() {
// 获取支付通道
plus.payment.getChannels(function(channels) {
for(var i in channels) {
if(channels[i].id == "wxpay") {
wxChannel = channels[i];
}
if(channels[i].id == "alipay") {
aliChannel = channels[i];
}
}
}, function(e) {
mui.alert("获取支付通道失败:" + e.message);
});
})
function pay(channel, str) {
var paychannel;
if(channel == 'ali') {
paychannel = aliChannel;
} else if(channel == 'wx') {
paychannel = wxChannel;
} else {
mui.toast('支付成功');
setTimeout(function() {
go("order_list.html");
}, 300);
return;
}
plus.payment.request(paychannel, str, function(result) {
plus.nativeUI.alert("支付成功!", function() {
back();
});
}, function(error) {
plus.nativeUI.alert("支付失败:" + JSON.stringify(error));
});
}
var vm = new Vue({
el: '#app',
data: {
address: {
id: 0,
name: '',
phone: '',
province: '',
city: '',
country: '',
postcode: '',
detail: '',
},
order_id: 0,
orderinfo: {},
remark: '',
payMethod: null,
},
methods: {
getImgUrl: function(url) {
return config.imgBasePath + url
},
selectAddress: function() {
go('contacts.html');
},
payBy: function(method) {
this.hidePay();
this.payMethod = method;
var self = this;
mui.prompt('', '请输入支付密码', '请输入支付密码', ['取消', '确定'], function(e) {
if(e.index == 1) {
var password = e.value;
postJson(
'api/verifyPaymentPasswd', {
password: password
},
function(ret) {
if(ret.code == 200) {
self.confirmPay()
} else {
mui.toast(ret.message);
}
}
)
}
}, 'div')
document.querySelector('.mui-popup-input input').type = 'password'
},
confirmPay: function() {
var self = this;
postJson(
'api/payOrder', {
order_id: self.order_id,
address_id: self.address.id,
remark: self.orderinfo.remark,
payChannel: self.payMethod,
},
function(ret) {
if(ret.code == 200) {
if(self.payMethod == 'wx') {
ret.data = JSON.stringify(ret.data);
}
console.log(ret.data);
pay(self.payMethod, ret.data)
} else {
mui.toast(ret.message)
}
},
function(xhr, type, e) {
},
true
)
},
goPay: function() {
mui('.shop_car_zf')[0].style.display = 'block';
},
hidePay: function() {
document.getElementById('coon').style.display = "none";
}
},
created: function() {
var self = this;
var params = getQuery();
self.keyword = params.keyword ? params.keyword : '';
params.order_id && (self.order_id = params.order_id);
getJson(
'api/orderinfo', {
order_id: self.order_id
},
function(ret) {
if(ret.code == 200) {
console.log(JSON.stringify(ret.data))
self.orderinfo = ret.data;
if (ret.data.address) {
self.address = ret.data.address
}
}
},
function() {
mui.toast('获取数据失败,请重试')
},
true
);
}
})
</script>
</html>