|
@@ -1,5 +1,20 @@
|
|
|
{extend name="extra@admin/content"}
|
|
|
|
|
|
+{block name="style"}
|
|
|
+<style>
|
|
|
+ .pay-qrc-test {
|
|
|
+ height: 248px;
|
|
|
+ width: 248px;
|
|
|
+ background: url('__STATIC__/plugs/layui/css/modules/layer/default/loading-2.gif') no-repeat center center
|
|
|
+ }
|
|
|
+
|
|
|
+ .refund-qrc-test {
|
|
|
+ text-align: center;
|
|
|
+ padding: 8px
|
|
|
+ }
|
|
|
+</style>
|
|
|
+{/block}
|
|
|
+
|
|
|
{block name="content"}
|
|
|
<form onsubmit="return false;" action="{:request()->url(true)}" data-auto="true" method="post"
|
|
|
class='form-horizontal' style='padding-top:20px'>
|
|
@@ -30,14 +45,26 @@
|
|
|
<div class="hr-line-dashed"></div>
|
|
|
|
|
|
<div class="form-group">
|
|
|
- <label class="col-sm-2 control-label">Cert(支付证书)</label>
|
|
|
- <div class="col-sm-7">
|
|
|
- <input type="hidden" name="cert_zip_md5" value="" onchange="this.value=$(this).attr('data-md5')"/>
|
|
|
- <div data-file="one" data-type="zip" data-field="cert_zip_md5" data-uptype="local"
|
|
|
- class="well" style="text-align:center;cursor:pointer">
|
|
|
- <span class="fa fa-check-circle-o" style="color:#00B83F;font-size:16px"></span>
|
|
|
- 已设置支付证书 (cert.zip)
|
|
|
- </div>
|
|
|
+ <label class="col-sm-2 control-label">Cert(双向证书)</label>
|
|
|
+ <div class="col-sm-8">
|
|
|
+ <input title="application_key.pem" type="hidden" name="wechat_cert_key_md5">
|
|
|
+ <input title="application_cert.pem" type="hidden" name="wechat_cert_cert_md5">
|
|
|
+ <button data-file="one" data-type="pem" data-field="wechat_cert_key_md5"
|
|
|
+ type="button" class="layui-btn layui-btn-primary">
|
|
|
+ {if file_exists(sysconf('wechat_cert_key'))}
|
|
|
+ 已上传 application_key.pem 文件
|
|
|
+ {else/}
|
|
|
+ 请上传 application_key.pem 文件
|
|
|
+ {/if}
|
|
|
+ </button>
|
|
|
+ <button data-file="one" data-type="pem" data-field="wechat_cert_cert_md5"
|
|
|
+ type="button" class="layui-btn layui-btn-primary">
|
|
|
+ {if file_exists(sysconf('wechat_cert_cert'))}
|
|
|
+ 已上传 application_cert.pem 文件
|
|
|
+ {else/}
|
|
|
+ 请上传 application_cert.pem 文件
|
|
|
+ {/if}
|
|
|
+ </button>
|
|
|
<p class="help-block">
|
|
|
企业打款、企业红包、订单退款等操作需要使用双向证书,可在<a href="https://pay.weixin.qq.com" target="_blank">微信商户平台</a>下载证书!
|
|
|
</p>
|
|
@@ -52,66 +79,57 @@
|
|
|
<div class="form-group">
|
|
|
<div class="col-sm-6 col-sm-offset-2 text-center">
|
|
|
<button type="submit" class="layui-btn">保存配置</button>
|
|
|
- <button type="button" onerror="alert(this.src)" data-pay-test class="layui-btn layui-btn-primary">支付测试
|
|
|
- </button>
|
|
|
- <style>
|
|
|
- .pay-qrc-test {
|
|
|
- height: 248px;
|
|
|
- width: 248px;
|
|
|
- background: url('http://basic.data.cuci.cc/static/plugs/layui/layer/skin/default/loading-2.gif') no-repeat center center
|
|
|
- }
|
|
|
+ <button type="button" data-pay-test class="layui-btn layui-btn-primary">支付测试</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
|
|
|
- .refund-qrc-test {
|
|
|
- text-align: center;
|
|
|
- padding: 8px
|
|
|
- }
|
|
|
- </style>
|
|
|
- <script>
|
|
|
- $(function () {
|
|
|
- /* global layer */
|
|
|
- $('[data-pay-test]').on('click', function () {
|
|
|
- var timer = null;
|
|
|
+</form>
|
|
|
+{/block}
|
|
|
+
|
|
|
+{block name="script"}
|
|
|
+<script>
|
|
|
+ $(function () {
|
|
|
+
|
|
|
+ /*! 证书上传动作 */
|
|
|
+ $('[name="wechat_cert_key_md5"],[name="wechat_cert_cert_md5"]').on('change', function () {
|
|
|
+ this.value = $(this).attr('data-md5');
|
|
|
+ $('[data-field="' + this.name + '"]').html('已选择 ' + this.title + ' 文件');
|
|
|
+ });
|
|
|
+
|
|
|
+ var isShow = false;
|
|
|
+ var timer = null;
|
|
|
+
|
|
|
+ /*! 支付测试动作 */
|
|
|
+ function payTest() {
|
|
|
+ $.form.load('{:url("pay")}?action=payqrc', {}, 'get', function (ret) {
|
|
|
+ if (ret.code === 1 || ret.code === 2) {
|
|
|
+ if(ret.code===2){
|
|
|
+ ret.url = '__STATIC__/theme/default/img/wechat/qrc_payed.jpg';
|
|
|
+ }
|
|
|
+ if(isShow){
|
|
|
+ $('.pay-qrc-test').attr('src',ret.url)
|
|
|
+ }else{
|
|
|
layer.open({
|
|
|
type: 1, title: false, closeBtn: 1, shadeClose: true,
|
|
|
- content: function () {
|
|
|
- return '<img class="pay-qrc-test" src="{src}"/>'.replace('{src}', 'http://basic.data.cuci.cc/index.php/wechat/conf/pay.html?action=payqrc')
|
|
|
- + '<p style="text-align:center">请用微信扫码测试支付!</p>'
|
|
|
- + '<p class="refund-qrc-test"><a class="btn btn-xs btn-warning">退款测试</a></p>';
|
|
|
- }(),
|
|
|
+ content: '<img class="pay-qrc-test" onerror="this.src=__STATIC__/theme/default/img/wechat/qrc_payed.jpg" src="' + ret.url + '"/>'
|
|
|
+ + '<p style="text-align:center">请用微信扫码测试支付!</p>'
|
|
|
+ + '<p class="refund-qrc-test"><a class="btn btn-xs btn-warning">退款测试</a></p>',
|
|
|
end: function () {
|
|
|
- (timer !== null) && window.clearTimeout(timer), timer = null;
|
|
|
+ isShow = false;
|
|
|
+ timer && window.clearInterval(timer);
|
|
|
},
|
|
|
success: function (layero, index) {
|
|
|
- $(layero).find('.pay-qrc-test').on('error', function () {
|
|
|
- $.form.load(this.src), layer.close(index);
|
|
|
- }).on('load', function () {
|
|
|
- var img = this;
|
|
|
- (timer !== null) && window.clearTimeout(timer), timer = null;
|
|
|
- timer = setTimeout(function () {
|
|
|
- img.src = img.src.replace(/\&t=\d*/, '') + '&t=' + (new Date().getTime());
|
|
|
- }, 3000);
|
|
|
- });
|
|
|
- $(layero).on('click', '.refund-qrc-test a', function () {
|
|
|
- $.msg.loading();
|
|
|
- $.get('http://basic.data.cuci.cc/index.php/wechat/conf/pay.html?action=refund', function (ret) {
|
|
|
- if (ret.code === "SUCCESS") {
|
|
|
- $.msg.tips(ret.info, 2, function () {
|
|
|
- (timer !== null) && window.clearTimeout(timer), timer = null;
|
|
|
- layer.close(index);
|
|
|
- });
|
|
|
- } else {
|
|
|
- $.msg.tips(ret.info, 2);
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
+ isShow = true;
|
|
|
+ timer = setInterval(payTest,1000);
|
|
|
}
|
|
|
});
|
|
|
- });
|
|
|
- });
|
|
|
- </script>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
-</form>
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ $('[data-pay-test]').on('click', payTest);
|
|
|
+ });
|
|
|
|
|
|
+</script>
|
|
|
{/block}
|