ts-glitter 21.5.3 → 21.5.5

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.
Files changed (79) hide show
  1. package/lowcode/Entry.js +1 -1
  2. package/lowcode/Entry.ts +1 -1
  3. package/lowcode/cms-plugin/account-info.js +79 -67
  4. package/lowcode/cms-plugin/account-info.ts +327 -311
  5. package/lowcode/cms-plugin/information/information-module.ts +3 -1
  6. package/lowcode/cms-plugin/list-header-option.js +1 -0
  7. package/lowcode/cms-plugin/list-header-option.ts +1 -0
  8. package/lowcode/cms-plugin/shopping-information.js +468 -0
  9. package/lowcode/cms-plugin/shopping-information.ts +557 -0
  10. package/lowcode/cms-plugin/shopping-market-shopee.js +283 -231
  11. package/lowcode/cms-plugin/shopping-market-shopee.ts +401 -361
  12. package/lowcode/cms-plugin/shopping-order-manager.js +16 -4
  13. package/lowcode/cms-plugin/shopping-order-manager.ts +18 -3
  14. package/lowcode/glitter-base/global/language.js +4 -1
  15. package/lowcode/glitter-base/global/language.ts +4 -2
  16. package/lowcode/glitter-base/route/shopee.js +48 -11
  17. package/lowcode/glitter-base/route/shopee.ts +119 -80
  18. package/lowcode/glitterBundle/plugins/html-render.js +121 -90
  19. package/lowcode/glitterBundle/plugins/html-render.ts +367 -318
  20. package/lowcode/modules/image-library.js +2 -3
  21. package/lowcode/modules/image-library.ts +21 -7
  22. package/lowcode/public-components/checkout/index.js +90 -41
  23. package/lowcode/public-components/checkout/index.ts +101 -49
  24. package/lowcode/public-components/footer/footer-initial.js +11 -2
  25. package/lowcode/public-components/footer/footer-initial.ts +29 -18
  26. package/lowcode/public-components/headers/header-class.js +47 -35
  27. package/lowcode/public-components/headers/header-class.ts +54 -38
  28. package/lowcode/public-components/layout-plugin/social-links-01.js +122 -3
  29. package/lowcode/public-components/layout-plugin/social-links-01.ts +135 -10
  30. package/lowcode/public-components/product/pd-card-01.js +23 -14
  31. package/lowcode/public-components/product/pd-card-01.ts +25 -14
  32. package/lowcode/public-components/product/pd-card-02.js +23 -16
  33. package/lowcode/public-components/product/pd-card-02.ts +25 -16
  34. package/lowcode/public-components/product/pd-card-03.js +25 -16
  35. package/lowcode/public-components/product/pd-card-03.ts +27 -16
  36. package/lowcode/public-components/terms-related/index.js +13 -2
  37. package/lowcode/public-components/terms-related/index.ts +15 -2
  38. package/lowcode/public-components/user-manager/um-class.js +490 -501
  39. package/lowcode/public-components/user-manager/um-class.ts +872 -882
  40. package/lowcode/public-components/user-manager/um-info.js +41 -40
  41. package/lowcode/public-components/user-manager/um-info.ts +54 -56
  42. package/lowcode/public-components/user-manager/um-login.js +10 -13
  43. package/lowcode/public-components/user-manager/um-login.ts +15 -23
  44. package/lowcode/public-components/user-manager/um-orderlist.js +60 -51
  45. package/lowcode/public-components/user-manager/um-orderlist.ts +289 -275
  46. package/lowcode/public-components/user-manager/um-rebate.js +104 -82
  47. package/lowcode/public-components/user-manager/um-rebate.ts +294 -267
  48. package/lowcode/public-components/user-manager/um-receive.js +582 -0
  49. package/lowcode/public-components/user-manager/um-receive.ts +599 -0
  50. package/lowcode/public-components/user-manager/um-wishlist.js +72 -68
  51. package/lowcode/public-components/user-manager/um-wishlist.ts +240 -230
  52. package/package.json +1 -1
  53. package/src/api-public/controllers/shopee.js +17 -0
  54. package/src/api-public/controllers/shopee.js.map +1 -1
  55. package/src/api-public/controllers/shopee.ts +32 -0
  56. package/src/api-public/services/monitor.d.ts +1 -0
  57. package/src/api-public/services/post.js +17 -7
  58. package/src/api-public/services/post.js.map +1 -1
  59. package/src/api-public/services/rebate.js +2 -11
  60. package/src/api-public/services/rebate.js.map +1 -1
  61. package/src/api-public/services/rebate.ts +5 -12
  62. package/src/api-public/services/shopee.d.ts +23 -2
  63. package/src/api-public/services/shopee.js +230 -111
  64. package/src/api-public/services/shopee.js.map +1 -1
  65. package/src/api-public/services/shopee.ts +1012 -838
  66. package/src/api-public/services/user.js +2 -2
  67. package/src/api-public/services/user.js.map +1 -1
  68. package/src/api-public/services/user.ts +3 -3
  69. package/src/index.js +17 -7
  70. package/src/index.js.map +1 -1
  71. package/src/modules/tool.d.ts +4 -4
  72. package/src/modules/tool.js +2 -1
  73. package/src/modules/tool.js.map +1 -1
  74. package/src/services/backend-service.js +17 -7
  75. package/src/services/backend-service.js.map +1 -1
  76. package/src/services/template.d.ts +1 -1
  77. package/src/services/template.js +24 -18
  78. package/src/services/template.js.map +1 -1
  79. 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 "../glitter-base/route/shopee.js";
