| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- // let BASE_URL = 'http://114.55.0.7:8002';
- // const BASE_URL='http://8.136.98.49:8002'
- // let BASE_URL = 'http://218.28.198.186:10505'
- // let BASE_URL = 'https://wx.hnyfwlw.com'
- // let BASE_URL = 'https://wx.hnyfwlw.com';
- let BASE_URL = 'http://218.28.198.186:10508';
- export const myRequest = (options) => {
- // BASE_URL=uni.getStorageSync('http')
- // if(BASE_URL==''){
- // BASE_URL = 'https://wx.hnyfwlw.com/'
- // }
- // console.log(BASE_URL)
- var session_key = '';
- session_key = uni.getStorageSync('session_key');
- let url = options.url;
- let data = options.data || {};
- if (
- url != 'user.login.login_user' &&
- url != 'pest.pests.insect_discern' &&
- url != 'pest.pests.plant_discern' &&
- url != 'pest.pests.pests_contrast' &&
- url != 'pest.pests.pests_expert_img' &&
- url != 'pest.pests.pests_img' &&
- url != 'recognizationSys' &&
- url != 'base.bases.base_photo' &&
- url != 'pest.warning_record.rolemanage_img' &&
- url != 'home.homes.personal_photo' &&
- url != 'ascend.ascend_manage.product_info' &&
- url != 'ascend.ascend_manage.quality_info' &&
- url != 'ascend.ascend_manage.grow_info' &&
- url != 'ascend.ascend_manage.all_ascend' &&
- url != 'after_sale.after_sale_manage.device_check' &&
- url != 'after_sale.after_sale_manage.aftersale_apply'
- ) {
- data.token = session_key;
- }
- return new Promise((resolve, reject) => {
- uni.request({
- url: BASE_URL + options.url,
- method: options.method || 'POST',
- header: options.header || {
- 'Content-Type': 'application/x-www-form-urlencoded',
- },
- data: data,
- success: (res) => {
- if (res.data.errorCode == 403) {
- uni.removeStorageSync('session_key');
- uni.showToast({
- title: '登录已过期,请重新登录!',
- icon: 'none',
- });
- if (uni.getStorageSync('isLink')) {
- return false;
- } else {
- uni.setStorageSync('isLink', true);
- return uni.navigateTo({
- url: '/pages/login/login',
- });
- }
- }
- if (res.data.message) {
- if (
- res.data.message !== '识别无结果' &&
- res.data.message !== '该设备未绑定SIM'
- ) {
- return uni.showToast({
- title: res.data.message,
- icon: 'none',
- });
- } else {
- resolve(res.data.data);
- }
- }
- if (options.header) {
- resolve(res.data);
- return;
- }
- if (res.data.data) {
- resolve(res.data.data);
- } else {
- resolve(res.data);
- }
- },
- fail: (err) => {
- uni.showToast({
- title: '请求接口失败',
- icon: 'none',
- });
- reject(err);
- },
- });
- });
- };
|