require(‘js_asset.js’);
var shenxinmengchong = {
name: ‘shenxinmengchong’,
editInfo: 0,
stressID: 0,
iDindex: 0,
suiJiImage: 0,
textLabel: 0,
amid:0,
amflag:false,
onDestory: function(event) { this.wfInfo.setFramesId(0); FontId = null; StringId = null; PicId = null; return 0; }, onEvent: function(event) { switch(event) { case WindowEvent.winPush: case WindowEvent.winSuspended: { this.wf_bg_task.suspend(); } break; case WindowEvent.winTop: case WindowEvent.winResume: case WindowEvent.winReenter: if(this.wfInfo.lcdStatus){ this.wf_bg_task.resume(); } case WindowEvent.minTimeout: case WindowEvent.secTimeout: case WindowEvent.winRepaint: case WindowEvent.timeChange: this.draw(); break; case WindowEvent.userData: { if (arguments.length == 2) { this.decodeUserData(arguments[1]); this.drawEditInfo(); } } break; } return 0; }, decodeUserData: function(bytes) { if(bytes.data.byteLength >= 16) { //初始化自定义信息 this.initEditInfo(bytes); } }, readUserData: function() { var bytes = new Object; var flag = 0; FileManager().readWfFile({ filePath:'../style_color.bin', success: function (res) { print('readFile data.bin success callback ' + res.data.byteLength); bytes = res; flag = 1; }, fail: function (code){ print('readFile data.bin fail callback, error code' + code); }, complete: function(){ print('readFile data.bin complete callback'); } }); if (flag > 0) { //初始化自定义信息 this.initEditInfo(bytes); } }, initEditInfo: function(bytes) { var value = new Uint8Array(bytes.data); //将数据转成uint8数组 if(bytes.data.byteLength >= 16) { this.editInfo.wfStyle = value[0]; this.editInfo.timeStyle = value[1]; this.editInfo.colorNum = (value[12]<<0)+(value[13]<<8)+(value[14]<<16)+(value[15]<<24); var colorNum = (bytes.data.byteLength - 16)/4; colorNum = colorNum << 0; //取整 if (colorNum > this.editInfo.colorNum) { colorNum = this.editInfo.colorNum; } if (colorNum > 20) { colorNum = 20; } this.editInfo.colorNum = colorNum; for (var i = 0;i < colorNum; i++) { this.editInfo.color[i] = (value[16+i*4+0]<<0)+(value[16+i*4+1]<<8)+(value[16+i*4+2]<<16)+(value[16+i*4+3]<<24); } } }, drawEditInfo: function() { this.drawTime(true); }, //时间样式 drawTime: function(refresh) { var timeStyle; if (this.editInfo.timeStyle == 1) { timeStyle = [ PicId.Picstyle_1_0, PicId.Picstyle_1_1, PicId.Picstyle_1_2, PicId.Picstyle_1_3, PicId.Picstyle_1_4, PicId.Picstyle_1_5, PicId.Picstyle_1_6, PicId.Picstyle_1_7, PicId.Picstyle_1_8, PicId.Picstyle_1_9, PicId.Picstyle_1_10 ]; } else if (this.editInfo.timeStyle == 2) { timeStyle = [ PicId.Picminute0, PicId.Picminute1, PicId.Picminute2, PicId.Picminute3, PicId.Picminute4, PicId.Picminute5, PicId.Picminute6, PicId.Picminute7, PicId.Picminute8, PicId.Picminute9, PicId.Picminute10 ]; } else if (this.editInfo.timeStyle == 3) { timeStyle = [ PicId.Picstyle_2_0, PicId.Picstyle_2_1, PicId.Picstyle_2_2, PicId.Picstyle_2_3, PicId.Picstyle_2_4, PicId.Picstyle_2_5, PicId.Picstyle_2_6, PicId.Picstyle_2_7, PicId.Picstyle_2_8, PicId.Picstyle_2_9 ]; } else { timeStyle = [ PicId.Picstyle_0_0, PicId.Picstyle_0_1, PicId.Picstyle_0_2, PicId.Picstyle_0_3, PicId.Picstyle_0_4, PicId.Picstyle_0_5, PicId.Picstyle_0_6, PicId.Picstyle_0_7, PicId.Picstyle_0_8, PicId.Picstyle_0_9, PicId.Picstyle_0_10 ]; } //显示时分数字 if ((WatchfaceUpdata.hour_num & this.wfInfo.updataFlag) || (refresh)) { var value = (this.wfInfo.hour / 10) << 0; this.hourHigh.setPic(timeStyle[value]); this.hourLow.setPic(timeStyle[this.wfInfo.hour % 10]); if (this.editInfo.timeStyle == 1) { this.hourHigh.setPivot(29, 225); this.hourHigh.setAngle(-330); this.hourHigh.x = 204; this.hourHigh.y = 8; this.hourLow.setPivot(29, 225); this.hourLow.setAngle(-140); this.hourLow.x = 204; this.hourLow.y = 8; this.maohao.setPic(PicId.Picstyle_1_10); this.maohao.setAngle(0); this.maohao.visible = true; this.maohao.x = 219; this.maohao.y = 8; } else if (this.editInfo.timeStyle == 2) { this.hourHigh.setPivot(49, 233); this.hourHigh.setAngle(-430); this.hourHigh.x = 184; this.hourHigh.y = 0; this.hourLow.setPivot(49, 233); this.hourLow.setAngle(-170); this.hourLow.x = 184; this.hourLow.y = 0; this.maohao.setPic(PicId.Picminute10); this.maohao.setAngle(0); this.maohao.visible = true; this.maohao.x = 221; this.maohao.y = 0; } else if (this.editInfo.timeStyle == 3) { this.hourHigh.setPivot(50, 225); this.hourHigh.setAngle(-390); this.hourHigh.x = 183; this.hourHigh.y = 8; this.hourLow.setPivot(50, 225); this.hourLow.setAngle(-130); this.hourLow.x = 183; this.hourLow.y = 8; this.maohao.visible = false; } else { this.hourHigh.setPivot(29, 225); this.hourHigh.setAngle(-330); this.hourHigh.x = 204; this.hourHigh.y = 8; this.hourLow.setPivot(29, 225); this.hourLow.setAngle(-140); this.hourLow.x = 204; this.hourLow.y = 8; this.maohao.setPic(PicId.Picstyle_0_10); this.maohao.visible = true; this.maohao.x = 219; this.maohao.y = 8; } } if ((WatchfaceUpdata.min_num & this.wfInfo.updataFlag) || (refresh)) { var value_min = (this.wfInfo.min / 10) << 0; this.minHigh.setPic(timeStyle[value_min]); this.minLow.setPic(timeStyle[this.wfInfo.min % 10]); if (this.editInfo.timeStyle == 1) { this.minHigh.setPivot(29, 225); this.minHigh.setAngle(140); this.minHigh.x = 204; this.minHigh.y = 8; this.minLow.setPivot(29, 225); this.minLow.setAngle(330); this.minLow.x = 204; this.minLow.y = 8; } else if (this.editInfo.timeStyle == 2) { this.minHigh.setPivot(49, 233); this.minHigh.setAngle(170); this.minHigh.x = 184; this.minHigh.y = 0; this.minLow.setPivot(49, 233); this.minLow.setAngle(430); this.minLow.x = 184; this.minLow.y = 0; } else if (this.editInfo.timeStyle == 3) { this.minHigh.setPivot(50, 225); this.minHigh.setAngle(130); this.minHigh.x = 183; this.minHigh.y = 8; this.minLow.setPivot(50, 225); this.minLow.setAngle(390); this.minLow.x = 183; this.minLow.y = 8; } else { this.minHigh.setPivot(29, 225); this.minHigh.setAngle(140); this.minHigh.x = 204; this.minHigh.y = 8; this.minLow.setPivot(29, 225); this.minLow.setAngle(330); this.minLow.x = 204; this.minLow.y = 8; } } }, // str 0暂无数据 1活力爆表 2轻松自在 3心平气和 4放松一下 5神采奕奕 6真的乏了 7摸个鱼吧 8吃点好的 9活力爆表 // 暂无数据0 放松一下 1 心平气和2 轻松自在3 活力爆表4 真的乏了5 神采奕奕6 摸个鱼吧7 吃点好的 8 Changebg: function() { this.amflag = false; this.iDindex = (this.iDindex + 1) / 2; switch(this.wfInfo.stressID){ case 0: case 4: case 9: this.amid = this.iDindex % 2 ? PicId.Picw_anim01_001 : PicId.Picw_anim02_001; break; case 3: this.amid = this.iDindex % 2 ? PicId.Picw_anim03_001 : PicId.Picw_anim04_001; break; case 2: this.amid = this.iDindex % 2 ? PicId.Picw_anim05_001 : PicId.Picw_anim06_001; break; case 1: this.amid = PicId.Picw_anim07_001; break; case 6: this.amid = PicId.Picw_anim08_001; break; case 5: this.amid = PicId.Picw_anim09_001; break; case 7: this.amid = PicId.Picw_anim10_001; break; case 8: this.amid = PicId.Picw_anim11_001; break; default: break; } this.wf_bg_task.resume(); }, wf_bg_am: function() { switch(this.wfInfo.stressID){ case 0: case 4: case 9: if ((this.amflag == false)|| (this.amid > 323)) { this.amflag = true; if (this.amid > 175) { this.amid = PicId.Picw_anim02_001; } else { this.amid = PicId.Picw_anim01_001; } this.wf_bg_task.suspend(); return; } break; case 3: if ((this.amflag == false)|| (this.amid > 572)) { this.amflag = true; if (this.amid > 437) { this.amid = PicId.Picw_anim04_001; } else { this.amid = PicId.Picw_anim03_001; } this.wf_bg_task.suspend(); return; } break; case 2: if ((this.amflag == false)|| (this.amid > 813)) { this.amflag = true; if (this.amid > 694) { this.amid = PicId.Picw_anim06_001; } else { this.amid = PicId.Picw_anim05_001; } this.wf_bg_task.suspend(); return; } break; case 1: if ((this.amflag == false) || (this.amid > 947)){ this.amflag = true; if (this.amid > 947) { this.amid = PicId.Picw_anim07_001; this.wf_bg_task.suspend(); return; } } break; case 6: if ((this.amflag == false) || (this.amid > 1085)){ this.amflag = true; if (this.amid > 1085) { this.amid = PicId.Picw_anim08_001; this.wf_bg_task.suspend(); return; } } break; case 5: if ((this.amflag == false) || (this.amid > 1222)){ this.amflag = true; if (this.amid > 1222) { this.amid = PicId.Picw_anim09_001; this.wf_bg_task.suspend(); return; } } break; case 7: if ((this.amflag == false) || (this.amid > 1362)){ this.amflag = true; if (this.amid > 1362) { this.amid = PicId.Picw_anim10_001; this.wf_bg_task.suspend(); return; } } break; case 8: if ((this.amflag == false) || (this.amid > 1494)){ this.amflag = true; if (this.amid > 1494) { this.amid = PicId.Picw_anim11_001; this.wf_bg_task.suspend(); return; } } break; default: break; } this.animBg.setPic(this.amid); this.wfInfo.setFramesId(this.amid); this.amid++; }, jumpToStep: function() { JumpApp(WatchfaceJump.RXApp, 0); //跳步数 }, jumpToCalorie: function() { JumpApp(WatchfaceJump.RXApp, 0); //跳活动消耗 }, jumpToAqi: function() { JumpApp(WatchfaceJump.RXApp, 5, 6); //跳到aqi }, jumpToUv: function() { JumpApp(WatchfaceJump.RXApp, 5, 5); //跳uv }, jumpToPm25: function() { JumpApp(WatchfaceJump.RXApp, 5, 8); //跳pm25 }, jumpToBaro: function() { JumpApp(WatchfaceJump.RXApp, 7); //跳气压 }, jumpToAltitude: function() { JumpApp(WatchfaceJump.RXApp, 6); //跳海拔 }, jumpToHumidity: function() { JumpApp(WatchfaceJump.RXApp, 5, 2); //跳湿度 }, jumpToTemperature: function() { JumpApp(WatchfaceJump.RXApp, 4); //跳气温 }, jumpToStress: function() { JumpApp(WatchfaceJump.RXApp, 8); //跳压力 }, jumpToNull: function() { }, draw_step_widget: function(index) { var numAngle; if ((this.wfInfo.stepTarget == 0) || (this.wfInfo.steps >= this.wfInfo.stepTarget)) { numAngle = 300; } else { numAngle = this.wfInfo.steps / this.wfInfo.stepTarget * 300 << 0; } if (numAngle == 0 && this.wfInfo.steps > 0) { numAngle = 1; } if (index == 0) { this.widgetArc[index].visible = true; this.widgetArc[index].setAngles(1650, 1950, true); this.widgetArc[index].setAngles(1650, 1950, false); this.widgetArc[index].setAngles(1650, 1650 + numAngle, true); this.widgetArc[index].setAngles(1650, 1650 + numAngle, false); if (true == this.wfInfo.screenLock) { this.widgetArcLabel[index].print("--"); } else { this.widgetArcLabel[index].print("%d", this.wfInfo.steps); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.Stringstep); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc1.visible = true; this.widgetBgDian1.visible = false; this.widgetDian.visible = false; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToStep, this); } else { this.widgetArc[index].visible = true; this.widgetArc[index].setAngles(3450, 3750, true); this.widgetArc[index].setAngles(3450, 3750, false); this.widgetArc[index].setAngles(3750 - numAngle, 3750, true); this.widgetArc[index].setAngles(3750 - numAngle, 3750, false); if (true == this.wfInfo.screenLock) { this.widgetArcLabel[index].print("--"); } else { this.widgetArcLabel[index].print("%d", this.wfInfo.steps); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.Stringstep); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc2.visible = true; this.widgetBgDian2.visible = false; this.widgetDian1.visible = false; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToStep, this); } }, draw_calorie_widget: function(index) { var numAngle; if ((this.wfInfo.calorieTarget == 0) || (this.wfInfo.calorie >= this.wfInfo.calorieTarget)) { numAngle = 300; } else { numAngle = this.wfInfo.calorie / this.wfInfo.calorieTarget * 300 << 0; } if (numAngle == 0 && this.wfInfo.calorie > 0) { numAngle = 1; } if (index == 0) { this.widgetArc[index].visible = true; this.widgetArc[index].setAngles(1650, 1950, true); this.widgetArc[index].setAngles(1650, 1950, false); this.widgetArc[index].setAngles(1650, 1650 + numAngle, true); this.widgetArc[index].setAngles(1650, 1650 + numAngle, false); if (true == this.wfInfo.screenLock) { this.widgetArcLabel[index].print("--"); } else { this.widgetArcLabel[index].print("%d", this.wfInfo.calorie); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.Stringcalorie); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc1.visible = true; this.widgetBgDian1.visible = false; this.widgetDian1.visible = false; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToCalorie, this); } else { this.widgetArc[index].visible = true; this.widgetArc[index].setAngles(3450, 3750, true); this.widgetArc[index].setAngles(3450, 3750, false); this.widgetArc[index].setAngles(3750-numAngle, 3750, true); this.widgetArc[index].setAngles(3750-numAngle, 3750, false); if (true == this.wfInfo.screenLock) { this.widgetArcLabel[index].print("--"); } else { this.widgetArcLabel[index].print("%d", this.wfInfo.calorie); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.Stringcalorie); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc2.visible = true; this.widgetBgDian2.visible = false; this.widgetDian1.visible = false; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToCalorie, this); } }, draw_battery_widget: function(index) { if (index == 0) { this.widgetArc[index].visible = true; this.widgetArc[index].setAngles(1650, 1950, true); this.widgetArc[index].setAngles(1650, 1950, false); this.widgetArc[index].setAngles(1650, 1650+(this.wfInfo.battery/100*300 << 0), true); this.widgetArc[index].setAngles(1650, 1650+(this.wfInfo.battery/100*300 << 0), false); this.widgetArcLabel[index].print("%d%%", this.wfInfo.battery); this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.Stringbattery); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc1.visible = true; this.widgetBgDian1.visible = false; this.widgetDian.visible = false; } else { this.widgetArc[index].visible = true; this.widgetArc[index].setAngles(3450, 3750, true); this.widgetArc[index].setAngles(3450, 3750, false); this.widgetArc[index].setAngles(3750-(this.wfInfo.battery/100*300 << 0), 3750, true); this.widgetArc[index].setAngles(3750-(this.wfInfo.battery/100*300 << 0), 3750, false); this.widgetArcLabel[index].print("%d%%", this.wfInfo.battery); this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.Stringbattery); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc2.visible = true; this.widgetBgDian2.visible = false; this.widgetDian1.visible = false; } }, draw_aqi_widget: function(index) { if (index == 0) { this.widgetArc[index].visible = false; if (this.wfInfo.aqi == 0xFFFF) { this.widgetDian.setAngle(2550); this.widgetArcLabel[index].print("--"); } else { this.widgetDian.setAngle(2550+(this.wfInfo.aqi/300*300 << 0)); this.widgetArcLabel[index].print("%d", this.wfInfo.aqi); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.StringAQI); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc1.visible = false; this.widgetBgDian1.visible = true; this.widgetDian.visible = true; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToAqi, this); } else { this.widgetArc[index].visible = false; if (this.wfInfo.aqi == 0xFFFF) { this.widgetDian1.setAngle(1050); this.widgetArcLabel[index].print("--"); } else { this.widgetDian1.setAngle(1050-(this.wfInfo.aqi/300*300 << 0)); this.widgetArcLabel[index].print("%d", this.wfInfo.aqi); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.StringAQI); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc2.visible = false; this.widgetBgDian2.visible = true; this.widgetDian1.visible = true; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToAqi, this); } }, draw_uv_widget: function(index) { if (index == 0) { this.widgetArc[index].visible = false; if (this.wfInfo.uvRay == 0xFFFF) { this.widgetDian.setAngle(2550+(this.wfInfo.uvRay)); this.widgetArcLabel[index].print("--"); } else { this.widgetDian.setAngle(2550+(this.wfInfo.uvRay/15*300 << 0)); this.widgetArcLabel[index].print("%d.0", this.wfInfo.uvRay); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.StringUV); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc1.visible = false; this.widgetBgDian1.visible = true; this.widgetDian.visible = true; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToUv, this); } else { this.widgetArc[index].visible = false; if (this.wfInfo.uvRay == 0xFFFF) { this.widgetDian1.setAngle(1050); this.widgetArcLabel[index].print("--"); } else { this.widgetDian1.setAngle(1050-(this.wfInfo.uvRay/15*300 << 0)); this.widgetArcLabel[index].print("%d.0", this.wfInfo.uvRay); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.StringUV); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc2.visible = false; this.widgetBgDian2.visible = true; this.widgetDian1.visible = true; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToUv, this); } }, draw_pm25_widget: function(index) { if (index == 0) { this.widgetArc[index].visible = false; if (this.wfInfo.pm25 == 0xFFFF) { this.widgetDian.setAngle(2550); this.widgetArcLabel[index].print("--"); } else { this.widgetDian.setAngle(2550+(this.wfInfo.pm25/300*300 << 0)); this.widgetArcLabel[index].print("%d", this.wfInfo.pm25); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.StringPM25); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc1.visible = false; this.widgetBgDian1.visible = true; this.widgetDian.visible = true; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToPm25, this); } else { this.widgetArc[index].visible = false; if (this.wfInfo.pm25 == 0xFFFF) { this.widgetDian1.setAngle(1050); this.widgetArcLabel[index].print("--"); } else { this.widgetDian1.setAngle(1050-(this.wfInfo.pm25/300*300 << 0)); this.widgetArcLabel[index].print("%d", this.wfInfo.pm25); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.StringPM25); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc2.visible = false; this.widgetBgDian2.visible = true; this.widgetDian1.visible = true; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToPm25, this); } }, draw_baro_widget: function(index) { if (index == 0) { this.widgetArc[index].visible = false; if (this.wfInfo.baro == 0xFFFF) { this.widgetDian.setAngle(2550); this.widgetArcLabel[index].print("--"); } else { this.widgetDian.setAngle(2550+(((this.wfInfo.baro - 300) / 800 * 300) << 0)); this.widgetArcLabel[index].print("%d", this.wfInfo.baro); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.Stringbaro); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc1.visible = false; this.widgetBgDian1.visible = true; this.widgetDian.visible = true; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToBaro, this); } else { this.widgetArc[index].visible = false; if (this.wfInfo.baro == 0xFFFF) { this.widgetDian1.setAngle(1050); this.widgetArcLabel[index].print("--"); } else { this.widgetDian1.setAngle(1050-(((this.wfInfo.baro - 300) / 800 * 300) << 0)); this.widgetArcLabel[index].print("%d", this.wfInfo.baro); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.Stringbaro); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc2.visible = false; this.widgetBgDian2.visible = true; this.widgetDian1.visible = true; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToBaro, this); } }, draw_altitude_widget: function(index) { if (index == 0) { this.widgetArc[index].visible = false; if (this.wfInfo.altitude == 0xFFFF) { this.widgetDian.setAngle(2550); this.widgetArcLabel[index].print("--"); } else { this.widgetDian.setAngle(2550+((this.wfInfo.altitude + 800)/9600*300 << 0)); this.widgetArcLabel[index].print("%d", this.wfInfo.altitude); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.Stringaltitude); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc1.visible = false; this.widgetBgDian1.visible = true; this.widgetDian.visible = true; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToAltitude, this); } else { this.widgetArc[index].visible = false; if (this.wfInfo.altitude == 0xFFFF) { this.widgetDian1.setAngle(1050); this.widgetArcLabel[index].print("--"); } else { this.widgetDian1.setAngle(1050-((this.wfInfo.altitude + 800)/9600*300 << 0)); this.widgetArcLabel[index].print("%d", this.wfInfo.altitude); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.Stringaltitude); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc2.visible = false; this.widgetBgDian2.visible = true; this.widgetDian1.visible = true; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToAltitude, this); } }, draw_humidity_widget: function(index) { if (index == 0) { this.widgetArc[index].visible = false; if (this.wfInfo.humidity == 0xFFFF) { this.widgetDian.setAngle(2550); this.widgetArcLabel[index].print("--"); } else { this.widgetDian.setAngle(2550+(this.wfInfo.humidity/100*300 << 0)); this.widgetArcLabel[index].print("%d%%", this.wfInfo.humidity); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.Stringhumidity); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc1.visible = false; this.widgetBgDian1.visible = true; this.widgetDian.visible = true; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToHumidity, this); } else { this.widgetArc[index].visible = false; if (this.wfInfo.humidity == 0xFFFF) { this.widgetDian1.setAngle(1050); this.widgetArcLabel[index].print("--"); } else { this.widgetDian1.setAngle(1050-(this.wfInfo.humidity/100*300 << 0)); this.widgetArcLabel[index].print("%d%%", this.wfInfo.humidity); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.Stringhumidity); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc2.visible = false; this.widgetBgDian2.visible = true; this.widgetDian1.visible = true; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToHumidity, this); } }, draw_temperature_widget: function(index) { if (index == 0) { var temperatureHigh = this.wfInfo.temperatureHigh; var temperatureLow = this.wfInfo.temperatureLow; this.widgetArc[index].visible = false; if (this.wfInfo.temperature == 0xFFFF) { this.widgetDian.setAngle(2550); this.widgetArcLabel[index].print("--"); } else { this.widgetDian.setAngle(2550+(((this.wfInfo.temperature - temperatureLow) / (temperatureHigh - temperatureLow) * 300) << 0)); this.widgetArcLabel[index].print("%d°C", this.wfInfo.temperature); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.Stringtemperature); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc1.visible = false; this.widgetBgDian1.visible = true; this.widgetDian.visible = true; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToTemperature, this); } else { var temperatureHigh = this.wfInfo.temperatureHigh; var temperatureLow = this.wfInfo.temperatureLow; this.widgetArc[index].visible = false; if (this.wfInfo.temperature == 0xFFFF) { this.widgetDian1.setAngle(1050); this.widgetArcLabel[index].print("--"); } else { this.widgetDian1.setAngle(1050-(((this.wfInfo.temperature - temperatureLow) / (temperatureHigh - temperatureLow) * 300) << 0)); this.widgetArcLabel[index].print("%d°C", this.wfInfo.temperature); } this.widgetArcLabel[index].visible = true; this.widgetArcLabel1[index].setText(StringId.Stringtemperature); this.widgetArcLabel1[index].setFont(FontId.Fontvalue); this.widgetArcLabel1[index].visible = true; this.widgetBgArc2.visible = false; this.widgetBgDian2.visible = true; this.widgetDian1.visible = true; this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToTemperature, this); } }, drawWidgetNull: function(index) { if (index == 0) { this.widgetArc[index].visible = false; this.widgetArcLabel[index].visible = false; this.widgetArcLabel1[index].visible = false; this.widgetBgArc1.visible = false; this.widgetDian.visible = false; this.widgetBgDian1.visible = false; } else { this.widgetArc[index].visible = false; this.widgetArcLabel[index].visible = false; this.widgetArcLabel1[index].visible = false; this.widgetBgArc2.visible = false; this.widgetBgDian2.visible = false; this.widgetDian1.visible = false; } }, draw_widget: function(index) { switch (this.wduuid[index]) { case "8ea81818a932183836e8424010554e75": // 步数 this.draw_step_widget(index); break; case "c55e672512bc354e378c93869b0e4389": // 卡路里 this.draw_calorie_widget(index); break; case "54fb44783ac1b93efd33ee82d55b3565": // 电量 this.draw_battery_widget(index); break; case "14516ef561a7b1623661558b66db4997": // AQI this.draw_aqi_widget(index); break; case "f50fc612ef7d4a584e2b280dfacac916": // UV this.draw_uv_widget(index); break; case "db9ddb637cc36c79b3a8a9cd2644edac": // PM25 this.draw_pm25_widget(index); break; case "0af9d20ee745157fcc681178db05c08d": // 气压 this.draw_baro_widget(index); break; case "9f921d671a80f054b4f93edb304f8498": // 海拔 this.draw_altitude_widget(index); break; case "bef1f982e57b221431963b5470318f38": // 湿度 this.draw_humidity_widget(index); break; case "72a84500b5dc942ac6e5334da6e7fcda": // 温度 this.draw_temperature_widget(index); break; default: this.drawWidgetNull(index); this.widgetClickJump[index].setEventCb(EventType.clicked, this.jumpToNull, this); break; } }, update_widget: function() { if (WatchfaceUpdata.step & this.wfInfo.updataFlag) { for (var i = 0; i < 2; i++) { if (this.wduuid[i] == "8ea81818a932183836e8424010554e75") { this.draw_step_widget(i); } } } if (WatchfaceUpdata.calories & this.wfInfo.updataFlag) { for (var i = 0; i < 2; i++) { if (this.wduuid[i] == "c55e672512bc354e378c93869b0e4389") { this.draw_calorie_widget(i); } } } if (WatchfaceUpdata.battery & this.wfInfo.updataFlag) { for (var i = 0; i < 2; i++) { if (this.wduuid[i] == "54fb44783ac1b93efd33ee82d55b3565") { this.draw_battery_widget(i); } } } if (WatchfaceUpdata.weather & this.wfInfo.updataFlag) { for (var i = 0; i < 2; i++) { if (this.wduuid[i] == "14516ef561a7b1623661558b66db4997") { this.draw_aqi_widget(i); } if (this.wduuid[i] == "f50fc612ef7d4a584e2b280dfacac916") { this.draw_uv_widget(i); } if (this.wduuid[i] == "db9ddb637cc36c79b3a8a9cd2644edac") { this.draw_pm25_widget(i); } if (this.wduuid[i] == "bef1f982e57b221431963b5470318f38") { this.draw_humidity_widget(i); } } } if (WatchfaceUpdata.altitude & this.wfInfo.updataFlag) { for (var i = 0; i < 2; i++) { if (this.wduuid[i] == "0af9d20ee745157fcc681178db05c08d") { this.draw_baro_widget(i); } } for (var i = 0; i < 2; i++) { if (this.wduuid[i] == "9f921d671a80f054b4f93edb304f8498") { this.draw_altitude_widget(i); } } } if (WatchfaceUpdata.temperature & this.wfInfo.updataFlag) { for (var i = 0; i < 2; i++) { if (this.wduuid[i] == "72a84500b5dc942ac6e5334da6e7fcda") { this.draw_temperature_widget(i); } } } }, init_widget: function() { this.widgetInfo = EditWidgetInfo(); var changeFlag = [false, false]; for (var i = 0; i < this.widgetInfo.length; i++) { if ((this.widgetInfo[i].id > 101) || (this.widgetInfo[i].id < 100)) { continue; } var index = this.widgetInfo[i].id - 100; changeFlag[index] = true; if (this.wduuid[index] != this.widgetInfo[i].uuid) { this.wduuid[index] = this.widgetInfo[i].uuid; this.draw_widget(index); } } var defaultUUID = ["null","null"]; for (var i = 0; i < 2; i++) { if ((changeFlag[i] == false) && (this.wduuid[i] != defaultUUID[i])) { this.wduuid[i] = defaultUUID[i]; this.draw_widget(i); } } }, drawBgImage: function() { var bgNum = [ PicId.Picyanse_1, PicId.Picyanse_4, PicId.Picyanse_3, PicId.Picyanse_2, PicId.Picyanse_1, PicId.Picyanse_4, PicId.Picyanse_1, PicId.Picyanse_4, PicId.Picyanse_4, PicId.Picyanse_1 ]; var strId = [ StringId.Stringstr0, StringId.Stringstr4, StringId.Stringstr3, StringId.Stringstr2, StringId.Stringstr1, StringId.Stringstr6, StringId.Stringstr5, StringId.Stringstr7, StringId.Stringstr8, StringId.Stringstr9 ]; if (WatchfaceUpdata.stress & this.wfInfo.updataFlag) { this.bg.setPic(bgNum[this.wfInfo.stressID]); switch(this.wfInfo.stressID) { case 0: case 4: case 6: case 9: { if (this.wfInfo.stressID == 6) { this.animBg.setPic(PicId.Picw_anim08_001) } else { this.animBg.setPic(this.animBg1[this.iDindex % 2]) } this.labelDate.setColor(0xB1, 0x82, 0x1E); this.hourHigh.setColor(0xFF, 0xFB, 0xF5); this.hourLow.setColor(0xFF, 0xFA, 0xF0); this.maohao.setColor(0xFF, 0xF9, 0xEB); this.minHigh.setColor(0xFF, 0xF7, 0xE5); this.minLow.setColor(0xFF, 0xF6, 0xE0); } break; case 2: this.animBg.setPic(this.animBg3[this.iDindex % 2]); this.labelDate.setColor(0x3C, 0x97, 0x88); this.hourHigh.setColor(0xF6, 0xFD, 0xFD); this.hourLow.setColor(0xEE, 0xFC, 0xFC); this.maohao.setColor(0xED, 0xFF, 0xFF); this.minHigh.setColor(0xE3, 0xFA, 0xFA); this.minLow.setColor(0xDC, 0xF7, 0xF7); break; case 3: this.animBg.setPic(this.animBg2[this.iDindex % 2]); this.labelDate.setColor(0x75, 0x94, 0x1E); this.hourHigh.setColor(0xFC, 0xFD, 0xF6); this.hourLow.setColor(0xF9, 0xFC, 0xEE); this.maohao.setColor(0xF8, 0xFB, 0xE9); this.minHigh.setColor(0xF5, 0xFA, 0xE1); this.minLow.setColor(0xF0, 0xF7, 0xD4); break; case 1: case 5: case 7: case 8: if (this.wfInfo.stressID == 1) { this.animBg.setPic(PicId.Picw_anim07_001) } else if (this.wfInfo.stressID == 5) { this.animBg.setPic(PicId.Picw_anim09_001) } else if (this.wfInfo.stressID == 7){ this.animBg.setPic(PicId.Picw_anim10_001) } else { this.animBg.setPic(PicId.Picw_anim11_001) } this.labelDate.setColor(0xCE, 0x6E, 0x55); this.hourHigh.setColor(0xFF, 0xF7, 0xF5); this.hourLow.setColor(0xFF, 0xF3, 0xF0); this.maohao.setColor(0xFF, 0xEF, 0xEB); this.minHigh.setColor(0xFF, 0xEC, 0xE5); this.minLow.setColor(0xFF, 0xE7, 0xE0); break; default: break; } this.wfInfo.setFramesId(this.animBg); //启动定时器 this.wf_bg_task.resume(); } if (this.wfInfo.screenLock) { this.labelDate.print("%s", StringId.Stringstr9); } else if (this.wfInfo.stress == 0) { this.labelDate.print("%s", StringId.Stringstr0); } else if ((this.wfInfo.stressPassTime / 60 << 0) != this.textLabel) { this.textLabel = (this.wfInfo.stressPassTime / 60 << 0); if (((this.wfInfo.stressPassTime / 3600) << 0) >= 1) { this.labelDate.print("%s %d%s", strId[this.wfInfo.stressID], (this.wfInfo.stressPassTime / 3600) << 0, StringId.Stringhour); } else if (((this.wfInfo.stressPassTime / 60) << 0) >= 1) { this.labelDate.print("%s %d%s", strId[this.wfInfo.stressID], (this.wfInfo.stressPassTime / 60) << 0, StringId.Stringmin); } else { this.labelDate.print("%s %s", strId[this.wfInfo.stressID], StringId.Stringjust); } } }, draw: function() { this.drawTime(false); this.init_widget(); this.update_widget(); this.drawBgImage(); return 0; }, init: function(par) { //获得表盘参数信息 this.wfInfo = Watchface(); this.editInfo = new Object; this.editInfo.wfStyle = 0; // this.editInfo.timeStyle = 0; this.editInfo.colorNum = 0; this.editInfo.color = new Array(20); this.readUserData(); this.animBg1 = [PicId.Picw_anim01_001, PicId.Picw_anim02_001]; this.animBg2 = [PicId.Picw_anim03_001, PicId.Picw_anim04_001]; this.animBg3 = [PicId.Picw_anim05_001, PicId.Picw_anim06_001]; //显示底背景 this.bg = Image(par, PicId.Picyanse_1, 0, 0); this.wduuid = ["null","null"]; this.widgetBgArc1 = Image(par, PicId.PicwidgetBg_1, 10, 170); this.widgetBgArc1.visible = false; this.widgetBgArc2 = Image(par, PicId.PicwidgetBg_2, 434, 170); this.widgetBgArc2.visible = false; this.widgetBgDian1 = Image(par, PicId.PicwidgetBg_3, 10, 170); this.widgetBgDian1.visible = false; this.widgetBgDian2 = Image(par, PicId.PicwidgetBg_4, 434, 170); this.widgetBgDian2.visible = false; this.widgetDian = Image(par, PicId.PicwidgetDian, 223, 6); this.widgetDian.setPivot(10, 226); this.widgetDian.visible = false; this.widgetDian1 = Image(par, PicId.PicwidgetDian, 223, 6); this.widgetDian1.setPivot(10, 226); this.widgetDian1.visible = false; this.widgetArc = [Arc(par, 11, 11, 11, 444), Arc(par, 11, 11, 11, 444)]; for (var i = 0; i < 2; i++) { this.widgetArc[i].setColor(0xFF, 0xFF, 0xFF, true); this.widgetArc[i].setColor(0xFF, 0xFF, 0xFF, false); this.widgetArc[i].setRounded(true); this.widgetArc[i].setPrecision(true); this.widgetArc[i].setRotation(true); this.widgetArc[i].visible = false; } this.widgetArc[0].setAngles(3450, 3750, true); this.widgetArc[0].setAngles(3450, 3750, false); this.widgetArc[1].setAngles(1650, 1950, true); this.widgetArc[1].setAngles(1650, 1950, false); this.widgetArcLabel = [ArcText(par, "300", 10, 10), ArcText(par, "80%", 10, 10)]; for (var i = 0; i < 2; i++) { this.widgetArcLabel[i].setRecolor(1); this.widgetArcLabel[i].setColor(0xFF, 0xFF, 0xFF); this.widgetArcLabel[i].setFont(FontId.Fontvalue); this.widgetArcLabel[i].visible = false; this.widgetArcLabel[i].setClickAble(false); } this.widgetArcLabel[0].setRadius(204, 0); this.widgetArcLabel[0].setAlign(0, 1, 2860); this.widgetArcLabel[1].setRadius(227, 0); this.widgetArcLabel[1].setAlign(0, 3, 700); this.widgetArcLabel1 = [ArcText(par, "消耗", 10, 10), ArcText(par, "电量", 10, 10)]; for (var i = 0; i < 2; i++) { this.widgetArcLabel1[i].setRecolor(1); this.widgetArcLabel1[i].setColor(0xFF, 0xFF, 0xFF); this.widgetArcLabel1[i].setFont(FontId.Fontvalue); this.widgetArcLabel1[i].visible = false; this.widgetArcLabel1[i].setClickAble(false); } this.widgetArcLabel1[0].setRadius(232, 0); this.widgetArcLabel1[0].setAlign(1, 1, 2530); this.widgetArcLabel1[1].setRadius(225, 0); this.widgetArcLabel1[1].setAlign(1, 3, 1075); //时间显示 this.hourHigh = Image(par, PicId.Picstyle_0_0, 204, 8); this.hourHigh.visible = true; this.hourHigh.setPivot(29, 225); this.hourHigh.setAngle(-330); this.hourLow = Image(par, PicId.Picstyle_0_9, 204, 8); this.hourLow.visible = true; this.hourLow.setPivot(29, 225); this.hourLow.setAngle(-140); this.maohao = Image(par, PicId.Picstyle_0_10, 219, 8); this.maohao.visible = true; this.minHigh = Image(par, PicId.Picstyle_0_3, 204, 8); this.minHigh.visible = true; this.minHigh.setPivot(29, 225); this.minHigh.setAngle(140); this.minLow = Image(par, PicId.Picstyle_0_0, 204, 8); this.minLow.visible = true; this.minLow.setPivot(29, 225); this.minLow.setAngle(330); this.animBg = Image(par, PicId.Picanim_01, 0, 0); this.animBg.setEventCb(EventType.clicked, this.Changebg, this); this.wf_bg_task = Task(this, this.wf_bg_am, 34, false); var contStyle = { 'main:default': { 'bg-opa': 0, //隐藏背影 'border-side': 0x00, 'radius': 0, 'pad-all': 0, } }; this.widgetClickJump = [View(par, 0, 108, 100, 250),View(par, 412, 108, 100, 250)]; for (var i = 0; i < 2; i++) { this.widgetClickJump[i].setLocalStyle(contStyle); } //身心状态 this.labelDate = ArcText(par, "暂无数据", 15, 15); this.labelDate.setRadius(221, 0); this.labelDate.setRecolor(1); this.labelDate.setColor(0xB1, 0x82, 0x1E); this.labelDate.setAlign(1, 2, 1800); this.labelDate.setFont(FontId.Fonthealth); this.labelDate.visible = true; this.labelDate.setEventCb(EventType.clicked, this.jumpToStress, this); //设置显示 this.drawEditInfo(); this.draw(); return 0; }, onCreate: function(par, hor_res, ver_res) { print('onCreate: '); this.hor_max = hor_res; this.ver_max = ver_res; var fixedPage = View(par, 0, 0, hor_res, ver_res); var pageStyle = { 'main:default': { 'bg-color': 0x000000, 'border-side': 0x00, 'radius': 0, 'pad-all': 0, } }; fixedPage.setLocalStyle(pageStyle); this.par = fixedPage; this.init(fixedPage); return fixedPage; }
}
!subwm.registerSubWindow(shenxinmengchong);
shenxinmengchong = null;
this.wfInfo.stressID){
case 0:
case 4:
case 9:
this.amid = this.iDindex % 2 ? PicId.Picw_anim01_001 : PicId.Picw_anim02_001;
break;
现在遇到的问题是
1.动画表现每次都是连续播放 且在第一次之后 就不会展示第一组动画
2.动画不会交替播放
如何在图片选择阶段 对 PicId.Picw_anim01_001和PicId.Picw_anim02_001进行轮流播放?修改代码
不要分析太多 直接告诉我怎么做
最新发布