import store from '@/store'
import config from '@/config'
import { getToken } from '@/utils/auth'
import errorCode from '@/utils/errorCode'
import { toast, showConfirm, tansParams } from '@/utils/common'

const baseUrl = config.socketUrl

const websocket = config => {
    // 是否需要设置 token
    const isToken = (config.headers || {}).isToken === false
    config.header = config.header || {}
    let token = "";
    if (getToken() && !isToken) {
        token =  getToken()
    }
       let SocketTask = uni.connectSocket({
            url: config.baseUrl || baseUrl + config.url+""+token,
            success:function(res){
            },
            fail:function (res){
            }
        })
    return SocketTask;
}

export default websocket
