| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942 | 
							- import Vue from 'vue'
 
- import Vuex from 'vuex'
 
- import config from 'common/config.js'
 
- import reqUtil from 'util/util-js/requstUtil.js'
 
- import date from 'util/util-js/date.js'
 
- import cNumber from 'util/util-js/makeNumber.js'
 
- import BLE from 'util/util-js/BLE.js';
 
- //快速打击部分
 
- import o0 from "@/util/util-js/o0.js"
 
- import o0Project from "@/util/util-js/o0Project.js"
 
- import o0ProjectRelease from "@/util/util-js/o0ProjectRelease0.1.js"
 
- import deviceData from "@/util/util-js/devices.js"
 
- // 加载算法插件 JumpIdentificationModule
 
- var jumpIdenModule = uni.requireNativePlugin("JumpIdentificationModule")
 
- Vue.use(Vuex)
 
- const store = new Vuex.Store({
 
- 	state: {
 
- 		// vLog:'',
 
- 		//引导层
 
- 		bGuidePages: false,
 
- 		//是否显示Canvas
 
- 		bCanvasShow: true,
 
- 		/**
 
- 		 * 是否需要强制登录
 
- 		 */
 
- 		forcedLogin: false,
 
- 		/**
 
- 		 * 蓝牙实时发送数据的页面的名称
 
- 		 */
 
- 		currentPageName: '',
 
- 		hasLogin: false,
 
- 		userInfo: null,
 
- 		userName: "匿名",
 
- 		days: 0,
 
- 		remainingDays: 0,
 
- 		signature: '',
 
- 		avatarUrl: "/static/defaultAvatar.png",
 
- 		/**
 
- 		 * 新手教程相关
 
- 		 */
 
- 		// 是否是新用户,
 
- 		//TODO:登录接口返回的数据来判断
 
- 		bNewUser: false,
 
- 		//是否是第一次走新手
 
- 		bNewGuide: false,
 
- 		//解锁状态,和首次安装app相关
 
- 		//注意添加新字段时候。需要到 platform-page/guide.vue 确认需不需要添加新的reset
 
- 		guideUnlockState: {
 
- 			firstInstallation: true, //是否首次安装
 
- 			firstDisconnectBluetooth: true, //是否首次连接蓝牙
 
- 			firstUnlockJumpUp: true, //是否首次向上跳
 
- 			firstUnlockLeftAndRightJump: true, //是否首次左右跳
 
- 			firstUnlockLeftAndRightRotationJump: true,
 
- 			firstPromptSelectLevel: true //是否首次提示选择关卡
 
- 		},
 
- 		token: '',
 
- 		gender: 0,
 
- 		//省市区数据
 
- 		city: {
 
- 			label: '北京市-北京市-东城区',
 
- 			cityCode: "110101",
 
- 			//picker 选择器的index数组
 
- 			value: [0, 0, 0]
 
- 		},
 
- 		birthday: date.formatTime(new Date()),
 
- 		//默认值
 
- 		height: 0,
 
- 		weight: 0,
 
- 		//最近在玩的列表
 
- 		playGames: [],
 
- 		//最近在玩的排行游戏列表
 
- 		playRankingGames: [],
 
- 		//全部的游戏列表
 
- 		allGames: [],
 
- 		//关注的游戏列表
 
- 		favoriteGames: [],
 
- 		// 排行榜里面显示的游戏
 
- 		rankSelectedGame: null,
 
- 		rankInfo: null,
 
- 		cityName: "某市",
 
- 		/**
 
- 		 * 默认的运动数据
 
- 		 * date.addDaysFromNewDate(new Date(),1)
 
- 		 */
 
- 		defaultPlanData: {
 
- 			startTime: date.formatDate(new Date()),
 
- 			endTime: date.addDaysFromNewDate(new Date(), 6),
 
- 			targetWeight: 0, //目标公斤
 
- 			calorie: 360, //运动消耗的卡路里,默认300 大卡
 
- 			cumulativeCalorie: 0, //累计增重
 
- 			sportTime: 40, //运动时间
 
- 			/**
 
- 			 * 本地记录的消耗卡路里数量
 
- 			 */
 
- 			localCalorie: 0,
 
- 			/**
 
- 			 * 显示卡路里,过了12点清空
 
- 			 */
 
- 			showCalorie: 0,
 
- 			/**
 
- 			 * 总和
 
- 			 */
 
- 			allCalorie: 0
 
- 		},
 
- 		/**
 
- 		 * 计划的运动数据
 
- 		 */
 
- 		planData: {
 
- 			startTime: date.formatDate(new Date()),
 
- 			endTime: date.formatDate(new Date()), //date.addDaysFromNewDate(new Date(),1),
 
- 			targetWeight: 0, //目标公斤
 
- 			cumulativeCalorie: 0, //累计增重
 
- 			calorie: 300, //运动消耗的卡路里
 
- 			sportTime: 40, //运动时间
 
- 			/**
 
- 			 * 本地记录的消耗卡路里数量
 
- 			 */
 
- 			localCalorie: 0,
 
- 			/**
 
- 			 * 显示卡路里,过了12点清空
 
- 			 */
 
- 			showCalorie: 0,
 
- 			/**
 
- 			 * 总和
 
- 			 */
 
- 			allCalorie: 0
 
- 		},
 
- 		//记录表盘计划刷新的卡路里
 
- 		oldArcbarProCalorie: 0,
 
- 		//记录表盘当前的总卡路里
 
- 		oldArcbarAllCalorie: 0,
 
- 		//当前运动的世时间
 
- 		localSportTime: 0,
 
- 		//当前运动时间,运动时候记录的时间
 
- 		runingTime: 0,
 
- 		//蓝牙设备信息列表
 
- 		//id 不可变,用于保存到本地区分
 
- 		BLEInfoList: deviceData.getDeviceList(),
 
- 		//记录的蓝牙设备,保存id, 和对应的蓝牙连接数据
 
- 		BLEDeviceList: [],
 
- 		//显示的蓝牙设备,取本地数据时候更新
 
- 		BLEDeviceShowList: [],
 
- 		//选择连接的蓝牙设备
 
- 		BLEConnectDevice: null,
 
- 		//获取到的服务
 
- 		BLEGetServices: null,
 
- 		//当前发送给蓝牙的指令,目前是只有蓝牙手柄
 
- 		currentInstruction: '',
 
- 		instructionState: {
 
- 			// bAcc: false, //是否开启加速计状态
 
- 			// bGyroscope: false, //是否开启陀螺仪状态
 
- 			bOpen: false, //是否开启指令
 
- 			bSteps: false, //是否开启步数
 
- 		},
 
- 		//绑定的设备
 
- 		DeviceBindingList: [{
 
- 			id: 0,
 
- 			cname: "开启手机数据",
 
- 			ename: "bindMobilePhoneBandage",
 
- 			icon: "/static/devicesIcon/bandage.png",
 
- 			mIcon: "/static/devicesIcon/bandage.png",
 
- 			bRatio: false,
 
- 			usageMode: 'bindPhone',
 
- 			describe: '手机情景下使用',
 
- 			limitType: 'rebound', //限制回弹版本
 
- 			deviceType: 'mySelf', //指的是使用手机本身加速计计算
 
- 			deviceName: 'PHONE', //连接硬件名称
 
- 		}],
 
- 		ConnectBindingDevice: null,
 
- 		cIndex: -1,
 
- 		//当前是否连接
 
- 		bConnection: false,
 
- 		/**
 
- 		 * 通过验证的连接,比如通过mac验证,或者说是首页直连,都设置这个参数,确保已经连上
 
- 		 */
 
- 		bVerifiedConnection: false,
 
- 		/**
 
- 		 * 默认不是旧设备,旧设备使用的轴向不一样,名字为 BGBox_202012 ,新设备为 BGBox_202112
 
- 		 */
 
- 		bOldDeviceType: false,
 
- 		/**
 
- 		 * Android 出现不匹配的情况下,判断
 
- 		 * ios 暂时没有此类问题
 
- 		 */
 
- 		bPhoneMatched: false,
 
- 		//最近连接过的设备
 
- 		finallyUseDevice: null,
 
- 		/**
 
- 		 * 用户选择好友的信息
 
- 		 */
 
- 		finallySelectFriendInfo: null,
 
- 		//phoneNumber
 
- 		phoneNumber: '',
 
- 		mailboxNumber: '',
 
- 		//是否是第一次设置密码,根据这个值判断.默认未设置,即设置true
 
- 		setPasswordFirstTime: true,
 
- 		openid: '',
 
- 		appleid: '',
 
- 		//获取验证码
 
- 		bCodeDisabled: false,
 
- 		count: 59,
 
- 		interval: null,
 
- 		//conversion列表
 
- 		oldSwiperList: [],
 
- 		// 计划任务过期
 
- 		bPlanExpired: false,
 
- 		// 制定玩计划任务后
 
- 		bPlanFinish: false,
 
- 		//标准体重,男女根据当前年龄计算
 
- 		standardWeight: 0,
 
- 		//是否安装了微信
 
- 		bInstallWechat: false,
 
- 		bHideWeixin: false,
 
- 		//导航栏高度。这里统一参数,单位px
 
- 		navHeight: 46,
 
- 		tabbarHeight: 65,
 
- 		systemInfo: null, //系统全部信息
 
- 		clientName: '', //但是客户端名字
 
- 		system: '', // 系统版本
 
- 		platform: '', // 平台
 
- 		appName: '',
 
- 		version: '1.6.3', //软件版本
 
- 		versionCode: '21120701', //app.vue 自动获取.目前是h5 设置给了一个默认值
 
- 		showEndTime: config.endTime, //游戏显示时间字段,后台返回对应此时间之前的数据
 
- 		//现在游戏显示在对应的平台
 
- 		gamePlatform: {
 
- 			0: 'android',
 
- 			1: 'ios',
 
- 			2: 'all'
 
- 		},
 
- 		globalAcc: null,
 
- 		globalOri: null,
 
- 		globalAccData: {
 
- 			ax: 0,
 
- 			ay: 0,
 
- 			az: 0
 
- 		},
 
- 		globalGyroData: {
 
- 			gx: 0,
 
- 			gy: 0,
 
- 			gz: 0
 
- 		},
 
- 		globalLastGyroData: {
 
- 			gx: 0,
 
- 			gy: 0,
 
- 			gz: 0
 
- 		},
 
- 		globalMyAttitude: null,
 
- 		/**
 
- 		 * 当前显示的模式下标,区分总体的显示模块
 
- 		 * 比如拳击模块体验下,设置 0
 
- 		 * 跳绳为主的模式体验下,设置 1
 
- 		 */
 
- 		currentModeIndex: 0,
 
- 		//蓝牙变量操作
 
- 		/**
 
- 		 * 操作蓝牙设备
 
- 		 */
 
- 		bOpenBluetooth: false,
 
- 		/**
 
- 		 * 是否初始化蓝牙适配器
 
- 		 */
 
- 		bOpenSuccess: false,
 
- 		/**
 
- 		 * 是否监听蓝牙状态变化
 
- 		 */
 
- 		bListenAdapterStateChange: false,
 
- 		/**
 
- 		 * 是否监听寻找新设备事件
 
- 		 */
 
- 		bListenDeviceFound: false,
 
- 		// 设备Id
 
- 		BLEDeviceId: "",
 
- 		// 服务Id
 
- 		BLEServiceId: "",
 
- 		// 特征值id
 
- 		BLENotifyCharacteristicId: "",
 
- 		//监听rssi对象
 
- 		BLERSSIInterval: null,
 
- 		//蓝牙服务timeout
 
- 		getBLEDeviceServicesTimeout: null,
 
- 		//本地游戏地址
 
- 		// http://192.168.0.112:7456/build/index.html
 
- 		// http://127.0.0.1:7456/build/index.html
 
- 		LocationGameUrl: "http://110.43.54.43/t8/",
 
- 		//快速打击对象
 
- 		filter: null,
 
- 		deviceMs: 1,
 
- 		//改进版的沙袋打击对象
 
- 		sandbagAlgorithm: null,
 
- 		sandbagAlgorithmLastTime: new Date().getTime(),
 
- 		//记录一个沙包打击数量
 
- 		sandbagHitCount: 0,
 
- 		netSandbagHitCount: 0,
 
- 		/**
 
- 		 * 蓝牙参数对象
 
- 		 */
 
- 		// 设备Id
 
- 		deviceId: "",
 
- 		// 服务Id
 
- 		serviceId: "",
 
- 		notifyCharacteristicId: "",
 
- 		writeCharacteristicId: "",
 
- 		showToast: false,
 
- 		bListenerUpdate: false,
 
- 		bListenerJson: false,
 
- 		bListenerMac: false,
 
- 		bListenerAccArray: false,
 
- 		/**
 
- 		 * OTA config
 
- 		 */
 
- 		UUID_OTA_SERVICE: "f000ffc0-0451-4000-b000-000000000000", //OTA 服务对应的服务的 UUID
 
- 		UUID_IDENTFY: "f000ffc1-0451-4000-b000-000000000000", //OTA 版本特征值的UUID,读取版本就是写向这个特征值写入:0x00
 
- 		UUID_BLOCK: "f000ffc2-0451-4000-b000-000000000000", //OTA 写bin文件特征值UUID,发送bin文件就是写这个特征值
 
- 		/*****/
 
- 		/**
 
- 		 * 发送16进制时候,返回的刷新数据
 
- 		 */
 
- 		bListenerHexUpdate: false,
 
- 		BluetoothAdapter: null,
 
- 		//版本状态,用于区分部分特定的环境
 
- 		versionCodeState: {
 
- 			showGame: false,
 
- 			showVideo: false,
 
- 			versionCode: 0,
 
- 			title: 'none'
 
- 		},
 
- 		//显示蓝牙是否断开连接Modal
 
- 		bShowBLEConnectModal: false,
 
- 		bGamePlaying: false,
 
- 		//跳绳条件下计数
 
- 		bRopeKeyOne: 0,
 
- 		bRopeKeyTwo: 0,
 
- 		//钻石,金币
 
- 		cDiamond: 0,
 
- 		cGold: 0,
 
- 		/**
 
- 		 * 任务相关
 
- 		 */
 
- 		currentJumpTask: null,
 
- 		multiPersonList: [],
 
- 		singlePersonList: [],
 
- 		levels: [],
 
- 		/**
 
- 		 * 校准识别部分
 
- 		 */
 
- 		convertAcc: [{
 
- 			type: 'x',
 
- 			match: 'ax', //默认匹配一一对应
 
- 			direction: 1,
 
- 		}, {
 
- 			type: 'y',
 
- 			match: 'ay',
 
- 			direction: -1,
 
- 		}, {
 
- 			type: 'z',
 
- 			match: 'az',
 
- 			direction: -1,
 
- 		}],
 
- 		convertGyro: [{
 
- 			type: 'x',
 
- 			match: 'gx', //默认匹配一一对应
 
- 			direction: 1,
 
- 		}, {
 
- 			type: 'y',
 
- 			match: 'gy',
 
- 			direction: 1,
 
- 		}, {
 
- 			type: 'z',
 
- 			match: 'gz',
 
- 			direction: 1,
 
- 		}],
 
- 		/**
 
- 		 * 签到列表
 
- 		 */
 
- 		signInList: [],
 
- 		isSignIn: false,
 
- 		
 
- 		//读取文件的名称
 
- 		readDataName:"",
 
- 		filesList: [],
 
- 	},
 
- 	mutations: {
 
- 		
 
- 		
 
- 		
 
- 		/**
 
- 		 * 蓝牙解析后的数据,转化成对应的坐标系方向
 
- 		 * @param {Object} context
 
- 		 */
 
- 		onConvertDeviceData(state, context) {
 
- 			let {
 
- 				data,
 
- 				callback = null
 
- 			} = context;
 
- 			let {
 
- 				acc,
 
- 				gyro,
 
- 			} = data;
 
- 			//根据已校准的数据转化对应的轴
 
- 			let outAcc = {
 
- 				ax: acc[state.convertAcc[0].match] * state.convertAcc[0].direction,
 
- 				ay: acc[state.convertAcc[1].match] * state.convertAcc[1].direction,
 
- 				az: acc[state.convertAcc[2].match] * state.convertAcc[2].direction
 
- 			};
 
- 			let outGyro = {
 
- 				gx: gyro[state.convertGyro[0].match] * state.convertGyro[0].direction,
 
- 				gy: gyro[state.convertGyro[1].match] * state.convertGyro[1].direction,
 
- 				gz: gyro[state.convertGyro[2].match] * state.convertGyro[2].direction
 
- 			}
 
- 			if (callback)
 
- 				callback({
 
- 					convertAcc: outAcc,
 
- 					convertGyro: outGyro
 
- 				});
 
- 		},
 
- 		onAccAndGyroConvertDataGet(state) {
 
- 			const convertAcc = uni.getStorageSync('convertAcc');
 
- 			if (convertAcc) {
 
- 				state.convertAcc = convertAcc;
 
- 			}
 
- 			const convertGyro = uni.getStorageSync('convertGyro');
 
- 			if (convertGyro) {
 
- 				state.convertGyro = convertGyro;
 
- 			}
 
- 		},
 
- 		onAccAndGyroConvertDataSave(state) {
 
- 			uni.setStorageSync('convertAcc', state.convertAcc);
 
- 			uni.setStorageSync('convertGyro', state.convertGyro);
 
- 		},
 
- 		onAccAndGyroConvertDataReset(state) {
 
- 			state.convertAcc = [{
 
- 				type: 'x',
 
- 				match: 'ax', //默认匹配一一对应
 
- 				direction: 1,
 
- 			}, {
 
- 				type: 'y',
 
- 				match: 'ay',
 
- 				direction: -1,
 
- 			}, {
 
- 				type: 'z',
 
- 				match: 'az',
 
- 				direction: -1,
 
- 			}];
 
- 			state.convertGyro = [{
 
- 				type: 'x',
 
- 				match: 'gx', //默认匹配一一对应
 
- 				direction: 1,
 
- 			}, {
 
- 				type: 'y',
 
- 				match: 'gy',
 
- 				direction: 1,
 
- 			}, {
 
- 				type: 'z',
 
- 				match: 'gz',
 
- 				direction: 1,
 
- 			}];
 
- 			//重置一下数据保存
 
- 			this.commit('onAccAndGyroConvertDataSave');
 
- 		},
 
- 		/**
 
- 		 * 保存一份本地数据,加速计和陀螺仪
 
- 		 * @param {Object} data
 
- 		 * @param {Object} state
 
- 		 */
 
- 		setOutAccAndGyroData(state, data) {
 
- 			uni.setStorageSync('OutAccAndGyroData', data);
 
- 		},
 
- 		getOutAccAndGyroData(state) {
 
- 			const value = uni.getStorageSync('OutAccAndGyroData');
 
- 			return value;
 
- 		},
 
- 		copyOutAccANdGyroData() {
 
- 			const value = uni.getStorageSync('OutAccAndGyroData');
 
- 			uni.setClipboardData({
 
- 				data: value,
 
- 				success: () => {
 
- 					uni.showToast({
 
- 						icon: 'none',
 
- 						title: '复制成功'
 
- 					});
 
- 				}
 
- 			});
 
- 		},
 
- 		setGuideUnlockState(state, _guideUnlockState) {
 
- 			uni.setStorageSync('guideUnlockState', _guideUnlockState);
 
- 			state.guideUnlockState = _guideUnlockState;
 
- 		},
 
- 		getGuideUnlockState(state, _guideUnlockState) {
 
- 			//如果存在本地任务
 
- 			const value = uni.getStorageSync('guideUnlockState');
 
- 			if (value) {
 
- 				state.guideUnlockState = value;
 
- 			}
 
- 			console.log('获取guideUnlockState', state.guideUnlockState)
 
- 		},
 
- 		/**
 
- 		 * 设置当前操作的任务记录到本地
 
- 		 * @param {Object} state
 
- 		 * @param {Object} _taskObj
 
- 		 */
 
- 		setActionJumpTask(state, _taskObj) {
 
- 			uni.setStorageSync('currentJumpTask', _taskObj);
 
- 			state.currentJumpTask = _taskObj;
 
- 		},
 
- 		//获取本地任务对象
 
- 		getActionJumpTask(state) {
 
- 			//如果存在本地任务
 
- 			const value = uni.getStorageSync('currentJumpTask');
 
- 			if (value) {
 
- 				state.currentJumpTask = value;
 
- 			}
 
- 		},
 
- 		resetActionJumpTask(state) {
 
- 			state.currentJumpTask = null;
 
- 			uni.setStorageSync('currentJumpTask', state.currentJumpTask);
 
- 		},
 
- 		setFinallSelectFriendInfo(state, friendInfo) {
 
- 			state.finallySelectFriendInfo = friendInfo;
 
- 			console.log('finallySelectFriendInfo', JSON.stringify(friendInfo));
 
- 		},
 
- 		clearFinallFriendInfo(state) {
 
- 			state.finallySelectFriendInfo = null;
 
- 		},
 
- 		/**
 
- 		 * 获取记录的最后一次连接设备
 
- 		 * @param {Object} state
 
- 		 */
 
- 		getFinalUseDevice(state) {
 
- 			// 获取本地存储的最后一次使用的设备
 
- 			//1.获取最近连接的蓝牙设备, 指蓝牙搜索到的obj
 
- 			const value = uni.getStorageSync('finallyUseDevice');
 
- 			if (value) {
 
- 				state.finallyUseDevice = value;
 
- 			}
 
- 			console.log('获取的finallyUseDevice', value);
 
- 		},
 
- 		/**
 
- 		 * 存储最后一次使用的设备信息,后面登陆时候,如果存在设备最后一次使用信息,则自动连接
 
- 		 * @param {Object} state
 
- 		 * @param {Object} device
 
- 		 */
 
- 		setFinallUseDevice(state, device) {
 
- 			uni.setStorageSync('finallyUseDevice', device);
 
- 			state.finallyUseDevice = device;
 
- 			// console.log("保存finallyUseDevice:", state.finallyUseDevice);
 
- 			// uni.setStorage({
 
- 			// 	key: 'finallyUseDevice',
 
- 			// 	data: device,
 
- 			// 	success: (res) => {
 
- 			// 		state.finallyUseDevice = device;
 
- 			// 		console.log("保存finallyUseDevice:", res);
 
- 			// 	}
 
- 			// })
 
- 		},
 
- 		/**
 
- 		 * 移除记录的use device
 
- 		 */
 
- 		clearFinallUseDevice(state) {
 
- 			uni.removeStorage({
 
- 				key: 'finallyUseDevice',
 
- 				success: (res) => {
 
- 					state.finallyUseDevice = null;
 
- 					console.log("移除finallyUseDevice:", res);
 
- 				}
 
- 			})
 
- 		},
 
- 		/**
 
- 		 * 设置运动时间
 
- 		 * @param {Object} state
 
- 		 * @param {Object} time
 
- 		 */
 
- 		setLocalSportTime(state, time) {
 
- 			// let _sportTime = Number(time);
 
- 			state.localSportTime = Number(time);
 
- 			uni.setStorage({
 
- 				key: 'localSportTime',
 
- 				data: state.localSportTime,
 
- 				success: (res) => {
 
- 					// uni.showToast({
 
- 					// 	title: "保存成功"
 
- 					// })
 
- 				}
 
- 			})
 
- 		},
 
- 		/**
 
- 		 * 设置卡路里
 
- 		 * @param {Object} state
 
- 		 * @param {Object} calorie
 
- 		 */
 
- 		setLocalCalorie(state, calorie) {
 
- 			state.planData.localCalorie = Number(calorie);
 
- 			uni.setStorage({
 
- 				key: 'localCalorie',
 
- 				data: state.planData.localCalorie,
 
- 				success: (res) => {
 
- 					// uni.showToast({
 
- 					// 	title: "保存成功"
 
- 					// })
 
- 				}
 
- 			})
 
- 		},
 
- 		/**
 
- 		 * 设置表盘显示的卡路里,
 
- 		 * @param {Object} state
 
- 		 * @param {Object} calorie
 
- 		 */
 
- 		setShowCalorie(state, calorie) {
 
- 			state.planData.showCalorie = Number(calorie);
 
- 			uni.setStorage({
 
- 				key: 'showCalorie',
 
- 				data: state.planData.showCalorie,
 
- 				success: (res) => {
 
- 					// uni.showToast({
 
- 					// 	title: "保存成功"
 
- 					// })
 
- 				}
 
- 			})
 
- 		},
 
- 		/**
 
- 		 * 增加卡路里
 
- 		 * @param {Object} state
 
- 		 * @param {Object} calorie
 
- 		 */
 
- 		addlocalCalorie(state, calorie) {
 
- 			//卡路里不能为负数
 
- 			calorie = Math.abs(calorie);
 
- 			//当前需要添加的卡路里
 
- 			let temNum = Number(calorie);
 
- 			//本地的卡路里
 
- 			let temNum2 = Number(state.planData.localCalorie);
 
- 			// 本地加 + 传入的卡路里
 
- 			let _numberLocal = temNum.add(temNum2);
 
- 			//显示的卡路里
 
- 			let _showCalorie = Number(state.planData.showCalorie);
 
- 			//显示的卡路里加上 本地卡路里 和添加的卡路里之和要小于或等于 计划的卡路里
 
- 			let _allCalorie = _numberLocal.add(_showCalorie);
 
- 			// console.log("计算的最后卡路里_showCalorie:", _showCalorie,_allCalorie);
 
- 			//如果超过计划的,用计划的卡路里记录
 
- 			if (_allCalorie > state.planData.calorie) {
 
- 				let _calorie = Number(state.planData.calorie);
 
- 				//假如更新时候,localCalorie 值不为0,但是还未更新给服务器,此时,不能设置localCalorie 0
 
- 				//用传入的值,减去 allcalorie 总和和目标的差
 
- 				let _value = Number(_allCalorie).sub(_calorie);
 
- 				let _endValue = Number(_numberLocal).sub(_value);
 
- 				state.planData.localCalorie = Number(_endValue.toFixed(2));
 
- 				//如果大于或者等于的话,用计划 于 显示的卡路里 差值
 
- 				// state.planData.localCalorie = Number(_calorie.sub(_showCalorie).toFixed(2));
 
- 				// //显示最大值
 
- 				// state.planData.showCalorie = Number(_calorie.sub(state.planData.localCalorie).toFixed(2));
 
- 			} else {
 
- 				//
 
- 				state.planData.localCalorie = Number(_numberLocal.toFixed(2));
 
- 				// //输入的卡路里 + 自身显示的卡路里
 
- 				// state.planData.showCalorie = Number(temNum.add(_showCalorie).toFixed(2)); 
 
- 			}
 
- 			console.log("计算的最后卡路里:", state.planData);
 
- 			if (state.planData.localCalorie < 0) {
 
- 				//如果修改计划时候,本地数据计算的结果为负数,先取总和,localCalorie负再重置为0
 
- 				state.planData.showCalorie = _showCalorie.add(state.planData.localCalorie);
 
- 				state.planData.allCalorie = state.planData.showCalorie;
 
- 				state.planData.localCalorie = 0;
 
- 			} else {
 
- 				state.planData.allCalorie = _showCalorie.add(state.planData.localCalorie);
 
- 			}
 
- 			try {
 
- 				uni.setStorageSync('localCalorie', state.planData.localCalorie);
 
- 			} catch (e) {
 
- 				// error
 
- 				console.error(e);
 
- 			}
 
- 			try {
 
- 				uni.setStorageSync('showCalorie', state.planData.showCalorie);
 
- 			} catch (e) {
 
- 				// error
 
- 				console.error(e);
 
- 			}
 
- 			// uni.setStorage({
 
- 			// 	key: 'localCalorie',
 
- 			// 	data: state.planData.localCalorie,
 
- 			// 	success: (res) => {
 
- 			// 		// uni.showToast({
 
- 			// 		// 	title: "保存成功"
 
- 			// 		// })
 
- 			// 	}
 
- 			// })
 
- 			// uni.setStorage({
 
- 			// 	key: 'showCalorie',
 
- 			// 	data: state.planData.showCalorie,
 
- 			// 	success: (res) => {
 
- 			// 		// uni.showToast({
 
- 			// 		// 	title: "保存成功"
 
- 			// 		// })
 
- 			// 	}
 
- 			// })
 
- 		},
 
- 		/**
 
- 		 * 每次登陆同步本地数据到服务器
 
- 		 * 当天的数据更新,只更新一次
 
- 		 * @param {Object} state
 
- 		 */
 
- 		syncLocalDataToServer(state, callback) {
 
- 			let self = this;
 
- 			uni.getStorage({
 
- 				key: 'syncDate',
 
- 				success: function(res) {
 
- 					// console.log(res.data);
 
- 					let oldTime = res.data;
 
- 					let nDate = new Date();
 
- 					let newTime = date.formatDate(nDate);
 
- 					let days = date.datedifference(newTime, oldTime);
 
- 					// console.log(days);
 
- 					// 如果相差大于1天,
 
- 					if (days != 0) {
 
- 						// 更新存储日期
 
- 						uni.setStorageSync("syncDate", newTime);
 
- 						// 执行更新函数
 
- 						self.commit("syncRequestEvent", {
 
- 							success: () => {
 
- 								//清空显示的本地数据
 
- 								self.commit("setShowCalorie", 0);
 
- 								state.planData.allCalorie = state.planData.showCalorie.
 
- 								add(state.planData.localCalorie);
 
- 								if (callback)
 
- 									callback({
 
- 										newDate: nDate
 
- 									});
 
- 							}
 
- 						});
 
- 						//清空记录的本地运动时间
 
- 						// console.log('情况运动时间');
 
- 						self.commit("setLocalSportTime", 0);
 
- 						//设置本地数据是0
 
- 						state.localSportTime = 0;
 
- 					} else {
 
- 						if (callback)
 
- 							callback({
 
- 								newDate: nDate
 
- 							});
 
- 					}
 
- 					// date.getDays.
 
- 				},
 
- 				fail: function(res) {
 
- 					// console.error(res);
 
- 					// 如果没有日期,则存储一个新的
 
- 					let nDate = new Date();
 
- 					let tempTime = date.formatDate(nDate);
 
- 					uni.setStorageSync("syncDate", tempTime);
 
- 					if (callback)
 
- 						callback({
 
- 							newDate: nDate
 
- 						});
 
- 				}
 
- 			});
 
- 		},
 
- 		// 同步数据的请求
 
- 		syncRequestEvent(state, data) {
 
- 			let self = this;
 
- 			let {
 
- 				success,
 
- 				fail
 
- 			} = data;
 
- 			//需要卡路里取整存服务器,小数点后面,继续保留。以消除累计误差
 
- 			let oldLocalCalorie = state.planData.localCalorie;
 
- 			let _localCalorieInt = parseInt(state.planData.localCalorie);
 
- 			//小数点后面
 
- 			let _afterLocalCalorie = Number(oldLocalCalorie).sub(_localCalorieInt);
 
- 			console.log("*******===:", oldLocalCalorie, _localCalorieInt, _afterLocalCalorie);
 
- 			if (_localCalorieInt === 0) {
 
- 				// uni.showToast({
 
- 				// 	title: '',
 
- 				// 	icon: 'loading',
 
- 				// 	mask: true,
 
- 				// 	duration: 1000
 
- 				// })
 
- 				if (success)
 
- 					success();
 
- 				return;
 
- 			}
 
- 			uni.showToast({
 
- 				title: '',
 
- 				icon: 'loading',
 
- 				mask: false,
 
- 				duration: 10000
 
- 			})
 
- 			//把卡路里累计到cumulativeCalorie 变量,之后传服务器 += Math.round(state.planData.localCalorie)
 
- 			state.planData.cumulativeCalorie += _localCalorieInt;
 
- 			//添加到showCalorie 中
 
- 			state.planData.showCalorie = Number(state.planData.showCalorie).add(_localCalorieInt);
 
- 			state.planData.allCalorie = state.planData.showCalorie.add(_afterLocalCalorie);
 
- 			//不管是否同步成功,清空本地记录的卡路里,前一步已添加到cumulativeCalorie
 
- 			self.commit("setLocalCalorie", _afterLocalCalorie);
 
- 			self.commit("setShowCalorie", Number(state.planData.showCalorie));
 
- 			// 把卡路里记录到服务器
 
- 			reqUtil.requestData(config.URL.FITNESSPROGRAM, state.planData, 'POST').then(
 
- 				res => {
 
- 					// console.warn(res);
 
- 					if (res.code == 0) {
 
- 						uni.showToast({
 
- 							title: '同步成功',
 
- 							mask: true,
 
- 							duration: 1000
 
- 						});
 
- 						//同步一下服务器的返回值
 
- 						state.planData = Object.assign(state.planData, res.data);
 
- 						//暂时默认同步拳击1 的卡路里
 
- 						reqUtil.requestData(config.URL.UPLOADRANKING, {
 
- 							gameId: '1', //拳击模式 game id = 1;
 
- 							score: _localCalorieInt,
 
- 							cityCode: state.city.cityCode,
 
- 						}, "POST").then(res => {
 
- 								console.warn('****上传首页拳击卡路里,后面多个模式,可能需要多个不同的游戏id ***', res);
 
- 							},
 
- 							e => {
 
- 								console.log(e)
 
- 							});
 
- 						setTimeout(() => {
 
- 							uni.hideToast();
 
- 						}, 1000);
 
- 						if (success)
 
- 							success();
 
- 					} else {
 
- 						state.planData.cumulativeCalorie = Number(state.planData.cumulativeCalorie).sub(
 
- 							_localCalorieInt);
 
- 						state.planData.showCalorie = Number(state.planData.showCalorie).sub(
 
- 							_localCalorieInt);
 
- 						self.commit("setLocalCalorie", oldLocalCalorie);
 
- 						if (fail)
 
- 							fail();
 
- 					}
 
- 					console.log("减法 ==", Number(state.planData.cumulativeCalorie).sub(_localCalorieInt));
 
- 				},
 
- 				e => {
 
- 					console.log(e);
 
- 					state.planData.cumulativeCalorie = Number(state.planData.cumulativeCalorie).sub(
 
- 						_localCalorieInt);
 
- 					state.planData.showCalorie = Number(state.planData.showCalorie).sub(_localCalorieInt);
 
- 					self.commit("setLocalCalorie", oldLocalCalorie);
 
- 					uni.hideToast();
 
- 					if (fail)
 
- 						fail();
 
- 				}
 
- 			);
 
- 		},
 
- 		//登录成功后,重置一下状态
 
- 		resetCountDown(state) {
 
- 			if (state.interval) {
 
- 				clearInterval(state.interval);
 
- 				state.interval = null;
 
- 				state.count = 59;
 
- 				state.bCodeDisabled = false;
 
- 			}
 
- 		},
 
- 		/**
 
- 		 * 验证码操作 区分手机号和邮箱
 
- 		 * @param {Object} state
 
- 		 * @param {Object} context
 
- 		 */
 
- 		countDown(state, context) {
 
- 			let {
 
- 				account,
 
- 				type
 
- 			} = context;
 
- 			//限制验证码操作
 
- 			state.bCodeDisabled = true;
 
- 			state.interval = setInterval(() => {
 
- 				--state.count;
 
- 				if (state.count <= 0) {
 
- 					clearInterval(state.interval);
 
- 					state.interval = null;
 
- 					state.count = 59;
 
- 					state.bCodeDisabled = false;
 
- 				}
 
- 			}, 1000);
 
- 			setTimeout(() => {
 
- 				clearInterval(state.interval)
 
- 				state.count = 59;
 
- 				state.bCodeDisabled = false;
 
- 			}, 60000);
 
- 			//GETCODE "phoneNumber": phoneNumber; GETCODEACCORDINGTYPE
 
- 			reqUtil.requestData(config.URL.GETCODEACCORDINGTYPE, {
 
- 				account,
 
- 				type
 
- 			}).then(res => {
 
- 					console.log('requestData GETCODE =====', res);
 
- 					uni.showToast({
 
- 						title: "发送成功",
 
- 						mask: true,
 
- 						duration: 1000
 
- 					})
 
- 				},
 
- 				e => {
 
- 					console.log(e)
 
- 				});
 
- 		},
 
- 		//获取记录的蓝牙列表数据
 
- 		getBLEDeviceList(state) {
 
- 			// console.log("getBLEDeviceList=");
 
- 			uni.getStorage({
 
- 				key: 'BLEDeviceList',
 
- 				success: (res) => {
 
- 					// console.log("*****getBLEDeviceList=", res);
 
- 					let _list = res.data;
 
- 					state.BLEDeviceList = res.data;
 
- 					//更新BLEDeviceShowList 数组
 
- 					state.BLEDeviceShowList = [];
 
- 					_list.forEach(item => {
 
- 						//如果记录到本地的id,和信息列表中的id一致,则结合
 
- 						for (let i = 0; i < state.BLEInfoList.length; i++) {
 
- 							let eq = state.BLEInfoList[i];
 
- 							if (item.id == eq.id) {
 
- 								state.BLEDeviceShowList.push(Object.assign({}, item, eq));
 
- 								break;
 
- 							}
 
- 						}
 
- 					})
 
- 				}
 
- 			})
 
- 		},
 
- 		//添加蓝牙设备数据
 
- 		addBLEDevice(state, data) {
 
- 			let devicelist = [];
 
- 			if (state.BLEDeviceList && state.BLEDeviceList.length != 0) {
 
- 				devicelist = state.BLEDeviceList;
 
- 			}
 
- 			// console.log(data, devicelist)
 
- 			let bHas = false;
 
- 			devicelist.forEach((item, index, selfArr) => {
 
- 				if (item.id == data.id) {
 
- 					//如果存在,更新保存的数据,比如 mac或者uuid等 
 
- 					selfArr[index] = item = Object.assign({}, item, data);
 
- 					bHas = true;
 
- 				}
 
- 			})
 
- 			//把当前添加的的蓝牙设信息备作为最后一次连接覆盖到本地
 
- 			this.commit('setFinallUseDevice', data);
 
- 			if (!bHas) {
 
- 				//如果不是更新数据,就添加但却数据到列表
 
- 				devicelist.push(data);
 
- 			}
 
- 			uni.setStorage({
 
- 				key: 'BLEDeviceList',
 
- 				data: devicelist,
 
- 				success: (res) => {
 
- 					// uni.showToast({
 
- 					// 	title: "保存成功"
 
- 					// })
 
- 					state.BLEDeviceList = devicelist;
 
- 					// console.log("devicelist:",devicelist);
 
- 					//更新BLEDeviceShowList 数组
 
- 					state.BLEDeviceShowList = [];
 
- 					devicelist.forEach(item => {
 
- 						//如果记录到本地的id,和信息列表中的id一致,则结合
 
- 						for (let i = 0; i < state.BLEInfoList.length; i++) {
 
- 							let eq = state.BLEInfoList[i];
 
- 							if (item.id == eq.id) {
 
- 								// console.log("存储的======================:", item, eq);
 
- 								state.BLEDeviceShowList.push(Object.assign({}, item, eq));
 
- 								break;
 
- 							}
 
- 						}
 
- 					})
 
- 					// console.log("state.BLEDeviceShowList:",state.BLEDeviceShowList);
 
- 				}
 
- 			})
 
- 		},
 
- 		//删除蓝牙设备数据
 
- 		deleteBLEDevice(state, index) {
 
- 			let devicelist = [];
 
- 			devicelist = state.BLEDeviceList;
 
- 			devicelist.splice(index, 1);
 
- 			uni.setStorage({
 
- 				key: 'BLEDeviceList',
 
- 				data: devicelist,
 
- 				success: (res) => {
 
- 					uni.showToast({
 
- 						title: "删除成功"
 
- 					})
 
- 					state.BLEDeviceList = devicelist;
 
- 					//更新BLEDeviceShowList 数组
 
- 					state.BLEDeviceShowList = [];
 
- 					devicelist.forEach(item => {
 
- 						//如果记录到本地的id,和信息列表中的id一致,则结合
 
- 						for (let i = 0; i < state.BLEInfoList.length; i++) {
 
- 							let eq = state.BLEInfoList[i];
 
- 							if (item.id == eq.id) {
 
- 								state.BLEDeviceShowList.push(Object.assign({}, item, eq));
 
- 								break;
 
- 							}
 
- 						}
 
- 					})
 
- 				}
 
- 			})
 
- 		},
 
- 		//获取计划表数据
 
- 		getPlanData(state, callback) {
 
- 			reqUtil.requestData(config.URL.FITNESSPROGRAMGET).then(res => {
 
- 					// console.log('获取计划表数据:getPlanData=====', res.data);
 
- 					if (res.code == 0) {
 
- 						state.planData = Object.assign(state.planData, res.data);
 
- 						// 处理本地数据
 
- 						let templocalCalorie = uni.getStorageSync("localCalorie");
 
- 						// console.log("templocalCalorie:", templocalCalorie, state.planData);
 
- 						if (templocalCalorie) {
 
- 							templocalCalorie = Number(templocalCalorie);
 
- 							if (templocalCalorie > state.planData.calorie) {
 
- 								state.planData.localCalorie = state.planData.calorie;
 
- 								uni.setStorage({
 
- 									key: "localCalorie",
 
- 									data: state.planData.localCalorie
 
- 								});
 
- 							} else {
 
- 								state.planData.localCalorie = templocalCalorie;
 
- 							}
 
- 						} else {
 
- 							state.planData.localCalorie = 0;
 
- 						}
 
- 						//处理本地的cumulativeCalorie
 
- 						let tempShowCalorie = uni.getStorageSync("showCalorie");
 
- 						// console.log("tempShowCalorie:", tempShowCalorie, state.planData);
 
- 						if (tempShowCalorie) {
 
- 							tempShowCalorie = Number(tempShowCalorie);
 
- 							if (tempShowCalorie > state.planData.calorie) {
 
- 								state.planData.showCalorie = state.planData.calorie;
 
- 								uni.setStorage({
 
- 									key: "showCalorie",
 
- 									data: state.planData.showCalorie
 
- 								});
 
- 							} else {
 
- 								state.planData.showCalorie = tempShowCalorie;
 
- 							}
 
- 						} else {
 
- 							state.planData.showCalorie = 0;
 
- 						}
 
- 						state.planData.allCalorie = state.planData.showCalorie.add(state.planData
 
- 							.localCalorie);
 
- 						// console.log("======",state.planData )
 
- 						state.days = date.datedifference(res.data.startTime, res.data.endTime) + 1;
 
- 						let nDate = new Date();
 
- 						let tempTime = date.formatDate(nDate);
 
- 						state.remainingDays = date.datedifference(tempTime, res.data.endTime) + 1;
 
- 						console.log("state.remainingDays======", tempTime, res.data.endTime, state
 
- 							.remainingDays);
 
- 					}
 
- 					// showArcbar
 
- 					if (callback) {
 
- 						callback();
 
- 					}
 
- 				},
 
- 				e => {
 
- 					console.log(e)
 
- 				});
 
- 		},
 
- 		/**
 
- 		 * 获取全部游戏
 
- 		 * @param {Object} state
 
- 		 */
 
- 		getAllGame(state, callback) {
 
- 			//获得全部游戏列表
 
- 			if (state.allGames.length != 0) {
 
- 				if (callback)
 
- 					callback();
 
- 				return;
 
- 			}
 
- 			reqUtil.requestData(
 
- 				config.URL.GAMELIST_BY_RANKING_SHOW_AND_PLATFORM, {
 
- 					rankingShow: 1,
 
- 					page: 1,
 
- 					size: 100
 
- 				}
 
- 			).then(res => {
 
- 					// console.log('获取默认的全部游戏 =====', res);
 
- 					if (res.code == 0) {
 
- 						state.allGames = [];
 
- 						state.allGames = state.allGames.concat(res.data);
 
- 					}
 
- 					if (callback)
 
- 						callback();
 
- 				},
 
- 				e => {
 
- 					console.log(e);
 
- 					if (callback)
 
- 						callback();
 
- 				}
 
- 			);
 
- 		},
 
- 		getRankGame(state, data) {
 
- 			let {
 
- 				param,
 
- 				callback
 
- 			} = data;
 
- 			reqUtil.requestData(config.URL.GETRANKRANGR, param).then(res => {
 
- 					console.log('获取默认的游戏数据:GETRANKRANGR=====', res);
 
- 					if (res.data != null) {
 
- 						state.rankSelectedGame = res.data.gameInfo;
 
- 						state.rankInfo = res.data.rankInfo;
 
- 						//然后获取排名
 
- 					}
 
- 					if (callback)
 
- 						callback(res);
 
- 				},
 
- 				e => {
 
- 					console.log(e)
 
- 				});
 
- 		},
 
- 		/**
 
- 		 * 苹果端登陆
 
- 		 * @param {Object} state
 
- 		 * @param {Object} data
 
- 		 */
 
- 		appleUserInfoLogin(state, data) {
 
- 			let self = this;
 
- 			let {
 
- 				params,
 
- 				callback
 
- 			} = data;
 
- 			console.log('获取用户数据:USERINFOAPPLEADD params=====', params);
 
- 			reqUtil.requestData(config.URL.USERINFOAPPLEADD, params, 'POST').then(res => {
 
- 					console.log('获取用户数据:USERINFOAPPLEADD =====', res);
 
- 					if (res.code == 0) {
 
- 						let userInfo = res.data;
 
- 						self.commit('login', userInfo);
 
- 						console.log("11~~");
 
- 					} else if (res.code = 201) {
 
- 						state.hasLogin = true;
 
- 					}
 
- 					console.log("apple callback!!!");
 
- 					callback();
 
- 				},
 
- 				e => {
 
- 					console.log(e)
 
- 				});
 
- 		},
 
- 		//添加用户信息和登录
 
- 		addUserAvatarAndLogin(state, data) {
 
- 			let self = this;
 
- 			let {
 
- 				params,
 
- 				filePath,
 
- 				callback
 
- 			} = data;
 
- 			console.log("addUserAvatarAndLogin 初始化对应数据");
 
- 			reqUtil.reqUpload(config.URL.USERINFOADDAVATARINFO, params, filePath).then(res => {
 
- 					console.log('获取用户数据:USERINFOADDAVATARINFO =====', res);
 
- 					if (res.code == 0) {
 
- 						let userInfo = res.data;
 
- 						self.commit('login', userInfo);
 
- 					} else if (res.code = 201) {
 
- 						state.hasLogin = true;
 
- 					}
 
- 					if (callback) {
 
- 						callback();
 
- 					}
 
- 				},
 
- 				e => {
 
- 					console.log(e)
 
- 				});
 
- 		},
 
- 		//app登录或h5
 
- 		accountLogin(state, callback) {
 
- 			let self = this;
 
- 			// console.log("app登录或h5 初始化对应数据")
 
- 			reqUtil.requestData(config.URL.USERINFOURL).then(res => {
 
- 					console.warn('获取用户数据:USERINFOURL =====', res);
 
- 					if (res.code == 0) {
 
- 						let userInfo = res.data.userInfo;
 
- 						state.phoneNumber = res.data.phoneNumber || '';
 
- 						state.mailboxNumber = res.data.mailboxNumber || '';
 
- 						state.setPasswordFirstTime = res.data.setPasswordFirstTime;
 
- 						state.openid = res.data.openid || '';
 
- 						self.commit('login', userInfo);
 
- 					} else if (res.code = 201) {
 
- 						state.hasLogin = true;
 
- 						//新用户重置一下新手教程数据
 
- 						self.commit('setGuideUnlockState', {
 
- 							//是否首次安装
 
- 							firstInstallation: true, //是否首次安装
 
- 							firstDisconnectBluetooth: true, //是否首次连接蓝牙
 
- 							firstUnlockJumpUp: true, //是否首次向上跳
 
- 							firstUnlockLeftAndRightJump: true, //是否首次左右跳
 
- 							firstUnlockLeftAndRightRotationJump: true,
 
- 							firstPromptSelectLevel: true //是否首次提示选择关卡
 
- 						});
 
- 					}
 
- 					if (callback) {
 
- 						callback();
 
- 					}
 
- 				},
 
- 				e => {
 
- 					console.log(e)
 
- 				});
 
- 		},
 
- 		//小程序页面登录
 
- 		login(state, userInfo) {
 
- 			console.log("登陆的信息==", userInfo);
 
- 			if (userInfo.cityCode == "" || userInfo.cityCode == null) {
 
- 				//不存在就设置默认值
 
- 				userInfo.cityCode = state.city.cityCode;
 
- 			}
 
- 			let cityCode = userInfo.cityCode;
 
- 			// console.log("cicicicitycode:", cityCode);
 
- 			let provinceData = require('@/components/slambb-picker/city-data/province.js').default;
 
- 			let cityData = require('@/components/slambb-picker/city-data/city.js').default;
 
- 			let areaData = require('@/components/slambb-picker/city-data/area.js').default;
 
- 			// 解析citycode
 
- 			for (let i = 0; i < provinceData.length; i++) {
 
- 				if (provinceData[i].value == cityCode.substr(0, 2)) {
 
- 					let currentCityData = cityData[i];
 
- 					for (let j = 0; j < currentCityData.length; j++) {
 
- 						if (currentCityData[j].value == cityCode.substr(0, 4)) {
 
- 							let areaDataTemp = areaData[i][j];
 
- 							for (let k = 0; k < areaDataTemp.length; k++) {
 
- 								if (areaDataTemp[k].value == cityCode) {
 
- 									state.city.value = [i, j, k];
 
- 									state.city.label = provinceData[i].label +
 
- 										'-' +
 
- 										currentCityData[j].label +
 
- 										'-' +
 
- 										areaDataTemp[k].label;
 
- 									state.cityName = currentCityData[j].label;
 
- 									break;
 
- 								}
 
- 							}
 
- 							break;
 
- 						}
 
- 					}
 
- 					break;
 
- 				}
 
- 			}
 
- 			state.userInfo = userInfo;
 
- 			state.userName = userInfo.username || '新用户';
 
- 			state.avatarUrl = userInfo.avatarUrl || '/static/defaultAvatar.png';
 
- 			state.gender = userInfo.gender;
 
- 			state.signature = userInfo.signature || '';
 
- 			state.birthday = userInfo.birthday;
 
- 			state.city.cityCode = cityCode.toString();
 
- 			state.weight = userInfo.weight || state.weight;
 
- 			state.height = userInfo.height || state.height;
 
- 			state.hasLogin = true;
 
- 			//登录时候 获取一下排行榜里面的游戏
 
- 			// this.commit('getRankGame', {
 
- 			// 	param: {
 
- 			// 		type: "china",
 
- 			// 		cityCode: 12345
 
- 			// 	}
 
- 			// });
 
- 			//登录之后,进入此页面先设置平台参数
 
- 			if (state.platform == "ios") {
 
- 				uni.setStorageSync("platform", 1);
 
- 			} else if (state.platform == "android") {
 
- 				uni.setStorageSync("platform", 0);
 
- 			}
 
- 			//获取版本信息
 
- 			this.commit('getVersionCode');
 
- 		},
 
- 		// 退出登录
 
- 		// 删除token 操作
 
- 		delectToken(state, data) {
 
- 			let self = this;
 
- 			let {
 
- 				success
 
- 			} = data;
 
- 			reqUtil.requestData(config.URL.USERLOGINOUT, {}).then(res => {
 
- 					console.log('USERLOGINOUT=====', res);
 
- 					self.commit("logout");
 
- 					try {
 
- 						//清空保存的storage
 
- 						uni.clearStorageSync();
 
- 					} catch (e) {
 
- 						// error
 
- 						console.error(e);
 
- 					}
 
- 					if (state.BLERSSIInterval) {
 
- 						clearInterval(state.BLERSSIInterval);
 
- 						state.BLERSSIInterval = null;
 
- 					}
 
- 					if (state.BLEConnectDevice) {
 
- 						self.commit("onCloseBLEConnection", {
 
- 							getSuccess: () => {}
 
- 						});
 
- 					}
 
- 					if (success) {
 
- 						success(res);
 
- 					}
 
- 				},
 
- 				e => {
 
- 					console.log(e)
 
- 				});
 
- 		},
 
- 		logout(state) {
 
- 			state.userInfo = null;
 
- 			state.userName = "匿名";
 
- 			state.avatarUrl = '/static/defaultAvatar.png';
 
- 			state.days = '0';
 
- 			state.signature = '';
 
- 			state.gender = 0;
 
- 			state.hasLogin = false;
 
- 			state.phoneNumber = '';
 
- 			state.mailboxNumber = '';
 
- 			state.openid = '';
 
- 			state.appleid = '';
 
- 			//处理设备值
 
- 			state.cIndex = -1;
 
- 			//绑定的设备
 
- 			state.ConnectBindingDevice = null;
 
- 			//蓝牙设备
 
- 			state.BLEConnectDevice = null;
 
- 			//蓝牙服务
 
- 			state.BLEGetServices = null;
 
- 			//最近连接过的设备
 
- 			state.finallyUseDevice = null;
 
- 			//最近选择的好友
 
- 			state.finallySelectFriendInfo = null;
 
- 			//记录的蓝牙设备,保存id, 和对应的蓝牙连接数据
 
- 			state.BLEDeviceList = [];
 
- 			//显示的蓝牙设备,取本地数据时候更新
 
- 			state.BLEDeviceShowList = [];
 
- 			//记录表盘计划刷新的卡路里
 
- 			state.oldArcbarProCalorie = 0;
 
- 			//记录表盘当前的总卡路里
 
- 			state.oldArcbarAllCalorie = 0;
 
- 			//任务相关
 
- 			state.currentJumpTask = null;
 
- 		},
 
- 		loginUserInfo(state, data) {
 
- 			let {
 
- 				infoRes,
 
- 				success,
 
- 				fail
 
- 			} = data;
 
- 			console.log('loginUserInfo');
 
- 			reqUtil.requestData(config.URL.WXGETUSERINFO, {
 
- 				appid: 'wxd6dfd60729d33d17',
 
- 				encryptedData: infoRes.encryptedData,
 
- 				iv: infoRes.iv,
 
- 				signature: infoRes.signature,
 
- 				rawData: infoRes.rawData
 
- 			}).then(res => {
 
- 					console.log('wxInfoRes=====', res);
 
- 					let userInfo = res.data;
 
- 					this.commit('login', userInfo);
 
- 					if (success) {
 
- 						success(res);
 
- 					}
 
- 				},
 
- 				e => {
 
- 					console.log(e)
 
- 					if (fail) {
 
- 						success(fail);
 
- 					}
 
- 				});
 
- 		},
 
- 		//这里统一静默处理login
 
- 		oauth(state, context) {
 
- 			let {
 
- 				value,
 
- 				callback
 
- 			} = context;
 
- 			uni.login({
 
- 				provider: value,
 
- 				success: (res) => {
 
- 					// console.log('code:', res);
 
- 					reqUtil.requestData(config.URL.USERlOGINURL, {
 
- 						appid: 'wxd6dfd60729d33d17',
 
- 						code: res.code,
 
- 						platfrom: value
 
- 					}).then(res => {
 
- 							console.log('login token=====', res);
 
- 							state.token = res.data.token;
 
- 							uni.setStorageSync('token', state.token);
 
- 							uni.getUserInfo({
 
- 								provider: value,
 
- 								success: (infoRes) => {
 
- 									if (callback) {
 
- 										callback(infoRes);
 
- 									}
 
- 								},
 
- 								fail: (failRes) => {
 
- 									//假如没有授权,login 之后,不做处理,需要用户点击授权时候,再进行处理用户登录
 
- 									console.log('getUserInfo failRes:', failRes)
 
- 								}
 
- 							});
 
- 						},
 
- 						e => {
 
- 							console.log(e)
 
- 						});
 
- 				},
 
- 				fail: (err) => {
 
- 					console.error('授权登录失败:' + JSON.stringify(err));
 
- 				}
 
- 			});
 
- 		},
 
- 		onLuanchLogin(state, data) {
 
- 			let {
 
- 				success
 
- 			} = data;
 
- 			const filters = ['weixin', 'qq', 'sinaweibo'];
 
- 			let platform = '';
 
- 			uni.getProvider({
 
- 				service: 'oauth',
 
- 				success: (res) => {
 
- 					if (res.provider && res.provider.length) {
 
- 						for (let i = 0; i < res.provider.length; i++) {
 
- 							if (~filters.indexOf(res.provider[i])) {
 
- 								platform = res.provider[i];
 
- 								console.log("platform=", platform);
 
- 								uni.showToast({
 
- 									icon: 'loading',
 
- 									title: ''
 
- 								})
 
- 								this.commit('oauth', {
 
- 									value: platform,
 
- 									callback: (infoRes) => {
 
- 										// console.log("infoRes:", infoRes);
 
- 										this.commit('loginUserInfo', {
 
- 											infoRes: infoRes,
 
- 											success: (res) => {
 
- 												console.log("获取用户成功");
 
- 												if (success) {
 
- 													success(res);
 
- 												}
 
- 												uni.hideToast();
 
- 											},
 
- 											fail: (res) => {
 
- 												console.error("获取用户失败");
 
- 												uni.hideToast();
 
- 											}
 
- 										});
 
- 									}
 
- 								})
 
- 							}
 
- 						}
 
- 						this.hasProvider = true;
 
- 					}
 
- 				},
 
- 				fail: (err) => {
 
- 					console.error('获取服务供应商失败:' + JSON.stringify(err));
 
- 				}
 
- 			});
 
- 		},
 
- 		initAdapter(state, callback) {
 
- 			//初始化蓝牙模块
 
- 			let params = {
 
- 				success: (res) => {
 
- 					state.bOpenSuccess = true;
 
- 					state.bOpenBluetooth = true;
 
- 					if (callback)
 
- 						callback(res);
 
- 					//监听断开事件
 
- 					this.commit("B_OnBLEConnectionStateChange");
 
- 				},
 
- 				fail: (fail) => {
 
- 					state.bOpenSuccess = false;
 
- 					state.bOpenBluetooth = false;
 
- 					uni.showToast({
 
- 						title: '蓝牙尚未开启!',
 
- 						icon: 'none'
 
- 					})
 
- 				},
 
- 				complete: (complete) => {
 
- 					// console.log("complete bListenAdapterStateChange:", state.bListenAdapterStateChange);
 
- 					if (state.bListenAdapterStateChange) return;
 
- 					state.bListenAdapterStateChange = true;
 
- 					uni.onBluetoothAdapterStateChange((res) => {
 
- 						// console.log('adapterState changed, now is', res)
 
- 						// 手机蓝牙状态
 
- 						state.bOpenBluetooth = res.available;
 
- 						if (state.bOpenBluetooth && !state.bOpenSuccess) {
 
- 							this.commit('initAdapter');
 
- 						}
 
- 					})
 
- 				}
 
- 			};
 
- 			this.commit("B_OpenBluetoothAdapter", params);
 
- 		},
 
- 		// todo 未使用到
 
- 		onGetDevices(state, context) {
 
- 			let {
 
- 				success
 
- 			} = context;
 
- 			if (!state.BLEConnectDevice) return;
 
- 			// #ifdef APP-PLUS
 
- 			let deviceId = state.BLEConnectDevice.deviceId;
 
- 			uni.getBLEDeviceRSSI({
 
- 				deviceId,
 
- 				success: res => {
 
- 					let _dis = Math.pow(Math.E, (Math.abs(res.RSSI) - 66.78) / 16.56);
 
- 					if (_dis > state.BLEConnectDevice.limitDis) {
 
- 						if (state.cIndex != -1) {
 
- 							uni.showToast({
 
- 								title: '设备断开连接!',
 
- 								icon: 'none',
 
- 								duration: 2000,
 
- 								mask: true
 
- 							})
 
- 						}
 
- 						setTimeout(() => {
 
- 							this.commit("B_CloseBLEConnection", {
 
- 								deviceId: deviceId
 
- 							})
 
- 							state.cIndex = -1;
 
- 							state.bConnection = false;
 
- 							state.bVerifiedConnection = false;
 
- 						}, 1000)
 
- 					} else {
 
- 						// console.log("DIS~~~~~~~~~", _dis);
 
- 						if (success) {
 
- 							success({
 
- 								RSSI: res.RSSI,
 
- 								DIS: _dis
 
- 							});
 
- 						}
 
- 					}
 
- 				}
 
- 			})
 
- 			// #endif
 
- 		},
 
- 		//清除连接的开启的timeout
 
- 		onUnloadCreateBLEConnectionTimeout(state) {
 
- 			if (state.getBLEDeviceServicesTimeout) {
 
- 				clearTimeout(state.getBLEDeviceServicesTimeout);
 
- 				state.getBLEDeviceServicesTimeout = null;
 
- 			}
 
- 		},
 
- 		initBLEData(state) {
 
- 			// 设备Id
 
- 			state.deviceId = "";
 
- 			// 服务Id
 
- 			state.serviceId = "";
 
- 			state.notifyCharacteristicId = "";
 
- 			state.writeCharacteristicId = "";
 
- 			state.currentInstruction = "";
 
- 			state.showToast = false;
 
- 			state.bListenerUpdate = false;
 
- 			state.bListenerJson = false;
 
- 			state.bListenerMac = false;
 
- 			state.bListenerAccArray = false;
 
- 			//更新二进制的
 
- 			state.bListenerHexUpdate = false;
 
- 		},
 
- 		//连接蓝牙
 
- 		onCreateBLEConnection(state, context) {
 
- 			let {
 
- 				index,
 
- 				item,
 
- 				initItem = false,
 
- 				getSuccess = null,
 
- 				getinitAdapter = null
 
- 			} = context;
 
- 			uni.showToast({
 
- 				title: '连接设备中...',
 
- 				icon: 'loading',
 
- 				duration: 10000,
 
- 				mask: true
 
- 			})
 
- 			let params = {
 
- 				item: item,
 
- 				success: (success) => {
 
- 					state.bConnection = true;
 
- 					if (state.getBLEDeviceServicesTimeout) {
 
- 						clearTimeout(state.getBLEDeviceServicesTimeout);
 
- 						state.getBLEDeviceServicesTimeout = null;
 
- 					}
 
- 					state.getBLEDeviceServicesTimeout = setTimeout(() => {
 
- 						let retryCount = 5;
 
- 						this.commit("B_GetBLEDeviceServices", {
 
- 							retryCount: retryCount,
 
- 							item: item,
 
- 							callback: () => {
 
- 								uni.showToast({
 
- 									title: '连接成功',
 
- 									icon: 'loading',
 
- 									duration: 2000,
 
- 									mask: true
 
- 								})
 
- 								//是否需要设置item,默认不设置
 
- 								if (initItem) {
 
- 									state.cIndex = index;
 
- 									state.BLEConnectDevice = item;
 
- 								}
 
- 								if (getSuccess)
 
- 									getSuccess();
 
- 								/**
 
- 								 * 直接连接过成功
 
- 								 */
 
- 								state.bVerifiedConnection = true;
 
- 							},
 
- 							getServiceList: (serviceList) => {
 
- 								//搜索服务失败后
 
- 								state.BLEGetServices = serviceList;
 
- 							},
 
- 							getFail: () => {
 
- 								this.commit("B_CloseBLEConnection", {
 
- 									deviceId: item.deviceId
 
- 								})
 
- 								// state.cIndex = -1;
 
- 								// state.bConnection = false;
 
- 								// state.bVerifiedConnection = false;
 
- 								this.commit("onResetBLEConnection");
 
- 							}
 
- 						});
 
- 					}, 2000);
 
- 				},
 
- 				fail: (fail) => {
 
- 					console.log("***fail:", fail);
 
- 					if (fail.errCode === 10012) {
 
- 						console.log("连接超时,请重试!");
 
- 						uni.showToast({
 
- 							title: '连接失败,开启设备后尝试重新连接!',
 
- 							icon: 'none',
 
- 							duration: 3000,
 
- 							mask: true
 
- 						})
 
- 					} else if (fail.errCode === 10013) {
 
- 						console.log("连接失败,蓝牙地址无效!");
 
- 						uni.showToast({
 
- 							title: '连接失败,蓝牙地址无效',
 
- 							icon: 'none',
 
- 							duration: 2000,
 
- 							mask: true
 
- 						})
 
- 					} else if (fail.errCode === 10000) {
 
- 						this.commit('initAdapter', () => {
 
- 							if (getinitAdapter) {
 
- 								getinitAdapter();
 
- 							}
 
- 						})
 
- 					} else {
 
- 						// err.errCode10003原因多种:蓝牙设备未开启或异常导致无法连接;蓝牙设备被占用或者上次蓝牙连接未断开导致无法连接
 
- 						console.log("连接失败,请重试!", state.BLEConnectDevice);
 
- 						uni.showToast({
 
- 							title: '请尝试开启设备和重启app。',
 
- 							icon: 'none',
 
- 							duration: 2000,
 
- 							mask: true
 
- 						})
 
- 					}
 
- 				}
 
- 			};
 
- 			this.commit("B_CreateBLEConnection", params);
 
- 		},
 
- 		//devices hardware 连接后验证,这里不需要处理 bVerifiedConnection,通过mac 验证后处理
 
- 		onCreateBLESuccess(state, context) {
 
- 			let {
 
- 				item,
 
- 				getSuccess = null
 
- 			} = context;
 
- 			this.commit("B_CreateBLEConnection", {
 
- 				item: item,
 
- 				success: success => {
 
- 					state.BLEConnectDevice = item;
 
- 					state.bConnection = true;
 
- 					if (getSuccess) {
 
- 						getSuccess();
 
- 					}
 
- 				},
 
- 				fail: fail => {
 
- 					if (fail.errCode === 10012) {
 
- 						console.log("连接超时,请重试!");
 
- 						uni.showToast({
 
- 							title: '连接超时,检查对应设备是否开启?',
 
- 							icon: 'none',
 
- 							duration: 2000,
 
- 							mask: true
 
- 						})
 
- 					} else if (fail.errCode === 10013) {
 
- 						console.log("连接失败,蓝牙地址无效!");
 
- 						uni.showToast({
 
- 							title: '蓝牙地址无效,检查设备是否正常?',
 
- 							icon: 'none',
 
- 							duration: 2000,
 
- 							mask: true
 
- 						})
 
- 					} else if (fail.errCode === 10000) {
 
- 						console.log("连接失败,初始化 wx.openBluetoothAdapter 调用之后使用");
 
- 						uni.showToast({
 
- 							title: '连接失败,检查手机蓝牙是否开启?',
 
- 							icon: 'none',
 
- 							duration: 2000,
 
- 							mask: true
 
- 						})
 
- 					} else {
 
- 						console.log("连接失败,请重试!");
 
- 						uni.showModal({
 
- 							title: '连接失败',
 
- 							content: '设备未开启或被占用。请重启app和设备后重新连接。'
 
- 						})
 
- 						// uni.showToast({
 
- 						// 	title: '设备未开启或被占用异常导致无法连接。',
 
- 						// 	icon: 'none',
 
- 						// 	duration: 2000,
 
- 						// 	mask: true
 
- 						// })
 
- 					}
 
- 				}
 
- 			});
 
- 		},
 
- 		//获取蓝牙服务
 
- 		onGetBLEDeviceServices(state, context) {
 
- 			let {
 
- 				item,
 
- 				success = null,
 
- 			} = context;
 
- 			let retryCount = 5;
 
- 			this.commit("B_GetBLEDeviceServices", {
 
- 				retryCount: retryCount,
 
- 				item: item,
 
- 				callback: success,
 
- 				getServiceList: (serviceList) => {
 
- 					state.BLEGetServices = serviceList;
 
- 				},
 
- 				getFail: () => {
 
- 					this.commit("B_CloseBLEConnection", {
 
- 						deviceId: item.deviceId
 
- 					})
 
- 					this.commit("onResetBLEConnection");
 
- 				}
 
- 			})
 
- 		},
 
- 		//重置蓝牙连接参数
 
- 		onResetBLEConnection(state) {
 
- 			state.cIndex = -1;
 
- 			state.BLEConnectDevice = null;
 
- 			//蓝牙服务
 
- 			state.BLEGetServices = null;
 
- 			state.bConnection = false;
 
- 			state.bVerifiedConnection = false;
 
- 		},
 
- 		onCloseBLEConnection(state, context) {
 
- 			console.log("onCloseBLEConnection", state.BLEConnectDevice);
 
- 			let {
 
- 				getSuccess = null,
 
- 			} = context;
 
- 			if (state.BLERSSIInterval) {
 
- 				clearInterval(state.BLERSSIInterval);
 
- 				state.BLERSSIInterval = null;
 
- 			}
 
- 			this.commit("B_CloseBLEConnection", {
 
- 				deviceId: state.BLEConnectDevice.deviceId,
 
- 				success: () => {
 
- 					state.cIndex = -1;
 
- 					state.BLEConnectDevice = null;
 
- 					//蓝牙服务
 
- 					state.BLEGetServices = null;
 
- 					if (getSuccess) {
 
- 						getSuccess();
 
- 					}
 
- 					state.bConnection = false;
 
- 					state.bVerifiedConnection = false;
 
- 					uni.closeBluetoothAdapter({
 
- 						success(res) {
 
- 							console.log(res)
 
- 							state.bOpenBluetooth = false;
 
- 						}
 
- 					})
 
- 				}
 
- 			});
 
- 		},
 
- 		//不关闭 adapter
 
- 		onOnlyCloseBLEConnection(state, context) {
 
- 			let {
 
- 				getSuccess = null
 
- 			} = context;
 
- 			if (state.BLERSSIInterval) {
 
- 				clearInterval(state.BLERSSIInterval);
 
- 				state.BLERSSIInterval = null;
 
- 			}
 
- 			this.commit("B_CloseBLEConnection", {
 
- 				deviceId: state.BLEConnectDevice.deviceId,
 
- 				success: () => {
 
- 					state.cIndex = -1;
 
- 					state.BLEConnectDevice = null;
 
- 					//蓝牙服务
 
- 					state.BLEGetServices = null;
 
- 					if (getSuccess) {
 
- 						getSuccess();
 
- 					}
 
- 					state.bConnection = false;
 
- 					state.bVerifiedConnection = false;
 
- 				}
 
- 			});
 
- 		},
 
- 		onWriteBLEConnectionValue(state, context) {
 
- 			//#ifdef H5
 
- 			console.warn("h5不支持蓝牙:", 'onWriteBLEConnectionValue');
 
- 			return;
 
- 			//#endif
 
- 			let {
 
- 				getSuccess = null,
 
- 					getFail = null,
 
- 					value,
 
- 					bSendHex = false,
 
- 					bOpen = false,
 
- 			} = context;
 
- 			if (!state.BLEConnectDevice && state.cIndex == -1) {
 
- 				uni.showToast({
 
- 					title: '蓝牙设备未连接',
 
- 					icon: 'none'
 
- 				})
 
- 			}
 
- 			// console.log(22);
 
- 			//记录蓝牙盒子当前的指令
 
- 			// state.currentInstruction = value;
 
- 			// 发送 3 :开启原始数据
 
- 			// 发送4 :关闭原始数据
 
- 			// 发送 5 :开启步数
 
- 			// 发送6 :关闭步数
 
- 			if (value == "3") {
 
- 				state.instructionState.bOpen = true;
 
- 			} else if (value == "4") {
 
- 				state.instructionState.bOpen = false;
 
- 			} else if (value == "5") {
 
- 				state.instructionState.bSteps = true;
 
- 			} else if (value == "6") {
 
- 				state.instructionState.bSteps = false;
 
- 			} else if (bSendHex && bOpen) {
 
- 				state.instructionState.bOpen = true;
 
- 			} else if (bSendHex && !bOpen) {
 
- 				state.instructionState.bOpen = false;
 
- 			}
 
- 			let retryCount = 5;
 
- 			this.commit("B_WriteBLECharacteristicValue", {
 
- 				value,
 
- 				retryCount,
 
- 				getSuccess,
 
- 				getFail,
 
- 				bSendHex
 
- 			});
 
- 		},
 
- 		//获取距离
 
- 		onGetRSSITransDistance(state, context) {
 
- 			let {
 
- 				RSSI
 
- 			} = context;
 
- 			BLE.getRSSITransDistance(RSSI);
 
- 		},
 
- 		//添加使用的前端信息
 
- 		gOnAddClientInfo(state, context) {
 
- 			uni.getSystemInfo({
 
- 				success: (res) => {
 
- 					// console.log("系统信息:", res);
 
- 					let clientInfo = res;
 
- 					clientInfo.clientSystem = res.system;
 
- 					reqUtil.requestData(config.URL.ADDCLIENTINFO, clientInfo, 'POST').then(
 
- 						res => {
 
- 							console.warn(res);
 
- 						},
 
- 						e => {}
 
- 					);
 
- 				},
 
- 				fail: (err) => {},
 
- 				complete: () => {}
 
- 			})
 
- 		},
 
- 		//创建快速打击对象
 
- 		gCreateFilterObj(state) {
 
- 			state.filter = null;
 
- 			state.deviceMs = 1;
 
- 			state.filter = new o0Project.Filter();
 
- 			console.log("gCreateFilterObj");
 
- 		},
 
- 		//更新快速打击对象数据
 
- 		gUpdateFilter(state, context) {
 
- 			let {
 
- 				data,
 
- 				callback
 
- 			} = context;
 
- 			let {
 
- 				min,
 
- 				s,
 
- 				ms
 
- 			} = data;
 
- 			var msGap = ms - state.deviceMs;
 
- 			state.deviceMs = ms;
 
- 			while (msGap < 0) {
 
- 				msGap += 1000;
 
- 			}
 
- 			// console.log(data);
 
- 			let {
 
- 				ax,
 
- 				ay,
 
- 				az
 
- 			} = data.acc;
 
- 			let {
 
- 				gx,
 
- 				gy,
 
- 				gz
 
- 			} = data.gyro;
 
- 			// console.log(ax);
 
- 			state.filter.Update(new o0.Vector3(ax, ay, az), msGap, new o0.Vector3(gx, gy, gz),
 
- 				callback); //我自己的更新acc的函数
 
- 		},
 
- 		/**
 
- 		 * 创建一个沙袋打击对象
 
- 		 * @param {Object} state
 
- 		 */
 
- 		gCreateSandbagAlgorithm(state) {
 
- 			state.sandbagAlgorithm = null;
 
- 			state.sandbagAlgorithmLastTime = new Date().getTime();
 
- 			state.sandbagAlgorithm = new o0ProjectRelease.SandbagAlgorithm();
 
- 			console.log("gCreateSandbagAlgorithm");
 
- 		},
 
- 		/**
 
- 		 * 更新 沙袋打击对象 数据
 
- 		 * @param {Object} state
 
- 		 * @param {Object} context
 
- 		 */
 
- 		gUpdateSandbagAlgorithm(state, context) {
 
- 			let {
 
- 				data,
 
- 				callback = null
 
- 			} = context;
 
- 			let {
 
- 				ax,
 
- 				ay,
 
- 				az
 
- 			} = data.acc;
 
- 			let {
 
- 				gx,
 
- 				gy,
 
- 				gz
 
- 			} = data.gyro;
 
- 			/**
 
- 			 * ax / 10, az / 10, gz, -gx, data.ms ----- old
 
- 			 * ay / 10, -az / 10, gy, gz, data.msK
 
- 			 * let [hit, dir] = state.sandbagAlgorithm.Update(-ay, az, -gz, -gy, data.ms);
 
- 			 * 纠正后使用的轴向
 
- 			 * 	box["acc"] = {
 
- 						ax: -ay,
 
- 						ay: -ax,
 
- 						az: az
 
- 					};
 
- 					box["gyro"] = {
 
- 						gx: -gy,
 
- 						gy: -gx,
 
- 						gz: gz
 
- 					};
 
- 			 */
 
- 			let {
 
- 				ms
 
- 			} = data;
 
- 			let msGap = ms - state.deviceMs;
 
- 			state.deviceMs = ms;
 
- 			while (msGap < 0) {
 
- 				msGap += 1000;
 
- 			}
 
- 			let [hit, dir] = state.sandbagAlgorithm.Update(ax, az, -gz, gx, msGap);
 
- 			if (dir != undefined) {
 
- 				let temp = state.sandbagAlgorithm.getTempValue(dir);
 
- 				if (callback) {
 
- 					callback(temp);
 
- 				}
 
- 				// let hitCount = temp.hitCount;
 
- 			}
 
- 		},
 
- 		/**
 
- 		 * 开启加速计,陀螺仪,并且模拟ble发送
 
- 		 * @param {Object} state
 
- 		 */
 
- 		gStartSimulateBLEUpdate(state) {
 
- 			//todo 区分平台,目前是android 模块
 
- 			if (state.globalMyAttitude == null) {
 
- 				state.globalMyAttitude = uni.requireNativePlugin("MyAttitude");
 
- 				let globalEvent = uni.requireNativePlugin('globalEvent');
 
- 				globalEvent.addEventListener('updateAccAndGyro', function(e) {
 
- 					//updateAccAndGyro{"accelerometer":[-0.178375244140625,9.327804565429688,2.6168670654296875],"gyroscope":[0.0018310546875,-0.0019989013671875,0.0027923583984375]}
 
- 					//console.log('updateAccAndGyro' + JSON.stringify(e));
 
- 					let _accArray = e.accelerometer;
 
- 					let _gyroArray = e.gyroscope;
 
- 					state.globalAccData.ax = _accArray[0];
 
- 					state.globalAccData.ay = _accArray[1];
 
- 					state.globalAccData.az = _accArray[2];
 
- 					state.globalGyroData.gx = _gyroArray[0];
 
- 					state.globalGyroData.gy = _gyroArray[1];
 
- 					state.globalGyroData.gz = _gyroArray[2];
 
- 					let box = {};
 
- 					box["acc"] = state.globalAccData;
 
- 					box["gyro"] = state.globalGyroData;
 
- 					box["ms"] = e.ms;
 
- 					//更新数据给webview,在game-play-web||game-play-sub绑定
 
- 					//后面更新数据都用此接口
 
- 					uni.$emit('updateBLEDeviceData', box);
 
- 				});
 
- 			}
 
- 			var ret = state.globalMyAttitude.onStartAccAndGyro();
 
- 			if (!ret.accelerometer || !ret.gyroscope) {
 
- 				uni.showModal({
 
- 					title: '提示',
 
- 					content: '是否初始化,加速计:' + ret.accelerometer + ',陀螺仪:' + ret.gyroscope
 
- 				})
 
- 			}
 
- 			console.log('gStartSimulateBLEUpdate:', ret);
 
- 		},
 
- 		/**
 
- 		 * 停止加速计,陀螺仪
 
- 		 * @param {Object} state
 
- 		 */
 
- 		gStopSimulateBLEUpdate(state) {
 
- 			//todo 区分平台,目前是android 模块
 
- 			let globalEvent = uni.requireNativePlugin('globalEvent');
 
- 			globalEvent.removeEventListener('updateAccAndGyro');
 
- 			var ret = state.globalMyAttitude.onStopAccAndGyro();
 
- 			console.log('gStopSimulateBLEUpdate:', ret);
 
- 			state.globalMyAttitude = null;
 
- 		},
 
- 		/**
 
- 		 * 限制开始游戏
 
- 		 */
 
- 		glimitPlayGame(state, context) {
 
- 			let {
 
- 				gameTags,
 
- 				callback
 
- 			} = context;
 
- 			//没有标签直接进去
 
- 			if (gameTags.length == 0) {
 
- 				callback();
 
- 				return;
 
- 			}
 
- 			let canPlay = false;
 
- 			gameTags.forEach((item) => {
 
- 				//如果存在普通模式
 
- 				if (item.tagMode === 'normal') {
 
- 					canPlay = true;
 
- 				}
 
- 				if (canPlay)
 
- 					return;
 
- 			})
 
- 			if (!canPlay) {
 
- 				//2.如果普通模式不存在,就判断是否连接硬件了
 
- 				if (!state.BLEConnectDevice || state.cIndex == -1) {
 
- 					uni.showToast({
 
- 						title: "请连接标签对应的设备模式!",
 
- 						icon: "none",
 
- 						duration: 2000,
 
- 						mask: true
 
- 					})
 
- 					return;
 
- 				}
 
- 				//3.如果连接了设备,判断但是处于什么模式
 
- 				gameTags.forEach((item, index, selfArr) => {
 
- 					//如果存在普通模式
 
- 					if (item.tagMode === state.BLEConnectDevice.usageMode) {
 
- 						canPlay = true;
 
- 					}
 
- 					if (canPlay)
 
- 						return;
 
- 					if (index == selfArr.length - 1) {
 
- 						uni.showToast({
 
- 							title: "游戏没有当前设备模式!",
 
- 							icon: "none",
 
- 							duration: 2000,
 
- 							mask: true
 
- 						})
 
- 					}
 
- 				})
 
- 			}
 
- 			if (canPlay) {
 
- 				callback();
 
- 			}
 
- 		},
 
- 		checkAppUpdata(state) {
 
- 			//#ifdef APP-PLUS
 
- 			let _temp = {
 
- 				appid: plus.runtime.appid,
 
- 				version: state.version,
 
- 				versionCode: state.versionCode,
 
- 				platform: state.platform.toLocaleLowerCase(),
 
- 			}
 
- 			//#endif
 
- 			//#ifdef H5
 
- 			//此 _temp 测试用
 
- 			let _temp = {
 
- 				appid: '1',
 
- 				version: "2.0.0",
 
- 				versionCode: "20122202",
 
- 				platform: "android",
 
- 			}
 
- 			//#endif
 
- 			reqUtil.requestData(config.URL.APPVERSIONUPDATE, _temp).then(res => {
 
- 					console.log('requestData APPVERSIONUPDATE =====', res);
 
- 					let _data = res.data;
 
- 					if (res.code == 0 && res.data.status === 1) {
 
- 						uni.showModal({ //提醒用户更新  
 
- 							title: "更新提示",
 
- 							content: res.data.note,
 
- 							success: (res) => {
 
- 								if (res.confirm) {
 
- 									if (state.platform.toLocaleLowerCase() == "android") {
 
- 										plus.runtime.openURL(_data.url, function(res) {
 
- 											plus.nativeUI.alert("本机没安装应用宝,请安装后获取新版本。");
 
- 										}, 'com.tencent.android.qqdownloader');
 
- 									} else {
 
- 										//ios
 
- 										plus.runtime.openURL(_data.url);
 
- 									}
 
- 								}
 
- 							}
 
- 						})
 
- 					} else {
 
- 						uni.showToast({
 
- 							title: '当前为最新版本',
 
- 							icon: 'none',
 
- 							duration: 2000,
 
- 							mask: true
 
- 						})
 
- 					}
 
- 				},
 
- 				e => {
 
- 					console.log(e)
 
- 				});
 
- 		},
 
- 		/**
 
- 		 * 蓝牙BLE迁移到store.js
 
- 		 */
 
- 		// 初始化蓝牙模块适配器
 
- 		B_OpenBluetoothAdapter(state, context) {
 
- 			let {
 
- 				success,
 
- 				fail,
 
- 				complete
 
- 			} = context;
 
- 			//#ifdef H5
 
- 			console.warn('h5不加载蓝牙模块');
 
- 			return;
 
- 			//#endif
 
- 			uni.openBluetoothAdapter({
 
- 				success: res => {
 
- 					if (success)
 
- 						success(res);
 
- 				},
 
- 				fail: res => {
 
- 					if (fail)
 
- 						fail(res);
 
- 				},
 
- 				complete: res => {
 
- 					if (complete)
 
- 						complete(res);
 
- 				}
 
- 			})
 
- 		},
 
- 		/**
 
- 		 * 关闭蓝牙模块适配器
 
- 		 */
 
- 		B_CloseBluetoothAdapter() {
 
- 			//#ifdef H5
 
- 			console.warn('h5不加载蓝牙模块');
 
- 			return;
 
- 			//#endif
 
- 			uni.closeBluetoothAdapter({
 
- 				success: res => {
 
- 					console.log('断开蓝牙模块成功');
 
- 					uni.showToast({
 
- 						icon: "none",
 
- 						title: "蓝牙已经断开!",
 
- 						mask: false,
 
- 						duration: 3000
 
- 					});
 
- 				}
 
- 			});
 
- 		},
 
- 		B_OnBLEConnectionStateChange(state) {
 
- 			let _self = this;
 
- 			//#ifdef H5
 
- 			console.warn('h5不加载蓝牙模块');
 
- 			return;
 
- 			//#endif
 
- 			uni.onBLEConnectionStateChange(res => {
 
- 				// 该方法回调中可以用于处理连接意外断开等异常情况
 
- 				console.log(`蓝牙连接状态 -------------------------->`, JSON.stringify(res));
 
- 				if (!res.connected) {
 
- 					//要在连接的状态下 ,并且获取过匹配列表有参数的情况下,才提示重连
 
- 					if (!state.bShowBLEConnectModal && state.bVerifiedConnection) {
 
- 						state.bShowBLEConnectModal = true;
 
- 						let _connectItem = Object.assign({}, state.BLEConnectDevice);
 
- 						let _cIndex = state.cIndex;
 
- 						//断开连接后reset一下参数
 
- 						_self.commit("onResetBLEConnection");
 
- 						let _tip = state.bGamePlaying ? "蓝牙已断开是否重新连接蓝牙?重连需要重启游戏!" : "蓝牙已断开是否重新连接蓝牙";
 
- 						uni.showModal({
 
- 							title: _tip,
 
- 							success: (sRes) => {
 
- 								state.bShowBLEConnectModal = false;
 
- 								if (sRes.confirm) {
 
- 									console.log("重连的_cIndex:", _cIndex);
 
- 									_self.commit("onCreateBLEConnection", {
 
- 										item: _connectItem,
 
- 										index: _cIndex,
 
- 										initItem: true,
 
- 										getSuccess: () => {
 
- 											//此处不检查外部设备
 
- 											uni.$emit('retryConnectBLESuccess');
 
- 										},
 
- 										getinitAdapter: () => {}
 
- 									})
 
- 								}
 
- 							}
 
- 						})
 
- 					} else {
 
- 						//断开连接后reset一下参数
 
- 						_self.commit("onResetBLEConnection");
 
- 					}
 
- 					uni.$emit('callbackCloseBLE');
 
- 				}
 
- 			});
 
- 		},
 
- 		/**
 
- 		 * 连接低功耗蓝牙设备。
 
- 		 * 若APP在之前已有搜索过某个蓝牙设备,并成功建立连接,可直接传入之前搜索获取的 deviceId 直接尝试连接该设备,无需进行搜索操作。
 
- 		 */
 
- 		B_CreateBLEConnection(state, context) {
 
- 			let {
 
- 				item,
 
- 				success,
 
- 				fail
 
- 			} = context;
 
- 			this.commit('initBLEData');
 
- 			state.deviceId = item.deviceId;
 
- 			let timeout = 10000;
 
- 			// console.log("B_CreateBLEConnection deviceId ==", state.deviceId)
 
- 			uni.createBLEConnection({
 
- 				// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
 
- 				deviceId: state.deviceId,
 
- 				timeout: timeout,
 
- 				success: res => {
 
- 					if (success) {
 
- 						success(res);
 
- 					}
 
- 				},
 
- 				fail: res => {
 
- 					if (fail)
 
- 						fail(res);
 
- 				}
 
- 			});
 
- 		},
 
- 		/**
 
- 		 * 获取设备的服务ID
 
- 		 */
 
- 		B_GetBLEDeviceServices(state, context) {
 
- 			let {
 
- 				retryCount,
 
- 				item,
 
- 				callback,
 
- 				getServiceList,
 
- 				getFail,
 
- 			} = context;
 
- 			let serviceList = [];
 
- 			let _self = this;
 
- 			uni.getBLEDeviceServices({
 
- 				deviceId: item.deviceId,
 
- 				success: res => {
 
- 					// console.log("getBLEDeviceServices==", JSON.stringify(res), item);
 
- 					serviceList = res.services;
 
- 					if (getServiceList) {
 
- 						getServiceList(serviceList);
 
- 					}
 
- 					if (serviceList.length == 0) {
 
- 						if (retryCount > 0) {
 
- 							retryCount--;
 
- 							context.retryCount = retryCount;
 
- 							setTimeout(() => {
 
- 								this.commit('B_GetBLEDeviceServices', context);
 
- 							}, 500)
 
- 							return;
 
- 						}
 
- 						if (getFail) {
 
- 							getFail();
 
- 						}
 
- 						uni.hideToast();
 
- 						uni.showModal({
 
- 							title: '提示',
 
- 							content: '1.获取服务失败,请尝试重新连接设备。\r\n2.尝试重启设备再重新连接。'
 
- 						})
 
- 					}
 
- 					for (let i = 0; i < serviceList.length; i++) {
 
- 						let service = serviceList[i];
 
- 						if (service.uuid.toLocaleLowerCase() === item.PRIMARY_SERVICE
 
- 							.toLocaleLowerCase()) {
 
- 							state.serviceId = service.uuid;
 
- 							//开始获取指定服务的特征值
 
- 							_self.commit('B_GetBLEDeviceCharacteristics', {
 
- 								item: item,
 
- 								callback: callback
 
- 							});
 
- 							break;
 
- 						}
 
- 					}
 
- 				},
 
- 				fail: failRes => {
 
- 					console.log('device services:', failRes.services);
 
- 					uni.hideToast();
 
- 					uni.showModal({
 
- 						title: '连接错误',
 
- 						content: '请尝试重新连接设备。'
 
- 					})
 
- 					if (getFail) {
 
- 						getFail();
 
- 					}
 
- 				}
 
- 			});
 
- 		},
 
- 		/**
 
- 		 * 获取指定服务的特征值
 
- 		 */
 
- 		B_GetBLEDeviceCharacteristics(state, context) {
 
- 			let {
 
- 				item,
 
- 				callback
 
- 			} = context;
 
- 			let deviceId = state.deviceId;
 
- 			let serviceId = state.serviceId;
 
- 			let characteristicsList = [];
 
- 			uni.getBLEDeviceCharacteristics({
 
- 				deviceId,
 
- 				serviceId,
 
- 				success: res => {
 
- 					if (item.PRIMARY_NOTIFY != '') {
 
- 						state.notifyCharacteristicId = item.PRIMARY_NOTIFY;
 
- 						this.commit('B_NotifyBLECharacteristicValueChange', {
 
- 							callback: callback
 
- 						});
 
- 					}
 
- 					if (item.PRIMARY_WRITE != '') {
 
- 						state.writeCharacteristicId = item.PRIMARY_WRITE;
 
- 					}
 
- 				},
 
- 				fail: res => {
 
- 					console.log('device getBLEDeviceCharacteristics failed:', JSON.stringify(res))
 
- 				}
 
- 			})
 
- 		},
 
- 		//启用低功耗蓝牙设备特征值变化时的 notify 功能,订阅特征值。
 
- 		//注意:必须设备的特征值支持notify或者indicate才可以成功调用,具体参照 characteristic 的 properties 属性
 
- 		B_NotifyBLECharacteristicValueChange(state, context) {
 
- 			let {
 
- 				callback
 
- 			} = context;
 
- 			// 启用notify功能
 
- 			// console.log("启用notify功能");
 
- 			uni.notifyBLECharacteristicValueChange({
 
- 				state: true,
 
- 				deviceId: state.deviceId,
 
- 				serviceId: state.serviceId,
 
- 				characteristicId: state.notifyCharacteristicId,
 
- 				success: (res) => {
 
- 					this.commit('B_OnBLECharacteristicValueChange', {
 
- 						callback: callback
 
- 					});
 
- 				},
 
- 				fail: (res) => {
 
- 					uni.showToast({
 
- 						title: 'notify启动失败',
 
- 						icon: "none",
 
- 						mask: true
 
- 					});
 
- 				}
 
- 			})
 
- 		},
 
- 		//监听低功耗蓝牙设备的特征值变化。必须先启用notify接口才能接收到设备推送的notification。
 
- 		B_OnBLECharacteristicValueChange(state, context) {
 
- 			let {
 
- 				callback
 
- 			} = context;
 
- 			// console.log("onBLECharacteristicValueChange success");
 
- 			if (callback) {
 
- 				callback({
 
- 					notifyCharacteristicId: state.notifyCharacteristicId,
 
- 					writeCharacteristicId: state.writeCharacteristicId
 
- 				})
 
- 			}
 
- 			uni.onBLECharacteristicValueChange(function(res) {
 
- 				//如果是ota 更新服务,这里处理通知ota更新数据
 
- 				if (res.serviceId.toLocaleLowerCase() === state.UUID_OTA_SERVICE) {
 
- 					uni.$emit("OTAValueChange", res);
 
- 					return;
 
- 				}
 
- 				//serviceId 0000FFF0-0000-1000-8000-00805F9B34FB characteristic 0000FFF1-0000-1000-8000-00805F9B34FB
 
- 				// console.log(`store ${res.serviceId} characteristic ${res.characteristicId} has changed, now is ${res.value}`);
 
- 				let box = {};
 
- 				var resValue = BLE.ab2hext(res.value); //16进制字符串
 
- 				if (state.currentInstruction == "V" && state.showToast) {
 
- 					var resValueStr = BLE.hexToString(resValue);
 
- 					let _info = {
 
- 						type: 'version',
 
- 						instruction: 'V',
 
- 						value: resValueStr.replace(/\{|}/g, '').trim()
 
- 					}
 
- 					uni.$emit('listenerBLE', _info);
 
- 					state.currentInstruction = "";
 
- 					state.showToast = false;
 
- 					return;
 
- 				} else if (state.currentInstruction == 'M' && state.bListenerMac) {
 
- 					var resValueStr = BLE.hexToString(resValue);
 
- 					let _info = {
 
- 						type: 'mac',
 
- 						instruction: 'M',
 
- 						value: resValueStr.replace(/\{|}/g, '').trim()
 
- 					}
 
- 					uni.$emit('listenerBLE', _info);
 
- 					state.currentInstruction = "";
 
- 					state.bListenerMac = false;
 
- 					return;
 
- 				}
 
- 				//步数数据解析
 
- 				if (state.bListenerJson) {
 
- 					var resValueStr = BLE.hexToString(resValue);
 
- 					console.log(resValueStr);
 
- 					box["Json"] = resValueStr;
 
- 					uni.$emit('updateBLEDeviceJson', box);
 
- 				}
 
- 				//解析4组加速计数据
 
- 				if (state.bListenerAccArray) {
 
- 					let ms1 = BLE.hex2int(resValue.substr(2, 4));
 
- 					let min1 = BLE.hex2int(resValue.substr(6, 2));
 
- 					let s1 = BLE.hex2int(resValue.substr(8, 2));
 
- 					let ax1Str = resValue.substr(10, 4);
 
- 					let ay1Str = resValue.substr(14, 4);
 
- 					let az1Str = resValue.substr(18, 4);
 
- 					let ax1 = BLE.hexToSignedInt(ax1Str) / 32768 * 16;
 
- 					let ay1 = BLE.hexToSignedInt(ay1Str) / 32768 * 16;
 
- 					let az1 = BLE.hexToSignedInt(az1Str) / 32768 * 16;
 
- 					let ms2 = BLE.hex2int(resValue.substr(22, 4));
 
- 					let min2 = BLE.hex2int(resValue.substr(26, 2));
 
- 					let s2 = BLE.hex2int(resValue.substr(28, 2));
 
- 					let ax2Str = resValue.substr(30, 4);
 
- 					let ay2Str = resValue.substr(34, 4);
 
- 					let az2Str = resValue.substr(38, 4);
 
- 					let ax2 = BLE.hexToSignedInt(ax2Str) / 32768 * 16;
 
- 					let ay2 = BLE.hexToSignedInt(ay2Str) / 32768 * 16;
 
- 					let az2 = BLE.hexToSignedInt(az2Str) / 32768 * 16;
 
- 					let ms3 = BLE.hex2int(resValue.substr(42, 4));
 
- 					let min3 = BLE.hex2int(resValue.substr(46, 2));
 
- 					let s3 = BLE.hex2int(resValue.substr(48, 2));
 
- 					let ax3Str = resValue.substr(50, 4);
 
- 					let ay3Str = resValue.substr(54, 4);
 
- 					let az3Str = resValue.substr(58, 4);
 
- 					let ax3 = BLE.hexToSignedInt(ax3Str) / 32768 * 16;
 
- 					let ay3 = BLE.hexToSignedInt(ay3Str) / 32768 * 16;
 
- 					let az3 = BLE.hexToSignedInt(az3Str) / 32768 * 16;
 
- 					let ms4 = BLE.hex2int(resValue.substr(62, 4));
 
- 					let min4 = BLE.hex2int(resValue.substr(66, 2));
 
- 					let s4 = BLE.hex2int(resValue.substr(68, 2));
 
- 					let ax4Str = resValue.substr(70, 4);
 
- 					let ay4Str = resValue.substr(74, 4);
 
- 					let az4Str = resValue.substr(78, 4);
 
- 					let ax4 = BLE.hexToSignedInt(ax4Str) / 32768 * 16;
 
- 					let ay4 = BLE.hexToSignedInt(ay4Str) / 32768 * 16;
 
- 					let az4 = BLE.hexToSignedInt(az4Str) / 32768 * 16;
 
- 					let accArray = [{
 
- 						ax: ax1,
 
- 						ay: ay1,
 
- 						az: az1,
 
- 						ms: ms1,
 
- 						min: min1,
 
- 						s: s1
 
- 					}, {
 
- 						ax: ax2,
 
- 						ay: ay2,
 
- 						az: az2,
 
- 						ms: ms2,
 
- 						min: min2,
 
- 						s: s2
 
- 					}, {
 
- 						ax: ax3,
 
- 						ay: ay3,
 
- 						az: az3,
 
- 						ms: ms3,
 
- 						min: min3,
 
- 						s: s3
 
- 					}, {
 
- 						ax: ax4,
 
- 						ay: ay4,
 
- 						az: az4,
 
- 						ms: ms4,
 
- 						min: min4,
 
- 						s: s4
 
- 					}]
 
- 					for (let i = 0; i < accArray.length; i++) {
 
- 						let _temp = accArray[i];
 
- 						box["acc"] = {
 
- 							ax: _temp.ax,
 
- 							ay: _temp.ay,
 
- 							az: _temp.az,
 
- 						};
 
- 						box["min"] = _temp.min;
 
- 						box["s"] = _temp.s;
 
- 						box["ms"] = _temp.ms;
 
- 						uni.$emit('updateBLEDeviceData', box);
 
- 					}
 
- 				}
 
- 				//原始数据解析
 
- 				if (state.bListenerUpdate) {
 
- 					//R/L 左手还是右手
 
- 					let handle = resValue.substr(6, 2);
 
- 					let axStr = resValue.substr(8, 4);
 
- 					let ayStr = resValue.substr(12, 4);
 
- 					let azStr = resValue.substr(16, 4);
 
- 					//一个字节最大只能表示265  2个字节可以表示65536  然后你这边做一下转换 例如00 3E   3*16+14=62 ----->0.03  g 
 
- 					//(真实值= AD值 /32768  * 16)
 
- 					//0.003 = 62 / 2768  * 16
 
- 					let ax = BLE.hexToSignedInt(axStr) / 32768 * 16;
 
- 					let ay = BLE.hexToSignedInt(ayStr) / 32768 * 16;
 
- 					let az = BLE.hexToSignedInt(azStr) / 32768 * 16;
 
- 					let gxStr = resValue.substr(20, 4);
 
- 					let gyStr = resValue.substr(24, 4);
 
- 					let gzStr = resValue.substr(28, 4);
 
- 					//角速度(AD值/32768 * 2000) 角速度单位是 °/s  范围是 正负2000
 
- 					let gx = BLE.hexToSignedInt(gxStr) / 32768 * 2000;
 
- 					let gy = BLE.hexToSignedInt(gyStr) / 32768 * 2000;
 
- 					let gz = BLE.hexToSignedInt(gzStr) / 32768 * 2000;
 
- 					//毫秒
 
- 					let ms = BLE.hex2int(resValue.substr(2, 4));
 
- 					//分
 
- 					let min = BLE.hex2int(resValue.substr(32, 2));
 
- 					//秒
 
- 					let s = BLE.hex2int(resValue.substr(34, 2));
 
- 					// ax / 10, az / 10, gz, -gx, data.ms ----- old
 
- 					// let [hit, dir] = state.sandbagAlgorithm.Update(-ay, az, -gz, -gy, data.ms);
 
- 					box["handle"] = BLE.hexToString(handle);
 
- 					/**
 
- 					 * 纠正手柄传感器轴向。
 
- 					 * 以方向键向上为 -g = y ,左右按钮向上 -g = x, 按键面向上 -g = z;
 
- 					 * 陀螺仪旋转方向:逆时针为负-,顺时针为正+;
 
- 					 */
 
- 					box["acc"] = {
 
- 						ax: -ay,
 
- 						ay: -ax,
 
- 						az: az
 
- 					};
 
- 					box["gyro"] = {
 
- 						gx: -gy,
 
- 						gy: -gx,
 
- 						gz: gz
 
- 					};
 
- 					box["min"] = min;
 
- 					box["s"] = s;
 
- 					box["ms"] = ms;
 
- 					//16进制参数
 
- 					box["hex"] = resValue;
 
- 					//更新数据给webview,在game-play-web||game-play-sub绑定
 
- 					//后面更新数据都用此接口
 
- 					uni.$emit('updateBLEDeviceData', box);
 
- 				}
 
- 				//todo 解析跳绳模式
 
- 				if (state.bListenerHexUpdate) {
 
- 					//报头,固定
 
- 					let byte1 = resValue.substr(0, 2);
 
- 					//功能码,todo 
 
- 					let byte2 = resValue.substr(2, 2);
 
- 					// 报文类型,后续区分在这里,目前是跳绳模式类型
 
- 					let byte3 = resValue.substr(4, 2);
 
- 					//报文内容,长度以 2为单位 动态变化
 
- 					let byteData = resValue.substr(6, resValue.length - 10)
 
- 					//报文按照长度2切割
 
- 					let byteArray = byteData.replace(/(\d{2})(?=(?:\d{2})+(?!\d))/g, '$1,').split(',');
 
- 					console.log("byteArray:", byteArray);
 
- 					// 校验
 
- 					let byteVerify = resValue.substr(resValue.length - 4, 2);
 
- 					// 报尾,结束
 
- 					let byteEnd = resValue.substr(resValue.length - 2, 2);
 
- 					//todo 暂时先这样触发
 
- 					if (byteArray.length == 2 && byteArray[0] != byteArray[1]) {
 
- 						if (byteArray[0] == '00') {
 
- 							state.bRopeKeyOne = 1;
 
- 						} else {
 
- 							//'01'
 
- 							state.bRopeKeyTwo = 1;
 
- 						}
 
- 						if (state.bRopeKeyOne == 1 && state.bRopeKeyTwo == 1) {
 
- 							state.bRopeKeyOne = 0;
 
- 							state.bRopeKeyTwo = 0;
 
- 							box["Rope"] = 1;
 
- 							uni.$emit('updateBLEDeviceData', box);
 
- 						}
 
- 					}
 
- 				}
 
- 			});
 
- 		},
 
- 		/**
 
- 		 * 开启跳绳模式
 
- 		 */
 
- 		B_OpenRopeSkipping() {
 
- 			// this.commit('onWriteBLEConnectionValue', {
 
- 			// 	value: "5B310101FE5D",
 
- 			// 	bSendHex: true,
 
- 			// 	bOpen: true
 
- 			// });
 
- 			console.log('B_OpenRopeSkipping', 3);
 
- 			this.commit('onWriteBLEConnectionValue', {
 
- 				value: "3"
 
- 			});
 
- 		},
 
- 		/**
 
- 		 * 关闭跳绳模式
 
- 		 */
 
- 		B_CloseRopeSkipping() {
 
- 			// this.commit('onWriteBLEConnectionValue', {
 
- 			// 	value: "5B210100FF5D",
 
- 			// 	bSendHex: true,
 
- 			// 	bOpen: false
 
- 			// });
 
- 			this.commit('onWriteBLEConnectionValue', {
 
- 				value: "4"
 
- 			});
 
- 		},
 
- 		//向低功耗蓝牙设备特征值中写入二进制数据。注意:必须设备的特征值支持 write 才可以成功调用。
 
- 		B_WriteBLECharacteristicValue(state, context) {
 
- 			let {
 
- 				value,
 
- 				retryCount,
 
- 				success,
 
- 				getFail,
 
- 				bSendHex,
 
- 			} = context;
 
- 			if (!value && value === '') {
 
- 				uni.showToast({
 
- 					title: "指令为空"
 
- 				})
 
- 				return;
 
- 			}
 
- 			let _sendData;
 
- 			if (bSendHex) {
 
- 				state.bRopeKeyTwo = 0;
 
- 				state.bRopeKeyOne = 0;
 
- 				//如果是发送16进制
 
- 				state.bListenerHexUpdate = true;
 
- 				//重置原 update
 
- 				state.bListenerUpdate = false;
 
- 				let typedArray = new Uint8Array(value.match(/[\da-f]{2}/gi).map(function(h) {
 
- 					return parseInt(h, 16)
 
- 				}))
 
- 				_sendData = typedArray.buffer;
 
- 			} else {
 
- 				state.bListenerHexUpdate = false;
 
- 				//记录一下指令
 
- 				state.currentInstruction = value;
 
- 				//V 获取版本,M 获取mac 地址
 
- 				if (value == "V")
 
- 					state.showToast = true;
 
- 				if (value == "M") {
 
- 					state.showToast = true;
 
- 					state.bListenerMac = true;
 
- 				}
 
- 				if (value == "4") {
 
- 					state.bListenerUpdate = false;
 
- 				}
 
- 				if (value == "3") {
 
- 					if (state.bListenerUpdate) {
 
- 						// uni.showToast({
 
- 						// 	title: "原始数据已开启"
 
- 						// })
 
- 						console.warn("原始数据已开启");
 
- 						// return;
 
- 					}
 
- 					state.bListenerUpdate = true;
 
- 				}
 
- 				if (value == "6") {
 
- 					// state.bListenerJson = false;
 
- 					state.bListenerAccArray = false;
 
- 				}
 
- 				if (value == "5") {
 
- 					// if (state.bListenerJson) {
 
- 					// 	uni.showToast({
 
- 					// 		title: "步数数据已开启"
 
- 					// 	})
 
- 					// 	return;
 
- 					// }
 
- 					// state.bListenerJson = true;
 
- 					if (state.bListenerAccArray) {
 
- 						uni.showToast({
 
- 							title: "加速计组数据已开启"
 
- 						})
 
- 						return;
 
- 					}
 
- 					state.bListenerAccArray = true;
 
- 				}
 
- 				_sendData = BLE.str2ab(value);
 
- 			}
 
- 			// console.log("currentInstruction:", state.currentInstruction, value, state.bListenerUpdate, state
 
- 			// 	.bListenerMac,
 
- 			// 	state.bListenerHexUpdate);
 
- 			// console.log("state.deviceId:", state.deviceId, state.serviceId, state.writeCharacteristicId);
 
- 			uni.writeBLECharacteristicValue({
 
- 				deviceId: state.deviceId,
 
- 				serviceId: state.serviceId,
 
- 				// 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
 
- 				characteristicId: state.writeCharacteristicId,
 
- 				// 这里的value是ArrayBuffer类型
 
- 				value: _sendData,
 
- 				success: (res) => {
 
- 					console.log('writeBLECharacteristicValue success', res.errMsg, value,
 
- 						retryCount);
 
- 					if (success) {
 
- 						success(res);
 
- 					}
 
- 				},
 
- 				fail: (fail) => {
 
- 					console.log(fail)
 
- 					//重新写入
 
- 					if (retryCount > 0) {
 
- 						console.log("writeBLECharacteristicValue Rewrite ===================>" +
 
- 							value + " == " + retryCount);
 
- 						retryCount--;
 
- 						setTimeout(() => {
 
- 							this.commit("B_WriteBLECharacteristicValue", {
 
- 								value,
 
- 								retryCount,
 
- 								success,
 
- 								getFail
 
- 							});
 
- 						}, 300);
 
- 					}
 
- 					if (getFail) {
 
- 						getFail(fail);
 
- 					}
 
- 				}
 
- 			})
 
- 		},
 
- 		/**
 
- 		 * 断开蓝牙连接
 
- 		 */
 
- 		B_CloseBLEConnection(state, context) {
 
- 			let {
 
- 				deviceId,
 
- 				success = null
 
- 			} = context;
 
- 			uni.closeBLEConnection({
 
- 				deviceId,
 
- 				success: res => {
 
- 					if (success)
 
- 						success();
 
- 				},
 
- 				fail: (fail) => {
 
- 					console.log("关闭蓝牙失败", fail);
 
- 				}
 
- 			});
 
- 		},
 
- 		//获取手机中蓝牙已匹配的设备
 
- 		B_GetBondedDevices(state, context) {
 
- 			// console.log("getBondedDevices ====>");
 
- 			let {
 
- 				success = null,
 
- 					deviceId = null
 
- 			} = context;
 
- 			//Android
 
- 			function android_bluetooth_list(deviceName, deviceId, count, callback) {
 
- 				console.log("===》调用android_bluetooth_list count:", count);
 
- 				var main = plus.android.runtimeMainActivity();
 
- 				var BluetoothAdapter = plus.android.importClass("android.bluetooth.BluetoothAdapter");
 
- 				var BAdapter = BluetoothAdapter.getDefaultAdapter();
 
- 				var Context = plus.android.importClass("android.content.Context");
 
- 				var lists = BAdapter.getBondedDevices();
 
- 				plus.android.importClass(lists);
 
- 				var len = lists.size();
 
- 				// var BluetoothManager = plus.android.importClass("android.bluetooth.BluetoothManager");
 
- 				// var BluetoothDevice = plus.android.importClass("android.bluetooth.BluetoothDevice");
 
- 				// var ProfileType = plus.android.importClass("android.bluetooth.ProfileType");
 
- 				// plus.android.importClass(BluetoothManager);
 
- 				// plus.android.importClass(BluetoothDevice);
 
- 				// plus.android.importClass(ProfileType);
 
- 				// var UUID = plus.android.importClass("java.util.UUID");  
 
- 				// var uuid = UUID.fromString("0000FFF0-0000-1000-8000-00805F9B34FB"); 
 
- 				// var gDevice = BAdapter.getRemoteDevice("C5:5C:19:04:00:30");  
 
- 				// plus.android.importClass(gDevice);  
 
- 				// var bluetoothSocket = gDevice.createInsecureRfcommSocketToServiceRecord(uuid);  
 
- 				// plus.android.importClass(bluetoothSocket); 
 
- 				// console.log("是否连接:",bluetoothSocket.isConnected());
 
- 				// var deviceLists = BluetoothManager.getConnectedDevices();
 
- 				// plus.android.importClass(deviceLists);
 
- 				// console.log("deviceLists.len=" + deviceLists.size());
 
- 				console.log("getBondedDevices.len=", len, "deviceId:", deviceId);
 
- 				//测试start===》 如果没有配对的设备,重新获取
 
- 				// count--;
 
- 				// if(count >0){
 
- 				// 	setTimeout(()=>{
 
- 				// 		android_bluetooth_list("BGBox", deviceId, count, callback);
 
- 				// 	},1000)
 
- 				// 	return;
 
- 				// }
 
- 				//测试end
 
- 				if (len == 0) {
 
- 					//如果没有配对的设备,重新获取
 
- 					count--;
 
- 					if (count > 0) {
 
- 						setTimeout(() => {
 
- 							android_bluetooth_list("BGBox", deviceId, count, callback);
 
- 						}, 2000)
 
- 					} else {
 
- 						if (callback)
 
- 							callback(null);
 
- 					}
 
- 				} else {
 
- 					var iterator = lists.iterator();
 
- 					let temp = null;
 
- 					plus.android.importClass(iterator);
 
- 					while (iterator.hasNext()) {
 
- 						var d = iterator.next();
 
- 						plus.android.importClass(d);
 
- 						// if (d.getName().indexOf(deviceName) > -1) 
 
- 						// console.log(d.getAddress(), deviceId);
 
- 						if (deviceId == null && d.getName().indexOf(deviceName) > -1) {
 
- 							let typeEnum = {
 
- 								0: 'Unknown',
 
- 								1: 'Classic',
 
- 								2: 'Le',
 
- 								3: 'Dual'
 
- 							};
 
- 							let bondStateEnum = {
 
- 								10: 'None',
 
- 								11: 'Bonding',
 
- 								12: 'Bonded'
 
- 							};
 
- 							temp = {
 
- 								name: d.getName(),
 
- 								address: d.getAddress(),
 
- 								type: {
 
- 									'value': d.getType(),
 
- 									'name': typeEnum[d.getType()]
 
- 								},
 
- 								bondState: {
 
- 									'value': d.getBondState(),
 
- 									'name': bondStateEnum[d.getBondState()]
 
- 								}
 
- 							}
 
- 							console.log("获取到设备,并且跳出:", temp);
 
- 							break;
 
- 						} else if (d.getAddress() == deviceId) {
 
- 							// console.log(d.getName());
 
- 							// console.log(d.getAddress());
 
- 							// Classic	1	
 
- 							// Dual	3	
 
- 							// Le	2	
 
- 							// Unknown	0
 
- 							// console.log(d.getType());
 
- 							// Bonded	12
 
- 							// Bonding	11	Indicates bonding (pairing) is in progress with the remote device.
 
- 							// None	10
 
- 							// console.log(d.getBondState());
 
- 							let typeEnum = {
 
- 								0: 'Unknown',
 
- 								1: 'Classic',
 
- 								2: 'Le',
 
- 								3: 'Dual'
 
- 							};
 
- 							let bondStateEnum = {
 
- 								10: 'None',
 
- 								11: 'Bonding',
 
- 								12: 'Bonded'
 
- 							};
 
- 							temp = {
 
- 								name: d.getName(),
 
- 								address: d.getAddress(),
 
- 								type: {
 
- 									'value': d.getType(),
 
- 									'name': typeEnum[d.getType()]
 
- 								},
 
- 								bondState: {
 
- 									'value': d.getBondState(),
 
- 									'name': bondStateEnum[d.getBondState()]
 
- 								}
 
- 							}
 
- 							console.log("获取到设备,并且跳出:", temp);
 
- 							break;
 
- 						}
 
- 					}
 
- 					// return temp;
 
- 					if (temp == null && count > 0) {
 
- 						count--;
 
- 						setTimeout(() => {
 
- 							android_bluetooth_list("BGBox", deviceId, count, callback);
 
- 						}, 2000)
 
- 					} else {
 
- 						if (callback)
 
- 							callback(temp);
 
- 					}
 
- 				}
 
- 			}
 
- 			function ios_bluetooth_list(deviceName, callback) {
 
- 				//原生操作 首先需要通过 uni.requireNativePlugin("ModuleName") 获取 module
 
- 				var SLABluetoothModule = uni.requireNativePlugin("SLABluetoothUniPlugin-SLAModule")
 
- 				if (SLABluetoothModule) {
 
- 					SLABluetoothModule.getConnectionDevicesAsync({
 
- 						serviceUUIDs: "FFF0"
 
- 					}, (res) => {
 
- 						console.log("***************getConnectionDevicesAsync:", JSON.stringify(res));
 
- 						if (res.data) {
 
- 							console.log("获取到对应的匹配设备!");
 
- 							let typeEnum = {
 
- 								0: 'Unknown',
 
- 								1: 'Classic',
 
- 								2: 'Le',
 
- 								3: 'Dual'
 
- 							};
 
- 							let bondStateEnum = {
 
- 								10: 'None',
 
- 								11: 'Bonding',
 
- 								12: 'Bonded'
 
- 							};
 
- 							let temp = {
 
- 								name: res.data[0].name,
 
- 								address: res.data[0].identifier,
 
- 								type: {
 
- 									'value': 2,
 
- 									'name': typeEnum[2]
 
- 								},
 
- 								bondState: {
 
- 									'value': 12,
 
- 									'name': bondStateEnum[12]
 
- 								}
 
- 							}
 
- 							if (callback) {
 
- 								callback({
 
- 									"device": temp
 
- 								});
 
- 							}
 
- 						} else {
 
- 							console.log("匹配设备数据不存在!");
 
- 							if (callback) {
 
- 								callback({
 
- 									"device": null
 
- 								});
 
- 							}
 
- 						}
 
- 					})
 
- 				} else {
 
- 					console.error("不存在SLABluetoothModule ios 插件!");
 
- 					if (callback) {
 
- 						callback({
 
- 							"device": null
 
- 						});
 
- 					}
 
- 				}
 
- 			}
 
- 			let device = null;
 
- 			let _count = 3;
 
- 			switch (plus.os.name) {
 
- 				case "Android":
 
- 					// Android平台: plus.android.*  
 
- 					android_bluetooth_list("BGBox", deviceId, _count, (data) => {
 
- 						device = data;
 
- 						console.log("android getBondedDevices 匹配的对象======>", device)
 
- 						if (device != null) {
 
- 							state.bPhoneMatched = true;
 
- 						} else {
 
- 							state.bPhoneMatched = false;
 
- 						}
 
- 						if (success) {
 
- 							success(device);
 
- 						}
 
- 					});
 
- 					break;
 
- 				case "iOS":
 
- 					// iOS平台: plus.ios.*  
 
- 					ios_bluetooth_list("BGBox", (res) => {
 
- 						device = res.device
 
- 						if (success) {
 
- 							success(device);
 
- 						}
 
- 						console.log("ios getBondedDevices 匹配的对象======>", device)
 
- 						if (device != null) {
 
- 							state.bPhoneMatched = true;
 
- 						} else {
 
- 							state.bPhoneMatched = false;
 
- 						}
 
- 					});
 
- 					break;
 
- 				default:
 
- 					// 其它平台  
 
- 					if (success) {
 
- 						success(device);
 
- 					}
 
- 					break;
 
- 			}
 
- 			// if (success) {
 
- 			// 	success(device);
 
- 			// }
 
- 		},
 
- 		B_OpenBLESetting() {
 
- 			function android_bluetooth_setting() {
 
- 				var main = plus.android.runtimeMainActivity(); //获取activity  
 
- 				var Intent = plus.android.importClass('android.content.Intent');
 
- 				var Settings = plus.android.importClass('android.provider.Settings');
 
- 				var intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS); //可设置表中所有Action字段  
 
- 				main.startActivity(intent);
 
- 			}
 
- 			function ios_bluetooth_setting() {
 
- 				// var UIApplication = plus.ios.import("UIApplication");  
 
- 				// var application2 = UIApplication.sharedApplication();  
 
- 				// var NSURL2 = plus.ios.import("NSURL");  
 
- 				// var setting2 = NSURL2.URLWithString("app-settings:");  
 
- 				// application2.openURL(setting2);  
 
- 				// plus.ios.deleteObject(setting2);  
 
- 				// plus.ios.deleteObject(NSURL2);  
 
- 				// plus.ios.deleteObject(application2);
 
- 				// plus.runtime.openURL({
 
- 				// 	action: 'App-Prefs:root=Bluetooth'
 
- 				// }, function(e) {
 
- 				// 	console.log(JSON.stringify(e));
 
- 				// });
 
- 				plus.runtime.launchApplication({
 
- 					action: 'App-Prefs:root=Bluetooth'
 
- 				}, function(e) {
 
- 					console.log(JSON.stringify(e));
 
- 				});
 
- 			}
 
- 			let device = null;
 
- 			switch (plus.os.name) {
 
- 				case "Android":
 
- 					// Android平台: plus.android.*  
 
- 					android_bluetooth_setting();
 
- 					break;
 
- 				case "iOS":
 
- 					// iOS平台: plus.ios.*  
 
- 					ios_bluetooth_setting();
 
- 					break;
 
- 				default:
 
- 					// 其它平台  
 
- 					break;
 
- 			}
 
- 		},
 
- 		//获取versionCode状态,用于处理特定的信息显示
 
- 		getVersionCode(state) {
 
- 			let self = this;
 
- 			console.log("state.versionCode:" + state.versionCode);
 
- 			reqUtil.requestData(config.URL.GETVERSIONCODE, {
 
- 				code: state.versionCode
 
- 			}).then(res => {
 
- 					console.log('获取版本控制信息 =====' + JSON.stringify(res));
 
- 					if (res.code == 0) {
 
- 						state.versionCodeState = Object.assign({}, state.versionCodeState, res.data);
 
- 						/**
 
- 						 * 初始化配置表方案
 
- 						 * 搞一个区分平台上线显示等,根据版本版本号,是否显示,平台限制等区别
 
- 						 */
 
- 						//显示,隐藏游戏栏目
 
- 						uni.setTabBarItem({
 
- 							index: 2,
 
- 							visible: state.versionCodeState.showGame
 
- 						})
 
- 						//显示,隐藏视频栏目
 
- 						uni.setTabBarItem({
 
- 							index: 3,
 
- 							visible: state.versionCodeState.showVideo
 
- 						})
 
- 					}
 
- 				},
 
- 				e => {
 
- 					console.log(e)
 
- 				});
 
- 		},
 
- 		/**
 
- 		 * 任务其他操作
 
- 		 */
 
- 		//获取关卡信息
 
- 		getLevelList(state, callback) {
 
- 			let self = this;
 
- 			reqUtil
 
- 				.requestData(config.URL.GETLEVELLIST, {}) //GETLEVELJUMPLIST
 
- 				.then(
 
- 					res => {
 
- 						if (res.code == 0) {
 
- 							// state.singlePersonList = res.data.singlePerson;
 
- 							// state.multiPersonList = res.data.multiPerson;
 
- 							// console.log(res.data);
 
- 							let levels = res.data;
 
- 							state.levels = levels;
 
- 							if (1 === state.currentModeIndex) {
 
- 								//关卡是跳绳
 
- 								state.singlePersonList = levels.singlePersonMap[0];
 
- 								state.multiPersonList = levels.multiPersonMap[0];
 
- 							} else if (0 === state.currentModeIndex) {
 
- 								//关卡是拳击
 
- 								state.singlePersonList = levels.singlePersonMap[1];
 
- 								state.multiPersonList = levels.multiPersonMap[1];
 
- 							}
 
- 							//获取到数据时候,重置actionJump
 
- 							self.commit('resetActionJumpTask');
 
- 							if (callback)
 
- 								callback();
 
- 						}
 
- 					},
 
- 					e => {
 
- 						console.log(e);
 
- 					}
 
- 				);
 
- 		},
 
- 		//切换关卡列表信息K
 
- 		switchLevelList(state, _levelType) {
 
- 			// console.log( state.levels.multiPersonMap)
 
- 			// console.log( state.levels.singlePersonMap)
 
- 			if (state.levels.singlePersonMap && state.levels.singlePersonMap.length >= _levelType)
 
- 				state.singlePersonList = state.levels.singlePersonMap[_levelType - 1];
 
- 			else
 
- 				state.singlePersonList = [];
 
- 			if (state.levels.multiPersonMap && state.levels.multiPersonMap.length >= _levelType)
 
- 				state.multiPersonList = state.levels.multiPersonMap[_levelType - 1];
 
- 			else
 
- 				state.multiPersonList = [];
 
- 			if (1 === _levelType) {
 
- 				//关卡是跳绳
 
- 				state.currentModeIndex = 1;
 
- 			} else if (2 === _levelType) {
 
- 				//关卡是拳击
 
- 				state.currentModeIndex = 0;
 
- 			}
 
- 			// console.log(state.currentModeIndex)
 
- 		},
 
- 		/**
 
- 		 * 获取钱包信息
 
- 		 * @param {Object} state
 
- 		 * @param {Object} callback
 
- 		 */
 
- 		getUserWallets(state, callback) {
 
- 			reqUtil
 
- 				.requestData(config.URL.USERGETWALLETINFO, {})
 
- 				.then(
 
- 					res => {
 
- 						if (res.code == 0) {
 
- 							console.log('USERGETWALLETINFO:' + JSON.stringify(res.data));
 
- 							state.cGold = res.data.gold;
 
- 							state.cDiamond = res.data.diamond;
 
- 							if (callback)
 
- 								callback();
 
- 						}
 
- 					},
 
- 					e => {
 
- 						console.log(e);
 
- 					}
 
- 				);
 
- 		},
 
- 		setGoldAndDiamond(state, context) {
 
- 			let {
 
- 				gold,
 
- 				diamond
 
- 			} = context;
 
- 			state.cGold = gold;
 
- 			state.cDiamond = diamond;
 
- 		},
 
- 		/**
 
- 		 * 抽屉和弹出框
 
- 		 */
 
- 		hideDrawerById(state, context) {
 
- 			// let { id } = context;
 
- 			//personal-drawer
 
- 			uni.getSubNVueById('personal-drawer').hide('slide-in-left', 200);
 
- 		},
 
- 		showDrawerById(state, context) {
 
- 			// let { id } = context;
 
- 			//personal-drawer
 
- 			uni.getSubNVueById('personal-drawer').show('slide-in-left', 200);
 
- 		},
 
- 		closeDrawerById(state, context) {
 
- 			const subNVue = uni.getSubNVueById('personal-drawer');
 
- 			subNVue.close();
 
- 			console.log('销毁侧滑栏子窗体');
 
- 		},
 
- 		showPopupById(state, context) {
 
- 			let {
 
- 				type,
 
- 				item
 
- 			} = context;
 
- 			console.log(type, item);
 
- 			switch (type) {
 
- 				case 'levelReward':
 
- 					uni.$emit('reward-popup', {
 
- 						title: '奖励',
 
- 						content: '',
 
- 						type: type,
 
- 						item: {
 
- 							gold: item.rewardGold,
 
- 							diamond: item.rewardDiamond,
 
- 							honor: item.rewardHonor
 
- 						},
 
- 						operationItem: item
 
- 					});
 
- 					break;
 
- 				case 'prompt':
 
- 					// 向 popup 传递消息
 
- 					uni.$emit('reward-popup', {
 
- 						title: '奖励',
 
- 						content: '',
 
- 						type: type,
 
- 						item: {
 
- 							gold: item.rewardGold,
 
- 							diamond: item.rewardDiamond,
 
- 							honor: item.rewardHonor
 
- 						},
 
- 						operationItem: item
 
- 					});
 
- 					break;
 
- 				case 'unlock':
 
- 					// 向 popup 传递消息
 
- 					uni.$emit('reward-popup', {
 
- 						title: '解锁关卡',
 
- 						content: '',
 
- 						type: type,
 
- 						item: {
 
- 							consumeGold: item.consumeGold,
 
- 							consumeDiamond: item.consumeDiamond
 
- 						},
 
- 						operationItem: item
 
- 					});
 
- 					break;
 
- 				case 'signIn':
 
- 					this.commit("onSendSignInPopup", context);
 
- 					break;
 
- 				case 'pkFinish':
 
- 					// 向 popup 传递消息
 
- 					uni.$emit('reward-popup', {
 
- 						title: 'pk完成',
 
- 						content: '',
 
- 						type: type,
 
- 						item: item,
 
- 						operationItem: item
 
- 					});
 
- 					break;
 
- 				default:
 
- 					uni.showToast({
 
- 						title: 'showPopup类型为空',
 
- 						icon: 'none'
 
- 					})
 
- 					break;
 
- 			}
 
- 			// #ifdef APP-PLUS
 
- 			//personal-popup
 
- 			const subNVue = uni.getSubNVueById('personal-popup')
 
- 			subNVue.show('zoom-out', 250)
 
- 			// #endif
 
- 		},
 
- 		closePopupById(state, context) {
 
- 			const subNVue = uni.getSubNVueById('personal-popup')
 
- 			subNVue.close();
 
- 			console.log('销毁奖励子窗体');
 
- 		},
 
- 		showGuideById(state, context) {
 
- 			let {
 
- 				type,
 
- 				item
 
- 			} = context;
 
- 			uni.$emit('guide-popup', {
 
- 				title: 'guide',
 
- 				content: '定制guide',
 
- 				type: type,
 
- 				item: item,
 
- 				operationItem: item
 
- 			});
 
- 			const subNVue = uni.getSubNVueById('personal-guide')
 
- 			subNVue.show('fade-in', 250)
 
- 		},
 
- 		closeGuideById() {
 
- 			const subNVue = uni.getSubNVueById('personal-guide')
 
- 			subNVue.close();
 
- 			console.log('销毁新手指引子窗体');
 
- 		},
 
- 		/**
 
- 		 * 获取签到列表
 
- 		 * @param {Object} state
 
- 		 * @param {Object} callback
 
- 		 */
 
- 		getSignInList(state, callback) {
 
- 			reqUtil
 
- 				.requestData(config.URL.GETSIGNINLIST, {})
 
- 				.then(
 
- 					res => {
 
- 						if (res.code == 0) {
 
- 							// console.log('GETSIGNINLIST:' + JSON.stringify(res.data));
 
- 							state.signInList = res.data.signInList;
 
- 							state.isSignIn = res.data.isSignIn;
 
- 							if (callback)
 
- 								callback(res.data);
 
- 						}
 
- 					},
 
- 					e => {
 
- 						console.log(e);
 
- 					}
 
- 				);
 
- 		},
 
- 		/**
 
- 		 * 签到
 
- 		 * @param {Object} state
 
- 		 * @param {Object} callback
 
- 		 */
 
- 		onUserSignIn(state, callback) {
 
- 			reqUtil
 
- 				.requestData(config.URL.USERSIGNIN, {})
 
- 				.then(
 
- 					res => {
 
- 						console.log('USERSIGNIN:' + JSON.stringify(res));
 
- 						if (res.code == 0) {
 
- 							state.cGold = res.data.userGold;
 
- 							state.cDiamond = res.data.userDiamond;
 
- 							uni.showToast({
 
- 								title: '签到成功',
 
- 								mask: true
 
- 							})
 
- 							//根据dayType 计算最近一个flag
 
- 							for (let i = 0; i < state.signInList.length; i++) {
 
- 								if (res.data.signIn.dayType == state.signInList[i].dayType) {
 
- 									state.signInList[i] = Object.assign({}, state.signInList[i], res.data
 
- 										.signIn);
 
- 									break;
 
- 								}
 
- 							}
 
- 							state.isSignIn = true;
 
- 							if (callback)
 
- 								callback(res.data);
 
- 						} else if (res.code == 901) {
 
- 							uni.showToast({
 
- 								title: '今天已签到',
 
- 								mask: true
 
- 							})
 
- 						}
 
- 					},
 
- 					e => {
 
- 						console.log(e);
 
- 					}
 
- 				);
 
- 		},
 
- 		onSendSignInPopup(state, context) {
 
- 			let {
 
- 				type,
 
- 				item
 
- 			} = context;
 
- 			let _reward = [{
 
- 					name: 'gold',
 
- 					width: 28,
 
- 					height: 28,
 
- 					url: '../../../static/common/sideBar/sGold.png',
 
- 					selectedUrl: '../../../static/common/subNVue/sign/sign-grey-gold@2x.png',
 
- 					explain: '',
 
- 					value: 20,
 
- 					isSelect: false
 
- 				},
 
- 				{
 
- 					name: 'diamond',
 
- 					width: 28,
 
- 					height: 28,
 
- 					url: '../../../static/common/sideBar/sDiamond.png',
 
- 					selectedUrl: '../../../static/common/subNVue/sign/sign-grey-diamond@2x.png',
 
- 					explain: '',
 
- 					value: 20,
 
- 					isSelect: false
 
- 				}
 
- 			];
 
- 			let list = state.signInList;
 
- 			let lists = [];
 
- 			for (let i = 0; i < list.length; i++) {
 
- 				if (0 !== list[i].gold) {
 
- 					lists.push(Object.assign({}, _reward[0], {
 
- 						value: list[i].gold
 
- 					}))
 
- 				} else if (0 !== list[i].diamond) {
 
- 					lists.push(Object.assign({}, _reward[1], {
 
- 						value: list[i].diamond
 
- 					}))
 
- 				}
 
- 				lists[i].isSelect = list[i].flag == 1 ? true : false;
 
- 			}
 
- 			// console.log("list:"+JSON.stringify(list));
 
- 			// 向 popup 传递消息
 
- 			uni.$emit('reward-popup', {
 
- 				title: '每日签到',
 
- 				content: '',
 
- 				type: type,
 
- 				lists: lists,
 
- 				isSignIn: state.isSignIn
 
- 			});
 
- 		},
 
- 		/**
 
- 		 * 记录沙袋打击计数
 
- 		 * @param {Object} state
 
- 		 * @param {Object} count
 
- 		 */
 
- 		setSandbagHitCount(state, count) {
 
- 			// uni.setStorageSync('sandbagHitCount', count);
 
- 			state.sandbagHitCount = count;
 
- 		},
 
- 		addSandbagHitCount(state, context) {
 
- 			let {
 
- 				count
 
- 			} = context;
 
- 			let addCount = Number(state.sandbagHitCount) + Number(count);
 
- 			// console.log("addCount:" + addCount);
 
- 			state.sandbagHitCount = addCount;
 
- 			uni.setStorageSync('sandbagHitCount', state.sandbagHitCount);
 
- 		},
 
- 		getSandbagHitCount(state) {
 
- 			const value = uni.getStorageSync('sandbagHitCount');
 
- 			if (value) {
 
- 				state.sandbagHitCount = value;
 
- 			} else {
 
- 				state.sandbagHitCount = 0;
 
- 			}
 
- 		},
 
- 		/**
 
- 		 * 获取用户等hitcount数据
 
- 		 * 同步沙袋计数
 
- 		 * @param {Object} state
 
- 		 */
 
- 		getUserData_hitCount(state) {
 
- 			//获取本地数据
 
- 			this.commit("getSandbagHitCount");
 
- 			reqUtil
 
- 				.requestData(config.URL.USERDATA_GETHITCOUNT, {}, 'POST')
 
- 				.then(
 
- 					res => {
 
- 						console.log('USERDATA_GETHITCOUNT:' + JSON.stringify(res));
 
- 						if (res.code == 0) {
 
- 							if (res.data.isReset) {
 
- 								this.commit("setSandbagHitCount", 0);
 
- 							} else {
 
- 								if (res.data.hitCount > state.sandbagHitCount) {
 
- 									this.commit("setSandbagHitCount", res.data.hitCount);
 
- 									state.netSandbagHitCount = res.data.hitCount;
 
- 								} else if (res.data.hitCount < state.sandbagHitCount) {
 
- 									//获取时候,小于本地记录的,则同步到网络
 
- 									this.commit("uploadUserData_hitCount");
 
- 								}
 
- 							}
 
- 						}
 
- 					},
 
- 					e => {
 
- 						console.log(e);
 
- 					}
 
- 				);
 
- 		},
 
- 		uploadUserData_hitCount(state) {
 
- 			//如果拳击数没变化,则不用上传
 
- 			if (state.netSandbagHitCount == state.sandbagHitCount) return;
 
- 			reqUtil
 
- 				.requestData(config.URL.USERDATA_UPLOADHITCOUNT, {
 
- 					hitCount: state.sandbagHitCount
 
- 				}, 'POST')
 
- 				.then(
 
- 					res => {
 
- 						console.log('USERDATA_UPLOADHITCOUNT:' + JSON.stringify(res));
 
- 						if (res.code == 0) {
 
- 							this.commit("setSandbagHitCount", res.data.hitCount)
 
- 							state.netSandbagHitCount = res.data.hitCount;
 
- 						}
 
- 					},
 
- 					e => {
 
- 						console.log(e);
 
- 					}
 
- 				);
 
- 		},
 
- 		onConnectSocket(state) {
 
- 			let self = this;
 
- 			uni.connectSocket({
 
- 				// #ifdef APP-PLUS
 
- 				url: 'wss://www.9527fun.cn/api_dev/websocket/APPLog/123'
 
- 				// #endif
 
- 				// #ifdef H5
 
- 				// url:'wss://www.9527fun.cn/api_dev/websocket/APPLog/123'
 
- 				url: 'ws://192.168.0.108:9090/api_dev/websocket/APPLog/123'
 
- 				// #endif
 
- 			});
 
- 			uni.onSocketMessage(function(res) {
 
- 				console.log('收到服务器内容:' + res.data);
 
- 			});
 
- 			uni.onSocketOpen(function(res) {
 
- 				console.log('WebSocket连接已打开!');
 
- 			});
 
- 			uni.onSocketError(function(res) {
 
- 				console.log('WebSocket连接打开失败,请检查!');
 
- 			});
 
- 		},
 
- 		onCloseSocket(state) {
 
- 			uni.onSocketClose(function(res) {
 
- 				console.log('WebSocket 已关闭!');
 
- 			});
 
- 		},
 
- 		onSendSocketMessage(state, msg) {
 
- 			console.log("发送数据", msg);
 
- 			uni.sendSocketMessage({
 
- 				data: JSON.stringify(msg)
 
- 			});
 
- 		},
 
- 		
 
- 		
 
- 		//jumpIdenModule 算法插件  start
 
- 		jumpIdenModule_SearchData(state, context) {
 
- 			state.filesList = [];
 
- 			let {
 
- 				data,
 
- 				callback = null
 
- 			} = context;
 
- 			let url = "http://42.192.165.168:2022/search";
 
- 			let _temp = {
 
- 				name: state.readDataName
 
- 			}
 
- 			console.log('requestData search ===== url:' + url);
 
- 			reqUtil.requestData(url, _temp,'POST').then(res => {
 
- 				
 
- 					let strArray = res.split('\n');
 
- 						console.log(strArray);
 
- 					for (let i = 0; i < strArray.length-1; i++) {
 
- 						let _name = strArray[i].split('.')[0];
 
- 						if (_name.Length <= 0) continue;
 
- 						let item = Object.assign({}, {
 
- 							cname:_name,
 
- 							bRatio: false
 
- 						});
 
- 						state.filesList.push(item);
 
- 					}
 
- 					uni.showToast({
 
- 						title: '获取列表成功!',
 
- 						icon: 'none',
 
- 						duration: 1000,
 
- 						mask: true
 
- 					})
 
- 				},
 
- 				e => {
 
- 					console.log(e)
 
- 					uni.showToast({
 
- 						title: '请求失败!',
 
- 						icon: 'none',
 
- 						duration: 1000,
 
- 						mask: true
 
- 					})
 
- 				});
 
- 		},
 
- 		jumpIdenModule_DownloadReadData(state,context) {
 
- 			let {
 
- 				data,
 
- 				callback = null
 
- 			} = context;
 
- 			let downloadUrl = "http://42.192.165.168:2022/download";
 
- 			console.log('requestData downloadUrl ===== url:' + downloadUrl);
 
- 			reqUtil.requestData(downloadUrl, {name:data.cname},'POST').then(res => {
 
- 					//console.log(res);
 
- 					uni.setStorageSync('readData', res);
 
- 					if(callback)
 
- 						callback(res);
 
- 					//读取的数据传入android端
 
- 					let _temp = jumpIdenModule.onJumpInitInputData({
 
- 						data: res
 
- 					})
 
- 					
 
- 					uni.showToast({
 
- 						title: '' + _temp.msg,
 
- 						icon: 'none',
 
- 						duration: 1000,
 
- 						mask: true
 
- 					})
 
- 				},
 
- 				e => {
 
- 					console.log(e)
 
- 					uni.showToast({
 
- 						title: '请求失败!',
 
- 						icon: 'none',
 
- 						duration: 1000,
 
- 						mask: true
 
- 					})
 
- 				});
 
- 		},
 
- 		jumpIdenModule_onJumpInit() {
 
- 			let res = jumpIdenModule.onJumpInit();
 
- 			uni.showToast({
 
- 				title: ''+ res.code,
 
- 				icon: 'none',
 
- 				duration: 1000,
 
- 				mask: true
 
- 			})
 
- 		},
 
- 		jumpIdenModule_onJumpInitLocalData(){
 
- 			let res = jumpIdenModule.onJumpInitLocalData();
 
- 			uni.showToast({
 
- 				title: ''+ res.code,
 
- 				icon: 'none',
 
- 				duration: 1000,
 
- 				mask: true
 
- 			})
 
- 		},
 
- 		jumpIdenModule_onTestJump6AxisDataUpdate() {
 
- 			let box = {};
 
- 			box["acc"] = {
 
- 				ax: 11,
 
- 				ay: 22,
 
- 				az: 33,
 
- 			};
 
- 			box["gyro"] = {
 
- 				gx: 111,
 
- 				gy: 222,
 
- 				gz: 333,
 
- 			};
 
- 			box["ms"] = 33;
 
- 			jumpIdenModule.onJump6AxisDataUpdate(box)
 
- 		},
 
- 		jumpIdenModule_onTestUpdate() {
 
- 			jumpIdenModule.onTestUpdate();
 
- 		},
 
- 		jumpIdenModule_onJump6AxisDataUpdate(state,context){
 
- 			let {
 
- 				data,
 
- 				callback = null
 
- 			} = context;
 
- 			let res = jumpIdenModule.onJump6AxisDataUpdate({hex:data.hex});
 
- 			if(callback)
 
- 				callback(res);
 
- 		},
 
- 		
 
- 		onGetReadDataName(state){
 
- 			console.log(1)
 
- 			state.readDataName = uni.getStorageSync('readDataName');
 
- 		},
 
- 		onSetReadDataName(state, value) {
 
- 			uni.setStorageSync('readDataName', value);
 
- 			state.readDataName = value;
 
- 		},
 
- 		//jumpIdenModule 算法插件 end
 
- 	}
 
- })
 
- export default store
 
 
  |