ts-glitter 17.9.9 → 18.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lowcode/Entry.js +19 -1
- package/lowcode/Entry.ts +28 -1
- package/lowcode/cms-plugin/POS-setting.js +0 -17
- package/lowcode/cms-plugin/POS-setting.ts +1 -26
- package/lowcode/cms-plugin/pos-pages/imin-module.js +20 -0
- package/lowcode/cms-plugin/pos-pages/imin-module.ts +25 -0
- package/lowcode/cms-plugin/shopping-product-setting.js +33 -22
- package/lowcode/cms-plugin/shopping-product-setting.ts +50 -35
- package/lowcode/glitter-base/route/api-track.js +1 -1
- package/lowcode/glitter-base/route/api-track.ts +1 -1
- package/lowcode/public-components/public/ad.ts +1 -0
- package/package.json +1 -1
- package/src/api-public/services/fb-api.js +6 -5
- package/src/api-public/services/fb-api.js.map +1 -1
- package/src/api-public/services/fb-api.ts +10 -8
package/lowcode/Entry.js
CHANGED
|
@@ -15,6 +15,7 @@ import { GlobalUser } from './glitter-base/global/global-user.js';
|
|
|
15
15
|
import { EditorConfig } from './editor-config.js';
|
|
16
16
|
import { ShareDialog } from './glitterBundle/dialog/ShareDialog.js';
|
|
17
17
|
import { Language } from './glitter-base/global/language.js';
|
|
18
|
+
import { PayConfig } from "./cms-plugin/pos-pages/pay-config.js";
|
|
18
19
|
export class Entry {
|
|
19
20
|
static onCreate(glitter) {
|
|
20
21
|
var _a, _b;
|
|
@@ -89,7 +90,7 @@ export class Entry {
|
|
|
89
90
|
}
|
|
90
91
|
window.renderClock = (_b = window.renderClock) !== null && _b !== void 0 ? _b : clockF();
|
|
91
92
|
console.log(`Entry-time:`, window.renderClock.stop());
|
|
92
|
-
glitter.share.editerVersion = '
|
|
93
|
+
glitter.share.editerVersion = 'V_18.0.0';
|
|
93
94
|
glitter.share.start = new Date();
|
|
94
95
|
const vm = {
|
|
95
96
|
appConfig: [],
|
|
@@ -339,6 +340,23 @@ export class Entry {
|
|
|
339
340
|
window.root.classList.add('light-mode');
|
|
340
341
|
function toNext() {
|
|
341
342
|
console.log(`to-next-time:`, window.renderClock.stop());
|
|
343
|
+
glitter.runJsInterFace('pos-device', {}, (res) => {
|
|
344
|
+
PayConfig.deviceType = res.deviceType === 'neostra' ? 'pos' : 'web';
|
|
345
|
+
if (PayConfig.deviceType === 'pos') {
|
|
346
|
+
const script = document.createElement('script');
|
|
347
|
+
script.type = 'text/javascript';
|
|
348
|
+
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/mui/3.7.1/js/mui.min.js';
|
|
349
|
+
script.integrity = 'sha512-5LSZkoyayM01bXhnlp2T6+RLFc+dE4SIZofQMxy/ydOs3D35mgQYf6THIQrwIMmgoyjI+bqjuuj4fQcGLyJFYg==';
|
|
350
|
+
script.referrerPolicy = 'no-referrer';
|
|
351
|
+
script.crossOrigin = 'anonymous';
|
|
352
|
+
document.head.appendChild(script);
|
|
353
|
+
glitter.addMtScript(['https://oss-sg.imin.sg/web/iMinPartner/js/imin-printer.min.js', 'https://cdn.jsdelivr.net/npm/jsbarcode@3.11.5/dist/JsBarcode.all.min.js'], () => { }, () => { });
|
|
354
|
+
setTimeout(() => {
|
|
355
|
+
window.IminPrintInstance = new IminPrinter();
|
|
356
|
+
window.IminPrintInstance.connect();
|
|
357
|
+
}, 3000);
|
|
358
|
+
}
|
|
359
|
+
});
|
|
342
360
|
running().then(() => __awaiter(this, void 0, void 0, function* () {
|
|
343
361
|
{
|
|
344
362
|
console.log(`to-page-time:`, window.renderClock.stop());
|
package/lowcode/Entry.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {GlobalUser} from './glitter-base/global/global-user.js';
|
|
|
7
7
|
import {EditorConfig} from './editor-config.js';
|
|
8
8
|
import {ShareDialog} from './glitterBundle/dialog/ShareDialog.js';
|
|
9
9
|
import {Language} from './glitter-base/global/language.js';
|
|
10
|
+
import {PayConfig} from "./cms-plugin/pos-pages/pay-config.js";
|
|
10
11
|
|
|
11
12
|
export class Entry {
|
|
12
13
|
public static onCreate(glitter: Glitter) {
|
|
@@ -90,7 +91,7 @@ export class Entry {
|
|
|
90
91
|
}
|
|
91
92
|
(window as any).renderClock = (window as any).renderClock ?? clockF();
|
|
92
93
|
console.log(`Entry-time:`, (window as any).renderClock.stop());
|
|
93
|
-
glitter.share.editerVersion = '
|
|
94
|
+
glitter.share.editerVersion = 'V_18.0.0';
|
|
94
95
|
glitter.share.start = new Date();
|
|
95
96
|
const vm: {
|
|
96
97
|
appConfig: any;
|
|
@@ -353,6 +354,32 @@ export class Entry {
|
|
|
353
354
|
|
|
354
355
|
function toNext() {
|
|
355
356
|
console.log(`to-next-time:`, (window as any).renderClock.stop());
|
|
357
|
+
//設定裝置類型
|
|
358
|
+
glitter.runJsInterFace('pos-device', {}, (res) => {
|
|
359
|
+
PayConfig.deviceType = res.deviceType === 'neostra' ? 'pos' : 'web';
|
|
360
|
+
//POS機台啟用列印功能
|
|
361
|
+
if (PayConfig.deviceType === 'pos') {
|
|
362
|
+
const script = document.createElement('script');
|
|
363
|
+
script.type = 'text/javascript';
|
|
364
|
+
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/mui/3.7.1/js/mui.min.js';
|
|
365
|
+
script.integrity = 'sha512-5LSZkoyayM01bXhnlp2T6+RLFc+dE4SIZofQMxy/ydOs3D35mgQYf6THIQrwIMmgoyjI+bqjuuj4fQcGLyJFYg==';
|
|
366
|
+
script.referrerPolicy = 'no-referrer';
|
|
367
|
+
script.crossOrigin = 'anonymous';
|
|
368
|
+
// 当脚本加载完成后执行回调函数
|
|
369
|
+
document.head.appendChild(script);
|
|
370
|
+
glitter.addMtScript(
|
|
371
|
+
['https://oss-sg.imin.sg/web/iMinPartner/js/imin-printer.min.js', 'https://cdn.jsdelivr.net/npm/jsbarcode@3.11.5/dist/JsBarcode.all.min.js'],
|
|
372
|
+
() => {},
|
|
373
|
+
() => {}
|
|
374
|
+
);
|
|
375
|
+
setTimeout(() => {
|
|
376
|
+
//@ts-ignore
|
|
377
|
+
window.IminPrintInstance = new IminPrinter();
|
|
378
|
+
//@ts-ignore
|
|
379
|
+
window.IminPrintInstance.connect();
|
|
380
|
+
}, 3000);
|
|
381
|
+
}
|
|
382
|
+
});
|
|
356
383
|
running().then(async () => {
|
|
357
384
|
{
|
|
358
385
|
console.log(`to-page-time:`, (window as any).renderClock.stop());
|
|
@@ -159,23 +159,6 @@ height: 51px;
|
|
|
159
159
|
}
|
|
160
160
|
static main(gvc) {
|
|
161
161
|
const glitter = gvc.glitter;
|
|
162
|
-
gvc.glitter.runJsInterFace('pos-device', {}, (res) => {
|
|
163
|
-
PayConfig.deviceType = res.deviceType === 'neostra' ? 'pos' : 'web';
|
|
164
|
-
if (PayConfig.deviceType === 'pos') {
|
|
165
|
-
const script = document.createElement('script');
|
|
166
|
-
script.type = 'text/javascript';
|
|
167
|
-
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/mui/3.7.1/js/mui.min.js';
|
|
168
|
-
script.integrity = 'sha512-5LSZkoyayM01bXhnlp2T6+RLFc+dE4SIZofQMxy/ydOs3D35mgQYf6THIQrwIMmgoyjI+bqjuuj4fQcGLyJFYg==';
|
|
169
|
-
script.referrerPolicy = 'no-referrer';
|
|
170
|
-
script.crossOrigin = 'anonymous';
|
|
171
|
-
document.head.appendChild(script);
|
|
172
|
-
glitter.addMtScript(['https://oss-sg.imin.sg/web/iMinPartner/js/imin-printer.min.js', 'https://cdn.jsdelivr.net/npm/jsbarcode@3.11.5/dist/JsBarcode.all.min.js'], () => { }, () => { });
|
|
173
|
-
setTimeout(() => {
|
|
174
|
-
window.IminPrintInstance = new IminPrinter();
|
|
175
|
-
window.IminPrintInstance.connect();
|
|
176
|
-
}, 3000);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
162
|
gvc.addStyle(`
|
|
180
163
|
.dialog-box {
|
|
181
164
|
width: 100vw;
|
|
@@ -189,32 +189,7 @@ height: 51px;
|
|
|
189
189
|
public static main(gvc: GVC) {
|
|
190
190
|
const glitter = gvc.glitter;
|
|
191
191
|
// https://unpkg.com/html5-qrcode/minified/html5-qrcode.min.js
|
|
192
|
-
|
|
193
|
-
gvc.glitter.runJsInterFace('pos-device', {}, (res) => {
|
|
194
|
-
PayConfig.deviceType = res.deviceType === 'neostra' ? 'pos' : 'web';
|
|
195
|
-
//POS機台啟用列印功能
|
|
196
|
-
if (PayConfig.deviceType === 'pos') {
|
|
197
|
-
const script = document.createElement('script');
|
|
198
|
-
script.type = 'text/javascript';
|
|
199
|
-
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/mui/3.7.1/js/mui.min.js';
|
|
200
|
-
script.integrity = 'sha512-5LSZkoyayM01bXhnlp2T6+RLFc+dE4SIZofQMxy/ydOs3D35mgQYf6THIQrwIMmgoyjI+bqjuuj4fQcGLyJFYg==';
|
|
201
|
-
script.referrerPolicy = 'no-referrer';
|
|
202
|
-
script.crossOrigin = 'anonymous';
|
|
203
|
-
// 当脚本加载完成后执行回调函数
|
|
204
|
-
document.head.appendChild(script);
|
|
205
|
-
glitter.addMtScript(
|
|
206
|
-
['https://oss-sg.imin.sg/web/iMinPartner/js/imin-printer.min.js', 'https://cdn.jsdelivr.net/npm/jsbarcode@3.11.5/dist/JsBarcode.all.min.js'],
|
|
207
|
-
() => {},
|
|
208
|
-
() => {}
|
|
209
|
-
);
|
|
210
|
-
setTimeout(() => {
|
|
211
|
-
//@ts-ignore
|
|
212
|
-
window.IminPrintInstance = new IminPrinter();
|
|
213
|
-
//@ts-ignore
|
|
214
|
-
window.IminPrintInstance.connect();
|
|
215
|
-
}, 3000);
|
|
216
|
-
}
|
|
217
|
-
});
|
|
192
|
+
|
|
218
193
|
gvc.addStyle(`
|
|
219
194
|
.dialog-box {
|
|
220
195
|
width: 100vw;
|
|
@@ -124,4 +124,24 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
|
|
|
124
124
|
}), 1000);
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
+
static printCode(code) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
const IminPrintInstance = window.IminPrintInstance;
|
|
130
|
+
function generateBarcodeBase64(barcodeString) {
|
|
131
|
+
const canvas = document.createElement("canvas");
|
|
132
|
+
JsBarcode(canvas, barcodeString, {
|
|
133
|
+
format: "CODE128",
|
|
134
|
+
lineColor: "#000000",
|
|
135
|
+
width: 2,
|
|
136
|
+
height: 50,
|
|
137
|
+
displayValue: false
|
|
138
|
+
});
|
|
139
|
+
const base64String = canvas.toDataURL("image/png");
|
|
140
|
+
console.log("Base64 Barcode:", base64String);
|
|
141
|
+
return base64String;
|
|
142
|
+
}
|
|
143
|
+
IminPrintInstance.printSingleBitmap(generateBarcodeBase64(code));
|
|
144
|
+
yield IminPrintInstance.printAndFeedPaper(20);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
127
147
|
}
|
|
@@ -138,4 +138,29 @@ ${tempDiv.querySelector('.invoice-detail-sum')!!.children[2].textContent!.replac
|
|
|
138
138
|
await IminPrintInstance.printAndFeedPaper(100)
|
|
139
139
|
},1000)
|
|
140
140
|
}
|
|
141
|
+
//列印QRCODE
|
|
142
|
+
public static async printCode(code:string){
|
|
143
|
+
const IminPrintInstance:any=(window as any).IminPrintInstance
|
|
144
|
+
function generateBarcodeBase64(barcodeString:any) {
|
|
145
|
+
const canvas = document.createElement("canvas");
|
|
146
|
+
|
|
147
|
+
// 使用 JsBarcode 將條碼字串渲染到 canvas
|
|
148
|
+
//@ts-ignore
|
|
149
|
+
JsBarcode(canvas, barcodeString, {
|
|
150
|
+
format: "CODE128", // 條碼格式,可根據需求更換
|
|
151
|
+
lineColor: "#000000", // 條碼顏色
|
|
152
|
+
width: 2, // 條碼寬度
|
|
153
|
+
height: 50, // 條碼高度
|
|
154
|
+
displayValue: false // 是否顯示條碼值
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// 將 canvas 轉換為 base64 圖片
|
|
158
|
+
const base64String = canvas.toDataURL("image/png");
|
|
159
|
+
console.log("Base64 Barcode:", base64String);
|
|
160
|
+
|
|
161
|
+
return base64String;
|
|
162
|
+
}
|
|
163
|
+
IminPrintInstance.printSingleBitmap(generateBarcodeBase64(code))
|
|
164
|
+
await IminPrintInstance.printAndFeedPaper(20)
|
|
165
|
+
}
|
|
141
166
|
}
|
|
@@ -25,6 +25,8 @@ import { ProductConfig } from './product-config.js';
|
|
|
25
25
|
import { ShoppingSettingBasic } from "./shopping-setting-basic.js";
|
|
26
26
|
import { ShoppingSettingAdvance } from "./shopping-setting-advance.js";
|
|
27
27
|
import { ProductInitial } from "../public-models/product.js";
|
|
28
|
+
import { PayConfig } from "./pos-pages/pay-config.js";
|
|
29
|
+
import { IminModule } from "./pos-pages/imin-module.js";
|
|
28
30
|
const html = String.raw;
|
|
29
31
|
export class ShoppingProductSetting {
|
|
30
32
|
static main(gvc, type = 'product') {
|
|
@@ -1359,30 +1361,39 @@ export class ShoppingProductSetting {
|
|
|
1359
1361
|
<div class="title-container px-0">
|
|
1360
1362
|
<div style="color:#393939;font-weight: 700;">商品管理</div>
|
|
1361
1363
|
<div class="flex-fill"></div>
|
|
1362
|
-
${
|
|
1363
|
-
const
|
|
1364
|
-
if (
|
|
1365
|
-
|
|
1366
|
-
|
|
1364
|
+
${(() => {
|
|
1365
|
+
const ba = [];
|
|
1366
|
+
if (PayConfig.deviceType !== 'pos') {
|
|
1367
|
+
ba.push(BgWidget.grayButton('條碼列印', gvc.event(() => {
|
|
1368
|
+
IminModule.printCode(`variants-` + variant.barcode);
|
|
1369
|
+
}), { icon: `fa-solid fa-rectangle-barcode` }));
|
|
1367
1370
|
}
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1371
|
+
ba.push(BgWidget.grayButton('商品條碼', gvc.event(() => {
|
|
1372
|
+
const dialog = new ShareDialog(gvc.glitter);
|
|
1373
|
+
if (!variant.barcode) {
|
|
1374
|
+
dialog.errorMessage({ text: '請先設定商品條碼' });
|
|
1375
|
+
return;
|
|
1376
|
+
}
|
|
1377
|
+
window.parent.glitter.addMtScript([
|
|
1378
|
+
{
|
|
1379
|
+
src: 'https://cdn.jsdelivr.net/npm/qrcode/build/qrcode.min.js',
|
|
1380
|
+
},
|
|
1381
|
+
], () => {
|
|
1382
|
+
window.parent.QRCode.toDataURL(`variants-` + variant.barcode, {
|
|
1383
|
+
width: 200,
|
|
1384
|
+
margin: 2,
|
|
1385
|
+
}, function (err, url) {
|
|
1386
|
+
if (err) {
|
|
1387
|
+
console.error(err);
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
window.parent.glitter.openDiaLog(new URL('../dialog/image-preview.js', import.meta.url).href, 'preview', url);
|
|
1391
|
+
});
|
|
1392
|
+
}, () => {
|
|
1382
1393
|
});
|
|
1383
|
-
},
|
|
1384
|
-
|
|
1385
|
-
})
|
|
1394
|
+
}), { icon: `fa-regular fa-eye` }));
|
|
1395
|
+
return ba.join(`<div class="mx-2"></div>`);
|
|
1396
|
+
})()}
|
|
1386
1397
|
</div>
|
|
1387
1398
|
<div style="display: flex;width: 100%;height: 70px;flex-direction: column;justify-content: center;align-items: flex-start;gap: 8px;">
|
|
1388
1399
|
<div style="font-weight: 400;font-size: 16px;">存貨單位 (SKU)
|
|
@@ -16,6 +16,8 @@ import {ProductConfig} from './product-config.js';
|
|
|
16
16
|
import {ShoppingSettingBasic} from "./shopping-setting-basic.js";
|
|
17
17
|
import {ShoppingSettingAdvance} from "./shopping-setting-advance.js";
|
|
18
18
|
import {ActiveSchedule, Product, ProductInitial} from "../public-models/product.js";
|
|
19
|
+
import {PayConfig} from "./pos-pages/pay-config.js";
|
|
20
|
+
import {IminModule} from "./pos-pages/imin-module.js";
|
|
19
21
|
|
|
20
22
|
const html = String.raw;
|
|
21
23
|
|
|
@@ -1493,42 +1495,55 @@ export class ShoppingProductSetting {
|
|
|
1493
1495
|
<div class="title-container px-0">
|
|
1494
1496
|
<div style="color:#393939;font-weight: 700;">商品管理</div>
|
|
1495
1497
|
<div class="flex-fill"></div>
|
|
1496
|
-
${
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1498
|
+
${(()=>{
|
|
1499
|
+
const ba=[];
|
|
1500
|
+
if(PayConfig.deviceType !== 'pos'){
|
|
1501
|
+
ba.push(BgWidget.grayButton(
|
|
1502
|
+
'條碼列印',
|
|
1503
|
+
gvc.event(() => {
|
|
1504
|
+
IminModule.printCode(`variants-` + variant.barcode)
|
|
1505
|
+
}),
|
|
1506
|
+
{icon: `fa-solid fa-rectangle-barcode`}
|
|
1507
|
+
))
|
|
1508
|
+
}
|
|
1509
|
+
ba.push(BgWidget.grayButton(
|
|
1510
|
+
'商品條碼',
|
|
1511
|
+
gvc.event(() => {
|
|
1512
|
+
const dialog = new ShareDialog(gvc.glitter);
|
|
1513
|
+
if (!variant.barcode) {
|
|
1514
|
+
dialog.errorMessage({text: '請先設定商品條碼'});
|
|
1515
|
+
return;
|
|
1516
|
+
}
|
|
1517
|
+
(window.parent as any).glitter.addMtScript(
|
|
1518
|
+
[
|
|
1519
|
+
{
|
|
1520
|
+
src: 'https://cdn.jsdelivr.net/npm/qrcode/build/qrcode.min.js',
|
|
1521
|
+
},
|
|
1522
|
+
],
|
|
1523
|
+
() => {
|
|
1524
|
+
(window.parent as any).QRCode.toDataURL(
|
|
1525
|
+
`variants-` + variant.barcode,
|
|
1526
|
+
{
|
|
1527
|
+
width: 200,
|
|
1528
|
+
margin: 2,
|
|
1529
|
+
},
|
|
1530
|
+
function (err: any, url: any) {
|
|
1531
|
+
if (err) {
|
|
1532
|
+
console.error(err);
|
|
1533
|
+
return;
|
|
1534
|
+
}
|
|
1535
|
+
(window.parent as any).glitter.openDiaLog(new URL('../dialog/image-preview.js', import.meta.url).href, 'preview', url);
|
|
1521
1536
|
}
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
)
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
)}
|
|
1537
|
+
);
|
|
1538
|
+
},
|
|
1539
|
+
() => {
|
|
1540
|
+
}
|
|
1541
|
+
);
|
|
1542
|
+
}),
|
|
1543
|
+
{icon: `fa-regular fa-eye`}
|
|
1544
|
+
))
|
|
1545
|
+
return ba.join(`<div class="mx-2"></div>`)
|
|
1546
|
+
})()}
|
|
1532
1547
|
</div>
|
|
1533
1548
|
<div style="display: flex;width: 100%;height: 70px;flex-direction: column;justify-content: center;align-items: flex-start;gap: 8px;">
|
|
1534
1549
|
<div style="font-weight: 400;font-size: 16px;">存貨單位 (SKU)
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ class FbApi {
|
|
|
19
19
|
user_id: 'manager'
|
|
20
20
|
});
|
|
21
21
|
return {
|
|
22
|
-
link: `https://graph.facebook.com/v22.0/${cf.pixel}/events
|
|
22
|
+
link: `https://graph.facebook.com/v22.0/${cf.pixel}/events`.trim(),
|
|
23
23
|
api_token: cf.api_token
|
|
24
24
|
};
|
|
25
25
|
}
|
|
@@ -76,6 +76,9 @@ class FbApi {
|
|
|
76
76
|
var _a;
|
|
77
77
|
try {
|
|
78
78
|
const cf = await this.config();
|
|
79
|
+
console.log(`cf.link=>`, this.app_name);
|
|
80
|
+
console.log(`cf.link=>`, cf.link);
|
|
81
|
+
console.log(`cf.api_token=>`, cf.api_token);
|
|
79
82
|
if (cf.link && cf.api_token) {
|
|
80
83
|
data.user_data = {
|
|
81
84
|
"client_ip_address": (req.query.ip || req.headers['x-real-ip'] || req.ip),
|
|
@@ -84,7 +87,7 @@ class FbApi {
|
|
|
84
87
|
};
|
|
85
88
|
if (this.token) {
|
|
86
89
|
const dd = (await new user_js_1.User(this.app_name).getUserData(this.token.userID, 'userID'));
|
|
87
|
-
if (dd.userData) {
|
|
90
|
+
if (dd && dd.userData) {
|
|
88
91
|
const email = dd.userData.email;
|
|
89
92
|
const phone = dd.userData.phone;
|
|
90
93
|
email && (data.user_data.email = [tool_js_1.default.hashSHA256(email)]);
|
|
@@ -92,14 +95,12 @@ class FbApi {
|
|
|
92
95
|
}
|
|
93
96
|
}
|
|
94
97
|
data.event_time = (new Date().getTime() / 1000).toFixed(0);
|
|
95
|
-
data.action_source = 'website';
|
|
96
|
-
console.log(data);
|
|
97
98
|
return await new Promise(async (resolve, reject) => {
|
|
98
99
|
try {
|
|
99
100
|
axios_1.default
|
|
100
101
|
.post(cf.link, JSON.stringify({
|
|
101
102
|
data: [data],
|
|
102
|
-
access_token: cf.api_token
|
|
103
|
+
access_token: cf.api_token,
|
|
103
104
|
}), {
|
|
104
105
|
headers: {
|
|
105
106
|
'Content-Type': 'application/json',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fb-api.js","sourceRoot":"","sources":["fb-api.ts"],"names":[],"mappings":";;;;;;AACA,uCAA+B;AAC/B,kDAA0B;AAE1B,qEAA0C;AAG1C,8EAAmD;AAEnD,MAAa,KAAK;IAId,YAAY,QAAgB,EAAC,KAAa;QACtC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,KAAK,GAAC,KAAK,CAAA;IACpB,CAAC;IAEM,KAAK,CAAC,MAAM;
|
|
1
|
+
{"version":3,"file":"fb-api.js","sourceRoot":"","sources":["fb-api.ts"],"names":[],"mappings":";;;;;;AACA,uCAA+B;AAC/B,kDAA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@ -17,12 +17,13 @@ export class FbApi {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
public async config() {
|
|
20
|
+
|
|
20
21
|
const cf = await new User(this.app_name).getConfigV2({
|
|
21
22
|
key: 'login_fb_setting',
|
|
22
23
|
user_id: 'manager'
|
|
23
24
|
})
|
|
24
25
|
return {
|
|
25
|
-
link: `https://graph.facebook.com/v22.0/${cf.pixel}/events
|
|
26
|
+
link: `https://graph.facebook.com/v22.0/${cf.pixel}/events`.trim(),
|
|
26
27
|
api_token: cf.api_token
|
|
27
28
|
}
|
|
28
29
|
}
|
|
@@ -82,33 +83,34 @@ export class FbApi {
|
|
|
82
83
|
public async post(data: any,req:express.Request) {
|
|
83
84
|
try {
|
|
84
85
|
const cf = await this.config();
|
|
86
|
+
console.log(`cf.link=>`,this.app_name)
|
|
87
|
+
console.log(`cf.link=>`,cf.link)
|
|
88
|
+
console.log(`cf.api_token=>`,cf.api_token)
|
|
85
89
|
if (cf.link && cf.api_token) {
|
|
86
|
-
|
|
87
90
|
data.user_data={
|
|
88
91
|
"client_ip_address": (req.query.ip || req.headers['x-real-ip'] || req.ip) as string,
|
|
89
92
|
"fbc": req.cookies._fbc,
|
|
90
93
|
"fbp": req.cookies._fbp
|
|
91
94
|
}
|
|
92
|
-
|
|
93
95
|
if(this.token){
|
|
94
96
|
const dd=(await new User(this.app_name).getUserData(this.token.userID as any, 'userID'))
|
|
95
|
-
if(dd.userData){
|
|
97
|
+
if(dd && dd.userData){
|
|
96
98
|
const email=dd.userData.email;
|
|
97
99
|
const phone=dd.userData.phone;
|
|
98
100
|
email && (data.user_data.email=[tool.hashSHA256(email)])
|
|
99
101
|
phone && (data.user_data.ph=[tool.hashSHA256(phone)])
|
|
100
102
|
}
|
|
101
|
-
|
|
102
103
|
}
|
|
103
104
|
data.event_time=(new Date().getTime() / 1000).toFixed(0);
|
|
104
|
-
data.action_source='website'
|
|
105
|
-
|
|
105
|
+
// data.action_source='website'
|
|
106
|
+
// data.test_event_code='TEST82445'
|
|
107
|
+
// console.log(data)
|
|
106
108
|
return await new Promise<boolean>(async (resolve, reject) => {
|
|
107
109
|
try {
|
|
108
110
|
axios
|
|
109
111
|
.post(cf.link, JSON.stringify({
|
|
110
112
|
data: [data],
|
|
111
|
-
access_token: cf.api_token
|
|
113
|
+
access_token: cf.api_token,
|
|
112
114
|
}), {
|
|
113
115
|
headers: {
|
|
114
116
|
'Content-Type': 'application/json',
|