ts-glitter 21.5.3 → 21.5.4
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 +1 -1
- package/lowcode/Entry.ts +1 -1
- package/lowcode/cms-plugin/account-info.js +79 -67
- package/lowcode/cms-plugin/account-info.ts +327 -311
- package/lowcode/cms-plugin/information/information-module.ts +3 -1
- package/lowcode/cms-plugin/list-header-option.js +1 -0
- package/lowcode/cms-plugin/list-header-option.ts +1 -0
- package/lowcode/cms-plugin/shopping-information.js +468 -0
- package/lowcode/cms-plugin/shopping-information.ts +557 -0
- package/lowcode/cms-plugin/shopping-market-shopee.js +283 -231
- package/lowcode/cms-plugin/shopping-market-shopee.ts +401 -361
- package/lowcode/cms-plugin/shopping-order-manager.js +16 -4
- package/lowcode/cms-plugin/shopping-order-manager.ts +18 -3
- package/lowcode/glitter-base/global/language.js +4 -1
- package/lowcode/glitter-base/global/language.ts +4 -2
- package/lowcode/glitter-base/route/shopee.js +48 -11
- package/lowcode/glitter-base/route/shopee.ts +119 -80
- package/lowcode/glitterBundle/plugins/html-render.js +121 -90
- package/lowcode/glitterBundle/plugins/html-render.ts +367 -318
- package/lowcode/modules/image-library.js +2 -3
- package/lowcode/modules/image-library.ts +21 -7
- package/lowcode/public-components/checkout/index.js +90 -41
- package/lowcode/public-components/checkout/index.ts +101 -49
- package/lowcode/public-components/footer/footer-initial.js +11 -2
- package/lowcode/public-components/footer/footer-initial.ts +29 -18
- package/lowcode/public-components/headers/header-class.js +47 -35
- package/lowcode/public-components/headers/header-class.ts +54 -38
- package/lowcode/public-components/layout-plugin/social-links-01.js +122 -3
- package/lowcode/public-components/layout-plugin/social-links-01.ts +135 -10
- package/lowcode/public-components/product/pd-card-01.js +23 -14
- package/lowcode/public-components/product/pd-card-01.ts +25 -14
- package/lowcode/public-components/product/pd-card-02.js +23 -16
- package/lowcode/public-components/product/pd-card-02.ts +25 -16
- package/lowcode/public-components/product/pd-card-03.js +25 -16
- package/lowcode/public-components/product/pd-card-03.ts +27 -16
- package/lowcode/public-components/terms-related/index.js +13 -2
- package/lowcode/public-components/terms-related/index.ts +15 -2
- package/lowcode/public-components/user-manager/um-class.js +490 -501
- package/lowcode/public-components/user-manager/um-class.ts +872 -882
- package/lowcode/public-components/user-manager/um-info.js +41 -40
- package/lowcode/public-components/user-manager/um-info.ts +54 -56
- package/lowcode/public-components/user-manager/um-login.js +10 -13
- package/lowcode/public-components/user-manager/um-login.ts +15 -23
- package/lowcode/public-components/user-manager/um-orderlist.js +60 -51
- package/lowcode/public-components/user-manager/um-orderlist.ts +289 -275
- package/lowcode/public-components/user-manager/um-rebate.js +104 -82
- package/lowcode/public-components/user-manager/um-rebate.ts +294 -267
- package/lowcode/public-components/user-manager/um-receive.js +582 -0
- package/lowcode/public-components/user-manager/um-receive.ts +599 -0
- package/lowcode/public-components/user-manager/um-wishlist.js +72 -68
- package/lowcode/public-components/user-manager/um-wishlist.ts +240 -230
- package/package.json +1 -1
- package/src/api-public/controllers/shopee.js +17 -0
- package/src/api-public/controllers/shopee.js.map +1 -1
- package/src/api-public/controllers/shopee.ts +32 -0
- package/src/api-public/services/monitor.d.ts +1 -0
- package/src/api-public/services/post.js +17 -7
- package/src/api-public/services/post.js.map +1 -1
- package/src/api-public/services/rebate.js +2 -11
- package/src/api-public/services/rebate.js.map +1 -1
- package/src/api-public/services/rebate.ts +5 -12
- package/src/api-public/services/shopee.d.ts +23 -2
- package/src/api-public/services/shopee.js +230 -111
- package/src/api-public/services/shopee.js.map +1 -1
- package/src/api-public/services/shopee.ts +1012 -838
- package/src/api-public/services/user.js +2 -2
- package/src/api-public/services/user.js.map +1 -1
- package/src/api-public/services/user.ts +3 -3
- package/src/index.js +17 -7
- package/src/index.js.map +1 -1
- package/src/modules/tool.d.ts +4 -4
- package/src/modules/tool.js +2 -1
- package/src/modules/tool.js.map +1 -1
- package/src/services/backend-service.js +17 -7
- package/src/services/backend-service.js.map +1 -1
- package/src/services/template.d.ts +1 -1
- package/src/services/template.js +24 -18
- package/src/services/template.js.map +1 -1
- package/src/services/template.ts +34 -37
|
@@ -1,390 +1,430 @@
|
|
|
1
|
-
import {GVC} from '../glitterBundle/GVController.js';
|
|
2
|
-
import {BgWidget} from '../backend-manager/bg-widget.js';
|
|
3
|
-
import {ApiUser} from '../glitter-base/route/user.js';
|
|
4
|
-
import {ShareDialog} from '../glitterBundle/dialog/ShareDialog.js';
|
|
5
|
-
import {ApiShopee} from
|
|
6
|
-
import {ApiPageConfig} from
|
|
1
|
+
import { GVC } from '../glitterBundle/GVController.js';
|
|
2
|
+
import { BgWidget } from '../backend-manager/bg-widget.js';
|
|
3
|
+
import { ApiUser } from '../glitter-base/route/user.js';
|
|
4
|
+
import { ShareDialog } from '../glitterBundle/dialog/ShareDialog.js';
|
|
5
|
+
import { ApiShopee } from '../glitter-base/route/shopee.js';
|
|
6
|
+
import { ApiPageConfig } from '../api/pageConfig.js';
|
|
7
|
+
import { response } from 'express';
|
|
7
8
|
|
|
8
|
-
const css=String.raw
|
|
9
|
+
const css = String.raw;
|
|
10
|
+
|
|
11
|
+
interface IShopeeBlock {
|
|
12
|
+
btnText: string;
|
|
13
|
+
url: string;
|
|
14
|
+
title: string;
|
|
15
|
+
subTitle: string;
|
|
16
|
+
click: (blockID: string) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//todo 這邊需要一個開關是 讓客戶決定有沒需要讓shopnex主動同步shopee
|
|
9
20
|
export class MarketShopee {
|
|
21
|
+
public static main(gvc: GVC) {
|
|
22
|
+
const html = String.raw;
|
|
23
|
+
const shopee = localStorage.getItem('shopeeCode');
|
|
24
|
+
const id = gvc.glitter.getUUID();
|
|
25
|
+
let loading = false;
|
|
26
|
+
let first = true;
|
|
10
27
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const data: {
|
|
15
|
-
code: string,
|
|
16
|
-
shop_id: number
|
|
17
|
-
} = JSON.parse(shopee)
|
|
18
|
-
ApiShopee.getToken(data.code, data.shop_id);
|
|
19
|
-
localStorage.removeItem('shopeeCode');
|
|
20
|
-
}
|
|
21
|
-
return (
|
|
22
|
-
BgWidget.container(
|
|
23
|
-
gvc.bindView(() => {
|
|
24
|
-
const id = gvc.glitter.getUUID();
|
|
25
|
-
const key = 'marketShopee';
|
|
26
|
-
const vm: {
|
|
27
|
-
loading: boolean;
|
|
28
|
-
data: {
|
|
29
|
-
offer_ID: string,
|
|
30
|
-
advertiser_ID: string,
|
|
31
|
-
commission: string,
|
|
32
|
-
};
|
|
33
|
-
config:any
|
|
34
|
-
} = {
|
|
35
|
-
loading: true,
|
|
36
|
-
data: {
|
|
37
|
-
offer_ID: '',
|
|
38
|
-
advertiser_ID: '',
|
|
39
|
-
commission: '',
|
|
40
|
-
},
|
|
41
|
-
config:{}
|
|
42
|
-
};
|
|
43
|
-
const html = String.raw;
|
|
28
|
+
function reload(id: String) {
|
|
29
|
+
gvc.notifyDataChange(id);
|
|
30
|
+
}
|
|
44
31
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
32
|
+
//
|
|
33
|
+
function showShopeeBlock(blockData: IShopeeBlock) {
|
|
34
|
+
const blockID = gvc.glitter.getUUID();
|
|
35
|
+
return BgWidget.mainCard(html`
|
|
36
|
+
${gvc.bindView(() => {
|
|
37
|
+
return {
|
|
38
|
+
bind: blockID,
|
|
39
|
+
view: async () => {
|
|
40
|
+
if (first) {
|
|
41
|
+
let res = await ApiShopee.syncStatus();
|
|
42
|
+
loading = res.response.result;
|
|
43
|
+
first = false;
|
|
44
|
+
}
|
|
45
|
+
return [
|
|
46
|
+
html`
|
|
47
|
+
<div class="tx_700 d-flex flex-column">${blockData.title}</div>
|
|
48
|
+
${BgWidget.grayNote(blockData.subTitle)}
|
|
49
|
+
<div>
|
|
50
|
+
${loading
|
|
51
|
+
? BgWidget.grayButton(
|
|
52
|
+
html` <div class="d-flex align-items-center" style="gap:8px;">
|
|
53
|
+
<div class="spinner-border spinner" style="width:20px;height: 20px;"></div>
|
|
54
|
+
同步中請稍候...
|
|
55
|
+
</div>`,
|
|
56
|
+
gvc.event(() => {})
|
|
57
|
+
)
|
|
58
|
+
: ``}
|
|
59
|
+
<button
|
|
60
|
+
class="shopee-btn ${loading ? `d-none` : ``}"
|
|
61
|
+
onclick="${gvc.event(() => {
|
|
62
|
+
blockData.click(blockID);
|
|
63
|
+
})}"
|
|
64
|
+
>
|
|
65
|
+
${blockData.btnText}
|
|
66
|
+
</button>
|
|
67
|
+
</div>
|
|
68
|
+
`,
|
|
69
|
+
].join('');
|
|
70
|
+
},
|
|
71
|
+
divCreate: {
|
|
72
|
+
class: `d-flex flex-column`,
|
|
73
|
+
style: 'gap:8px;',
|
|
74
|
+
},
|
|
75
|
+
onCreate: () => {
|
|
76
|
+
ApiShopee.syncStatus().then(res => {
|
|
77
|
+
loading = res.response.result;
|
|
78
|
+
if (gvc.glitter.share.shopee_interval) {
|
|
79
|
+
clearInterval(gvc.glitter.share.shopee_interval);
|
|
80
|
+
}
|
|
81
|
+
gvc.glitter.share.shopee_interval = setTimeout(() => {
|
|
82
|
+
gvc.notifyDataChange(blockID);
|
|
83
|
+
}, 1000);
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
})}
|
|
88
|
+
`);
|
|
89
|
+
}
|
|
59
90
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
91
|
+
if (shopee) {
|
|
92
|
+
const data: {
|
|
93
|
+
code: string;
|
|
94
|
+
shop_id: number;
|
|
95
|
+
} = JSON.parse(shopee);
|
|
96
|
+
ApiShopee.getToken(data.code, data.shop_id);
|
|
97
|
+
localStorage.removeItem('shopeeCode');
|
|
98
|
+
}
|
|
99
|
+
return (
|
|
100
|
+
BgWidget.container(
|
|
101
|
+
gvc.bindView(() => {
|
|
102
|
+
const id = gvc.glitter.getUUID();
|
|
103
|
+
const key = 'marketShopee';
|
|
104
|
+
const vm: {
|
|
105
|
+
loading: boolean;
|
|
106
|
+
data: {
|
|
107
|
+
offer_ID: string;
|
|
108
|
+
advertiser_ID: string;
|
|
109
|
+
commission: string;
|
|
110
|
+
};
|
|
111
|
+
config: any;
|
|
112
|
+
} = {
|
|
113
|
+
loading: true,
|
|
114
|
+
data: {
|
|
115
|
+
offer_ID: '',
|
|
116
|
+
advertiser_ID: '',
|
|
117
|
+
commission: '',
|
|
118
|
+
},
|
|
119
|
+
config: {},
|
|
120
|
+
};
|
|
72
121
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
122
|
+
function save_shopee() {
|
|
123
|
+
ApiUser.setPublicConfig({
|
|
124
|
+
key: 'shopp_config',
|
|
125
|
+
value: vm.config,
|
|
126
|
+
user_id: 'manager',
|
|
127
|
+
});
|
|
128
|
+
}
|
|
76
129
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (vm.loading) {
|
|
85
|
-
return BgWidget.spinner();
|
|
86
|
-
}
|
|
87
|
-
const html = String.raw;
|
|
88
|
-
return [
|
|
89
|
-
html`
|
|
90
|
-
<div class="title-container">
|
|
91
|
-
${BgWidget.title('蝦皮串接與同步')}
|
|
92
|
-
<div class="flex-fill"></div>
|
|
93
|
-
</div>`,
|
|
94
|
-
BgWidget.mbContainer(18),
|
|
95
|
-
BgWidget.mainCard(html`
|
|
96
|
-
<div class="d-flex flex-column" style="gap:12px;">
|
|
97
|
-
<div class="tx_700 d-flex align-items-center" style="gap:5px;">當前商店授權狀態
|
|
98
|
-
${gvc.bindView(() => {
|
|
99
|
-
const id = gvc.glitter.getUUID()
|
|
100
|
-
return {
|
|
101
|
-
bind: id,
|
|
102
|
-
view: async () => {
|
|
103
|
-
const access_token = await ApiPageConfig.getPrivateConfig((window.parent as any).appName, 'shopee_access_token')
|
|
104
|
-
if (access_token.response.result[0] && access_token.response.result[0].value.access_token) {
|
|
105
|
-
let dead_line = new Date(access_token.response.result[0]['updated_at'])
|
|
106
|
-
dead_line.setTime(dead_line.getTime() + 30 * 3600 * 24 * 1000)
|
|
107
|
-
return BgWidget.infoInsignia(`已授權至 ${gvc.glitter.ut.dateFormat(dead_line, 'yyyy-MM-dd')}`)
|
|
108
|
-
} else {
|
|
109
|
-
return BgWidget.warningInsignia('尚未授權')
|
|
110
|
-
}
|
|
130
|
+
function drawDialog(callback: (startTime: string, endTime: string , gvc:GVC) => void) {
|
|
131
|
+
const today = new Date().toISOString().split('T')[0];
|
|
132
|
+
let startDate = today;
|
|
133
|
+
let endDate = today;
|
|
134
|
+
gvc.glitter.innerDialog((gvc: GVC) => {
|
|
135
|
+
gvc.addStyle(css`
|
|
136
|
+
/* 外部容器 */
|
|
111
137
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
localStorage.setItem("shopee", window.parent.location.href)
|
|
122
|
-
ApiShopee.generateAuth(window.parent.location.href);
|
|
123
|
-
})}">授權蝦皮
|
|
124
|
-
</button>
|
|
125
|
-
<button id="" class="shopee-btn mt-3 d-none"
|
|
126
|
-
onclick="${gvc.event(() => {
|
|
127
|
-
const dialog = new ShareDialog(gvc.glitter);
|
|
128
|
-
dialog.dataLoading({
|
|
129
|
-
visible: true
|
|
130
|
-
})
|
|
131
|
-
ApiShopee.syncProduct((res: any) => {
|
|
132
|
-
dialog.dataLoading({
|
|
133
|
-
visible: false
|
|
134
|
-
})
|
|
135
|
-
console.log("res -- ", res);
|
|
136
|
-
})
|
|
138
|
+
.shopee-sync {
|
|
139
|
+
background: #fff;
|
|
140
|
+
border: 1px solid #e0e0e0;
|
|
141
|
+
border-radius: 8px;
|
|
142
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
143
|
+
padding: 20px;
|
|
144
|
+
width: 300px;
|
|
145
|
+
text-align: center;
|
|
146
|
+
}
|
|
137
147
|
|
|
148
|
+
/* 標題樣式 */
|
|
138
149
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const id = gvc.glitter.getUUID()
|
|
146
|
-
let loading=false
|
|
147
|
-
let first=true
|
|
148
|
-
function reload(){
|
|
149
|
-
gvc.notifyDataChange(id)
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
bind: id,
|
|
153
|
-
view: async () => {
|
|
154
|
-
if(first){
|
|
155
|
-
loading=(await ApiShopee.syncStatus()).response.result;
|
|
156
|
-
first=false
|
|
157
|
-
}
|
|
158
|
-
return [
|
|
159
|
-
html`
|
|
160
|
-
<div class="tx_700 d-flex flex-column">匯入蝦皮商品
|
|
161
|
-
</div>
|
|
162
|
-
${BgWidget.grayNote('如要同步蝦皮商品庫存,請先匯入蝦皮商品。')}
|
|
163
|
-
<div>
|
|
164
|
-
${loading ? BgWidget.grayButton(`<div class="d-flex align-items-center" style="gap:8px;">
|
|
165
|
-
<div class="spinner-border spinner" style="width:20px;height: 20px;"></div>同步中請稍候...
|
|
166
|
-
</div>`,gvc.event(()=>{})):``}
|
|
167
|
-
<button class="shopee-btn ${loading ? `d-none`:``}" onclick="${gvc.event(() => {
|
|
168
|
-
const today = new Date().toISOString().split('T')[0];
|
|
169
|
-
let startDate = today;
|
|
170
|
-
let endDate = today;
|
|
171
|
-
gvc.glitter.innerDialog((gvc: GVC) => {
|
|
172
|
-
gvc.addStyle(html`
|
|
150
|
+
.sync-header {
|
|
151
|
+
font-size: 18px;
|
|
152
|
+
font-weight: bold;
|
|
153
|
+
color: #ee4d2d;
|
|
154
|
+
margin-bottom: 20px;
|
|
155
|
+
}
|
|
173
156
|
|
|
174
|
-
|
|
175
|
-
.shopee-sync {
|
|
176
|
-
background: #fff;
|
|
177
|
-
border: 1px solid #e0e0e0;
|
|
178
|
-
border-radius: 8px;
|
|
179
|
-
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
180
|
-
padding: 20px;
|
|
181
|
-
width: 300px;
|
|
182
|
-
text-align: center;
|
|
183
|
-
}
|
|
157
|
+
/* 輸入區域 */
|
|
184
158
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
font-weight: bold;
|
|
189
|
-
color: #ee4d2d;
|
|
190
|
-
margin-bottom: 20px;
|
|
191
|
-
}
|
|
159
|
+
.sync-body {
|
|
160
|
+
margin-bottom: 20px;
|
|
161
|
+
}
|
|
192
162
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
163
|
+
.sync-body label {
|
|
164
|
+
display: block;
|
|
165
|
+
font-size: 14px;
|
|
166
|
+
color: #333;
|
|
167
|
+
margin-bottom: 5px;
|
|
168
|
+
text-align: left;
|
|
169
|
+
}
|
|
197
170
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
171
|
+
.sync-input {
|
|
172
|
+
width: 100%;
|
|
173
|
+
padding: 10px;
|
|
174
|
+
font-size: 14px;
|
|
175
|
+
border: 1px solid #ddd;
|
|
176
|
+
border-radius: 4px;
|
|
177
|
+
margin-bottom: 15px;
|
|
178
|
+
box-sizing: border-box;
|
|
179
|
+
outline: none;
|
|
180
|
+
transition: border-color 0.3s;
|
|
181
|
+
}
|
|
205
182
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
font-size: 14px;
|
|
210
|
-
border: 1px solid #ddd;
|
|
211
|
-
border-radius: 4px;
|
|
212
|
-
margin-bottom: 15px;
|
|
213
|
-
box-sizing: border-box;
|
|
214
|
-
outline: none;
|
|
215
|
-
transition: border-color 0.3s;
|
|
216
|
-
}
|
|
183
|
+
.sync-input:focus {
|
|
184
|
+
border-color: #ee4d2d;
|
|
185
|
+
}
|
|
217
186
|
|
|
218
|
-
|
|
219
|
-
border-color: #ee4d2d;
|
|
220
|
-
}
|
|
187
|
+
/* 按鈕樣式 */
|
|
221
188
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}
|
|
189
|
+
.sync-button {
|
|
190
|
+
background-color: #ee4d2d;
|
|
191
|
+
color: #fff;
|
|
192
|
+
font-size: 16px;
|
|
193
|
+
font-weight: bold;
|
|
194
|
+
padding: 10px 20px;
|
|
195
|
+
border: none;
|
|
196
|
+
border-radius: 4px;
|
|
197
|
+
cursor: pointer;
|
|
198
|
+
transition: background-color 0.3s;
|
|
199
|
+
width: 100%;
|
|
200
|
+
}
|
|
235
201
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
202
|
+
.sync-button:hover {
|
|
203
|
+
background-color: #d44123;
|
|
204
|
+
}
|
|
239
205
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
206
|
+
.sync-button:active {
|
|
207
|
+
background-color: #b8341b;
|
|
208
|
+
}
|
|
243
209
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
210
|
+
/* 響應式樣式 */
|
|
211
|
+
@media (max-width: 400px) {
|
|
212
|
+
.shopee-sync {
|
|
213
|
+
width: 90%;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
`);
|
|
217
|
+
return html`
|
|
218
|
+
<div
|
|
219
|
+
id="date-sync"
|
|
220
|
+
style="position:relative;background: #fff;border: 1px solid #e0e0e0;border-radius: 8px;box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);padding: 20px;width: 300px;text-align: center;"
|
|
221
|
+
>
|
|
222
|
+
<i
|
|
223
|
+
class="fa-regular fa-circle-xmark fs-5 text-dark cursor_pointer"
|
|
224
|
+
style="position: absolute;right: 5px; top: 5px;"
|
|
225
|
+
onclick="${gvc.event(() => {
|
|
226
|
+
gvc.closeDialog();
|
|
227
|
+
})}"
|
|
228
|
+
></i>
|
|
229
|
+
<div class="sync-header">選擇同步商品的日期區間</div>
|
|
230
|
+
<div class="sync-body">
|
|
231
|
+
<label for="start-date">開始日期:</label>
|
|
232
|
+
<input
|
|
233
|
+
type="date"
|
|
234
|
+
id="start-date"
|
|
235
|
+
value="${startDate}"
|
|
236
|
+
class="sync-input"
|
|
237
|
+
onchange="${gvc.event((e: any) => {
|
|
238
|
+
startDate = e.value;
|
|
239
|
+
})}"
|
|
240
|
+
/>
|
|
241
|
+
<label for="end-date">結束日期:</label>
|
|
242
|
+
<input
|
|
243
|
+
type="date"
|
|
244
|
+
id="end-date"
|
|
245
|
+
value="${endDate}"
|
|
246
|
+
class="sync-input"
|
|
247
|
+
onchange="${gvc.event((e: any) => {
|
|
248
|
+
if (new Date(startDate) > new Date(endDate)) {
|
|
249
|
+
alert('開始日期不能晚於結束日期');
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
endDate = e.value;
|
|
253
|
+
})}"
|
|
254
|
+
/>
|
|
255
|
+
</div>
|
|
256
|
+
<button
|
|
257
|
+
id="confirm-btn"
|
|
258
|
+
class="sync-button"
|
|
259
|
+
onclick="${gvc.event(() => {
|
|
260
|
+
callback(startDate, endDate , gvc);
|
|
261
|
+
})}"
|
|
262
|
+
>
|
|
263
|
+
確定
|
|
264
|
+
</button>
|
|
265
|
+
</div>
|
|
266
|
+
`;
|
|
267
|
+
}, 'sync');
|
|
268
|
+
}
|
|
266
269
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
270
|
+
Promise.all([
|
|
271
|
+
ApiUser.getPublicConfig(key, 'manager'),
|
|
272
|
+
ApiUser.getPublicConfig('shopp_config', 'manager'),
|
|
273
|
+
]).then(dd => {
|
|
274
|
+
vm.loading = false;
|
|
275
|
+
dd[0].response.value && (vm.data = dd[0].response.value);
|
|
276
|
+
vm.config = dd[1].response.value;
|
|
277
|
+
vm.config.auto_async = vm.config.auto_async ?? true;
|
|
278
|
+
gvc.notifyDataChange(id);
|
|
279
|
+
});
|
|
271
280
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
gvc.closeDialog()
|
|
285
|
-
loading=true
|
|
286
|
-
reload()
|
|
287
|
-
})}">確定
|
|
288
|
-
</button>
|
|
289
|
-
</div>
|
|
290
|
-
`
|
|
291
|
-
}, 'sync')
|
|
281
|
+
gvc.addStyle(css`
|
|
282
|
+
.shopee-btn {
|
|
283
|
+
background-color: #fb5533; /* 主橙色 */
|
|
284
|
+
color: #ffffff; /* 白色文字 */
|
|
285
|
+
border: none; /* 無邊框 */
|
|
286
|
+
border-radius: 5px; /* 圓角按鍵 */
|
|
287
|
+
padding: 10px 20px; /* 按鍵內邊距 */
|
|
288
|
+
font-size: 16px; /* 文字大小 */
|
|
289
|
+
font-weight: bold; /* 粗體文字 */
|
|
290
|
+
cursor: pointer; /* 指針樣式 */
|
|
291
|
+
transition: all 0.3s ease; /* 漸變效果 */
|
|
292
|
+
}
|
|
292
293
|
|
|
294
|
+
.shopee-btn:hover {
|
|
295
|
+
background-color: #d94428; /* 深橙色 */
|
|
296
|
+
}
|
|
293
297
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
298
|
+
.shopee-btn:active {
|
|
299
|
+
background-color: #c03d24; /* 更深的橙色 */
|
|
300
|
+
}
|
|
301
|
+
`);
|
|
302
|
+
return {
|
|
303
|
+
bind: id,
|
|
304
|
+
view: () => {
|
|
305
|
+
if (vm.loading) {
|
|
306
|
+
return BgWidget.spinner();
|
|
307
|
+
}
|
|
308
|
+
const html = String.raw;
|
|
309
|
+
return [
|
|
310
|
+
html` <div class="title-container">
|
|
311
|
+
${BgWidget.title('蝦皮串接與同步')}
|
|
312
|
+
<div class="flex-fill"></div>
|
|
313
|
+
</div>`,
|
|
314
|
+
BgWidget.mbContainer(18),
|
|
315
|
+
BgWidget.mainCard(html`
|
|
316
|
+
<div class="d-flex flex-column" style="gap:12px;">
|
|
317
|
+
<div class="tx_700 d-flex align-items-center" style="gap:5px;">
|
|
318
|
+
當前商店授權狀態
|
|
319
|
+
${gvc.bindView(() => {
|
|
320
|
+
const id = gvc.glitter.getUUID();
|
|
321
|
+
return {
|
|
322
|
+
bind: id,
|
|
323
|
+
view: async () => {
|
|
324
|
+
const access_token = await ApiPageConfig.getPrivateConfig(
|
|
325
|
+
(window.parent as any).appName,
|
|
326
|
+
'shopee_access_token'
|
|
327
|
+
);
|
|
328
|
+
if (access_token.response.result[0] && access_token.response.result[0].value.access_token) {
|
|
329
|
+
let dead_line = new Date(access_token.response.result[0]['updated_at']);
|
|
330
|
+
dead_line.setTime(dead_line.getTime() + 30 * 3600 * 24 * 1000);
|
|
331
|
+
return BgWidget.infoInsignia(
|
|
332
|
+
`已授權至 ${gvc.glitter.ut.dateFormat(dead_line, 'yyyy-MM-dd')}`
|
|
333
|
+
);
|
|
334
|
+
} else {
|
|
335
|
+
return BgWidget.warningInsignia('尚未授權');
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
};
|
|
339
|
+
})}
|
|
340
|
+
</div>
|
|
341
|
+
<div>
|
|
342
|
+
為了啟用蝦皮相關服務,請點擊下方按鈕進行授權操作,蝦皮授權有效期限為30天,請定期前往此頁面刷新有效期限。
|
|
343
|
+
</div>
|
|
344
|
+
</div>
|
|
345
|
+
<button
|
|
346
|
+
class="shopee-btn mt-3"
|
|
347
|
+
onclick="${gvc.event(() => {
|
|
348
|
+
localStorage.setItem('shopee', window.parent.location.href);
|
|
349
|
+
ApiShopee.generateAuth(window.parent.location.href);
|
|
350
|
+
})}"
|
|
351
|
+
>
|
|
352
|
+
授權蝦皮
|
|
353
|
+
</button>
|
|
354
|
+
<button
|
|
355
|
+
class="shopee-btn mt-3"
|
|
356
|
+
onclick="${gvc.event(() => {
|
|
357
|
+
localStorage.setItem('shopee', window.parent.location.href);
|
|
358
|
+
ApiShopee.generateOrderAuth(window.parent.location.href);
|
|
359
|
+
})}"
|
|
360
|
+
>
|
|
361
|
+
授權蝦皮訂單同步
|
|
362
|
+
</button>
|
|
363
|
+
<button
|
|
364
|
+
id=""
|
|
365
|
+
class="shopee-btn mt-3 d-none"
|
|
366
|
+
onclick="${gvc.event(() => {
|
|
367
|
+
const dialog = new ShareDialog(gvc.glitter);
|
|
368
|
+
dialog.dataLoading({
|
|
369
|
+
visible: true,
|
|
370
|
+
});
|
|
371
|
+
ApiShopee.syncProduct((res: any) => {
|
|
372
|
+
dialog.dataLoading({
|
|
373
|
+
visible: false,
|
|
374
|
+
});
|
|
375
|
+
});
|
|
376
|
+
})}"
|
|
377
|
+
>
|
|
378
|
+
同步商品庫存
|
|
379
|
+
</button>
|
|
380
|
+
`),
|
|
381
|
+
BgWidget.mbContainer(18),
|
|
382
|
+
showShopeeBlock({
|
|
383
|
+
btnText: '匯入商品',
|
|
384
|
+
subTitle: '如要同步蝦皮商品庫存,請先匯入蝦皮商品。',
|
|
385
|
+
title: '匯入蝦皮商品',
|
|
386
|
+
url: '',
|
|
387
|
+
click: blockID => {
|
|
388
|
+
drawDialog((startDate,endDate ,gvcDialog)=>{
|
|
389
|
+
const startTime = Math.floor(new Date(startDate).getTime() / 1000);
|
|
390
|
+
const endTime = Math.floor(new Date(endDate).getTime() / 1000);
|
|
327
391
|
|
|
392
|
+
ApiShopee.getItemList(startTime, endTime, (response: any) => {
|
|
393
|
+
gvcDialog.closeDialog();
|
|
394
|
+
gvc.notifyDataChange(blockID);
|
|
395
|
+
});
|
|
328
396
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
// class: `d-flex flex-column`, style: 'gap:8px;'
|
|
361
|
-
// }
|
|
362
|
-
// }
|
|
363
|
-
// })}
|
|
364
|
-
// <button id="" class="shopee-btn mt-3 d-none"
|
|
365
|
-
// onclick="${gvc.event(() => {
|
|
366
|
-
// const dialog = new ShareDialog(gvc.glitter);
|
|
367
|
-
// dialog.dataLoading({
|
|
368
|
-
// visible: true
|
|
369
|
-
// })
|
|
370
|
-
// ApiShopee.syncProduct((res: any) => {
|
|
371
|
-
// dialog.dataLoading({
|
|
372
|
-
// visible: false
|
|
373
|
-
// })
|
|
374
|
-
// console.log("res -- ", res);
|
|
375
|
-
// })
|
|
376
|
-
//
|
|
377
|
-
//
|
|
378
|
-
// })}">同步商品庫存
|
|
379
|
-
// </button>
|
|
380
|
-
// `)
|
|
381
|
-
].join('');
|
|
382
|
-
},
|
|
383
|
-
};
|
|
384
|
-
})
|
|
385
|
-
) + BgWidget.mbContainer(120)
|
|
386
|
-
);
|
|
387
|
-
}
|
|
397
|
+
loading = true;
|
|
398
|
+
})
|
|
399
|
+
},
|
|
400
|
+
}),
|
|
401
|
+
// BgWidget.mbContainer(18),
|
|
402
|
+
// showShopeeBlock({
|
|
403
|
+
// btnText: '匯入訂單',
|
|
404
|
+
// subTitle: '如要同步蝦皮訂單,請先匯入定單。',
|
|
405
|
+
// title: '匯入蝦皮訂單',
|
|
406
|
+
// url: '',
|
|
407
|
+
// click: (blockID) => {
|
|
408
|
+
// drawDialog((startDate,endDate ,gvcDialog)=>{
|
|
409
|
+
// const startTime = Math.floor(new Date(startDate).getTime() / 1000);
|
|
410
|
+
// const endTime = Math.floor(new Date(endDate).getTime() / 1000);
|
|
411
|
+
//
|
|
412
|
+
// ApiShopee.getOrderList(startTime, endTime, (response: any) => {
|
|
413
|
+
// gvcDialog.closeDialog();
|
|
414
|
+
// gvc.notifyDataChange(blockID);
|
|
415
|
+
// });
|
|
416
|
+
//
|
|
417
|
+
// loading = true;
|
|
418
|
+
// })
|
|
419
|
+
// },
|
|
420
|
+
// }),
|
|
421
|
+
].join('');
|
|
422
|
+
},
|
|
423
|
+
};
|
|
424
|
+
})
|
|
425
|
+
) + BgWidget.mbContainer(120)
|
|
426
|
+
);
|
|
427
|
+
}
|
|
388
428
|
}
|
|
389
429
|
|
|
390
430
|
(window as any).glitter.setModule(import.meta.url, MarketShopee);
|