publish_tab_template.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. // 模板设置表单内容
  3. // 从 publish_setting.php 复制的模板设置部分
  4. // 获取应用信息
  5. $id = bees_decrypt(SafeRequest("id", "get"));
  6. $row = db("appid")->where("in_uid", $this->userid)->where("in_id", $id)->find();
  7. $row or exit(include_once dirname(__FILE__) . "/../pack/error/404.php");
  8. ?>
  9. <div class="download-template">
  10. <!-- 设置语言 -->
  11. <div class="form-group clearfix">
  12. <label class="control-label col-sm-1">设置语言</label>
  13. <div class="col-sm-10">
  14. <ul class="clearfix template-language radio-round">
  15. <li class="clearfix <?php if ($row["template_language"] == "zh") { ?>active<?php } ?>" data-language="zh">
  16. <span class="icon icon-radio <?php if ($row["template_language"] == "zh") { ?>icon-radio-checked <?php } ?>fl"></span>
  17. <span class="fl">简体中文</span>
  18. </li>
  19. <li class="clearfix <?php if ($row["template_language"] == "en") { ?>active<?php } ?>" data-language="en">
  20. <span class="icon icon-radio <?php if ($row["template_language"] == "en") { ?>icon-radio-checked <?php } ?>fl"></span>
  21. <span class="fl">English</span>
  22. </li>
  23. <li class="clearfix <?php if ($row["template_language"] == "zh-tw") { ?>active<?php } ?>" data-language="zh-tw">
  24. <span class="icon icon-radio <?php if ($row["template_language"] == "zh-tw") { ?>icon-radio-checked <?php } ?>fl"></span>
  25. <span class="fl">繁體中文</span>
  26. </li>
  27. <input type="hidden" name="template_language" value="<?php echo $row["template_language"]; ?>">
  28. </ul>
  29. </div>
  30. </div>
  31. <!-- 设置模板 -->
  32. <div class="form-group">
  33. <label class="control-label col-sm-1">设置模板</label>
  34. <div class="col-sm-10">
  35. <ul class="clearfix template-list">
  36. <?php
  37. foreach (range(1, 7) as $k => $v) {
  38. ?>
  39. <li class="<?php echo $row["template"] == $v ? "active" : ""; ?>">
  40. <div class="t-checked-wrap">
  41. <img src="/static/index/image/template-<?php echo $v; ?>.jpg" class="img-responsive">
  42. <div class="t-checked" style="<?php if ($row["template"] == $v) { ?>display: flex;<?php } ?>"></div>
  43. </div>
  44. <a style="display: none;" href="/index/template/<?php echo bees_encrypt($row["in_id"]); ?>/tmp<?php echo $v; ?>" target="_blank" class="text">预览</a>
  45. <input type="radio" name="template" value="<?php echo $v; ?>" <?php if ($row["template"] == $v) { ?>checked<?php } ?> class="hidden">
  46. </li>
  47. <?php
  48. }
  49. ?>
  50. </ul>
  51. </div>
  52. </div>
  53. <!-- 保存按钮 -->
  54. <div class="form-group clearfix">
  55. <input type="hidden" name="id" value="<?php echo bees_encrypt($row["in_id"]); ?>" />
  56. <label class="control-label col-sm-1"></label>
  57. <div class="col-sm-6">
  58. <button id="submitTemplateButton" type="button" class="btn-apps-save">
  59. 保存
  60. </button>
  61. </div>
  62. </div>
  63. </div>
  64. <!-- 成功提示模态框 -->
  65. <div class="modal fade ms-modal auto-hide-modal" id="msModalTemplateSetting" tabindex="-1" role="dialog" style="display: none;">
  66. <div class="modal-dialog modal-sm" role="document">
  67. <div class="modal-content">
  68. <div class="modal-body">
  69. <div class="text-center">
  70. <div class="auto-hide">
  71. <span class="icon icon-modal-success3"></span>
  72. <div class="mt5">
  73. 保存成功
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. <script>
  82. // 模板设置相关的JavaScript逻辑
  83. $(document).ready(function() {
  84. // 初始化单选按钮样式
  85. tab.radioRound({
  86. el: ".radio-round li",
  87. checkedClass: "icon-radio-checked"
  88. });
  89. // 下载模板选中
  90. $(".download-template ul li .t-checked-wrap").click(function() {
  91. var i = $(this).parent().index();
  92. $(".download-template ul li .t-checked-wrap").find(".t-checked").hide();
  93. $(this).find(".t-checked").css("display", "flex");
  94. $(".download-template ul li input[type=radio]").prop("checked", false);
  95. $(this).parent("li").find("input[type=radio]").prop("checked", true);
  96. });
  97. // 设置模板页语言
  98. $(".download-template .template-language li").click(function() {
  99. var val = $(this).data('language');
  100. $("input[name='template_language']").val(val);
  101. });
  102. // 保存按钮点击事件
  103. $('#submitTemplateButton').click(function() {
  104. // 创建临时表单进行提交,包含所有必要的参数
  105. var formData = {
  106. id: $('input[name="id"]').val(),
  107. // 保持基本设置字段的默认值
  108. app_name: '<?php echo addslashes($row["in_name"]); ?>',
  109. url: '<?php echo $row["in_link"]; ?>',
  110. // 保持高级设置字段的默认值
  111. show_guide: '<?php echo $row["in_tutorial"]; ?>',
  112. in_private: '<?php echo $row["in_private"]; ?>',
  113. in_use_auth_code: '<?php echo $row["in_use_auth_code"]; ?>',
  114. password: '<?php echo $row["in_apppwd"]; ?>',
  115. auth_code_dispense_url: '<?php echo $row["auth_code_dispense_url"]; ?>',
  116. in_captcha: '<?php echo $row["in_captcha"]; ?>',
  117. limit_num: '<?php echo $row["in_applimit"]; ?>',
  118. qq: '<?php echo $row["in_contact"]; ?>',
  119. appstore_url: '<?php echo $row["in_appstore"]; ?>',
  120. remark: '<?php echo $row["in_remark"]; ?>',
  121. app_intro: '<?php echo addslashes($row["in_appintro"]); ?>',
  122. // 模板设置字段
  123. template_language: $("input[name='template_language']").val(),
  124. template: $("input[name='template']:checked").val()
  125. };
  126. $.ajax({
  127. url: '/index/ajax_profile/edit',
  128. type: 'POST',
  129. data: formData,
  130. dataType: 'json',
  131. success: function(data) {
  132. if (data.code != 200) {
  133. alert(data.msg);
  134. } else {
  135. $("#msModalTemplateSetting").find(".modal-dialog").addClass("modal-sm").find(".auto-hide .mt5").text("保存成功");
  136. autoHideModal('#msModalTemplateSetting', 3000);
  137. }
  138. },
  139. error: function() {
  140. alert('保存失败,请重试');
  141. }
  142. });
  143. });
  144. });
  145. // 自动隐藏模态框函数
  146. function autoHideModal(obj1, time) {
  147. var autoHide = null;
  148. clearTimeout(autoHide);
  149. $(obj1).modal('show');
  150. $(".modal-backdrop").hide();
  151. autoHide = setTimeout(function() {
  152. $(obj1).modal("hide");
  153. }, time);
  154. }
  155. </script>