6
- import {ApiPageConfig} from "../api/pageConfig.js";
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
- public static main(gvc: GVC) {
12
- const shopee = localStorage.getItem('shopeeCode');
13
- if (shopee) {
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
- function save_shopee(){
46
- ApiUser.setPublicConfig({
47
- key:'shopp_config',
48
- value:vm.config,
49
- user_id:'manager'
50
- })
51
- }
52
- Promise.all([ApiUser.getPublicConfig(key, 'manager'),ApiUser.getPublicConfig('shopp_config', 'manager')]).then((dd)=>{
53
- vm.loading = false;
54
- dd[0].response.value && (vm.data = dd[0].response.value);
55
- vm.config=dd[1].response.value;
56
- vm.config.auto_async= vm.config.auto_async ?? true;
57
- gvc.notifyDataChange(id);
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
- gvc.addStyle(css`
61
- .shopee-btn {
62
- background-color: #FB5533; /* 主橙色 */
63
- color: #FFFFFF; /* 白色文字 */
64
- border: none; /* 無邊框 */
65
- border-radius: 5px; /* 圓角按鍵 */
66
- padding: 10px 20px; /* 按鍵內邊距 */
67
- font-size: 16px; /* 文字大小 */
68
- font-weight: bold; /* 粗體文字 */
69
- cursor: pointer; /* 指針樣式 */
70
- transition: all 0.3s ease; /* 漸變效果 */
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
- .shopee-btn:hover {
74
- background-color: #D94428; /* 深橙色 */
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
- .shopee-btn:active {
78
- background-color: #C03D24; /* 更深的橙色 */
79
- }
80
- `)
81
- return {
82
- bind: id,
83
- view: () => {
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
- </div>
116
- <div>
117
- 為了啟用蝦皮相關服務,請點擊下方按鈕進行授權操作,蝦皮授權有效期限為30天,請定期前往此頁面刷新有效期限。
118
- </div>
119
- </div>
120
- <button class="shopee-btn mt-3" onclick="${gvc.event(() => {
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
- </button>
141
- `),
142
- BgWidget.mbContainer(18),
143
- BgWidget.mainCard(html`
144
- ${gvc.bindView(() => {
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
- .sync-header {
187
- font-size: 18px;
188
- font-weight: bold;
189
- color: #ee4d2d;
190
- margin-bottom: 20px;
191
- }
159
+ .sync-body {
160
+ margin-bottom: 20px;
161
+ }
192
162
 
193
- /* 輸入區域 */
194
- .sync-body {
195
- margin-bottom: 20px;
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
- .sync-body label {
199
- display: block;
200
- font-size: 14px;
201
- color: #333;
202
- margin-bottom: 5px;
203
- text-align: left;
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
- .sync-input {
207
- width: 100%;
208
- padding: 10px;
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
- .sync-input:focus {
219
- border-color: #ee4d2d;
220
- }
187
+ /* 按鈕樣式 */
221
188
 
222
- /* 按鈕樣式 */
223
- .sync-button {
224
- background-color: #ee4d2d;
225
- color: #fff;
226
- font-size: 16px;
227
- font-weight: bold;
228
- padding: 10px 20px;
229
- border: none;
230
- border-radius: 4px;
231
- cursor: pointer;
232
- transition: background-color 0.3s;
233
- width: 100%;
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
- .sync-button:hover {
237
- background-color: #d44123;
238
- }
202
+ .sync-button:hover {
203
+ background-color: #d44123;
204
+ }
239
205
 
240
- .sync-button:active {
241
- background-color: #b8341b;
242
- }
206
+ .sync-button:active {
207
+ background-color: #b8341b;
208
+ }
243
209
 
244
- /* 響應式樣式 */
245
- @media (max-width: 400px) {
246
- .shopee-sync {
247
- width: 90%;
248
- }
249
- } `)
250
- return html`
251
- <div id="date-sync"
252
- 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;">
253
- <i
254
- class="fa-regular fa-circle-xmark fs-5 text-dark cursor_pointer"
255
- style="position: absolute;right: 5px; top: 5px;"
256
- onclick="${gvc.event(() => {
257
- gvc.closeDialog();
258
- })}"
259
- ></i>
260
- <div class="sync-header">選擇同步商品的日期區間</div>
261
- <div class="sync-body">
262
- <label for="start-date">開始日期:</label>
263
- <input type="date" id="start-date" value="${startDate}"
264
- class="sync-input" onchange="${gvc.event((e: any) => {
265
- startDate = e.value
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
- <label for="end-date">結束日期:</label>
269
- <input type="date" id="end-date" value="${endDate}"
270
- class="sync-input" onchange="${gvc.event((e: any) => {
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
- if (new Date(startDate) > new Date(endDate)) {
273
- alert('開始日期不能晚於結束日期');
274
- return;
275
- }
276
- endDate = e.value
277
- })}"/>
278
- </div>
279
- <button id="confirm-btn" class="sync-button"
280
- onclick="${gvc.event(() => {
281
- const startTime = Math.floor(new Date(startDate).getTime() / 1000);
282
- const endTime = Math.floor(new Date(endDate).getTime() / 1000);
283
- ApiShopee.getItemList(startTime, endTime, (response: any) => {})
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
- </button>
296
- </div>
297
- `
298
- ].join('')
299
- },
300
- divCreate: {
301
- class: `d-flex flex-column`, style: 'gap:8px;'
302
- },onCreate:()=>{
303
- ApiShopee.syncStatus().then((res)=>{
304
- loading=res.response.result
305
- if(gvc.glitter.share.shopee_interval){
306
- clearInterval(gvc.glitter.share.shopee_interval)
307
- }
308
- gvc.glitter.share.shopee_interval=setTimeout(()=>{
309
- gvc.notifyDataChange(id)
310
- },1000)
311
- })
312
- }
313
- }
314
- })}
315
- <button id="" class="shopee-btn mt-3 d-none"
316
- onclick="${gvc.event(() => {
317
- const dialog = new ShareDialog(gvc.glitter);
318
- dialog.dataLoading({
319
- visible: true
320
- })
321
- ApiShopee.syncProduct((res: any) => {
322
- dialog.dataLoading({
323
- visible: false
324
- })
325
- console.log("res -- ", res);
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
- </button>
331
- `),
332
- // BgWidget.mbContainer(18),
333
- // BgWidget.mainCard(html`
334
- // ${gvc.bindView(() => {
335
- // const id = gvc.glitter.getUUID()
336
- // return {
337
- // bind: id,
338
- // view: () => {
339
- // return [
340
- // html`
341
- // <div class="tx_700 d-flex flex-column">是否自動同步庫存
342
- // </div>
343
- // ${BgWidget.grayNote('啟用庫存同步功能,即會自動同步蝦皮庫存,避免商品超賣。')}
344
- // <div class="cursor_pointer form-check form-switch ms-0 ps-0"
345
- // style="">
346
- // <input
347
- // class="form-check-input m-0"
348
- // type="checkbox"
349
- // onchange="${gvc.event((e, event) => {
350
- // vm.config.auto_async=!vm.config.auto_async;
351
- // save_shopee()
352
- // })}"
353
- // ${vm.config.auto_async ? `checked`:``}
354
- // />
355
- // </div>
356
- // `
357
- // ].join('')
358
- // },
359
- // divCreate: {
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);