|
|
|
|
@ -296,18 +296,15 @@ const img_url = import.meta.env.VITE_APP_IMG_URL
|
|
|
|
|
const ws = new ReconnectingWebSocket(import.meta.env.VITE_APP_WS_URL);
|
|
|
|
|
|
|
|
|
|
ws.onopen = function(evt) {
|
|
|
|
|
console.log("Connection open ...");
|
|
|
|
|
console.log(bonus.sn)
|
|
|
|
|
if(bonus.sn){
|
|
|
|
|
ws.send(JSON.stringify({action: 'init', payload: bonus.sn}));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ws.onmessage = function(evt) {
|
|
|
|
|
console.log( "Received Message: " + evt.data);
|
|
|
|
|
// console.log( "Received Message: " + evt.data);
|
|
|
|
|
let data = JSON.parse(evt.data);
|
|
|
|
|
if(data.action === 'use'){
|
|
|
|
|
console.log('use')
|
|
|
|
|
bonus.remain -= 1;
|
|
|
|
|
if(bonus.remain === 0){
|
|
|
|
|
showToast('優惠券已被搶完');
|
|
|
|
|
|