| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- // const BASE_URL='http://8.136.98.49:8002'
- let BASE_URL = ''
- export const myRequest=(options)=>{
- uni.getStorage({
- key: 'http',
- success: (res)=> {
- BASE_URL = res.data
- },
- fail: (res) => {
- BASE_URL = 'http://8.136.98.49:8002'
- }
- });
- var session_key=""
- // uni.getStorage({
- // key:'session_key',
- // success:function(res){
- // session_key=res.data
- // console.log(111)
- // }
- // })
- session_key=uni.getStorageSync('session_key')
- console.log(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:{
- "Content-Type": "application/x-www-form-urlencoded",
- },
- data:data,
- success:(res)=>{
- if(res.data.message!=""){
- return uni.showToast({
- title:res.data.message,
- icon:"none"
- })
- }
- resolve(res.data.data)
- },
- fail:(err)=>{
- uni.showToast({
- title:'请求接口失败'
- })
- reject(err)
- }
- })
- })
- }
|