用AI赚第一桶💰低成本搭建一套AI赚钱工具,源码可二开。 广告
[TOC] ##### 获取用户信息 >[info]util.getUserInfo(callback) 获取成功后会将用户信息写入到缓存中,如果指定了回调函数,则会调用回调函数 * callback 获取成功后的回调函数 *示例* ``` var app = getApp() Page( onLoad: function () { var that = this app.getUserInfo(function (userInfo) { //更新数据 that.setData({ userInfo: userInfo }); }); } }); ``` ##### 发起的是 HTTPS 请求 >[info]util.request(option) 此函数是扩展小程序的wx.request函数,您请求模块中的接口数据时,必须使用此函数请求,模块中才可以获取到用户的身份信息和签名安全验证 * option.cachetime 缓存时间,在此周期内不重复请求,默认不缓存 获取成功后的回调函数 *示例* ``` function getHotelList(cb) { app.util.request({ url: 'entry/wxapp/hotellists', data: { m: 'ewei_hotel', }, cachetime: 30, success: function (res) { if (res.data.errno == 0) { typeof cb == "function" && cb(res); } else { failGo(res.data.message); } }, fail: function () { failGo('请检查连接地址'); } }) } ``` ##### 生成微擎URL地址 >[info]util.url(action, querystring) 与微擎系统中的 url() 函数一致 * action 微擎系统中的controller, action, do,格式为 'wxapp/home/navs' * querystring 格式为 {参数名1 : 值1, 参数名2 : 值2} *示例* ``` util.url('entry/wxapp/hotellists', {m : 'ewei_hotel'}); //地址为:https://pro.we7.cc/app/index.php?i=8641&t=8907&c=entry&a=wxapp&do=hotellists&state=we7sid-89d565916d5496ef322630a73f170f99&sign=c6ab3b6fd8d564419e7fb7e809e3efba&m=ewei_hotel ```