sf
jiangping
2025-04-30 dcdb0231034810232f2542f3865666ebf72daf11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import store from '@/store/index.js'
/**
 * @param {string} url 请求地址
 * @param {object} data 请求参数
 * @param {string} method 请求方法
 */ 
const request = (url, data, method) => {
    if (url !== 'business/goods/listForH5' && url !== 'business/brand/list') {
        uni.showLoading({ title: '请求中', mask: true });
    }
    return new Promise((resole, reject) => {
        // https://dmtest.ahapp.net/preselect_interface/
        // https://dm.ahapp.net/preselect_interface/
        // http://mjyx.doumee.com/preselect_interface/
        // http://yx.doumee.com/preselect_interface/
        // http://127.0.0.1/interface/    http://192.168.0.15:10024/   preselect_web_interface
        // https://dmtest.ahapp.net/preselect_h5_interface/${url}   http://127.0.0.1:10022/  http://192.168.0.35:10024/
        // http://127.0.0.1:10024/   测试
        // https://yx.ahapp.net/h5_interface/${url}
        uni.request({
            url: `https://yx.ahapp.net/h5_interface_v2/${url}`,
            method,
            data,
            header: {
                'content-type': 'application/json',
                'Access-Control-Allow-Origin': '*',
                'zhubo-auth-token': store.state.Cookies ? store.state.Cookies : '111111111111111111111111111111111111'
            },
            success: (res) => {
                if (res.data.code === 401) {
                    uni.redirectTo({
                        url: '/pages/login/login'
                    });
                }
                if (res.data.code === 200) {
                    resole(res.data)
                } else {
                    uni.showToast({ title: res.data.message, icon: 'none', duration: 2000 });
                }
            },
            fail(err) {
                reject()
            },
            complete() {
                if (url !== 'business/goods/listForH5' && url !== 'business/brand/list') {
                    uni.hideLoading();
                }
            }
        })
    })
}
 
const get = (url, data) => request(url, data, 'GET')
 
const post = (url, data) => request(url, data, 'POST')
 
export {
    get,
    post
}