### Install WeApp Function Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/weapp/index.htm Handles the installation of a WeApp. It sets the target URL for the installation form and submits it, displaying a loading indicator. ```JavaScript function install(obj) { var id = $(obj).attr('data-id'); var form2 = $('#form2'); form2.find('input[name=id]').val(id); var url = "{:url('Weapp/install')}"; form2.attr('action', url); layer_loading('正在处理'); form2.submit(); } ``` -------------------------------- ### Install Weapp Function Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/weapp/mybuy.htm Handles the installation of a Weapp by submitting a form with the Weapp ID. ```javascript function install(obj) { var id = $(obj).attr('data-id'); var form2 = $('#form2'); form2.find('input[name=id]').val(id); var url = "{:url('Weapp/install')}"; form2.attr('action', url); layer_loading('正在处理'); form2.submit(); } ``` -------------------------------- ### Handle Plugin Installation or Purchase Flow Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/shop/market_index.htm Routes plugin installation based on purchase status and payment requirement. Opens purchase confirmation dialog if payment is needed, then proceeds with installation on confirmation. ```JavaScript function goPage(obj) { event.stopPropagation(); var id = $(obj).attr('data-id'); var buy = $(obj).attr('data-buy'); var needmoney = $(obj).attr('data-needmoney'); var code = $(obj).attr('data-weapp_code'); var min_version = $(obj).attr('data-min_version'); if (buy == 1 ){ remoteInstall(code,min_version); } else { if (needmoney == 0){ remoteInstall(code,min_version); }else { window.open("https://www.eyoucms.com/plus/view.php?aid="+id); layer.open({ type: 1, shade: layer_shade, title: '友情提示', btn: ['购买成功', '购买失败'], yes: function (index, layero) { layer.closeAll(); remoteInstall(code, min_version); }, btn2: function(index, layero){ layer.close(); // location.reload()//重新加载页面 }, cancel: function () { //右上角关闭回调 // return false //开启该代码可禁止点击该按钮关闭 }, shadeClose: true, //点击遮 ``` -------------------------------- ### Remote Install Weapp Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/weapp/index.htm Initiates a remote installation of a Weapp by submitting a form with the Weapp code and minimum version. Displays a loading indicator during the process. ```javascript function remoteInstall(code, min_version) { var form2 = $('#form2'); form2.find('input[name=code]').val(code); form2.find('input[name=min_version]').val(min_version); var url = "{:url('Weapp/remoteInstall')}"; form2.attr('action', url); layer_loading('远程安装'); form2.submit(); } ``` -------------------------------- ### Remote Install Weapp Function Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/weapp/mybuy.htm Initiates the remote installation of a Weapp by submitting a form with Weapp code and minimum version. ```javascript function remoteInstall(code, min_version) { var form2 = $('#form2'); form2.find('input[name=code]').val(code); form2.find('input[name=min_version]').val(min_version); var url = "{:url('Weapp/remoteInstall')}"; form2.attr('action', url); layer_loading('远程安装'); form2.submit(); } ``` -------------------------------- ### Initialize OSS Upload Source: https://github.com/weng-xianhu/eyoucms/blob/master/template/pc/users/article_media_edit.htm Sets up the initial parameters for an OSS upload, including file validation for extension and size. It then makes an AJAX request to get upload credentials. ```javascript function OssUpload(num) { var file = $("#oss_click_sys_"+num)[0].files[0]; var url = URL.createObjectURL(file); var oVideo = document.createElement('video'); var duration = 0; oVideo.setAttribute('src',url); oVideo.oncanplay = ()=>{ duration = parseInt(oVideo.duration); } var fileName = file.name; var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase(); var ext = judgeExtMedia(fileExt); if (ext==-1) { showErrorMsg('不支持选中的视频格式,可在附件设置中修改'); return false; } var size = "{$upload_max_filesize}"; if (file.size > size) { showErrorMsg('视频大小超过限制,可在附件设置中修改'); return false; } $.ajax({ type: 'POST', url: "__ROOT_DIR__/index.php?m=plugins&c=AliyunOss&a=oss_upload", data: {_ajax: 1}, dataType: "JSON", success: function ``` -------------------------------- ### Include Static Assets and Global Variables Source: https://github.com/weng-xianhu/eyoucms/blob/master/template/mobile/users/shop_query_express.htm Includes necessary CSS and JavaScript files, and a global site name variable. Ensure these paths are correct for your project setup. ```html {eyou:global name='web_name' /} {eyou:static file="users/skin/css/bootstrap.min.css"/} {eyou:static file="users/skin/css/eyoucms.css"/} {eyou:static file="users/skin/css/basic.css"/} {eyou:include file="users/skin/css/diy_css.htm"/} {eyou:static file="/public/static/common/js/jquery.min.js"/} {eyou:static file="/public/plugins/layer-v3.1.0/layer.js"/} {eyou:static file="users/skin/js/global.js"/} ``` -------------------------------- ### Welcome Page Async Handling (JavaScript) Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/theme/welcome_taskflow.htm Initiates an asynchronous GET request to the 'Ajax/welcome_handle' endpoint. This is used for background processing of business logic required when entering the welcome page. ```javascript $.get("{:url('Ajax/welcome_handle', ['\'_ajax\'=>1])}"); // 进入欢迎页面需要异步处理的业务 ``` -------------------------------- ### Get Goods Comment List Source: https://context7.com/weng-xianhu/eyoucms/llms.txt Retrieves a list of comments for a specific product. Requires the 'Comment' plugin to be installed. ```APIDOC ## GET /api/v1.Api/get_goods_comment_list ### Description Retrieve a list of comments for a given product. ### Method GET ### Endpoint /api/v1.Api/get_goods_comment_list ### Query Parameters - **aid** (integer) - Required - The ID of the article or product. - **page** (integer) - Optional - The page number for pagination. Defaults to 1. - **apikey_token** (string) - Required - API key token. ### Request Example ```bash curl -G "https://yourdomain.com/api/v1.Api/get_goods_comment_list" \ --data-urlencode "aid=101" \ --data-urlencode "page=1" \ --data-urlencode "apikey_token=abc123-1700000000" ``` ### Response #### Success Response (200) - **code** (integer) - Indicates success (1) or failure (0). - **data** (array) - An array of comment objects, each containing `comment_id`, `content`, `nickname`, `pics`, and `add_time`. #### Response Example ```json { "code": 1, "data": [ { "comment_id": 1, "content": "商品质量很好", "nickname": "小明", "pics": [], "add_time": 1700000000 } ] } ``` ``` -------------------------------- ### Initialize Date Pickers and Form Rendering Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/discount/active_add.htm Initializes date picker components for start date, end date, and preheat time using layui. It also renders the form elements. This setup code should be run when the page loads. ```javascript layui.use(['form', 'laydate'], function(){ var form = layui.form, laydate = layui.laydate; laydate.render({ elem: '#start_date' ,type: 'datetime' }); laydate.render({ elem: '#end_date' ,type: 'datetime' }); laydate.render({ elem: '#preheat_time' ,type: 'datetime' }); form.render(); }); ``` -------------------------------- ### Initialize Product Form and Settings Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/shop_product/add.htm Sets up initial form states and event handlers for product addition, including city site settings, tab switching, jump link visibility, and category model validation. ```javascript $(function () { try { var web_citysite_open = {$global['web_citysite_open']|default=0}; var site_province_id = {$site_province_id|default=0}; var site_city_id = {$site_city_id|default=0}; var site_area_id = {$site_area_id|default=0}; if (web_citysite_open > 0 && site_province_id > 0) { $('select[name=province_id]').val(site_province_id); set_city_list(site_city_id); set_area_list(site_area_id); } }catch(e){} //选项卡切换列表 $('.tab-base').find('.tab').click(function(){ $('.tab-base').find('.tab').each(function(){ $(this).removeClass('current'); }); $(this).addClass('current'); var tab_index = $(this).data('index'); $(".tab_div_1, .tab_div_2, .tab_div_3, .tab_div_4, .tab_div_5").hide(); $(".tab_div_"+tab_index).show(); layer.closeAll(); }); $('input[name=is_jump]').click(function(){ if ($(this).is(':checked')) { $('.dl_jump').show(); } else { $('.dl_jump').hide(); } }); var dftypeid = {$typeid|default='0'}; $('#typeid').change(function() { var current_channel = $(this).find('option:selected').data('current_channel'); if (0 < $(this).val() && {$channeltype} != current_channel) { showErrorMsg('请选择对应模型的栏目!'); $(this).val(dftypeid); } else if ({$channeltype} == current_channel) { layer.closeAll(); } GetAddonextitem(1, $(this).val(), {$channeltype}, 0, true); }); $(document).click(function(){ $('#often_tags').hide(); $('#often_tags_input').hide(); event.stopPropagation(); }); $('#often_tags').click(function(){ $('#often_tags').show(); event.stopPropagation(); }); $('input[name=tags]').keyup(function(){ var tags = $.trim($(this).val()); $('#seo_keywords').val(tags); }); }); ``` -------------------------------- ### JavaScript: Open SMS Configuration Tutorial Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/notice/conf_sms.htm Opens a tutorial link in a new window based on the selected SMS provider. The tutorial URL is dynamically generated to point to the relevant documentation. ```javascript function openArticle() { var new_sms_type = $("input[name=sms_type]:checked").val(); var aid = new_sms_type == 1?8754:11143; click_to_eyou_1575506523('https://www.eyoucms.com/plus/view.php?aid='+aid+'&origin_eycms=1','短信配置教程'); } ``` -------------------------------- ### Initialize Welcome Page Logic Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/theme/welcome_shop.htm Sets up initial logic for the welcome page, including checking for security patch updates and language version compatibility. It also triggers an asynchronous request for welcome page business logic and language tips. ```JavaScript $(function () { if (1 == VarSecurityPatch) { checkUpgradeSecurityVersion(); } else { {eq name="upgrade" value="true"} check_upgrade_version(); {/eq} } $.get("{:url('Ajax/welcome_handle', ['_ajax'=>1])}"); // 进入欢迎页面需要异步处理的业务 check_language_tips(); // 检测语言版本 function check_language_tips() { if (__main_lang__ != __lang__) { var language_title = $('#language_title', window.parent.document).html(); layer.msg('当前后台已切换至【'+language_title+'】编辑状态!', {time:3000}); } } // 检测系统安全补丁更新弹窗 function checkUpgradeSecurityVersion() { $.ajax({ type : "GET", url : "{:url('Ajax/check_upgrade_version', ['_ajax'=>1])}", data : {}, dataType : "JSON", success: function(res) { if (1 == res.code) { if (2 == res.data.code) { /*显示顶部导航更新提示*/ try { $("#upgrade_filelist", window.parent.document).html(res.data.msg.upgrade); $("#upgrade_intro", window.parent.document).html(res.data.msg.intro); $("#upgrade_notice", window.parent.document).html(res.data.msg.notice); $('#a_upgrade', window.parent.document).attr('data-version',res.data.msg.key_num).attr('data-max_version',res.data.msg.max_version).show(); } catch(e) {} $('#upgrade_filelist').html(res.data.msg.upgrade); $('#upgrade_intro').html(res.data.msg.intro); $('#upgrade_notice').html(res.data.msg.notice); $('#a_upgrade').attr('data-version', res.data.msg.key_num).attr('data-max_version', res.data.msg.max_version).attr('title ``` -------------------------------- ### Initialize Product Variables and URLs Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/shop_product/add.htm Sets up initial JavaScript variables and defines URLs for various product-related operations like image handling, spec management, and price updates. ```javascript var aid = 0; var action = 'add'; var goodsSpecImage = "{:url('ShopProduct/goodsSpecImage', \[\'_ajax\'=>1\])}"; // 初始化规格,清除多余规格数据 var initializationSpec = "{:url('ShopProduct/initialization_spec', \[\_ajax\'=>1\])}"; // 商品规格检测是否有空值 var goodsSpecDetectionUrl = "{:url('ShopProduct/goods_spec_detection', \[\_ajax\'=>1\])}"; // 保存编辑商品价格库存 var editProductSpecPrice = "{:url('ShopProduct/edit_product_spec_price', \[\_ajax\'=>1\])}"; // 添加产品自定义规格 var addProductCustomSpec = "{:url('ShopProduct/add_product_custom_spec', \[\_ajax\'=>1\])}"; // 删除产品自定义规格 var delProductCustomSpec = "{:url('ShopProduct/del_product_custom_spec', \[\_ajax\'=>1\])}"; // 添加产品自定义规格名 var addProductCustomSpecName = "{:url('ShopProduct/add_product_custom_spec_name', \[\_ajax\'=>1\])}"; // 添加产品自定义规格值 var addProductCustomSpecValue = "{:url('ShopProduct/add_product_custom_spec_value', \[\_ajax\'=>1\])}"; ``` -------------------------------- ### Get Selected Text Source: https://github.com/weng-xianhu/eyoucms/blob/master/public/plugins/Ueditor/index.html Retrieves the currently selected text within the editor. Selects the range before getting text to ensure content is captured. ```javascript function getText() { //当你点击按钮时编辑区域已经失去了焦点,如果直接用getText将不会得到内容,所以要在选回来,然后取得内容 var range = UE.getEditor('editor').selection.getRange(); range.select(); var txt = UE.getEditor('editor').selection.getText(); alert(txt) } ``` -------------------------------- ### Initialize Member Discount Variables and Configuration Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/shop_product/edit.htm Sets up variables for member discount type and product ID, then conditionally loads member discount price template if discount type is set to specified member levels. ```JavaScript var usersDiscountAid = {$field.aid|default='0'}; var usersDiscountType = {$field.users_discount_type|default='0'}; // 如果选择的是指定会员级别则自动执行 if (1 === parseInt(usersDiscountType)) getUsersDiscountPriceTpl(); ``` -------------------------------- ### Upload Media to Aliyun OSS Source: https://github.com/weng-xianhu/eyoucms/blob/master/template/pc/users/article_media_add.htm Handles media uploads to Aliyun OSS. It first requests upload credentials from the server and then uses FormData to upload the file. Progress is tracked and displayed. Ensure the file input element with id 'courseware_file' and the target display element are correctly set up. ```javascript function upload_addonFieldExt_courseware_oss(obj) { var file = $("#courseware_file")[0].files[0]; //获取文件路径名 var fileName = file.name; var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase(); var ext = judgeExtMedia(fileExt, 1); if (ext == -1) { showErrorMsg('不支持选中的文件格式,可在附件设置中修改'); return false; } var size = "{$upload_max_filesize}"; if (file.size > size) { showErrorMsg('文件大小超过限制,可在附件设置中修改'); return false; } $.ajax({ type: 'POST', url: "__ROOT_DIR__/index.php?m=plugins&c=AliyunOss&a=oss_upload", data: { _ajax: 1 }, dataType: "JSON", success: function(res1) { if (1 == res1.code) { fileName = res1.data.filePath + fileExt; //组装发送数据 var request = new FormData(); request.append("OSSAccessKeyId", res1.data.accessid); //Bucket 拥有者的Access Key Id。 request.append("policy", res1.data.policy); //policy规定了请求的表单域的合法性 request.append("Signature", res1.data.signature); //根据Access Key Secret和policy计算的签名信息,OSS验证该签名信息从而验证该Post请求的合法性 request.append("key", fileName); //文件名字,可设置路径 request.append("success_action_status", 201); // 让服务端返回200,不然,默认会返回204 request.append('file', file); //需要上传的文件 file $.ajax({ url: res1.data.host, //上传阿里地址 data: request, processData: false, cache: false, contentType: false, dataType: 'xml', type: 'post', xhr: function() { //获取ajaxSettings中的xhr对象,为它的upload属性绑定progress事件的处理函数 myXhr = $.ajaxSettings.xhr(); if (myXhr.upload) { //检查upload属性是否存在 //绑定progress事件的回调函数 myXhr.upload.addEventListener('progress', function(e) { var curr = e.loaded; var total = e.total; var process = parseInt(curr / total * 100); $("#upload_addonFieldExt_courseware_oss").html('上传中...' + process + "%'"); }); } return myXhr; //xhr对象返回给jQuery使用 }, success: function(res2) { var res = $(res2).find('PostResponse'); if (res) { var key = res.find('Key').text(); $("#upload_addonFieldExt_courseware_oss").html(ey_foreign_system10); setTimeout(function() { $('#upload_addonFieldExt_courseware_oss').html('oss上传'); }, 2000); var video_url = res1.data.domain + "/" + key; $("#addonFieldExt_courseware").val(video_url); } else { $("#upload_addonFieldExt_courseware_oss").html('上传失败'); setTimeout(function() { $('#upload_addonFieldExt_courseware_oss').html('oss上传'); }, 2000); } }, error: function(e) { showErrorMsg(e.responseText); return false; } }); } else { $("#courseware_file").val(''); showErrorMsg(res1.msg); } }, error: function(e) { $("#courseware_file").val(''); showErrorMsg(e.responseText); } }); } ``` -------------------------------- ### Conditional WeApp Button Rendering Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/weapp/index.htm Renders installation and deletion buttons based on user access rights and application status. Includes logic for both initial installation and remote deletion. ```HTML {empty name="$vo.status"} {empty name="$vo.is_buy"} {eq name="'Weapp@install'|is_check_access" value="1"} [安装](javascript:void(0);) {/eq} {eq name="'Weapp@del'|is_check_access" value="1"} [删除](javascript:void(0);) {/eq} {else /} {eq name="'Weapp@install'|is_check_access" value="1"} [安装](javascript:void(0);) {/eq} {eq name="'Weapp@del_remote'|is_check_access" value="1"} [删除](javascript:void(0);) {/eq} {/empty} {else /} {eq name="'Weapp@execute'|is_check_access" value="1"} {if condition="empty($vo['config']['management']['href'])"} [管理]({:url('Weapp/execute',array('sm'=>$vo['code'],'sc'=>$vo['code'],'sa'=>'index'))}) {else /} [管理]({$vo['config']['management']['href']}) {/if} {/eq} {eq name="'Weapp@uninstall'|is_check_access" value="1"} [卸载](javascript:void(0);) {/eq} {/empty} ``` -------------------------------- ### Check and Call Points Shop Plugin Source: https://context7.com/weng-xianhu/eyoucms/llms.txt This code checks if the Points Shop plugin is installed and enabled, then initializes and uses its logic. Ensure the plugin is correctly installed and accessible. ```php // 检查并调用积分商城插件(参考 Api::users_detail) $weappInfo = model('ShopPublicHandle')->getWeappPointsShop(); if (!empty($weappInfo)) { $users = $this->getUser(false); $pointsShopLogic = new \app\plugins\logic\PointsShopLogic($users); $data['showPointsShop'] = $pointsShopLogic->showPointsShop($weappInfo); } ``` -------------------------------- ### Open Welcome Page Template Creation Dialog Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/index/theme_welcome_conf.htm Handles the creation of a new welcome page template. It first checks if security question verification is enabled. If not, it prompts the user to set it up. If verification is enabled or set up, it opens a dialog to create a new template. ```javascript function welcome_tplname_add() { $.ajax({ url: "{:url('Security/ajax_security_ask_open', ['_ajax'=>1])}", type: 'GET', dataType: 'JSON', data: {}, success: function(res){ var security_ask_open = res.data.security_ask_open; if (0 == security_ask_open) { showConfirm('需要设置密保问题验证才可以继续', {btn:['去设置', '取消']}, function(){ layer.closeAll(); var iframes = layer.open({ type: 2, title: '安全验证中心', fixed: true, //不固定 shadeClose: false, shade: layer_shade, offset: 'auto', // // maxmin: true, //开启最大化最小化按钮 area: ['100%', '100%'], content: "{:url('Security/second_ask_init')}"+"&source=theme_welcome", success: function(layero, index){ } }); layer.full(iframes); }); return false; } var url = "{:url('Index/ajax_theme_tplfile_add',['type'=>'welcome'])}"; //iframe窗 layer.open({ type: 2, title: '新建欢迎页模板', fixed: true, //不固定 shadeClose: false, shade: layer_shade, maxmin: false, //开启最大化最小化按钮 area: ['100%', '100%'], content: url }); }, error: function(e){ showErrorMsg(e.responseText); return false; } }); } ``` -------------------------------- ### Check Comment Plugin Installation Source: https://context7.com/weng-xianhu/eyoucms/llms.txt This code checks if the Comment plugin directory exists. If not, it throws an error, indicating that the plugin must be installed before proceeding. Ensure the path './weapp/Comment/' is correct. ```php // 检查评论插件(参考 Api::submitArticleComment) if (!is_dir('./weapp/Comment/')) { $this->error('请先安装评论插件'); } $res = model('v1.Api')->addArticleComment($param, $users); ``` -------------------------------- ### Initialize Data Backup Process Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/tools/index.htm Initiates the data backup process by sending a POST request with selected tables. It handles initial validation and displays loading states. ```javascript $(document).ready(function(){ // 表格行点击选中切换 $('#tb_flexigrid >tbody >tr').click(function(){ $(this).toggleClass('trSelected'); }); // 点击刷新数据 $('.fa-refresh').click(function(){ location.href = location.href; }); }); (function($){ var $form = $("#export-form"), $export = $(".export_btn"), tables $export.click(function(){ if($("input[name^='tables']:checked").length == 0){ layer.alert('请选中要备份的数据表', { icon: 5, title:false, closeBtn:false }); return false; } $export.addClass("disabled"); $export.find('a').html("正在发送备份请求..."); $.post("{:url('Tools/export', ober=>1)}", $form.serialize(), function(res){ if(res.code){ tables = res.tables; var loading = layer.msg('正在备份表('+res.tab.table+')……0.01%', { icon: 1, time: 3600000, //1小时后后自动关闭 shade: [0.2] //0.1透明度的白色背景 }); $export.find('a').html(res.msg + "开始备份,请不要关闭本页面!"); backup(res.tab); window.onbeforeunload = function(){ return "正在备份数据库,请不要关闭!" } } else { layer.alert(res.msg, { icon: 5, title:false, closeBtn:false }); $export.removeClass("disabled"); $export.find('a').html("立即备份"); } }, "json"); return false; }); function backup(tab, status){ status && showmsg(tab.id, "开始备份……(0%)"); $.post("{:url('Tools/export', ober=>1)}", tab, function(res){ if(res.code){ if (tab.table) { showmsg(tab.id, res.msg); $('#upgrade_backup_table').html(tab.table); $('#upgrade_backup_speed').html(tab.speed); $export.find('a').html('初始化成功!正在备份表('+tab.table+')……'+tab.speed+'%,请不要关闭本页面!'); } else { $export.find('a').html('初始化成功!开始备份……,请不要关闭本页面!'); } if(!$.isPlainObject(res.tab)){ var loading = layer.msg('备份完成……100%,请不要关闭本页面!', { icon: 1, time: 2000, //1小时后后自动关闭 shade: [0.2] //0.1透明度的白色背景 }); $export.removeClass("disabled"); $export.find('a').html("备份完成……100%,点击重新备份"); setTimeout(function(){ layer.closeAll(); layer.alert('备份成功!', { icon: 6, title:false, closeBtn:false }); }, 1000); window.onbeforeunload = function(){ return null } return; } setTimeout(function () { backup(res.tab, tab.id != res.tab.id); }, 350); } else { layer.closeAll(); $export.removeClass("disabled"); $export.find('a').html("立即备份"); } }, "json"); } function showmsg(id, msg){ $form.find("input[value=" + tables[id] + "]").closest("tr").find(".info").html(msg); } })(jQuery); ``` -------------------------------- ### JavaScript for Plugin Interaction Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/weapp/plugin.htm Handles table row selection, page refreshing, and remote plugin installation. It also manages the logic for purchasing and installing plugins based on their status and requirements. ```javascript $(document).ready(function () { // 表格行点击选中切换 $('#flexigrid > table>tbody >tr').click(function () { $(this).toggleClass('trSelected'); }); // 点击刷新数据 $('.fa-refresh').click(function () { location.href = location.href; }); }); function remoteInstall(code, min_version) { var form2 = $('#form2'); form2.find('input[name=code]').val(code); form2.find('input[name=min_version]').val(min_version); var url = "{:url('Weapp/remoteInstall')}"; form2.attr('action', url); layer_loading('正在处理'); form2.submit(); } function goPage(obj) { var id = $(obj).attr('data-id'); var buy = $(obj).attr('data-buy'); var needmoney = $(obj).attr('data-needmoney'); var code = $(obj).attr('data-weapp_code'); var min_version = $(obj).attr('data-min_version'); if (buy == 1 ){ remoteInstall(code,min_version); } else { if (needmoney == 0){ remoteInstall(code,min_version); } else { window.open("https://www.eyoucms.com/plus/view.php?aid="+id); layer.open({ type: 1, shade: layer_shade, title: '友情提示', btn: ['购买成功', '购买失败'], yes: function (index, layero) { layer.closeAll(); remoteInstall(code, min_version); }, btn2: function(index, layero){ layer.close(); // location.reload()//重新加载页面 }, cancel: function () { //右上角关闭回调 // return false //开启该代码可禁止点击该按钮关闭 }, shadeClose: true, //点击遮罩关闭 content: "
购买成功可在线安装该插件!
" }); } } } function jump() { location.reload(); } ``` -------------------------------- ### Initialize Google Map and Event Handlers Source: https://github.com/weng-xianhu/eyoucms/blob/master/public/plugins/Ueditor/dialogs/gmap/gmap.html Sets up the Google Map, marker, and search functionality. It also handles loading existing map images to pre-fill the dialog. ```javascript domUtils.on(window,"load",function(){ var map = new google.maps.Map(document.getElementById('container'), { zoom: 3, streetViewControl: false, scaleControl: true, mapTypeId: google.maps.MapTypeId.ROADMAP }); var imgcss; var marker = new google.maps.Marker({ map: map, draggable: true }); function doSearch(){ var address = document.getElementById('address').value; var geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': address}, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { var bounds = results[0].geometry.viewport; map.fitBounds(bounds); marker.setPosition(results[0].geometry.location); marker.setTitle(address); } else alert(lang.searchError); }); } $G('address').onkeydown = function (evt){ evt = evt || event; if (evt.keyCode == 13) { doSearch(); } }; $G("doSearch").onclick = doSearch; dialog.onok = function (){ var center = map.getCenter(); var point = marker.getPosition(); var url = "http://maps.googleapis.com/maps/api/staticmap?center=" + center.lat() + ',' + center.lng() + "&zoom=" + map.zoom + "&size=520x340&maptype=" + map.getMapTypeId() + "&markers=" + point.lat() + ',' + point.lng() + "&sensor=false"; editor.execCommand('inserthtml', ''); }; function getPars(str,par){ var reg = new RegExp(par+"=((\\d+|[.,]*) *)","g"); return reg.exec(str)[1]; } var img = editor.selection.getRange().getClosedNode(); if(img && img.src.indexOf("http://maps.googleapis.com/maps/api/staticmap")!=-1){ var url = img.getAttribute("src"); var centers = getPars(url,"center").split(","); point = new google.maps.LatLng(Number(centers[0]),Number(centers[1])); map.setCenter(point); map.setZoom(Number(getPars(url,"zoom"))); centers = getPars(url,"markers").split(","); marker.setPosition(new google.maps.LatLng(Number(centers[0]),Number(centers[1]))); imgcss = img.style.cssText; }else{ setTimeout(function(){ doSearch(); },30) } }); ``` -------------------------------- ### Initialize City/Area Selection Logic Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/shop_product/edit.htm Sets up the logic for selecting province, city, and area for the product. It conditionally calls functions to populate city and area lists based on the selected province and city, respectively, if the city site feature is enabled. ```javascript $(function () { try { var web_citysite_open = {$global['web_citysite_open']|default=0}; if (web_citysite_open > 0) { var province_id = {$field.province_id|default=0}; var city_id = {$field.city_id|default=0}; var area_id = {$field.area_id|default=0}; if (province_id > 0) { set_city_list(city_id); } if (city_id > 0) { set_area_list(area_id); } } }catch(e){} }); ``` -------------------------------- ### Initialize Layui Datepickers Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/coupon/edit.htm Renders Layui datepicker instances for various date input fields, including start date, end date, use start time, and use end time. ```javascript layui.use('laydate', function() { var laydate = layui.laydate; laydate.render({ elem: '#start_date' ,type: 'datetime' }); laydate.render({ elem: '#end_date' ,type: 'datetime' }); laydate.render({ elem: '#use_start_time' ,type: 'datetime' }); laydate.render({ elem: '#use_end_time' ,type: 'datetime' }); }) ``` -------------------------------- ### Get Marker Point and Address Details Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/map/get_coordinate.htm Event handler for marker dragend. Uses Geocoder to get the address components and full address from a given point, then updates input fields for address and coordinates. ```javascript function getMarkerPoint(e) { //通过点击百度地图,可以获取到对应的point, 由point的lng、lat属性就可以获取对应的经度纬度 var pot = ''; if (!e.point) { pot = e; } else { pot = e.point; } myGeo.getLocation(pot, function(rs){ //addressComponents对象可以获取到详细的地址信息 var addComp = rs.addressComponents; var alladdress = addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber; document.getElementById("alladdress").value = alladdress; //详细地址 document.getElementById("location").value = pot.lng + ',' + pot.lat; // 经度 纬度 }); } ``` -------------------------------- ### Initialize City Site Selection Logic Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/media/add.htm Sets up the initial selection for province, city, and area based on predefined variables. This script assumes the existence of JavaScript functions 'set_city_list' and 'set_area_list'. ```javascript $(function () { try { var web_citysite_open = {$global['web_citysite_open']|default=0}; var site_province_id = {$site_province_id|default=0}; var site_city_id = {$site_city_id|default=0}; var site_area_id = {$site_area_id|default=0}; if (web_citysite_open > 0 && site_province_id > 0) { $('select[name=province_id]').val(site_province_id); set_city_list(site_city_id); set_area_list(site_area_id); } }catch(e){} //选项卡切换列表 $('.tab-base').find('.tab').click(function(){ $('.tab-base').find('.tab').each(function(){ $(this).removeClass('current'); }); $(this).addClass('current'); var tab_index = $(this).data('index'); $(".tab_div_1, .tab_div_2, .tab_div_3").hide(); $(".tab_div_"+tab_index).show(); layer.closeAll(); }); $('input[name=is_jump]').click(function(){ if ($(this).is(':checked')) { $('.dl_jump').show(); } else { $('.dl_jump').hide(); } }); var dftypeid = {$typeid|default='0'}; $('#typeid').change(function(){ var current_channel = $(this).find('option:selected').data('current_channel'); if (0 < $(this).val() && {$channeltype} != current_channel) { showErrorMsg('请选择对应模型的栏目!'); $(this).val(dftypeid); } else if ({$channeltype} == current_channel) { layer.closeAll(); } GetAddonextitem(1, $(this).val(), {$channeltype}, 0, true); }); $(document).click(function(){ $('#often_tags').hide(); $('#often_tags_input').hide(); event.stopPropagation(); }); $('#often_tags').click(function(){ $('#often_tags').show(); event.stopPropagation(); }); $('input[name=restric_type]').click(function(){ $('#dl_arc_level_id').hide(); $('#dl_users_price').hide(); $('#no_vip_pay_label').hide(); var restric_type = $(this).val(); $('#arc_level_id').find('option:eq(0)').attr('selected',true); if (-1 < $.inArray(restric_type, \[ '1','3' \])) { $('#dl_users_price').show(); } if (-1 < $.inArray(restric_type, \[ '2','3' \])) { $('#dl_arc_level_id').show(); if (2 == restric_type) { $('#no_vip_pay_label').show(); if ($('#no_vip_pay').is(':checked')){ $('#dl_users_price').show(); } } } }); $('input[name=tags]').keyup(function(){ var tags = $.trim($(this).val()); $('#seo_keywords').val(tags); }); }); ``` -------------------------------- ### Handle Coupon Use Type Selection Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/admin/template/coupon/edit.htm Manages the enabling and disabling of date input fields based on the selected coupon use type (fixed time, start from receipt day, start from next day). ```javascript function chooseUseType(obj){ var val = $(obj).val(); if ( 1 == val ) { $("#use_start_time").attr('disabled',false); $("#use_end_time").attr('disabled',false); $("#valid_days_2").attr('disabled',true); $("#valid_days_3").attr('disabled',true); }else if( 2 == val ){ $("#valid_days_2").attr('disabled',false); $("#use_start_time").attr('disabled',true); $("#use_end_time").attr('disabled',true); $("#valid_days_3").attr('disabled',true); }else if( 3 == val ){ $("#valid_days_3").attr('disabled',false); $("#use_start_time").attr('disabled',true); $("#use_end_time").attr('disabled',true); $("#valid_days_2").attr('disabled',true); } } ``` -------------------------------- ### Get Marker Point and Geocoding Details Source: https://github.com/weng-xianhu/eyoucms/blob/master/application/api/template/uiset/map.htm This function is triggered when a marker is dragged or initially set. It uses the Baidu Geocoder to get the address components and full address from a given point, then updates input fields with the address and coordinates. ```javascript function getMarkerPoint(e) { //通过点击百度地图,可以获取到对应的point, 由point的lng、lat属性就可以获取对应的经度纬度 var pot = ''; if (!e.point) { pot = e; } else { pot = e.point; } myGeo.getLocation(pot, function(rs){ //addressComponents对象可以获取到详细的地址信息 var addComp = rs.addressComponents; var alladdress = addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber; document.getElementById("alladdress").value = alladdress; //详细地址 document.getElementById("location").value = pot.lng + ',' + pot.lat; // 经度 纬度 }); } ```