author Javen
 *  copyright description export class TemplateData { private touser : string ; private template_id : string ; private url : string ; private miniprogram : MiniProgram ; private data : Map < string , TemplateItem > ; public New ( ) { this . data = new Map < string , TemplateItem > ( ) ; this . miniprogram = new MiniProgram ( ) ; return this ; } public get getToUser ( ) : string { return this . touser ; } public setToUser ( touser ) { this . touser = touser ; return this ; } public get getTemplateId ( ) : string { return this . template_id ; } public setTemplateId ( templateId ) { this . template_id = templateId ; return this ; } public get getTemplateUrl ( ) : string { return this . url ; } public setTemplateUrl ( url ) { this . url = url ; return this ; } public get getMiniProgram ( ) : MiniProgram { return this . miniprogram ; } public setMiniProgram ( miniprogram ) { this . miniprogram = miniprogram ; return this ; } public add ( key , value , color ) { this . data . set ( key , new TemplateItem ( value , color ) ) ; return this ; } public build ( ) { let temp = { touser : this . touser , template_id : this . template_id , url : this . url , miniprogram : this . miniprogram , data : this . _mapToObj ( this . data ) } ; return JSON . stringify ( temp ) ; } _mapToObj ( map ) { let obj = Object . create ( null ) ; for ( let [ k , v ] of map ) { obj [ k ] = v ; } return obj ; } _objToMap ( obj ) { let strMap = new Map ( ) ; for ( let k of Object . keys ( obj ) ) { strMap . set ( k , obj [ k ] ) ; } return strMap ; } } export class MiniProgram { private appid : string ; private pagepath : string ; constructor ( appId ? , pagePath ? ) { this . appid = appId || '' ; this . pagepath = pagePath || '' ; } public get getAppId ( ) : string { return this . appid ; } public set setAppId ( appid ) { this . appid = appid ; } public get getPagePath ( ) : string { return this . pagepath ; } public set getPagePath ( pagepath ) { this . pagepath = pagepath ; } } export class TemplateItem { private value : string ; private color : string ; constructor ( value , color ) { this . value = value ; this . color = color ; } public get getValue ( ) : string { return this . value ; } public set setValue ( value ) { this . value = value ; } public get getColor ( ) : string { return this . color ; } public set setColor ( color ) { this . color = color ; } }