connecting.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <div>
  3. <van-row class="padding">
  4. <van-col span="5">
  5. <div class="device_bg flex flex-direction align-center justify-center">
  6. <img src="https://img.shuimuai.com/web/phone.png" alt="" class="device_phone">
  7. <text class="text-gray device_text"> 我的手机</text>
  8. </div>
  9. </van-col>
  10. <van-col span="3" offset="1">
  11. <div class="dot_container flex align-center">
  12. <div class="dot_wait">
  13. <img src="https://img.shuimuai.com/m_sign_gou%402x.png" alt="" class="moving_dot">
  14. </div>
  15. </div>
  16. </van-col>
  17. <van-col span="5" offset="0">
  18. <div class="device_bg flex flex-direction align-center justify-center">
  19. <img src="https://img.shuimuai.com/web/sign_green.png" alt="" class="sign_green">
  20. <img src="https://img.shuimuai.com/web/brain.png" alt="" class="device_brain">
  21. <text class="text-gray device_text"> 已连接</text>
  22. </div>
  23. </van-col>
  24. <van-col span="3" offset="1">
  25. <div class="dot_container flex align-center">
  26. <div class="dot_wait">
  27. <img v-if="connect_toy == 1" src="https://img.shuimuai.com/web/dot.png" alt="" class="moving_dot"
  28. :class="{moving:connect_toy==1}"
  29. />
  30. <img v-if="connect_toy == 2" src="https://img.shuimuai.com/m_sign_gou%402x.png" alt="" class="moving_dot">
  31. <img v-if="connect_toy == 3" src="https://img.shuimuai.com/fail.png" alt="" class="moving_dot">
  32. </div>
  33. </div>
  34. </van-col>
  35. <van-col span="5" offset="0">
  36. <div class="device_bg flex flex-direction align-center justify-center">
  37. <img src="https://img.shuimuai.com/web/uav.png" alt="" class="uav_toy">
  38. <text class="text-gray device_text">
  39. <template v-if="connect_toy == 1 || connect_toy == 3">
  40. 智能喷雾恐龙
  41. </template>
  42. <template v-if="connect_toy == 2 || connect_toy == 4">
  43. 已连接
  44. </template>
  45. </text>
  46. </div>
  47. </van-col>
  48. </van-row>
  49. <!-- 按钮组合-->
  50. <van-row gutter="6">
  51. <van-col span="8">
  52. <button class="cu-btn bg-red lg text-white" @click="change_status">
  53. <img src="https://img.shuimuai.com/m_duankainaohuan.png" class="cut_brain_icon" alt="">
  54. <text class=" cut_text">断开脑环</text>
  55. </button>
  56. </van-col>
  57. <van-col span="12" offset="1" v-if="connect_toy == 1">
  58. <van-row class="text-center">
  59. <text class="text-gray text-lg">
  60. 连接中...
  61. </text>
  62. </van-row>
  63. </van-col>
  64. <!-- 已经连接玩具-->
  65. <div v-if="connect_toy == 2">
  66. <van-col span="8">
  67. <button class="cu-btn bg-red lg cu-btn-primary" @click="open_choose_toy">
  68. <img src="https://img.shuimuai.com/m_xuanzewanju.png" alt="" class="cut_brain_icon">
  69. <text class=" cut_text">选择玩具</text>
  70. </button>
  71. </van-col>
  72. <van-col span="8">
  73. <button class="cu-btn bg-red lg cu-btn-primary" @click="choose_pay_window">
  74. <img src="https://img.shuimuai.com/web/start_game_icon.png" alt="" class="cut_start_game_icon">
  75. <text class=" cut_text" style="padding: 0px;">开始游戏</text>
  76. </button>
  77. </van-col>
  78. </div>
  79. <!-- 玩具连接失败-->
  80. <div v-if="connect_toy == 3">
  81. <van-col span="8">
  82. <button class="cu-btn bg-red lg cu-btn-primary" @click="choose_pay_window">
  83. <img src="https://img.shuimuai.com/m_xuanzewanju.png" alt="" class="cut_brain_icon">
  84. <text class=" cut_text">选择玩具</text>
  85. </button>
  86. </van-col>
  87. <van-col span="8">
  88. <van-row class="text-center">
  89. <text class="text-gray text-lg">
  90. 连接失败
  91. </text>
  92. </van-row>
  93. </van-col>
  94. </div>
  95. <!-- 玩具连接中-->
  96. <div v-if="connect_toy == 4">
  97. <van-col span="8">
  98. <button class="cu-btn bg-red lg cu-btn-primary" @click="choose_pay_window">
  99. <img src="https://img.shuimuai.com/m_xuanzewanju.png" alt="" class="cut_brain_icon">
  100. <text class=" cut_text">选择玩具</text>
  101. </button>
  102. </van-col>
  103. <van-col span="8">
  104. <button class="cu-btn bg-green lg ">
  105. <img src="https://img.shuimuai.com/web/start_game_icon.png" alt="" class="cut_start_game_icon">
  106. <text class=" cut_text" style="padding: 0px;">游戏中</text>
  107. </button>
  108. </van-col>
  109. </div>
  110. </van-row>
  111. <!-- 选择消费方式的窗口 -->
  112. <van-overlay :show="pay_window" @click="onClickHide" z-index="5">
  113. <div class="pay_type_window">
  114. <div class="pay_type_title padding">
  115. <text class="text-bold pay_type_title_text">选择消费方式</text>
  116. </div>
  117. <van-row gutter="11">
  118. <van-col span="11" offset="1">
  119. <div class="pay_type_item flex flex-direction justify-center align-center" @click.prevent="choose_pay(2)">
  120. <view class="text-xl padding">
  121. <text class="text-white text-bold">消费时间</text>
  122. </view>
  123. </div>
  124. </van-col>
  125. <van-col span="11">
  126. <div class="pay_type_item flex flex-direction justify-center align-center" @click.prevent="choose_pay(1)">
  127. <view class="text-xl padding">
  128. <text class="text-white text-bold">消费次卡</text>
  129. </view>
  130. <view class="text-sm">
  131. <text class="text-white">次卡时间为10分钟</text>
  132. </view>
  133. </div>
  134. </van-col>
  135. </van-row>
  136. </div>
  137. <img src="https://img.shuimuai.com/web/boy2.png" alt="" class="connected_boy2">
  138. </van-overlay>
  139. <van-toast id="van-toast"/>
  140. </div>
  141. </template>
  142. <script>
  143. import {gameStart} from "@/requests/game";
  144. import Toast from "../../../../static/vant/toast/toast";
  145. let $this;
  146. export default {
  147. name: "connected",
  148. props: ['connect_toy', 'deviceId'],
  149. data() {
  150. return {
  151. pay_window: false,
  152. // 使用类型 1次数 2时间 0未选择
  153. pay_type: 0
  154. }
  155. },
  156. watch: {
  157. // pay_type($new, $old) {
  158. // if ($new > 0) {
  159. // $this.change_toy_connect_status(4)
  160. // $this.to_playing()
  161. // }
  162. // }
  163. },
  164. methods: {
  165. open_choose_toy() {
  166. $this.$emit('open_choose_toy', true)
  167. },
  168. //打开选择消费的选项框
  169. choose_pay_window() {
  170. $this.pay_window = true
  171. },
  172. //选择消费的时间或者次数
  173. choose_pay($event) {
  174. $this.pay_type = $event
  175. let $params = {
  176. type: $event,
  177. device_id: $this.deviceId,
  178. access_token: wx.getStorageSync('token')
  179. }
  180. gameStart($params).then((res) => {
  181. let $data = res.data
  182. console.log('游戏开始返回', $data)
  183. // if ($data.code == 0) {
  184. if ($data.code) {
  185. Toast.success({
  186. message: $data.errmsg,
  187. onClose() {
  188. $this.$emit('game_start')
  189. mpvue.navigateTo({
  190. url: "/pages/start/main?mode=" + $event
  191. })
  192. }
  193. })
  194. } else {
  195. Toast.fail($data.errmsg)
  196. }
  197. })
  198. },
  199. //点击隐藏
  200. onClickHide() {
  201. $this.pay_window = false
  202. },
  203. // 前往正在玩的波动时间界面
  204. to_playing() {
  205. console.log('跳转')
  206. },
  207. //修改连接状态
  208. change_toy_connect_status($status) {
  209. $this.$emit('change_toy_connect_status', $status)
  210. },
  211. change_status() {
  212. $this.$emit('change_status', 0)
  213. }
  214. },
  215. created() {
  216. $this = this
  217. }
  218. }
  219. </script>
  220. <style scoped>
  221. @import url('../../static/connecting.css');
  222. </style>