| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- // const BASE_URL='http://8.136.98.49:8002'
- // let BASE_URL = 'http://192.168.1.112:8002'
- export const myRequest = (options) => {
- let BASE_URL = uni.getStorageSync('http');
- if (BASE_URL == '') {
- // BASE_URL = 'http://8.136.98.49:8002'//线上
- BASE_URL =
- process.env.NODE_ENV === 'development'
- ? 'http://114.115.147.140:8002'
- : 'http://8.136.98.49:8002';
- // BASE_URL = 'http://192.168.1.77:8002'
- }
- // BASE_URL = 'http://121.41.98.97:8002'
- console.log(BASE_URL, 'my request', process.env.NODE_ENV);
- // console.log(BASE_URL)
- var session_key = '';
- session_key = uni.getStorageSync('session_key');
- let url = '';
- let data = options.data || {};
- if (options.url.split('=')[1]) {
- url = options.url.split('=')[1];
- } else {
- url = options.url.split('api/')[1];
- }
- // console.log(url)
- 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;
- }
- console.log(data, 'request data');
- return new Promise((resolve, reject) => {
- uni.request({
- url: BASE_URL + options.url,
- method: options.method || 'POST',
- header: {
- 'Content-Type': 'application/x-www-form-urlencoded',
- },
- data: data,
- success: (res) => {
- console.log(res.data, 'http response');
- if (res.data.message != '') {
- if (
- res.data.message == '识别无结果' ||
- res.data.message == '该设备未绑定SIM'
- ) {
- resolve(res.data.data);
- } else {
- return uni.showToast({
- title: res.data.message,
- icon: 'none',
- });
- }
- }
- resolve(res.data.data);
- },
- fail: (err) => {
- uni.showToast({
- title: '请求接口失败',
- });
- reject(err);
- },
- });
- });
- };
|