push.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. {include file="common/header"/}
  2. <div class="LM-container">
  3. <div class="LM-main">
  4. <fieldset class="layui-elem-field layui-field-title">
  5. </fieldset>
  6. <form class="layui-form layui-form-pane" lay-filter="form">
  7. <input type="hidden" name="id" id="id">
  8. <div class="layui-form-item">
  9. <label class="layui-form-label">usdt钱包地址</label>
  10. <div class="layui-input-inline">
  11. <input type="text" name="usdt" lay-verify="required" class="layui-input">
  12. </div>
  13. </div>
  14. <div class="layui-form-item">
  15. <label class="layui-form-label">收款二维码</label>
  16. <input type="hidden" name="code" id="logo">
  17. <div class="layui-input-block">
  18. <div class="layui-upload">
  19. <button type="button" class="layui-btn layui-btn-primary" id="logoBtn"><i
  20. class="icon icon-upload3"></i>{:lang('upload')}
  21. </button>
  22. <div class="layui-upload-list">
  23. <img class="layui-upload-img" id="site_logo">
  24. <p id="demoText"></p>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="layui-form-item">
  30. <div class="layui-input-inline">
  31. <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
  32. <!--<a href="{:url('hlep')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>-->
  33. </div>
  34. </div>
  35. </form>
  36. </div>
  37. </div>
  38. {include file="common/footer"/}
  39. <script>
  40. layui.use(['form', 'layer','upload','laydate'], function () {
  41. var form = layui.form, laydate=layui.laydate,layer = layui.layer,$= layui.jquery,upload = layui.upload;
  42. var info = '';
  43. var config = {$config|raw};
  44. console.log("config",config)
  45. //日期范围
  46. laydate.render({
  47. elem: '#date'
  48. ,range: true
  49. });
  50. form.val("form", config);
  51. $('#site_logo').attr('src',config.code);
  52. if(info){
  53. }
  54. form.render();
  55. form.on('submit(submit)', function (data) {
  56. console.log("data",data.field)
  57. loading =layer.load(1, {shade: [0.1,'#fff']});
  58. $.post("push", data.field, function (res) {
  59. layer.close(loading);
  60. if (res.code== 200) {
  61. layer.msg(res.msg, {time: 1800, icon: 1}, function () {
  62. // location.href = res.url;
  63. // location.href = res.url;
  64. });
  65. } else {
  66. layer.msg(res.msg, {time: 1800, icon: 2});
  67. }
  68. },"json");
  69. });
  70. //普通图片上传
  71. var uploadInst = upload.render({
  72. elem: '#logoBtn'
  73. ,url: '{:url("uploads/uploads")}'
  74. ,before: function(obj){
  75. //预读本地文件示例,不支持ie8
  76. obj.preview(function(index, file, result){
  77. $('#site_logo').attr('src', result); //图片链接(base64)
  78. });
  79. }
  80. ,done: function(res){
  81. //上传成功
  82. if(res.code>0){
  83. $('#logo').val(res.url);
  84. }else{
  85. //如果上传失败
  86. return layer.msg('上传失败');
  87. }
  88. }
  89. ,error: function(){
  90. //演示失败状态,并实现重传
  91. var demoText = $('#demoText');
  92. demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
  93. demoText.find('.demo-reload').on('click', function(){
  94. uploadInst.upload();
  95. });
  96. }
  97. });
  98. });
  99. </script>