comfun.js 797 Bytes
import inter from 'comenter'
function cache(key,value){
    if(value){
        wx.setStorageSync(key,value);
    }
    return wx.getStorageSync(key);
};
function setBarTitle(title){
    wx.setNavigationBarTitle({
        title:title
    })
};
function request(url,data){
    var obj={};
    wx.request({
        url:url, //仅为示例,并非真实的接口地址
        method:'POST',
        data: data,
        header: {
            'content-type': 'application/x-www-form-urlencoded'
        },
        success:function(res) {
            obj.result='success';
            obj.jsondata=res.data;
            return obj;
        },
        fail:function(){
            obj.result='fail';
            return obj;
        }
    })
}
module.exports = {
    cache,
    setBarTitle,
    request
}