order.js
3.2 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
define(['jquery', 'bootstrap', 'frontend', 'frontend-ebook', 'layer', 'config'], function ($, undefined, Frontend, Ebook, Layer, Config) {
var Controller = {
index: function () {
},
pay: function () {
this.info();
},
info: function () {
console.log(1332);
$(document).on('click', '#payorder', function () {
if (Config.invokejson) {
WeixinJSBridge.invoke('getBrandWCPayRequest', Config.invokejson,
function (res) {
if (res.err_msg == "get_brand_wcpay_request:ok") {
layer.msg('支付成功!', {}, function () {
location.href = "/ebook/shelf";
});
}
}
);
} else {
Layer.msg("请使用微信扫描上方二维码支付!");
}
});
$(document).on('click', '#deleteorder', function () {
var that = this;
layer.confirm('确认取消订单?', {
btn: ['确定', '取消'] //按钮
}, function () {
Layer.load();
$.ajax({
url: 'service/delete_order',
data: {id: $(that).attr("book-id"), order_id: $(that).attr("order-id")},
type: 'post',
success: function (ret) {
Layer.closeAll('loading');
if (ret == 'success') {
Layer.msg("取消订单成功!", {icon: 1}, function () {
location.href = '/ebook/shelf';
});
} else {
Ebook.popMessage("取消订单失败!");
}
}, error: function () {
Layer.closeAll('loading');
Ebook.popMessage("操作失败!请重试!");
}
})
}, function () {
});
});
if (Config.invokejson) {
var onBridgeReady = function () {
if (Config.paynow == 1) {
$('#payorder').trigger('click');
}
}
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
}
} else {
onBridgeReady();
}
} else {
if (Config.paynow == 1) {
$('#payorder').trigger('click');
}
}
}
};
return Controller;
});