subGame.nvue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290
  1. <template>
  2. <view>
  3. <!-- :src="url" src = 'http://192.168.0.112:7456/build/index.html' src = 'http://192.168.0.109:7456/'-->
  4. <!-- @receivedtitle="onReceivedTitle" @pagefinish="onPageFinish" http://192.168.31.223:7456/-->
  5. <view class="web-view">
  6. <web-view class="web-view-child" :src="url" ref="webview" @pagestart="onPageStart"
  7. @onPostMessage="handlePostMessage" @error="onError"></web-view>
  8. </view>
  9. <view class="web-back" @click="navBack">
  10. <image style="width: 40rpx;height: 40rpx;" src="/static/gameCloseW.png"></image>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. import reqUtil from "@/util/util-js/requstUtil.js";
  16. import config from "@/common/config.js";
  17. import fruit from "@/components/fruitMachine/fruit.js"
  18. // import AccAndOri from "@/util/util-js/AccAndOri.js"
  19. import puchConfig from "@/util/util-js/puchConfig.js"
  20. import EquipmentAction from "@/util/util-js/EquipmentAction.js"
  21. import ActionJump from "@/util/util-js/action/jump-0.2.js"
  22. var currentWebview;
  23. var orientId = null,
  24. accId = null;
  25. import {
  26. mapState,
  27. mapMutations
  28. } from 'vuex';
  29. export default {
  30. computed: mapState([
  31. 'avatarUrl', 'gender', 'userName', 'city', 'BLEConnectDevice', 'instructionState',
  32. 'currentInstruction',
  33. 'cIndex', 'globalAcc', 'globalOri', 'LocationGameUrl',
  34. 'ConnectBindingDevice',
  35. 'currentModeIndex',
  36. 'bOldDeviceType'
  37. ]),
  38. data() {
  39. return {
  40. url: '',
  41. pagefinish: '',
  42. error: '',
  43. PageStart: false, // 记录网页请求的加载状态,true 加载成功 false 加载失败
  44. gameQuitListener: false, //游戏是否初始化退出监听
  45. xA: 0,
  46. yA: 0,
  47. zA: 0,
  48. oldxA: 0,
  49. oldzA: 0,
  50. bUpdateOnce: false,
  51. bDelayOnce: false,
  52. mass: puchConfig.BOXING_MASS,
  53. //X轴的变化数组值
  54. xAccArray: [],
  55. xMax: 0,
  56. maxTimeoutId: null,
  57. bMaxPause: false,
  58. xMin: 0,
  59. minTimeoutId: null,
  60. bMinPause: false,
  61. bCalculation: false,
  62. calTimeout: null,
  63. //角度比 z/x
  64. angleRatio: 1, //
  65. //当前选择的item
  66. decodeItem: null,
  67. //拳击数据判断对象
  68. EquipmentActionObj: null,
  69. BLENum: 0,
  70. BLEACX: 0,
  71. BLEACYL: 0,
  72. //是否是游戏里面开启的监听,如果是的话,退出游戏界面时候需要关闭相应的监听,如加速计和陀螺仪
  73. bGameOpenListen: false,
  74. //手机陀螺仪和加速计android模块
  75. bMyAttitudeListen: false,
  76. /**
  77. * 跳绳相应数据
  78. */
  79. //跳绳数据判断对象
  80. actionJumpObj: null,
  81. BLEAccIndex: 0
  82. }
  83. },
  84. onLoad() {
  85. let _self = this;
  86. var pages = getCurrentPages();
  87. var page = pages[pages.length - 1];
  88. currentWebview = page.$getAppWebview();
  89. //监听一次调用setOnceGameOption
  90. console.log("子组件初始化");
  91. uni.$once("setOnceGameOption", (option) => {
  92. console.log("setOnceGameOption=", option);
  93. if (option && option.item) {
  94. this.decodeItem = JSON.parse(decodeURIComponent(option.item));
  95. this.url = this.decodeItem.gameWebUrl;
  96. let temp = {
  97. fObjectId: this.decodeItem.gameId,
  98. recentlyType: 0
  99. }
  100. // console.log("game temp:", config.URL.RECENTLYPLAYINGADD);
  101. //添加最近在玩的游戏
  102. reqUtil.requestData(config.URL.RECENTLYPLAYINGADD, temp).then(res => {
  103. console.log('RECENTLYPLAYINGADD =====', res);
  104. if (res.code == 0) {}
  105. },
  106. e => {
  107. console.log(e)
  108. });
  109. }
  110. });
  111. //子窗体onload 后获取父窗体的onload数据
  112. uni.$emit("game-load");
  113. uni.getCurrentSubNVue().addEventListener("hide", function() {
  114. console.log("subNVue子窗体已隐藏!");
  115. //通知游戏,页面退出
  116. _self.sendMessage("onSubHide", {
  117. msg: '退出页面'
  118. });
  119. uni.$off('updateBLEDeviceData', _self.BLECallback);
  120. //json
  121. uni.$off('updateBLEDeviceJson', _self.BLEJsonCallback);
  122. //去掉监听
  123. if (_self.bMyAttitudeListen) {
  124. _self.gStopSimulateBLEUpdate();
  125. }
  126. // console.log(_self.BLEConnectDevice);
  127. //如果连接了蓝牙设备是手柄
  128. if (_self.BLEConnectDevice && ( _self.BLEConnectDevice.deviceType == "BLEHandle" || _self.BLEConnectDevice.deviceType == "BLEIntelligent")) {
  129. //开启设备回调 3/4关闭
  130. _self.onWriteBLEConnectionValue({
  131. value: "4"
  132. });
  133. //关闭json 回调
  134. _self.onWriteBLEConnectionValue({
  135. value: "6"
  136. });
  137. uni.$off('updateBLEDeviceData', _self.gWatchBLEUpdate);
  138. if (0 === _self.currentModeIndex) {
  139. //拳击柱
  140. _self.uploadUserData_hitCount();
  141. }
  142. } //关闭跳绳模式指令
  143. else if (_self.BLEConnectDevice && _self.BLEConnectDevice.deviceType == "BLERope") {
  144. console.warn("还没设置关闭跳绳模式")
  145. _self.B_CloseRopeSkipping();
  146. uni.$off('updateBLEDeviceData', _self.gWatchBLEUpdate);
  147. }
  148. uni.$emit("game-unload", {
  149. globalAcc: _self.globalAcc,
  150. globalOri: _self.globalOri,
  151. bGameOpenListen: _self.bGameOpenListen
  152. });
  153. });
  154. //*****注释蓝牙操作******
  155. // 监听事件
  156. // uni.$on('callbackCloseBLE', this.callbackCloseBLE);
  157. // uni.$on('callbackBLEState', this.callbackBLEState);
  158. // uni.$on('updateBLEDeviceData', this.BLECallback);
  159. //监听物理返回按钮
  160. plus.key.addEventListener('backbutton', () => {
  161. this.navBack();
  162. }, false);
  163. //设置store状态
  164. _self.$store.state.bGamePlaying = true;
  165. },
  166. onUnload() {
  167. this.$store.state.bGamePlaying = false;
  168. console.log("subNVue子窗体 onUnload!");
  169. //*****注释蓝牙操作******
  170. // uni.$off('callbackCloseBLE', this.callbackCloseBLE);
  171. // uni.$off('callbackBLEState', this.callbackBLEState);
  172. //取消相应的绑定事件
  173. uni.$off('watchAcceleration', this.gWatchAcceleration);
  174. uni.$off("watchAcceleration", this.gWatchBoxingAcc);
  175. uni.$off("watchAcceleration", this.gWatchHitBoxingAcc);
  176. uni.$off('watchOrientation', this.gWatchOrientation);
  177. uni.$emit("game-unload");
  178. },
  179. methods: {
  180. ...mapMutations(['addlocalCalorie', 'syncRequestEvent', 'onWriteBLEConnectionValue', 'B_WriteHexToBLECharacteristic',
  181. 'gCreateFilterObj', 'gUpdateFilter', 'B_OpenRopeSkipping', 'B_CloseRopeSkipping',
  182. 'gStopSimulateBLEUpdate', 'gStartSimulateBLEUpdate', 'gIntelligentUpdateSandbagAlgorithm', 'gUpdateSandbagAlgorithm',
  183. 'gCreateSandbagAlgorithm','gIntelligentCreateSandbagAlgorithm', 'onConvertDeviceData', 'addSandbagHitCount', 'uploadUserData_hitCount',
  184. 'jumpIdenModule_onJump6AxisDataUpdate'
  185. ]),
  186. navBack() {
  187. this.sendMessage("onQuit", {
  188. type: "right-button",
  189. msg: '点击右上角按钮退出游戏'
  190. });
  191. uni.showModal({
  192. title: '提示',
  193. content: '是否退出游戏?',
  194. success: (res) => {
  195. //如果游戏需要监听退出,则需要走完游戏端流程,才能退出,否则直接退出
  196. if (this.gameQuitListener) {
  197. this.sendMessage("onQuitModal", {
  198. data: res,
  199. msg: '退出提示'
  200. });
  201. } else {
  202. if (res.confirm) {
  203. uni.getCurrentSubNVue().hide('auto');
  204. }
  205. }
  206. }
  207. })
  208. },
  209. //蓝牙断开连接时候
  210. callbackCloseBLE() {
  211. this.sendMessage("onDeviceClose", {
  212. msg: '设备断开连接。'
  213. });
  214. },
  215. //蓝牙状态回调
  216. callbackBLEState(res) {
  217. // console.log("game callbackBLEState==", res);
  218. // 暂时只返回数据连接错误信息
  219. // uni.$emit("callbackBLEState", {
  220. // state: -1,
  221. // msg: "设备数据错误"
  222. // });
  223. this.sendMessage("onDeviceState", res)
  224. },
  225. BLECallback(data) {
  226. let dataType = 'Box';
  227. // if (data.hasOwnProperty("ax")) {
  228. // dataType = "Accelerometer"
  229. // }else if(data.hasOwnProperty("gx")){
  230. // dataType = "Gyroscope"
  231. // }
  232. // 设备回调后面用这个接口
  233. let BLEState = {
  234. device: this.BLEConnectDevice, //连接的蓝牙设备
  235. instructionState: this.instructionState, //开启的指令状态
  236. currentInstruction: this.currentInstruction, //当前发送的指令记录
  237. dataType: dataType, //回调的数据类型
  238. data: data //蓝牙回调的数据
  239. }
  240. this.sendMessage("onDeviceUpdateData", BLEState);
  241. },
  242. BLEJsonCallback(data) {
  243. let dataType = 'Json';
  244. // 设备回调后面用这个接口
  245. let BLEState = {
  246. device: this.BLEConnectDevice, //连接的蓝牙设备
  247. instructionState: this.instructionState, //开启的指令状态
  248. currentInstruction: this.currentInstruction, //当前发送的指令记录
  249. dataType: dataType, //回调的数据类型
  250. data: data //蓝牙回调的数据
  251. }
  252. this.sendMessage("onDeviceUpdateJson", BLEState);
  253. },
  254. /**
  255. * 图片转化base64
  256. * @param {Object} url
  257. * @param {Object} callback
  258. */
  259. urlToBase64(url, callback) {
  260. let toBase64Url;
  261. uni.request({
  262. url: url,
  263. method: 'GET',
  264. responseType: 'arraybuffer',
  265. success: async res => {
  266. let base64 = uni.arrayBufferToBase64(res.data);
  267. toBase64Url = 'data:image/jpeg;base64,' + base64;
  268. if (callback)
  269. callback(toBase64Url, res.data);
  270. }
  271. })
  272. },
  273. /**
  274. * 初始化发送数据给游戏
  275. */
  276. sendGameInit() {
  277. console.log("this.avatarUrl:", this.avatarUrl);
  278. this.urlToBase64(this.avatarUrl, (toBase64Url) => {
  279. let device = null;
  280. /**
  281. * 卡路里消耗参数
  282. */
  283. let calorieParams = {
  284. hitUnit: 0,
  285. runUnit: puchConfig.getRunCalorie(1),
  286. jumpUnit: puchConfig.getJumpCalorie(1)
  287. };
  288. if (this.BLEConnectDevice) {
  289. // device = {
  290. // cname: this.BLEConnectDevice.cname,
  291. // ename: this.BLEConnectDevice.ename,
  292. // name: this.BLEConnectDevice.name
  293. // };
  294. // calorieParams = {
  295. // runUnit: 0.55, // 比跳的稍微大一点
  296. // jumpUnit: 0.5 // 跳的次数 * 0.5
  297. // };
  298. device = {
  299. cname: this.BLEConnectDevice.cname,
  300. ename: this.BLEConnectDevice.ename,
  301. name: this.BLEConnectDevice.name
  302. };
  303. calorieParams.hitUnit = puchConfig.getBoxingCalorie(1);
  304. } else if (this.ConnectBindingDevice) {
  305. device = {
  306. cname: this.ConnectBindingDevice.cname,
  307. ename: this.ConnectBindingDevice.ename,
  308. name: this.ConnectBindingDevice.name
  309. };
  310. calorieParams.hitUnit = puchConfig.getBoxingCalorie(1);
  311. }
  312. //到时候可能要区分是什么类型
  313. let item = {
  314. id: this.decodeItem.gameId,
  315. name: this.decodeItem.gameName
  316. };
  317. // console.log(this.BLEConnectDevice, device);
  318. let gameData = {
  319. avatarUrl: this.avatarUrl,
  320. avatarBase64Url: toBase64Url,
  321. userName: this.userName,
  322. gender: this.gender,
  323. caloriUnit: 10,
  324. calorieParams: calorieParams,
  325. //蓝牙连接的设备
  326. device: device,
  327. item: item
  328. }
  329. this.sendMessage("onGameInit", gameData);
  330. // console.log("onGameInit =", gameData);
  331. })
  332. },
  333. /**
  334. * 统一发送信息
  335. * @param {Object} gameData
  336. */
  337. sendMessage(functionName, gameData) {
  338. let data = {
  339. "funName": functionName,
  340. "gameData": gameData
  341. }
  342. if (!this.PageStart) {
  343. console.warn("页面未初始化不能传消息", data);
  344. return;
  345. }
  346. let initStr = JSON.stringify(data);
  347. // console.log(functionName);
  348. this.$refs.webview.evalJs("onWebViewMessage(" + initStr + ")");
  349. },
  350. sendMessageToWebview() {
  351. if (!this.PageStart) {
  352. uni.showModal({
  353. title: "暴躁的提示",
  354. content: "只有网页加载成功了才可以传参过去,不然无效哦。。"
  355. })
  356. return false;
  357. }
  358. /**
  359. * 下面的 jsfunction 代码你要自己在你的网页里面写一个方法 大致如下
  360. * 下面就是你基本的html知识了,我就不想说什么了,自己学。
  361. window.jsfunction = function(data){
  362. console.log('data', data);
  363. }
  364. */
  365. this.sendMessage("onDeviceUpdateData", {
  366. H: 1
  367. });
  368. },
  369. handlePostMessage: function(postData) {
  370. console.log("handlePostMessage得到参数", postData.detail);
  371. let temp = postData.detail.data[0];
  372. let gameData = temp.gameData;
  373. if (temp.funName == "uploadInfo") {
  374. //TODO:写入排行榜分数,后面需要在游戏完结里面调用
  375. //TODO: 后面游戏时间,卡路里的需要写入数据库,目前只是处理了分数
  376. // let num = Math.round(Math.random() * 10000);
  377. //1. gameScore 处理上传的分数
  378. // let _temp = {
  379. // gameId: '1595755153789139696',
  380. // score: 1230,
  381. // cityCode: '110101',
  382. // };
  383. //2. calorieBurned 处理卡路里
  384. // 记录卡路里到本地
  385. this.addlocalCalorie(gameData.calorieBurned);
  386. console.log("gameData.calorieBurned", gameData.calorieBurned);
  387. //然后更新上服务器
  388. this.syncRequestEvent({
  389. success: () => {
  390. // uni.$emit('updateArcbarData', '');
  391. let _temp = {
  392. //假如排行id 为空,排行榜就是游戏自己的id
  393. gameId: this.decodeItem.gameRankingId == null ? this.decodeItem
  394. .gameId : this.decodeItem.gameRankingId,
  395. score: gameData.gameScore,
  396. cityCode: this.city.cityCode,
  397. bMaxLimit: true
  398. }
  399. console.log('_temp =====', _temp);
  400. reqUtil.requestData(config.URL.UPLOADRANKING, _temp, "POST").then(res => {
  401. console.log('UPLOADRANKING =====', res);
  402. if (res.code == 0) {
  403. //TODO 后续游戏数据处理
  404. this.sendMessage("onUploadInfo", {
  405. code: 0,
  406. msg: '上传成功'
  407. });
  408. } else {
  409. //TODO 后续游戏数据处理
  410. this.sendMessage("onUploadInfo", {
  411. code: 400,
  412. msg: '上传失败'
  413. });
  414. }
  415. },
  416. e => {
  417. console.log(e)
  418. });
  419. },
  420. fail: () => {
  421. this.sendMessage("onUploadInfo", {
  422. code: 400,
  423. msg: '上传失败'
  424. });
  425. }
  426. });
  427. //3. gameTime 游戏时间
  428. //TODO 后面处理游戏时长
  429. } else if (temp.funName == "gameInit") {
  430. // 获取游戏信息
  431. this.sendGameInit();
  432. } else if (temp.funName == "aiRandomInfo") {
  433. // 获取aiRandomInfo
  434. reqUtil.requestData(config.URL.AIRANDOMINFO, {}).then(res => {
  435. console.log('AIRANDOMINFO =====', res);
  436. if (res.code == 0) {
  437. let data = res.data;
  438. this.urlToBase64(data.aiAvatar, (toBase64Url) => {
  439. let sendData = {
  440. aiId: data.aiId,
  441. aiName: data.aiName,
  442. aiGender: data.aiGender,
  443. aiType: data.aiType,
  444. aiAvatarBase64Url: toBase64Url
  445. }
  446. this.sendMessage("onAiRandomInfo", sendData);
  447. })
  448. }
  449. },
  450. e => {
  451. console.log(e)
  452. });
  453. } else if (temp.funName == "fruitInfo") {
  454. let fruitIndexArray = [0, 0, 0];
  455. if (gameData.hasOwnProperty("calorie")) {
  456. fruitIndexArray = fruit.getFruitIndex(gameData.calorie);
  457. }
  458. this.urlToBase64("https://bbeng-bucket.oss-cn-beijing.aliyuncs.com/cocos/fruitMachine.png", (
  459. toBase64Url) => {
  460. this.sendMessage("onFruitInfo", {
  461. // 水果雪碧图
  462. fruitBase64Url: toBase64Url,
  463. // 雪碧图 单张图片宽高
  464. unitWidth: 100,
  465. unitHeight: 100,
  466. unit: "px",
  467. imageStartPosY: 0,
  468. imageEndPosY: -1200,
  469. fruitIndexArray: fruitIndexArray
  470. });
  471. })
  472. } else if (temp.funName == "urlToBase64") {
  473. if (gameData.url) {
  474. this.urlToBase64(gameData.url, (toBase64Url) => {
  475. this.sendMessage("onUrlToBase64", {
  476. base64: toBase64Url,
  477. });
  478. })
  479. } else {
  480. this.sendMessage("onUrlToBase64", {
  481. base64: {},
  482. });
  483. }
  484. } else if (temp.funName == "openAccelerometer") {
  485. if (this.globalAcc) {
  486. uni.$off('watchAcceleration', this.gWatchAcceleration);
  487. uni.$on('watchAcceleration', this.gWatchAcceleration);
  488. } else {
  489. uni.$emit("bindAcc", {
  490. callback: (accId) => {
  491. console.log("开启的:globalAcc=", accId);
  492. this.bGameOpenListen = true;
  493. this.$store.state.globalAcc = accId;
  494. uni.$off('watchAcceleration', this.gWatchAcceleration);
  495. uni.$on('watchAcceleration', this.gWatchAcceleration);
  496. }
  497. });
  498. }
  499. } else if (temp.funName == "closeAccelerometer") {
  500. uni.$off('watchAcceleration', this.gWatchAcceleration);
  501. uni.$emit("unBindAcc", this.globalAcc);
  502. this.$store.state.globalAcc = null;
  503. } else if (temp.funName == "openOrientation") {
  504. //打开陀螺仪
  505. if (this.globalOri) {
  506. uni.$off('watchOrientation', this.gWatchOrientation);
  507. uni.$on('watchOrientation', this.gWatchOrientation);
  508. } else {
  509. uni.$emit("bindOri", {
  510. callback: (oriId) => {
  511. console.log("开启的:globalOri=", oriId);
  512. this.bGameOpenListen = true;
  513. this.$store.state.globalOri = oriId;
  514. uni.$off('watchOrientation', this.gWatchOrientation);
  515. uni.$on('watchOrientation', this.gWatchOrientation);
  516. }
  517. });
  518. }
  519. } else if (temp.funName == "closeOrientation") {
  520. uni.$off('watchOrientation', this.gWatchOrientation);
  521. uni.$emit("unBindOri", this.globalOri);
  522. this.$store.state.globalOri = null;
  523. } else if (temp.funName == "bindBoxingPost") {
  524. if (this.globalAcc) {
  525. uni.$off('watchAcceleration', this.gWatchBoxingAcc);
  526. uni.$on('watchAcceleration', this.gWatchBoxingAcc);
  527. } else {
  528. uni.$emit("bindAcc", {
  529. callback: (accId) => {
  530. console.log("bindBoxingPost开启的:globalAcc=", accId);
  531. this.bGameOpenListen = true;
  532. this.$store.state.globalAcc = accId;
  533. uni.$off('watchAcceleration', this.gWatchBoxingAcc);
  534. uni.$on('watchAcceleration', this.gWatchBoxingAcc);
  535. }
  536. });
  537. }
  538. } else if (temp.funName == "unbindBoxingPost") {
  539. uni.$off('watchAcceleration', this.gWatchBoxingAcc);
  540. uni.$emit("unBindAcc", this.globalAcc);
  541. this.$store.state.globalAcc = null;
  542. } else if (temp.funName == "setAngleRatio") {
  543. if (gameData) {
  544. this.angleRatio = Number(gameData.angleRatio);
  545. console.log("this.angleRatio:", this.angleRatio);
  546. this.sendMessage("onSetAngleRatio", {
  547. angleRatio: this.angleRatio
  548. });
  549. }
  550. } else if (temp.funName == "bindHitBoxingPost") {
  551. /**
  552. * 返回拳击柱的绑定状态
  553. */
  554. console.log("bindHitBoxingPost");
  555. if (this.ConnectBindingDevice) {
  556. uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
  557. uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
  558. //hotman 沙袋情景
  559. this.gCreateSandbagAlgorithm();
  560. this.gStartSimulateBLEUpdate();
  561. return;
  562. }
  563. if (!this.BLEConnectDevice) return;
  564. //用设备来区分,开启什么加速计;
  565. if (this.BLEConnectDevice.deviceType == "BLEHandle" || this.BLEConnectDevice.deviceType ==
  566. "BLEIntelligent") {
  567. //处理蓝牙设备情况下
  568. //开启设备回调 3/4关闭
  569. this.onWriteBLEConnectionValue({
  570. value: "3"
  571. });
  572. // setTimeout(() => {
  573. // //设置加速计b:20ms a:10ms
  574. // this.onWriteBLEConnectionValue({
  575. // value: config.refreshRate
  576. // });
  577. // }, 2000)
  578. uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
  579. uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
  580. if (this.BLEConnectDevice.usageMode == "phone" || this.BLEConnectDevice.usageMode ==
  581. "general") {
  582. //手机情景或者自由模式
  583. this._createEquipmentBasedOnBoxingPostHit();
  584. } else if (this.BLEConnectDevice.usageMode == "hotman") {
  585. //hotman 沙袋情景
  586. // this.gCreateSandbagAlgorithm();
  587. if (this.BLEConnectDevice.deviceType == "BLEIntelligent") {
  588. this.gIntelligentCreateSandbagAlgorithm();
  589. } else {
  590. this.gCreateSandbagAlgorithm();
  591. }
  592. }
  593. } else if (this.BLEConnectDevice.deviceType == "mySelf") {
  594. //处理手机本身情况下
  595. if (this.globalAcc) {
  596. uni.$off('watchAcceleration', this.gWatchHitBoxingAcc);
  597. uni.$on('watchAcceleration', this.gWatchHitBoxingAcc);
  598. } else {
  599. //开启手机加速计
  600. uni.$emit("bindAcc", {
  601. callback: (accId) => {
  602. console.log("bindHitBoxingPost开启的:globalAcc=", accId);
  603. this.bGameOpenListen = true;
  604. this.$store.state.globalAcc = accId;
  605. uni.$off('watchAcceleration', this.gWatchHitBoxingAcc);
  606. uni.$on('watchAcceleration', this.gWatchHitBoxingAcc);
  607. if (this.BLEConnectDevice.usageMode == "phone" || this.BLEConnectDevice
  608. .usageMode == "general") {
  609. //手机情景或者自由模式
  610. this._createEquipmentBasedOnBoxingPostHit();
  611. } else if (this.BLEConnectDevice.usageMode == "hotman") {
  612. //hotman 沙袋情景 todo
  613. console.warn("没有处理手机加速计的 gCreateFilterObj");
  614. // this.gCreateFilterObj();
  615. }
  616. }
  617. });
  618. }
  619. } else if (this.BLEConnectDevice.deviceType == "BLERope") {
  620. //todo 开启跳绳模式
  621. this.B_OpenRopeSkipping();
  622. // this._createActionJumpOnBoxingPostHit();
  623. //监听蓝牙回调
  624. uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
  625. uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
  626. }
  627. } else if (temp.funName == "unbindHitBoxingPost") {
  628. /**
  629. * 解绑拳击柱的绑定状态
  630. */
  631. if (this.ConnectBindingDevice) {
  632. uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
  633. this.gStopSimulateBLEUpdate();
  634. return;
  635. }
  636. if (this.BLEConnectDevice && (this.BLEConnectDevice.deviceType == "BLEHandle" || this
  637. .BLEConnectDevice.deviceType == "BLEIntelligent")) {
  638. //开启设备回调 3/4关闭
  639. this.onWriteBLEConnectionValue({
  640. value: "4"
  641. });
  642. uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
  643. } else if (this.BLEConnectDevice && this.BLEConnectDevice.deviceType == "BLERope") {
  644. console.warn("unbindHitBoxingPost 还没设置关闭跳绳模式")
  645. this.onClearData();
  646. this.B_CloseRopeSkipping();
  647. uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
  648. } else {
  649. uni.$off('watchAcceleration', this.gWatchHitBoxingAcc);
  650. uni.$emit("unBindAcc", this.globalAcc);
  651. this.$store.state.globalAcc = null;
  652. }
  653. } else if (temp.funName == "closeGame") {
  654. uni.getCurrentSubNVue().hide('auto');
  655. } else if (temp.funName == "addQuitModal") {
  656. this.gameQuitListener = true;
  657. this.sendMessage("onQuitModalListener", {
  658. bListener: this.gameQuitListener
  659. });
  660. } else if (temp.funName == "removeQuitModal") {
  661. this.gameQuitListener = false;
  662. this.sendMessage("onQuitModalListener", {
  663. bListener: this.gameQuitListener
  664. });
  665. } else if (temp.funName == "writeBLEConnectionValue") {
  666. if (!gameData.value || gameData.value == "") return;
  667. if (!this.BLEConnectDevice) return;
  668. //蓝牙写入数据
  669. this.onWriteBLEConnectionValue(gameData);
  670. } else if(temp.funName == "writeHexToBLEDevice"){
  671. if (!gameData.value || gameData.value == "") return;
  672. if (!this.BLEConnectDevice) return;
  673. //蓝牙写入数据
  674. this.B_WriteHexToBLECharacteristic(gameData);
  675. } else if (temp.funName == "log") {
  676. console.log(gameData);
  677. } else if (temp.funName == "addDeviceUpdateListener") {
  678. uni.$off('updateBLEDeviceData', this.BLECallback);
  679. uni.$on('updateBLEDeviceData', this.BLECallback);
  680. } else if (temp.funName == "closeDeviceUpdateListener") {
  681. uni.$off('updateBLEDeviceData', this.BLECallback);
  682. } else if (temp.funName == "addDeviceJsonUpdateListener") {
  683. uni.$off('updateBLEDeviceJson', this.BLEJsonCallback);
  684. uni.$on('updateBLEDeviceJson', this.BLEJsonCallback);
  685. } else if (temp.funName == "closeDeviceJsonUpdateListener") {
  686. uni.$off('updateBLEDeviceJson', this.BLEJsonCallback);
  687. }
  688. //获取手机原始陀螺仪和加速计数据
  689. else if (temp.funName == "onStartAccAndGyro") {
  690. this.bMyAttitudeListen = true;
  691. this.gStartSimulateBLEUpdate();
  692. //监听蓝牙回调
  693. uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
  694. uni.$on('updateBLEDeviceData', this.gWatchBLEUpdate);
  695. } else if (temp.funName == "onStopAccAndGyro") {
  696. this.bMyAttitudeListen = false;
  697. this.gStopSimulateBLEUpdate();
  698. //监听蓝牙回调
  699. uni.$off('updateBLEDeviceData', this.gWatchBLEUpdate);
  700. }
  701. },
  702. onPageStart: function(e) {
  703. // 监听页面加载成功
  704. this.PageStart = true;
  705. console.log("onPageStart==", e);
  706. setTimeout(() => {
  707. //加载成功后,显示
  708. uni.getCurrentSubNVue().show('fade-in', 250, () => {});
  709. }, 100)
  710. },
  711. onPageFinish: function(e) {
  712. console.log("onPageFinish==", e);
  713. },
  714. onError: function(e) {
  715. // 监听页面加载错误
  716. // this.error = this.url;
  717. console.error(e);
  718. },
  719. gWatchAcceleration: function(a) {
  720. this.sendMessage("onWatchAccelerometer", a);
  721. return;
  722. if (this.ConnectBindingDevice && this.ConnectBindingDevice.deviceType == 1) {
  723. this.sendMessage("onWatchAccelerometer", a);
  724. } else if (this.BLEConnectDevice && this.cIndex != -1) {
  725. this.sendMessage("onWatchAccelerometer", a);
  726. }
  727. },
  728. gWatchOrientation: function(o) {
  729. this.sendMessage("onWatchOrientation", o);
  730. return;
  731. if (this.ConnectBindingDevice && this.ConnectBindingDevice.deviceType == 1) {
  732. this.sendMessage("onWatchOrientation", o);
  733. } else if (this.BLEConnectDevice && this.cIndex != -1) {
  734. this.sendMessage("onWatchOrientation", o);
  735. }
  736. },
  737. //监听返回计算好的puch
  738. gWatchBoxingAcc: function(a) {
  739. if (this.ConnectBindingDevice && this.ConnectBindingDevice.deviceType == 1) {
  740. //计算返回 puch leftPunch rightPunch
  741. this.updateHitData(a);
  742. } else if (this.BLEConnectDevice && this.cIndex != -1) {
  743. this.updateHitData(a);
  744. }
  745. },
  746. //只返回一个hit状态
  747. gWatchHitBoxingAcc: function(a) {
  748. if (this.ConnectBindingDevice && this.ConnectBindingDevice.deviceType == 1) {
  749. //计算返回 puch leftPunch rightPunch
  750. this.EquipmentActionObj.updateAcc({
  751. xA: a.xAxis,
  752. zA: a.yAxis,
  753. yA: a.zAxis
  754. })
  755. } else if (this.cIndex != -1 && this.BLEConnectDevice != null) {
  756. if (this.BLEConnectDevice.usageMode == "phone" || this.BLEConnectDevice.usageMode == "general") {
  757. this.EquipmentActionObj.updateAcc({
  758. xA: a.xAxis,
  759. zA: a.yAxis,
  760. yA: a.zAxis,
  761. bLimitRebound: false
  762. })
  763. } else if (this.BLEConnectDevice.usageMode == "hotman") {
  764. //hotman 沙袋情景 todo
  765. //后面处理手机加速计的数据
  766. }
  767. }
  768. },
  769. gWatchBLEUpdate: function(data) {
  770. //如果是模块外面触发,需要离线打包
  771. if (this.bMyAttitudeListen) {
  772. this.sendMessage("updateAccAndGyro", data);
  773. return;
  774. }
  775. if (this.ConnectBindingDevice) {
  776. //hotman 沙袋情景 todo
  777. this.gUpdateSandbagAlgorithm({
  778. data: data,
  779. callback: (res) => {
  780. // console.log(res);
  781. if (res.type == 'hit') {
  782. // console.log('gUpdateFilter callback:',res)
  783. //记录打击次数
  784. this.addSandbagHitCount({
  785. count: 1
  786. });
  787. let temp = {
  788. direction: res.direction,
  789. angle: res.angle,
  790. name: res.name,
  791. ename: res.ename,
  792. value: res.hit,
  793. mass: 10, //质量
  794. hitPower: res.hit, //计算的力
  795. //新增类型
  796. sendType: "ConnectBindingDevice",
  797. type: "none"
  798. }
  799. this.sendMessage("onBoxingPostHit", temp);
  800. }
  801. }
  802. });
  803. return;
  804. }
  805. if (this.BLEConnectDevice.usageMode == "phone" || this.BLEConnectDevice.usageMode == "general") {
  806. //手机情景或者自由模式
  807. let {
  808. ax,
  809. ay,
  810. az
  811. } = data.acc;
  812. //this.BLEConnectDevice.limitType == "rebound"
  813. //这里是监听 _createEquipmentBasedOnBoxingPostHit 回调
  814. this.EquipmentActionObj.updateTriaxialAcc({
  815. xA: ax * 9.80665,
  816. zA: ay * 9.80665,
  817. yA: az * 9.80665,
  818. bLimitRebound: false
  819. })
  820. } else if (this.BLEConnectDevice.usageMode == "hotman") {
  821. if(this.BLEConnectDevice.deviceType == "BLEIntelligent"){
  822. //智能hotman 沙袋情景
  823. this.gIntelligentUpdateSandbagAlgorithm({
  824. data: data,
  825. callback: (res) => {
  826. // console.log(res);
  827. if (res.type == 'hit') {
  828. // console.log('gUpdateFilter callback:',res)
  829. //记录打击次数
  830. this.addSandbagHitCount({
  831. count: 1
  832. });
  833. let temp = {
  834. direction: res.direction,
  835. angle: res.angle,
  836. name: res.name,
  837. ename: res.ename,
  838. value: res.hit,
  839. mass: 10, //质量
  840. hitPower: res.hit, //计算的力
  841. //新增类型
  842. sendType: "hotman",
  843. type: "none"
  844. }
  845. this.sendMessage("onBoxingPostHit", temp);
  846. }
  847. }
  848. });
  849. }else{
  850. //hotman 沙袋情景 todo
  851. this.gUpdateSandbagAlgorithm({
  852. data: data,
  853. callback: (res) => {
  854. // console.log(res);
  855. if (res.type == 'hit') {
  856. // console.log('gUpdateFilter callback:',res)
  857. //记录打击次数
  858. this.addSandbagHitCount({
  859. count: 1
  860. });
  861. let temp = {
  862. direction: res.direction,
  863. angle: res.angle,
  864. name: res.name,
  865. ename: res.ename,
  866. value: res.hit,
  867. mass: 10, //质量
  868. hitPower: res.hit, //计算的力
  869. //新增类型
  870. sendType: "hotman",
  871. type: "none"
  872. }
  873. this.sendMessage("onBoxingPostHit", temp);
  874. }
  875. }
  876. });
  877. }
  878. } else if (this.BLEConnectDevice.usageMode == "ropeSkipping") {
  879. //跳绳蓝牙反馈
  880. this.onBLERopeUpdate(data);
  881. }
  882. },
  883. updateHitData(a) {
  884. this.xA = a.xAxis;
  885. this.yA = a.yAxis;
  886. this.zA = a.zAxis;
  887. if (Math.abs(this.xA) > 8 && this.oldxA != this.xA && !this.bCalculation) {
  888. this.xAccArray.push(this.xA);
  889. this.oldxA = this.xA;
  890. if (this.calTimeout == null) {
  891. this.calTimeout = setTimeout(() => {
  892. this.bCalculation = true;
  893. for (let i = 0; i < this.xAccArray.length; i++) {
  894. if (this.xAccArray[i] < 0 && this.xAccArray[i] < this.xAccArray[this.xMin]) {
  895. this.xMin = i;
  896. } else if (this.xAccArray[i] > 0 && this.xAccArray[i] > this.xAccArray[this
  897. .xMax]) {
  898. this.xMax = i;
  899. }
  900. }
  901. console.log(this.xAccArray, "==", this.xMin, "==", this.xMax);
  902. if (this.xAccArray[this.xMin] < 0 && this.xAccArray[this.xMax] > 0) {
  903. if (this.xMin > this.xMax)
  904. this.onHit("xRCount", "左勾拳", "leftPunch", this.xAccArray[this.xMin], Math.ceil(
  905. Math.abs(this.xAccArray[this.xMin]) *
  906. puchConfig.BOXING_MASS));
  907. else if (this.xMin < this.xMax)
  908. this.onHit("xLCount", "右勾拳", "rightPunch", this.xAccArray[this.xMax], Math
  909. .ceil(Math.abs(this.xAccArray[this
  910. .xMax]) * puchConfig.BOXING_MASS));
  911. } else if (this.xAccArray[this.xMin] < 0) {
  912. this.onHit("xLCount", "右勾拳", "rightPunch", this.xAccArray[this.xMin], Math.ceil(
  913. Math.abs(this.xAccArray[this.xMin]) *
  914. puchConfig.BOXING_MASS));
  915. } else if (this.xAccArray[this.xMax] > 0) {
  916. this.onHit("xRCount", "左勾拳", "leftPunch", this.xAccArray[this.xMax], Math.ceil(Math
  917. .abs(this.xAccArray[this.xMax]) *
  918. puchConfig.BOXING_MASS));
  919. }
  920. setTimeout(() => {
  921. this.onResetCal();
  922. }, 100);
  923. this.calTimeout = null;
  924. }, 200);
  925. }
  926. } else if (this.zA < -10 && this.oldzA != this.zA && this.xAccArray.length == 0) {
  927. console.log("this.zA:", this.zA);
  928. this.oldzA = this.zA;
  929. setTimeout(() => {
  930. this.onResetCal();
  931. }, 200);
  932. this.onHit("zLCount", "直拳", "punch", this.zA, Math.ceil(Math.abs(this.zA) * puchConfig.BOXING_MASS));
  933. }
  934. },
  935. onHit(direction, name, ename, direValue, power) {
  936. // console.log(direction, direValue, power);
  937. let temp = {
  938. direction: direction,
  939. angle: 0,
  940. name: name,
  941. ename: ename,
  942. value: direValue,
  943. mass: this.mass, //质量
  944. hitPower: power, //计算的力
  945. //新增类型
  946. sendType: "BindBoxingPost",
  947. type: "none"
  948. }
  949. this.sendMessage("onBoxingPostHit", temp);
  950. },
  951. onResetCal() {
  952. this.xAccArray = [];
  953. this.xMax = 0;
  954. this.xMin = 0;
  955. this.bCalculation = false;
  956. this.oldxA = 0;
  957. this.oldzA = 0;
  958. this.calTimeout = null;
  959. },
  960. //创建一个 打击对象
  961. _createEquipmentBasedOnBoxingPostHit() {
  962. this.EquipmentActionObj = new EquipmentAction();
  963. this.EquipmentActionObj.addEventListener("resultantHit", (e) => {
  964. console.log(e);
  965. let temp = {
  966. direction: "allCount",
  967. angle: 0,
  968. name: "击中",
  969. ename: "hit",
  970. value: e.acc,
  971. mass: e.mass, //质量
  972. hitPower: e.power, //计算的力
  973. //新增类型
  974. sendType: "EquipmentActionObj",
  975. type: "none"
  976. }
  977. this.sendMessage("onBoxingPostHit", temp);
  978. })
  979. },
  980. /**
  981. * 创建一个 跳识别对象
  982. * @deprecated 此方法废弃,将使用c语音识别算法。
  983. */
  984. _createActionJumpOnBoxingPostHit() {
  985. this.actionJumpObj = new ActionJump();
  986. this.actionJumpObj.addEventListener('resultant', (e) => {
  987. let temp = {
  988. direction: "all",
  989. angle: 0,
  990. name: "击中", // this.BLEConnectDevice.name,
  991. ename: "hit", //this.BLEConnectDevice.ename,
  992. value: 10,
  993. mass: 10, //质量
  994. hitPower: 10, //计算的力
  995. //新增类型
  996. sendType: "ActionJumpObj",
  997. type: "none"
  998. }
  999. if (e.type == 'stateDataOfJump') {
  1000. // console.log("game stateDataOfJump");
  1001. this.sendMessage("onBoxingPostHit", temp);
  1002. } else if (e.type == 'stop') {
  1003. // console.log("game stop");
  1004. this.onClearData();
  1005. }
  1006. })
  1007. },
  1008. /**
  1009. * @param {Object} gameData
  1010. * 识别跳部分数据处理
  1011. */
  1012. onBLERopeUpdate(gameData) {
  1013. //调用识别算法
  1014. this.jumpIdenModule_onJump6AxisDataUpdate({
  1015. data: {
  1016. hex: gameData.hex
  1017. },
  1018. callback: (res) => {
  1019. if (res.code == 0) {
  1020. if (res.tag != -1) {
  1021. // this.jumpIdenModule_listenStateDataOfJump(res);
  1022. /**
  1023. * @deprecated
  1024. */
  1025. let temp = {
  1026. direction: "all",
  1027. angle: 0,
  1028. name: "跳", // this.BLEConnectDevice.name,
  1029. ename: "hit", //this.BLEConnectDevice.ename,
  1030. value: 0, //
  1031. mass: 0, //质量
  1032. hitPower: 0, //计算的力
  1033. //新增类型
  1034. sendType: "RopeSkipping",
  1035. type: "none",
  1036. angle: res.tag, //返回一个 tag方向
  1037. }
  1038. switch (res.tag) {
  1039. case 0:
  1040. //JumpType.NORMAL = 0
  1041. temp.type = "normal";
  1042. break;
  1043. case 1:
  1044. //right jump
  1045. temp.type = "right";
  1046. break;
  1047. case 2:
  1048. //left jump
  1049. temp.type = "left";
  1050. break;
  1051. case 3:
  1052. //right rotate jump
  1053. temp.type = "right_rotate";
  1054. break;
  1055. case 4:
  1056. //left rotate jump
  1057. temp.type = "left_rotate";
  1058. break;
  1059. default:
  1060. break;
  1061. }
  1062. this.sendMessage("onBoxingPostHit", temp);
  1063. // uni.showToast({
  1064. // title: res.tag + ',' + res.msg,
  1065. // icon: 'none',
  1066. // duration: 1000,
  1067. // mask: true
  1068. // })
  1069. }
  1070. }
  1071. }
  1072. });
  1073. //********陀螺仪角速度********
  1074. let {
  1075. gx,
  1076. gy,
  1077. gz
  1078. } = gameData.gyro;
  1079. let {
  1080. min,
  1081. s,
  1082. ms
  1083. } = gameData;
  1084. //-gameData.acc.ax * 10;
  1085. let _ax = gameData.acc.ax * 10;
  1086. let _ay = gameData.acc.ay * 10;
  1087. let _az = gameData.acc.az * 10;
  1088. //低通滤波分离重力
  1089. let alpha = 0.8;
  1090. this.xA = alpha * this.xA + (1 - alpha) * _ax;
  1091. this.yA = alpha * this.yA + (1 - alpha) * _ay;
  1092. this.zA = alpha * this.zA + (1 - alpha) * _az;
  1093. //高通滤波获取线性速度
  1094. let linear_acceleration_x = _ax - this.xA;
  1095. let linear_acceleration_y = _az - this.zA;
  1096. let linear_acceleration_z = _ay - this.yA;
  1097. // let _temp = {
  1098. // linearAcc: {
  1099. // lAccX: linear_acceleration_x,
  1100. // lAccY: linear_acceleration_y,
  1101. // lAccZ: linear_acceleration_z
  1102. // }, //gameData.acc,
  1103. // oriAcc: {
  1104. // oAccX: _ax,
  1105. // oAccY: _ay,
  1106. // oAccZ: _az
  1107. // },
  1108. // gravityAcc: {
  1109. // gravityX: this.xA,
  1110. // gravityY: this.yA,
  1111. // gravityZ: this.zA
  1112. // },
  1113. // bLimitRebound: false,
  1114. // resultant: Math.sqrt(_ax * _ax +
  1115. // _ay * _ay + _az * _az),
  1116. // runIndex: this.BLEAccIndex,
  1117. // //陀螺仪
  1118. // oriGyro: {
  1119. // oGyroX: gx,
  1120. // oGyroY: gy,
  1121. // oGyroZ: gz
  1122. // },
  1123. // //输入当前轴,旧设备使用Y轴,即为true
  1124. // bYAxis: this.bOldDeviceType ? true : false,
  1125. // };
  1126. // this.actionJumpObj.updateJump(_temp);
  1127. this.BLEAccIndex++;
  1128. },
  1129. onClearData() {
  1130. this.BLEAccIndex = 0;
  1131. },
  1132. }
  1133. }
  1134. </script>
  1135. <style>
  1136. /* #ifdef APP-PLUS */
  1137. .web-view {
  1138. flex: 1;
  1139. flex-direction: column;
  1140. /* background-color: #007AFF; */
  1141. }
  1142. .web-view-child {
  1143. width: 750rpx;
  1144. flex: 1;
  1145. }
  1146. /* #endif */
  1147. /* #ifdef H5 */
  1148. .web-view {
  1149. display: flex;
  1150. flex-direction: column;
  1151. position: absolute;
  1152. bottom: 0;
  1153. top: 0;
  1154. left: 0;
  1155. right: 0;
  1156. }
  1157. .web-view-child {
  1158. position: relative;
  1159. width: 100%;
  1160. height: 100%;
  1161. }
  1162. /* #endif */
  1163. .sendMessage {
  1164. width: 300rpx;
  1165. position: fixed;
  1166. bottom: 100rpx;
  1167. left: 50rpx;
  1168. }
  1169. .web-back {
  1170. position: fixed;
  1171. top: 40px;
  1172. right: 20px;
  1173. width: 160rpx;
  1174. height: 80rpx;
  1175. border-radius: 45px;
  1176. /* border: 1px solid #FFFFFF; */
  1177. /* box-shadow: 0px 0px 1px #FFFFFF; */
  1178. background-color: rgba(0, 0, 0, 1);
  1179. opacity: 0.5;
  1180. /* #ifndef APP-PLUS-NVUE */
  1181. /* z-Index: 999; */
  1182. display: flex;
  1183. /* #endif */
  1184. justify-content: center;
  1185. align-items: center;
  1186. }
  1187. </style>