|
|
@@ -1,78 +0,0 @@
|
|
|
-const WECARD_BASE_URL = 'https://open.wecard.qq.com' // wecard
|
|
|
-const MY_BASE_URL = 'http://demo.xwsyjjy.com' // my
|
|
|
-const CODE_BASE_URL = 'https://developdomain.chuanghai-tech.com' // code
|
|
|
-
|
|
|
-export const myRequest = (options) => {
|
|
|
-
|
|
|
- // 域名 或 url 为空,则不执行任何操作
|
|
|
- if (options.host == '' || options.url == '') {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- let BASE_URL = '';
|
|
|
-
|
|
|
- if (options.host == 'wecard')
|
|
|
- BASE_URL = WECARD_BASE_URL;
|
|
|
- else if (options.host == 'my')
|
|
|
- BASE_URL = MY_BASE_URL;
|
|
|
- else if (options.host == 'code')
|
|
|
- BASE_URL = CODE_BASE_URL;
|
|
|
- else
|
|
|
- return;
|
|
|
-
|
|
|
- uni.request({
|
|
|
- url: BASE_URL + options.url,
|
|
|
- method: options.method || 'GET',
|
|
|
- header: options.header || {},
|
|
|
- data: options.data || {},
|
|
|
- success: (res) => {
|
|
|
- // console.log(res)
|
|
|
- resolve(res)
|
|
|
- },
|
|
|
- fail: (err) => {
|
|
|
- uni.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: err.errMsg
|
|
|
- })
|
|
|
- reject(err)
|
|
|
- }
|
|
|
- })
|
|
|
- }).catch(
|
|
|
- err => {
|
|
|
- console.log("catch " + err);
|
|
|
- }
|
|
|
- )
|
|
|
-}
|
|
|
-
|
|
|
-// let BASE_URL = 'http://demo.xwsyjjy.com'
|
|
|
-// export const myRequest = (options) => {
|
|
|
-// return new Promise ((resolve, reject) => {
|
|
|
-// uni.request({
|
|
|
-// url: options.ip ? (options.ip + options.url) : (BASE_URL + options.url),
|
|
|
-// method: options.method || 'GET',
|
|
|
-// header: options.header || {},
|
|
|
-// data: options.data || {},
|
|
|
-// success: (res) => {
|
|
|
-// // console.log(res)
|
|
|
-// // if(res.data.static != "succ"){
|
|
|
-// // return uni.showToast({
|
|
|
-// // title: '获取数据失败'
|
|
|
-// // })
|
|
|
-// // }
|
|
|
-// // console.log(options)
|
|
|
-// resolve(res)
|
|
|
-// },
|
|
|
-// fail: (err) => {
|
|
|
-// uni.showToast({
|
|
|
-// title: '请求接口失败'
|
|
|
-// })
|
|
|
-// reject(err)
|
|
|
-// },
|
|
|
-// });
|
|
|
-// })
|
|
|
-
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|