12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- // let api = "https://passport.lrlz.com/mobile/index.php";
- let api = "http://192.168.1.200/mobile/index.php";
- function getReq(data, callback, method) {
- let options = {
- client_type: 'mini'
- }
- data = Object.assign({}, options, data);
- let session_id = wx.getStorageSync('session_id');
- if (!session_id && data['op'] != 'ministart') {
- setTimeout(() => {
- getReq(data, callback, method)
- }, 0);
- return;
- }
- let header = {
- 'content-type': 'application/json', // 默认值
- 'Cookie': 'MPHPSESSID=' + session_id
- }
- if (method == 'POST') {
- header = {
- 'content-type': 'application/x-www-form-urlencoded', // 数据转换成 query string
- 'Cookie': 'MPHPSESSID=' + session_id
- }
- }
- return wx.request({
- url: api,
- data,
- method: method || 'GET',
- header,
- success(res) {
- callback(res.data)
- },
- fail() {
- wx.showModal({
- confirmText: '重试',
- content: '网络错误',
- success: function (res) {
- if (res.confirm) {
- wx.reLaunch({
- url: "/pages/index/index"
- })
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- }
- })
- }
- module.exports = {
- getReq,
- host: api
- }
|