PHP - AJAX - 省市区三级联动

php

public function indexAction() {
    //获取父级代号pid
    $pid = $this->getParam('pcode');
    //数据查询
    $areaModel = new Model_Area();
    $fields = "*";
    $whereArr[] = array('pid', $pid);
    $areadetail = $areaModel->getArea($fields, $whereArr);
    //var_dump($areadetail);
    echo json_encode($areadetail);
}

  翻  牌  子

PHP - 钉钉 - 扫码 - 获取信息

引入 js

<script type="text/javascript" src="//g.alicdn.com/dingding/open-develop/0.8.4/dingtalk.js"></script>

内部代码如下,作用是实现二维码的展现。

<script>
        !function (window, document) {
            function d(a) {
                var e, c = document.createElement("iframe"),
                    d = "https://login.dingtalk.com/login/qrcode.htm?goto=" + a.goto ;
                //console.log(d);
                    d += a.style ? "&style=" + encodeURIComponent(a.style) : "",
                    d += a.href ? "&href=" + a.href : "",
                    c.src = d,
                    c.frameBorder = "0",
                    c.allowTransparency = "true",
                    c.scrolling = "no",
                    c.width =  a.width ? a.width + 'px' : "365px",
                    c.height = a.height ? a.height + 'px' : "400px",
                    e = document.getElementById(a.id),
                    e.innerHTML = "",
                    e.appendChild(c)
            }
            window.DDLogin = d
        }(window, document);
    </script>

  翻  牌  子

json - array - stdClass - 相互转化

将 json 转为 array

$userinfo = json_decode($userinfo, true);

将 json 的 stdClass Object 转为 array

$count = json_decode(json_encode($count), true);

遍历 json 的 stdClass Object

foreach($simplelist as $obj){
    echo "姓名:".$obj->name."&nbsp;uerid:".$obj->userid."<br/>";
}

Editor - 百度编辑器

实例化编辑器

var ue = UE.getEditor('editor2', {
    toolbars: [[
        'source', '|', 'undo', 'redo', '|',
        'bold', 'italic', 'underline', '|',
        'selectall', 'cleardoc', '|',
        'fontfamily', 'fontsize', '|',
        'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',
        'simpleupload', '|',
        'removeformat', '|'
    ]],
    iframeCssUrl: '../ueditor/themes/editor2.css',
    initialFrameHeight:500,
    enableAutoSave: false,
    enableContextMenu: false,
    elementPathEnabled : false,
    focus:false,
    autoHeightEnabled:false
});

  翻  牌  子

JS - 数组的交叉合并

js

var arr1 = new Array(3);
arr1[0] = "a";
arr1[1] = "b";
arr1[2] = "c";
arr1[3] = "d";
var arr2 = new Array(3);
arr2[0] = "x";
arr2[1] = "y";
arr2[2] = "z";
console.log(arr1);
console.log(arr2);
var length = arr1.length;
console.log(length);
var arr3 = new Array(3);
for(var j=0;j<length;j++){
    var a = 2*j;
    console.log(a);
    var b = 2*j+1;
    console.log(b);
    arr3[a]=arr1[j];
    arr3[b]=arr2[j];
}
console.log(arr3);
var str = arr3.join("");
console.log(str);
//axbyczd

ajax - 删除前的确认

if(confirm('确认删除图片' + selectItem.join(",") + '吗?')) {
        $.ajax({
            url: "del/batchdel",
            type: 'POST',
            dataType: 'json',
            data: 'items=' + selectItem.join(","),
            success: function (data) {
                if (data.code == 200) {
                    errorDis(data.info);
                    refresh();
                } else {
                    errorDis(data.info);
                    return false;
                }
            }
        });
    }

JS - 点击直接下载

js

function download(src) {
    var a = document.createElement('a');
    a.setAttribute("href", src);
    a.setAttribute("download", "");
    var evObj = document.createEvent('MouseEvents');
    evObj.initMouseEvent( 'click', true, true, window, 0, 0, 0, 0, 0, false, false, true, false, 0, null);
    a.dispatchEvent(evObj);
};

  翻  牌  子

JS - 同一界面内实例化2个编辑器

js

//实例化编辑器editor
var ue = UE.getEditor('editor');
//实例化编辑器editor2
var ue2 = UE.getEditor('editor2');
function removeformat() {
    //全选
    ue.execCommand('selectall');
    //未格式化的内容
    var content1 = ue.getContent();
    //清除格式
    ue.execCommand('removeformat');
    //格式化后的内容
    var content2 = ue.getContent();
    //过滤掉&nbsp;
    content2 = content2.replace(/&nbsp;/g, "");
    //过滤掉<p><br/></p>
    content2 = content2.replace(/<p><br\/><\/p>/g, "");
    //保留原来的内容
    ue.setContent(content1, false);
    //将内容赋予编辑器2
    ue2.setContent(content2, false);
}

  翻  牌  子