小程序常用方法(更新中)

#pragma mark --本地缓存--基本数据

var userData = wx.getStorageSync('UserData');

var unittype = userData.UnitType;

wx.removeStorageSync('session_key');

#pragma mark --可以滚动

overflow:auto

#pragma mark --请求方法

//好友列表

requestFriendListData: function (num) {

var userData = wx.getStorageSync("UserData");

this.setData({

userID: userData.UserId,

unitType: userData.UnitType

})

// loadH 加载完成是否影藏 loading  1为不影藏

// loadS 加载中是否显示 loading 1为不加载

// var loadH = num == 2 ? 2 : 1;

console.log("~~~~~~~~~~num~~~~~~`~", num, loadS)

var page = this;

PublicUtils.postData(page, '', 'PZ.TX_App_SNS.api.FirstPage.GetFriendList', function (dataList) {

var friends = dataList.obj;

var friendFrist = friends[0].List;

var friendSecond = friends[1].List;

for (var i = 0; i < friendSecond.length; i++) {

friendFrist.push(friendSecond[i]);

}

page.setData({

friendList: friendFrist

});

}, "", 2, 1)

},

#pragma mark --三目运算符class名字判断

class="categoryLeft {{activeList.length != 0 ? 'top8': ''}}"

#pragma mark --赋值

that.setData({

})

#pragma mark --链接跳转

wx.navigateTo({

url: '../searchfriend/searchfriend'

})

#pragma mark --绑定参数

url: '../friendDetail/friendDetail?type=' + 1 + '&FriendUnitId=' + unitid + '&FriendId=' + userid,

#pragma mark --方法回调

//获取seaction_key

obtainWXSeactionKey: function (call) {

//调用登录接口

publicutil.PostAjax(1, cont, 'PZ.TX_App_User.api.GetInfo.GetWxOpenId', false, function (data) {

if (data.Status == 0 && data.Data != '') {

var dataList = JSON.parse(data.Data);

if (dataList != '' && dataList.status == 200) {

var session_key = dataList.obj.session_key;

wx.setStorageSync('session_key', session_key);

if (typeof call == 'function')

call(dataList);

}

}

})

},

page.obtainWXSeactionKey(function (data) {

page.WXloginSuccessJumptoApp()

})

#pragma mark --方法传递参数

that.jumpToAppView(dataList)

jumpToAppView: function (dataList) {

}

#pragma mark --数组删除

that.orderlist.splice(that.orderIndex, 1);

你可能感兴趣的:(小程序常用方法(更新中))