require("../../common/manifest.js") require("../../common/vendor.js") global.webpackJsonpMpvue([1],{"0/Bm":function(t,e){},"3a+T":function(t,e,a){"use strict";var i={render:function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("van-row",{staticClass:"padding",attrs:{mpcomid:"3"}},[a("van-col",{attrs:{span:"5",offset:"4",mpcomid:"0"}},[a("div",{staticClass:"device_bg flex flex-direction align-center justify-center"},[a("img",{staticClass:"device_phone",attrs:{src:"https://img.shuimuai.com/web/phone.png",alt:""}}),t._v(" "),a("text",{staticClass:"text-gray device_text"},[t._v(" 我的手机")])])]),t._v(" "),a("van-col",{attrs:{span:"3",offset:"1",mpcomid:"1"}},[a("div",{staticClass:"dot_container flex align-center"},[a("div",{staticClass:"dot_wait"},[1==t.status?a("img",{staticClass:"moving_dot",class:{moving:1==t.status},attrs:{src:"https://img.shuimuai.com/web/dot.png",alt:""}}):t._e(),t._v(" "),2==t.status?a("img",{staticClass:"moving_dot",attrs:{src:"https://img.shuimuai.com/m_sign_gou%402x.png",alt:""}}):t._e(),t._v(" "),3==t.status?a("img",{staticClass:"moving_dot",attrs:{src:"https://img.shuimuai.com/fail.png",alt:""}}):t._e()])])]),t._v(" "),a("van-col",{attrs:{span:"5",offset:"0",mpcomid:"2"}},[a("div",{staticClass:"device_bg flex flex-direction align-center justify-center"},[a("img",{staticClass:"device_brain",attrs:{src:"https://img.shuimuai.com/web/brain.png",alt:""}}),t._v(" "),a("text",{staticClass:"text-gray device_text"},[t._v(" 水母智能脑机")])])])],1),t._v(" "),a("van-row",{staticClass:"text-center",attrs:{mpcomid:"10"}},[a("van-col",{attrs:{span:12,mpcomid:"5"}},[a("van-button",{attrs:{type:"danger",eventid:"0",mpcomid:"4"},on:{click:t.change_status}},[t._v("取消连接")])],1),t._v(" "),a("van-col",{attrs:{span:12,mpcomid:"9"}},[a("text",{staticClass:"text-gray text-lg"},[1==t.status?[t._v("\n 连接中...\n ")]:t._e(),t._v(" "),2==t.status?[t._v("\n 连接成功\n ")]:t._e(),t._v(" "),3==t.status?[t._v("\n 连接失败\n ")]:t._e()],2)])],1)],1)},staticRenderFns:[]};e.a=i},"3yqp":function(t,e,a){"use strict";e.a={name:"connecting",props:["status"],methods:{change_status:function(){this.$emit("change_brain_status",0)}}}},"4yrY":function(t,e,a){"use strict";e.a={name:"unconnect",data:function(){return{}},methods:{open_scan:function(){this.$emit("open_scan")}},created:function(){this},onShow:function(){}}},"5MmH":function(t,e,a){"use strict";var i={render:function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("van-row",{attrs:{mpcomid:"2"}},[a("van-col",{staticClass:"text-gray text-sm left",attrs:{span:"11",offset:"1",mpcomid:"0"}},[a("view",[t._v("1.打开手机蓝牙和位置信息")]),t._v(" "),a("view",[t._v("2.长按脑机侧面按钮启动脑机")]),t._v(" "),a("view",[t._v("3.点击扫码开始连接")])]),t._v(" "),a("van-col",{attrs:{span:"8",offset:"2",mpcomid:"1"}},[a("img",{staticClass:"connect_img",attrs:{src:"https://img.shuimuai.com/lanyashuimu.png"}})])],1),t._v(" "),a("button",{staticClass:"cu-btn lg cu-btn-primary text-white text-center scan_button margin-tb",attrs:{eventid:"0"},on:{click:t.open_scan}},[t._v("扫码连接脑机\n ")]),t._v(" "),a("van-toast",{attrs:{id:"van-toast",mpcomid:"3"}})],1)},staticRenderFns:[]};e.a=i},"5vTQ":function(t,e,a){"use strict";var i,s=a("YV7O"),n=a("TQoE"),o=a("pG1U"),c=a("nB6K"),l=a("Y3tu"),r=a("iy8u"),_=a("mDzu"),p=a("5S+K"),v=a("IcnI"),m=a("wOfB"),f=a("Agbe");a("Bgtx");e.a={name:"index_container",components:{banner:s.a,login_container:n.a,regist_container:o.a,personal_container:c.a,device_container:l.a},data:function(){return{login_status:"login",is_login:!1,regist_title:""}},methods:{get_init_data:function(){},change_status:function(t){this.login_status=t},to_recharge:function(){global.mpvue.navigateTo({url:"/pages/user_center/recharge/main"})},change_login_status:function(){this.is_login=v.a.getters.get_login_status()},change_title:function(t){0==t?this.regist_title="注册":1==t&&(this.regist_title="登录")},to_page:function(t){return"agent/index"!=t||8!=i.userinfo.level&&9!=i.userinfo.level?this.is_login?void global.mpvue.navigateTo({url:"/pages/"+t+"/main"}):(r.a.fail("请先登录"),!1):(r.a.fail("店员、店长不可进"),!1)},auth_msg:function(){wx.requestSubscribeMessage({tmplIds:["NV-xb_oOPutXLVge0ZnBxct_nNxS1j1XNCMtfp2c8zw","70xngszQ62NWHbbCjbggbz5-pvOu3Z8ttLbjfplJXLg"],success:function(t){console.log(t),r.a.success("授权成功")}})}},mounted:function(){wx.login({success:function(t){console.log(t)}})},onShow:function(){0==wx.getStorageSync("is_other_first")?wx.setStorageSync("is_other",!1):wx.setStorageSync("is_other",!0)},onHide:function(){},onLoad:function(t){1==m.a.getters.getGameStatus()&&_.a.alert({title:"系统提示",message:"正在结束上一个游戏"}).then(function(){Object(f.a)(m.a.getters.getGameAttMedDatas())});var e=wx.getStorageSync("token");e&&(v.a.setters.set_token(e),v.a.setters.set_login(!0),this.is_login=v.a.getters.get_login_status(),Object(p.b)().then(function(t){}))},created:function(){i=this},onShareAppMessage:function(){return{title:"欢迎进入水母星球",imageUrl:"http://img.shuimuai.com/sharePahe_one.jpg",path:"/pages/index/main"}}}},"7rf+":function(t,e,a){"use strict";var i,s=a("5S+K"),n=a("iy8u"),o=a("IcnI"),c=a("LOoJ");e.a={name:"regist",props:["title"],data:function(){return{phone:"",verfiy_code:"",time_out:0,invite:0,js_code:"",auth_login:!1,_userinfo:{nickName:"",avatarUrl:"",gender:""},btn_disabled:!0,time_show:!1,time_start:!1,time_count:60,protocol_show:!1}},watch:{verfiy_code:function(t,e){6==t.length&&wx.hideKeyboard()}},methods:{change_protocol_show:function(t){i.protocol_show=t},check_auth:function(){/(13\d|14[579]|15[^4\D]|17[^49\D]|18\d|19\d|16\d)\d{8}/.test(i.phone)&&/\d{6}/.test(i.verfiy_code)?i.btn_disabled=!1:i.btn_disabled=!0},goIndex:function(){this.$emit("changeStatus","login")},get_verify_code:function(){if(0==/(13\d|14[579]|15[^4\D]|17[^49\D]|18\d|19\d|16\d)\d{8}/.test(i.phone))return n.a.fail("请输入正确手机号"),!1;i.open_time_down();var t=void 0;t="注册"==i.title?{phone:i.phone,is_register:1}:{phone:i.phone,is_register:0},Object(s.k)(t).then(function(t){var e=t.data;n.a.success(e.errmsg)})},wechat_login:function(t){n.a.loading({forbidClick:!0,message:"操作中..."});var e={phone:i.phone,code:i.verfiy_code,js_code:i.js_code,invite:i.invite};e.user_name=i._userinfo.nickName,e.portrait=i._userinfo.avatarUrl,e.sex=i._userinfo.gender,global.mpvue.login({success:function(t){var a=t.code;e.js_code=a,"注册"==i.title?Object(s.m)(e).then(function(t){console.log(t),wx.setStorageSync("is_first",!0);var e=t.data;e.code?n.a.fail(e.errmsg):(n.a.clear(),i.login_success(e))},function(t){console.log(t)}):"登录"==i.title&&Object(s.l)(e).then(function(t){wx.setStorageSync("is_first",!1);var e=t.data;0==e.code?i.login_success(e):n.a.fail(e.errmsg)},function(t){console.log(t)})}})},login_success:function(t){n.a.success(t.errmsg),o.a.setters.set_token(t.data),o.a.setters.set_login(),i.$emit("change_login_status",!0),Object(c.a)(i)},open_time_down:function(){i.time_count=60,i.time_start=i.time_show=!0},time_finished:function(){i.time_start=i.time_show=!1},get_user_info:function(){wx.getUserProfile({desc:"获取你的昵称、头像、地区及性别",success:function(t){var e=t.userInfo;i._userinfo=e,i.wechat_login(),console.log("我能获取到用户的信息吗??",i._userinfo)},fail:function(t){n.a.fail("请进行授权登录")}})}},mounted:function(){i.invite=o.a.getters.get_invite_code(),console.log("regist-invite",i.invite),i.js_code=o.a.getters.getJsCode()},created:function(){i=this,wx.getSetting({success:function(t){t.authSetting["scope.userInfo"]?i.auth_login=!1:i.auth_login=!0,console.log("auth",i.auth_login)}})}}},Agbe:function(t,e,a){"use strict";e.a=function(t){wx.showLoading({title:"正在结束上一个游戏",mask:!0});if(console.log(t.attList.length,"结束游戏提交的数据量"),t.attList.length>300){var e=Math.ceil(t.attList.length/300),a=0,o=setInterval(function(){if(a=3&&t.userinfo.level<=7?a("view",{staticClass:"text-center font-sm"},[a("text",{staticClass:"text-gray"},[t._v("今日专注力免费训练时长还有:\n "),a("text",{staticClass:"text-yellow"},[t._v(t._s(t.userinfo.free_time))])])]):t._e(),t._v(" "),a("van-popup",{attrs:{show:t.is_outShow,"close-on-click-overlay":!1,"custom-class":"pop",overlay:"","z-index":"99",mpcomid:"11"}},[a("div",{staticClass:"quan_container padding-tb-xl"},[a("view",{staticClass:"margin-top-xl flex justify-center"},[a("text",{staticClass:"title"},[t._v(t._s(t.outCouponData.name))])]),t._v(" "),a("view",{staticClass:"flex justify-center margin-top"},[1==t.outCouponData.validity_time.type?a("text",{staticClass:"text-xs"},[t._v(t._s(t.outCouponData.validity_time.time_format)+" 之前领取有效")]):a("text",{staticClass:"text-xs"},[t._v(t._s(t.outCouponData.validity_time.start_time_format)+" 至 "+t._s(t.outCouponData.validity_time.end_time_format)+" 之前领取有效")])]),t._v(" "),1==t.outCouponData.type?a("view",{staticClass:"flex justify-center margin-top"},[a("div",{staticClass:"flex justify-center quan_container_lil"},[a("div",{staticStyle:{display:"flex","align-items":"baseline"}},[a("text",{staticClass:"hexiao time margin-right-xs"},[t._v(t._s(t.outCouponData.discount.time))]),t._v(" "),0==t.outCouponData.discount.type?a("text",{staticClass:"time_text"},[t._v("分钟")]):a("text",{staticClass:"time_text"},[t._v("次")])])])]):t._e(),t._v(" "),2==t.outCouponData.type?a("view",{staticClass:"flex justify-center margin-top"},[a("div",{staticClass:"flex justify-center quan_container_lil"},[a("div",{staticStyle:{display:"flex","align-items":"baseline"}},[a("text",{staticClass:"time_text"},[t._v("满")]),t._v(" "),a("text",{staticClass:"manjian time margin-lr-xs"},[t._v(t._s(t.outCouponData.discount.full))]),t._v(" "),a("text",{staticClass:"time_text"},[t._v("减")]),t._v(" "),a("text",{staticClass:"manjian time margin-left-xs"},[t._v(t._s(t.outCouponData.discount.reduce))])])])]):t._e(),t._v(" "),3==t.outCouponData.type?a("view",{staticClass:"flex justify-center margin-top"},[a("div",{staticClass:"flex justify-center quan_container_lil"},[a("div",{staticStyle:{display:"flex","align-items":"baseline"}},[a("text",{staticClass:"time_text"},[t._v("打")]),t._v(" "),a("text",{staticClass:"discount time margin-lr-sm"},[t._v(t._s(10*t.outCouponData.discount.discount))]),t._v(" "),a("text",{staticClass:"time_text"},[t._v("折")])])])]):t._e(),t._v(" "),4==t.outCouponData.type?a("view",{staticClass:"flex justify-center margin-top"},[a("div",{staticClass:"flex justify-center quan_container_lil"},[a("div",{staticStyle:{display:"flex","align-items":"baseline"}},[a("text",{staticClass:"time_text"},[t._v("随机")]),t._v(" "),a("text",{staticClass:"random time margin-lr-xs"},[t._v(t._s(t.outCouponData.discount.start))]),t._v(" "),a("text",{staticClass:"time_text"},[t._v("至")]),t._v(" "),a("text",{staticClass:"random time margin-lr-xs"},[t._v(t._s(t.outCouponData.discount.end))]),t._v(" "),a("text",{staticClass:"time_text"},[t._v("元")])])])]):t._e()]),t._v(" "),a("view",{staticClass:"flex justify-center margin-top-xl"},[a("button",{staticClass:"cu-btn get_btn text-white",attrs:{eventid:"2"},on:{click:t.get_coupon}},[t._v("\n 领取\n ")])],1)]),t._v(" "),a("van-popup",{attrs:{show:t.pop_show,round:"",eventid:"4",mpcomid:"12"},on:{close:t.close_pop}},[a("div",{staticClass:"err_container flex flex-direction align-center justify-around"},[a("view",[a("text",{staticClass:"title"},[t._v(" 您当前剩余时间不足 ")])]),t._v(" "),a("view",[a("text",{staticClass:"sub-title"},[t._v(" 请充值后进行游戏 ")])]),t._v(" "),a("img",{staticClass:"err_img",attrs:{src:"https://img.shuimuai.com/web/sign_notimeJfish.png",alt:""}}),t._v(" "),a("button",{staticClass:"cu-btn lg bg-primary text-white",attrs:{eventid:"3"},on:{click:t.to_recharge}},[t._v("\n 立即充值\n ")])],1)]),t._v(" "),a("van-toast",{attrs:{id:"van-toast",mpcomid:"13"}})],1)},staticRenderFns:[]};e.a=i},hkID:function(t,e){},"ia+7":function(t,e,a){"use strict";var i={render:function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"animation-slide-right",attrs:{id:"index_login_container"}},[t._m(0),t._v(" "),a("view",{staticClass:"text-df text-center slogen"},[t._v("在此将会体验到操控专注力的神奇感觉")]),t._v(" "),a("div",{staticClass:"sub_slogen text-center"},[t._v("\n 现在,开始您的专注力旅程吧!\n ")]),t._v(" "),a("div",{staticClass:"text-center padding-lr padding-top"},[t.is_scan?a("button",{staticClass:"cu-btn lg cu-btn-primary text-white text-center",attrs:{eventid:"1"},on:{click:function(e){t.to_regist(0)}}},[t._v("注册\n ")]):a("button",{staticClass:"cu-btn lg cu-btn-primary text-white text-center",attrs:{eventid:"0"},on:{click:t.to_scan}},[t._v("扫码注册\n ")])],1),t._v(" "),t._m(1),t._v(" "),a("view",{staticClass:"text-center text-lg padding-lr",attrs:{eventid:"2"},on:{click:function(e){t.to_regist(1)}}},[a("text",{staticClass:"text-gray under_line"},[t._v("账号登录")])]),t._v(" "),a("van-toast",{attrs:{id:"van-toast",mpcomid:"0"}}),t._v(" "),a("van-dialog",{attrs:{id:"van-dialog",mpcomid:"1"}})],1)},staticRenderFns:[function(){var t=this.$createElement,e=this._self._c||t;return e("view",{staticClass:" text-xl padding text-center"},[e("text",{staticClass:" text-bold title_color"},[this._v("欢迎来到水母星球!")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("view",{staticClass:"text-center slogen_title"},[e("text",{staticClass:"text-gray"},[this._v("如果您在我们实体店,请在店员的指导下连接水母智脑机")])])}]};e.a=i},kI2d:function(t,e){},mDzu:function(t,e,a){"use strict";let i=[];const s={show:!1,title:"",width:null,theme:"default",message:"",zIndex:100,overlay:!0,selector:"#van-dialog",className:"",asyncClose:!1,beforeClose:null,transition:"scale",customStyle:"",messageAlign:"",overlayStyle:"",confirmButtonText:"确认",cancelButtonText:"取消",showConfirmButton:!0,showCancelButton:!1,closeOnClickOverlay:!1,confirmButtonOpenType:""};let n=Object.assign({},s);const o=t=>(t=Object.assign(Object.assign({},n),t),new Promise((e,a)=>{const s=(t.context||function(){const t=getCurrentPages();return t[t.length-1]}()).selectComponent(t.selector);delete t.context,delete t.selector,s?(s.setData(Object.assign({callback:(t,i)=>{"confirm"===t?e(i):a(i)}},t)),wx.nextTick(()=>{s.setData({show:!0})}),i.push(s)):console.warn("未找到 van-dialog 节点,请确认 selector 及 context 是否正确")}));o.alert=(t=>o(t)),o.confirm=(t=>o(Object.assign({showCancelButton:!0},t))),o.close=(()=>{i.forEach(t=>{t.close()}),i=[]}),o.stopLoading=(()=>{i.forEach(t=>{t.stopLoading()})}),o.currentOptions=n,o.defaultOptions=s,o.setDefaultOptions=(t=>{n=Object.assign(Object.assign({},n),t),o.currentOptions=n}),o.resetDefaultOptions=(()=>{n=Object.assign({},s),o.currentOptions=n}),o.resetDefaultOptions(),e.a=o},nB6K:function(t,e,a){"use strict";var i=a("FbTb"),s=a("gZKW");var n=function(t){a("KqPs"),a("qoUQ")},o=a("ybqe")(i.a,s.a,n,"data-v-3b275ba2",null);e.a=o.exports},nxsI:function(t,e,a){"use strict";var i,s=a("iy8u"),n=a("mDzu"),o=a("IcnI"),c=a("5S+K");e.a={name:"login_container",data:function(){return{is_scan:!1,official_show:!1}},methods:{to_regist:function(t){this.$emit("changeStatus","regist"),this.$emit("changeTitle",t)},to_scan:function(){wx.scanCode({onlyFromCamera:!0,success:function(t){var e=t;if(e.result){var a=decodeURIComponent(e.result),n=a.match(/\?code=(.*)/);if(-1!=a.indexOf("jellyfish"))return s.a.fail("请先登录"),!1;var o=n[1];i.do_invite_code(o)}}})},do_invite_code:function(t){i.is_scan=!0,wx.login({success:function(e){var a=e.code;console.log(a),Object(c.h)(t,a).then(function(t){var e=t.data;0!=e.code&&s.a.fail(e.errmsg)})}}),o.a.setters.set_invite_code(t)},official_success:function(t){console.log("关注组件加载成功",t)},onClickHide:function(){i.official_show=!1}},mounted:function(){global.mpvue.login({success:function(t){var e=t.code;o.a.setters.setJsCode(e),Object(c.i)(e).then(function(t){var e=t.data.data;i.official_show=2==e.have_unionid})}})},onLoad:function(t){var e=wx.getStorageSync("code");if(t.q){var a=decodeURIComponent(t.q).match(/\?code=(.*)/)[1];this.do_invite_code(a),console.log("1---"+e,"2---"+a),e&&e!=a&&s.a.fail("该用户已绑定邀请码")}else this.is_scan=!1,n.a.alert({transition:"fade",message:"如需体验水母星球产品,请使用微信扫一扫水母星球邀请卡,注册水母星球会员",theme:"round-button"})},created:function(){i=this}}},pG1U:function(t,e,a){"use strict";var i=a("7rf+"),s=a("MvAJ");var n=function(t){a("W4RK")},o=a("ybqe")(i.a,s.a,n,"data-v-4c53fc58",null);e.a=o.exports},qoUQ:function(t,e){},vFh2:function(t,e){},vGuI:function(t,e,a){"use strict";var i=a("WZyD"),s=a("Y7+B");var n=function(t){a("eZH0")},o=a("ybqe")(i.a,s.a,n,"data-v-670be52d",null);e.a=o.exports},xMZz:function(t,e,a){"use strict";var i=a("mvHQ"),s=a.n(i),n=a("FdfV"),o=a("HFAl"),c=a("Ga+u"),l=a("vGuI"),r=a("B0CS"),_=a("iy8u"),p=a("mDzu"),v=a("RVip"),m=a("wOfB"),f=a("0xDb"),u=a("cZVI"),d=void 0;e.a={name:"device",components:{device_unconnect:n.a,device_connecting:o.a,device_connected:c.a,toy_connecting:l.a,gameIng:r.a},data:function(){return{rssi:0,device_status:0,connect_show:!1,device_bg:!1,choose_toy_window:{show:!1},toy_list:[],toy_item:{},toy_action:1,connect_toy:0,code:"jellyfish1234",deviceId:"",_device_index:!1,toy_id:0,toy_hex:"",device_power:0,toy_power:0,toy_sn:"教具",toy_UUID:"",start_show:!1,game_status:0,current_hex:"",toy_connected:!1,device_finded:!1,device_data:{sn:"",product_name:"",product_model:"",product_qrcode:"",production_date:"",manufacturing_plan:"",hardware_version:"",software_version:"",device_id:"",pc_device_id:"",ios_device_id:"",type:"",UUID:""},connect_status:!1,bleFoundTimeOut:void 0}},methods:{open_scan:function(){d.connect_status=!1,m.a.setters.setGameStatus(0),wx.getSystemInfoAsync({success:function(t){0==t.bluetoothEnabled?p.a.alert({title:"蓝牙功能未开启",message:"请打开蓝牙,允许水母星球使用蓝牙服务"}).then(function(){wx.openSystemBluetoothSetting()}):0==t.locationAuthorized?p.a.alert({title:"位置权限未开启",message:"当前无位置访问权限,请在手机[设置]应用中,允许[微信]使用位置服务"}).then(function(){wx.openAppAuthorizeSetting()}):0==t.locationEnabled?-1!=t.system.indexOf("iOS")?d.scan_to_bluetooth():p.a.alert({title:"位置信息未开启",message:"当前无位置访问权限,请在设置中,允许水母星球使用位置服务"}).then(function(){}):d.scan_to_bluetooth()}})},scan_to_bluetooth:function(){wx.scanCode({onlyFromCamera:!0,scanType:["barCode","qrCode"],success:function(t){var e=t;if(e.result){var a=decodeURIComponent(e.result),i="";"QR_CODE"==t.scanType?-1!=a.indexOf("AI")?i=a.substr(a.indexOf("AI")):a.toUpperCase().indexOf("JELLYFISH")&&(i=a.substr(a.toUpperCase().indexOf("JELLYFISH"))):i=t.result.toUpperCase(),d.code=i,m.a.setters.setIsNew(-1!=i.indexOf("AI")),console.log("头环码",i),m.a.setters.setDeviceSn(d.code),d.device_data.product_qrcode=a,d.device_data.sn=d.code,d.device_data.product_name="水母智脑机",d.device_data.manufacturing_plan="深圳水母智脑科技有限公司",d.device_data.type=1,d.device_data.production_date=Object(f.f)(),wx.getSystemInfo({success:function(t){"ios"==t.platform?wx.openBluetoothAdapter({mode:"central",success:function(t){"openBluetoothAdapter:ok"==t.errMsg&&wx.openBluetoothAdapter({mode:"peripheral",success:function(t){"openBluetoothAdapter:ok"==t.errMsg&&d.startBluetoothDevicesDiscovery()},fail:function(t){var e=d.$bluetooth.GetopenBluetoothAdapterError(t.errCode);setTimeout(function(){_.a.fail({message:e})},3e3)}})},fail:function(t){var e=d.$bluetooth.GetopenBluetoothAdapterError(t.errCode);setTimeout(function(){_.a.fail({message:e})},3e3)}}):wx.openBluetoothAdapter({mode:"peripheral",success:function(t){"openBluetoothAdapter:ok"==t.errMsg&&d.startBluetoothDevicesDiscovery()},fail:function(t){setTimeout(function(){_.a.fail({message:t.errCode})},3e3)}})}})}},fail:function(t){console.log(t)}})},on_close:function(){d.choose_toy_window.show=!1},choose_toy:function(t){d.toy_action=d.toy_list[t].id},open_choose_toy:function(){d.choose_toy_window.show=!0,d.toy_connected=!1,d.toy_sn="教具",d.$bluetooth.SendOrder("09")},choose_ok:function(){d.on_close(),d.change_toy_connect_status(1),d._device_index=d.toy_action-1;var t={};d.toy_list.forEach(function(e,a){e.id==d.toy_action&&(d.toy_item=t=e)}),d.toy_id=t.id;var e=d.toy_hex=t.hex.substr(t.hex.length-2,2);d.current_hex="03 00 "+e+" 00 0a","80"==e?wx.setStorageSync("report_mode",2):wx.setStorageSync("report_mode",1),d.$bluetooth.sendConnectOneToMore(e),setTimeout(function(){0==d.toy_connected&&d.change_toy_connect_status(3)},1e4)},change_toy_connect_status:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;d.connect_toy=t,d.connect_show=1==t},change_device_status:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(d.device_status=t,0==t||3==t){clearTimeout(d.bleFoundTimeOut),wx.offBluetoothDeviceFound(),wx.stopBluetoothDevicesDiscovery(),m.a.setters.setGameStatus(0),d.connect_toy=t,d.connect_show=!1,d.device_bg=!1,d.connect_status=!1,d.$bluetooth.SendOrder("09");var e=m.a.getters.getDeviceId();d.change_toy_connect_status(0),wx.closeBLEConnection({deviceId:e,success:function(t){_.a.success({message:"已成功断开"}),m.a.setters.clearDeviceToy(),wx.closeBluetoothAdapter()},fail:function(t){console.log("断开连接error:",t)},complete:function(t){d.device={},d.toy_UUID="",d.$forceUpdate()}})}else 2==t&&(d.connect_show=!0)},startBluetoothDevicesDiscovery:function(){wx.startBluetoothDevicesDiscovery({allowDuplicatesKey:!0,success:function(t){d.onBluetoothDeviceFound()},fail:function(t){d.change_device_status(3)}})},onBluetoothDeviceFound:function(){d.change_device_status(1),d.bleFoundTimeOut=setTimeout(function(){0==d.connect_status&&(wx.offBluetoothDeviceFound(),wx.stopBluetoothDevicesDiscovery(),d.change_device_status(0),p.a.confirm({message:"脑机连接失败",showCancelButton:!0,cancelButtonText:"查看指引"}).then(function(){}).catch(function(){wx.navigateTo({url:"/pages/guide/main"})}))},7e3);try{wx.onBluetoothDeviceFound(function(t){t.devices.forEach(function(t){(t.name||t.localName)&&(t.localName&&""!=t.localName&&(t.name=t.localName),t.name.toUpperCase()==d.code&&(d.stopBluetoothDevicesDiscovery(),console.log("搜索设备",t),d.createBLEConnection(t.deviceId),d.device_data.deviceId=t.deviceId,clearTimeout(d.bleFoundTimeOut)))})})}catch(t){console.log("打开蓝牙error",t)}},stopBluetoothDevicesDiscovery:function(){wx.stopBluetoothDevicesDiscovery()},createBLEConnection:function(t){wx.offBluetoothDeviceFound(),wx.stopBluetoothDevicesDiscovery(),wx.createBLEConnection({deviceId:t,success:function(e){d.connect_status=!0,wx.setBLEMTU({deviceId:t,mtu:250,success:function(t){console.log("设置mtu成功",s()(t))}}),Object(u.a)(d.code+",连接成功"),d.$bluetooth.current_device_sn=d.code,m.a.setters.setDeviceId(t),d.change_device_status(2),d.$bluetooth.getBLEDeviceServices(t);var a=setInterval(function(){m.a.getters.getServiceId()&&(clearInterval(a),d.$bluetooth.openNotify(d),d.$bluetooth.watchingDevice(d),d.$bluetooth.watch_bluetooth_status(d))},1500)},fail:function(t){console.log(t)}})},get_toy_list:function(){d.toy_list=[],Object(v.e)().then(function(t){var e={};t.data.data.forEach(function(t,a){e={id:parseInt(t.device_id),name:t.name,img:"https://img.shuimuai.com/"+t.img,hex:t.bluetooth},d.toy_list.push(e)}),m.a.setters.setToyList(d.toy_list)})},onStartGameShowClose:function(){d.start_show=!1,d.game_status=0},gameStart:function(){d.game_status=1,d.connect_toy=4}},mounted:function(){d.get_toy_list()},created:function(){d=this},onShow:function(){var t=m.a.getters.getGameStatus(),e=m.a.getters.getGameCloseStatus();3==t&&(0==wx.getStorageSync("ble_link_status")&&d.change_device_status(0),d.connect_toy=0,d.connect_show=!0,d.$bluetooth.watchingDevice(d),d.$bluetooth.watch_bluetooth_status(d),d.toy_UUID="",d.$forceUpdate(),1==e&&(d.connect_toy=0,d.connect_show=!1,d.device_status=0,d.$bluetooth.watch_bluetooth_status(d),d.toy_UUID="",d.$forceUpdate(),m.a.setters.clearDeviceToy()))},onHide:function(){},onLoad:function(t){var e=wx.getStorageSync("code");if(t.q){var a=decodeURIComponent(t.q).match(/\?code=(.*)/)[1];console.log("1---"+e,"2---"+a),e&&e!=a&&_.a.fail("该用户已绑定邀请码")}}}}},["MhDc"]);