Zepto(function($) {
    var openId = location.search.split('?')[1].split('=')[1]

    getBindState(function(resData){
        if(resData.success){
            $('.bind-succeed').removeClass('hidden')
        } else{
            $('.form').removeClass('hidden')
        }
    })

    $(".btn-submit").click(function(e) {
        e.preventDefault()
        submitBind({
            name: $('.form-name').val(),
            telephone: $('.form-phone').val(),
            openId: openId
        }, function(resData){
            if(resData.success){
                $('.form').addClass('hidden')
                $('.bind-succeed').removeClass('hidden')
            } else {
                alert('未绑定成功，请稍后再试...')
            }
        })
    })

    function submitBind(formData, callback) {
        ajax('POST', '/api/binding/bind', formData, callback)
    }

    function getBindState(callback) {
        ajax('GET', '/api/binding/state', {openId: openId}, callback)
    }

    function ajax(method, url, data, callback) {
        $.ajax({
            type: method,
            url: url,
            data: method === 'POST' ? JSON.stringify(data) : data,
            contentType: 'application/json',
            success: function(res && res.data) {
                if(res.ret){
                    callback(res.data)
                } else{
                    alert('服务器出了点小问题...')
                }
            }
        })
    }
})

@@ -1229,20 +1229,8 @@
 (res
- && res.data
 ) %7B%0A
@@ -1255,16 +1255,28 @@
 (res.ret
+ && res.data
 )%7B%0A     

fix binding err