10.10综合交易所原始源码-管理后台
admin
2026-01-06 a3cc41349752d6fb067df2a58e4e4b723a915f21
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import Axios from '@/utils/http'
import axios from "axios";
import {compress} from 'image-conversion';
import httpRequest from '@/utils/httpRequest'
 
// 获取消息列表
export const _getMsg = (message_id= '',order_no, party_id,show_img = true) => {
    console.log("order_no = " + order_no);
    console.log("party_id = " + party_id);
    return new Promise((resolve, reject) => {
        // Axios.fetch('api/newOnlinechat!list.action', {message_id,show_img }).then(res => {
        //     resolve(res.data)
        // })
        httpRequest({
            url: httpRequest.adornUrl('/normal/adminOtcOnlineChatAction!list.action'),
            method: 'get',
            params: httpRequest.adornParams(Object.assign(
                {
                    message_id:message_id,
                    show_img:show_img,
                    order_no:order_no,
                    partyid:party_id,
                }
            )),
            data: httpRequest.adornData(
              Object.assign(
                {
                }
              )
            )
          }).then(({ data }) => {
            resolve(data)
          })
    }) 
    
    // return request({
    //     url: "api/newOnlinechat!list.action",
    //     // loading: true,
    //     method: "GET",
    //     params: {
    //         message_id: params.message_id || '',  // 翻页用到
    //         show_img: params.show_img || true
    //     }
    // })
};
 
// 未读消息
export const _getUnreadMsg = (order_no, party_id) => {
    // return Axios.fetch('api/newOnlinechat!unread.action', params)
    // return request({
    //     url: "api/newOnlinechat!unread.action",
    //     loading: true,
    //     method: "GET",
    // })
    return new Promise((resolve, reject) => {
 
        httpRequest({
            url: httpRequest.adornUrl('/normal/adminOtcOnlineChatAction!unread.action'),
            method: 'get',
            params: httpRequest.adornParams(Object.assign(
                {
                    order_no:order_no,
                    partyid:party_id,
                }
            )),
            data: httpRequest.adornData(
              Object.assign(
                {
                    order_no:order_no,
                    partyid:party_id,
                }
              )
            )
          }).then(({ data }) => {
            resolve(data)
          })
    }) 
};
 
// 发送消息
export const _sendMsg= (type = 'text', content = '', order_no, party_id) => {
    // return Axios.fetch('api/newOnlinechat!send.action', {type, content})
    // return request({
    //     url: "api/newOnlinechat!send.action",
    //     // loading: true,
    //     method: "GET",
    //     params: {
    //         type, // 消息类型, img / text
    //         content
    //     }
    // })
 
    return new Promise((resolve, reject) => {
 
        httpRequest({
            url: httpRequest.adornUrl('/normal/adminOtcOnlineChatAction!send.action'),
            method: 'get',
            params: httpRequest.adornParams(Object.assign(
                {
                    type, content,
                    order_no:order_no,
                    partyid:party_id,
                }
            )),
            data: httpRequest.adornData(
              Object.assign(
                {
                }
              )
            )
          }).then(({ data }) => {
            resolve(data)
          })
    }) 
};
 
// 图片上传
export const _uploadImage = (file, callback) => {
    console.log(file)
    const isLt2M = file.size / 1024 / 1024 < 2;
    if (!isLt2M) {
        Toast.fail('上传头像图片大小不能超过 2MB!');
        return false;
    }
    // Toast.loading()
    // const BASE_URL = 'https://' + window.location.hostname
    const BASE_URL = ''
    return new Promise((resolve, reject) => {
        compress(file, 0.6).then(res => {
            const formData = new FormData()
            formData.append('file', res)
            axios.post(`${BASE_URL}public/uploadimg!execute.action`,
                formData,
                {
                    onDownloadProgress: (progressEvent) => {
                        console.log(progressEvent)
                        if (progressEvent.lengthComputeable) {
                            callback(((progressEvent.loaded / progressEvent.total) * 100).toFixed(2))
                        }
                    }
                },
                { headers:
                    { "Content-Type": "multipart/form-data" }
                }).then(res => {
                    // Toast.clear()
                    const { code, data } =res.data
                    if (code / 1=== 0) {
                        resolve(data)
                    }
                }).catch(err => {
                    // Toast.clear()
                    reject(err)
                })
            })
        })
    };
 
    // 选择图片文件后回调方法
    export const uploadImageChange = (file,callback) => {
        const isLt2M = file.size / 1024 / 1024 < 2;
        if (!isLt2M) {
            Toast.fail('上传图片大小不能超过 2MB!');
            return false;
        }
  
        let fileData = new FormData()
        fileData.append('file', file)
 
        
        //
        httpRequest({
          url: httpRequest.adornUrl('/api/uploadFile'),
          method: 'post',
          data: fileData,
          headers: {
            'Content-Type': 'multipart/form-data' // 设置请求头为 multipart/form-data
          }
        }).then(({ data }) => {
          //
          console.log("uploaded image = " + JSON.stringify(data));
          if(data.code == 0){
            if(callback){callback(data.data.path)}
            // this.$bus.$emit('SendMessage',{type:"img",content:""+data.data.httpUrl})
          }else{
            // this.$message(''+data.msg)
            if(callback){callback(null)}
          }
          //
        })
        .finally(() => {
            if(callback){callback(null)}
        })
 
      };