|
@@ -24,11 +24,14 @@
|
|
|
</template>
|
|
|
<script>
|
|
|
import { createAxiosByinterceptors } from '@/api/request';
|
|
|
-import Stomp from '@/lib/stompjs';
|
|
|
+// import Stomp from '@stomp/stompjs';
|
|
|
+import Stomp from '@stomp/stompjs';
|
|
|
import loginMinix from '@/mixins/login';
|
|
|
import { Decrypt, Encrypt } from '@/utils/crypto';
|
|
|
import { getIsMin, getIsWxh5, getUrlParams } from '@/utils/index.js';
|
|
|
-import SockJS from '@/utils/sockjs';
|
|
|
+import { Client } from "@stomp/stompjs/esm6/client";
|
|
|
+// import SockJS from '@/utils/sockjs';
|
|
|
+import SockJS from 'sockjs-client';
|
|
|
import uni from '@/utils/uniHooks';
|
|
|
import { getAppIdByGroupIdAndMallId } from '@/utils/index.js';
|
|
|
import sensorsFn from '@/plugins/sensors'
|
|
@@ -110,8 +113,13 @@ export default {
|
|
|
wss() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
try {
|
|
|
- const socket = new SockJS(`${this.getUrl()}/hafengWebsocket?token=${window.token}`);
|
|
|
- window.stompClient = Stomp.over(socket);
|
|
|
+ // Typical usage with SockJS
|
|
|
+ Stomp.Client.webSocketFactory = function () {
|
|
|
+ return new SockJS(`${this.getUrl()}/hafengWebsocket?token=${window.token}`);
|
|
|
+ };
|
|
|
+ // const socket = new SockJS(`${this.getUrl()}/hafengWebsocket?token=${window.token}`);
|
|
|
+ // window.stompClient = Stomp.over(socket);
|
|
|
+ window.stompClient = Stomp.Client;
|
|
|
window.stompClient.debug = null;
|
|
|
this.windowSendInit();
|
|
|
window.stompClient.connect({}, (frame) => {
|
|
@@ -140,19 +148,20 @@ export default {
|
|
|
*/
|
|
|
if (!type) return;
|
|
|
// console.log(259, '微信支付的options', options);
|
|
|
- window.stompClient.send(
|
|
|
- '/sendToWechat',
|
|
|
- {},
|
|
|
- JSON.stringify({
|
|
|
- token,
|
|
|
- data: Encrypt(
|
|
|
- JSON.stringify({
|
|
|
- type: type,
|
|
|
- funcName,
|
|
|
- options,
|
|
|
- })
|
|
|
- ),
|
|
|
- })
|
|
|
+ window.stompClient.publish(
|
|
|
+ {
|
|
|
+ destination: '/sendToWechat',
|
|
|
+ body: JSON.stringify({
|
|
|
+ token,
|
|
|
+ data: Encrypt(
|
|
|
+ JSON.stringify({
|
|
|
+ type: type,
|
|
|
+ funcName,
|
|
|
+ options,
|
|
|
+ })
|
|
|
+ ),
|
|
|
+ })
|
|
|
+ }
|
|
|
);
|
|
|
};
|
|
|
|