44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { defaultPrintConfig } from '../../config/config';
|
|
|
|
Page({
|
|
data: {
|
|
printConfig: defaultPrintConfig,
|
|
enableDebug: false,
|
|
},
|
|
|
|
onLoad() {
|
|
const printConfig = getApp().getPrintConfig() || defaultPrintConfig;
|
|
const enableDebug = wx.getStorageSync('enableDebug') || false;
|
|
this.setData({ printConfig, enableDebug });
|
|
},
|
|
|
|
onChangeHeader(e: WechatMiniprogram.CustomEvent) {
|
|
const header = e.detail.value as PrintHeader;
|
|
this.setData({ printConfig: { ...this.data.printConfig, header } });
|
|
},
|
|
|
|
onClickHeaderSetting(e: WechatMiniprogram.CustomEvent) {
|
|
const header = e.currentTarget.dataset.name as PrintHeader;
|
|
this.setData({ printConfig: { ...this.data.printConfig, header } });
|
|
},
|
|
|
|
onAppNameChange(e: WechatMiniprogram.CustomEvent) {
|
|
const appName = e.detail + '';
|
|
this.setData({ printConfig: { ...this.data.printConfig, appName } });
|
|
},
|
|
|
|
onConfirm() {
|
|
getApp().setPrintConfig(this.data.printConfig);
|
|
const enableDebug = this.data.enableDebug;
|
|
wx.setStorageSync('enableDebug', enableDebug);
|
|
wx.setEnableDebug({ enableDebug });
|
|
wx.navigateBack();
|
|
},
|
|
|
|
/** 真机调试线上包 */
|
|
toggleDebug() {
|
|
const enableDebug = !this.data.enableDebug;
|
|
this.setData({ enableDebug });
|
|
},
|
|
});
|