index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <view class="content">
  3. <!-- <view class="banner">
  4. <uni-swiper-dot class="uni-swiper-dot-box" :info="data" :current="current" field="content">
  5. <swiper class="swiper-box" :current="swiperDotIndex" @change="changeSwiper">
  6. <swiper-item v-for="(item, index) in data" :key="index">
  7. <view class="swiper-item" @click="clickBannerItem(item)">
  8. <image :src="imgUrl+item.image" mode="aspectFill" :draggable="false" />
  9. </view>
  10. </swiper-item>
  11. </swiper>
  12. </uni-swiper-dot>
  13. </view> -->
  14. <view style="height: 10vh;text-align: center;">
  15. <image style="height: 3vh;width: 15vh;margin-top: 5vh;"
  16. src="../static/images/new/starts/login/backImg2.png"></image>
  17. </view>
  18. <view style="text-align: center;top:12vh;position: relative;color: aliceblue;">
  19. <view style="font-size: 30rpx;">Please choose from the below options:</view>
  20. <view style="font-size: 20rpx;">Charge up quickly & easily to enjoy a smarter life!</view>
  21. </view>
  22. <view
  23. style="margin:0 5vw;left:0px;right:0px;text-align: center;top:55vh;position: absolute;display: flex;flex-direction: rows;justify-content: space-evenly;">
  24. <!-- <view style="color:white;width:80px;">
  25. 设备编号
  26. </view> -->
  27. <view style="text-align: center;">
  28. <view class="blue" @click="buleTeeth()">
  29. <image src="../static/images/new/starts/index/blue.png" style="width: 60px;height: 60px;margin-top: 2vh;"></image>
  30. </view>
  31. <view class="" @click="scan">
  32. <image src="../static/images/new/starts/index/scan.png" style="width: 60px;height: 60px;margin-top: 2vh;"
  33. ></image>
  34. </view>
  35. <!-- <view class="" @click="scan">
  36. <image src="../static/images/new/starts/index/bind.png" style="width: 60px;height: 60px;margin-top: 2vh;"
  37. ></image>
  38. </view> -->
  39. <!-- <u--input v-model="sn" placeholder="请输入设备编号" color="white"
  40. style="width: 10vw;padding-left:10px;background: rgb(90, 88, 115);text-align: left;font-size: 20px;width:90vw;border-radius: 100vh;height: 40px;">
  41. <u-button slot="suffix" @click="binddevice"
  42. style="background: #505086;color:white;border-radius: 100vh;width: 120px;margin-right: -10px;">绑 定</u-button>
  43. </u--input> -->
  44. </view>
  45. </view>
  46. <!-- <view class="container">
  47. <view class="item" @click="buleTeeth">
  48. <image :src = "imgUrl+'/index/bluetooth.png'"/>
  49. <view class="item-text">{{i18('蓝牙连接')}}</view>
  50. </view>
  51. <view class="item" @click="scan">
  52. <image :src = "imgUrl+'/index/scan.png'"/>
  53. <view class="item-text">{{i18('扫码绑定')}}</view>
  54. </view>
  55. <view class="item" @click="devicelist">
  56. <image :src = "imgUrl+'/index/device-2.png'"/>
  57. <view class="item-text">{{i18('设备列表')}}</view>
  58. </view>
  59. <view class="item" @click="wifi">
  60. <image :src = "imgUrl+'/index/bluetooth.png'"/>
  61. <view class="item-text">{{i18('WIFI配网')}}</view>
  62. </view>
  63. </view> -->
  64. </view>
  65. </template>
  66. <script>
  67. import {
  68. getDeviceInfoFromQrcode,
  69. bindDevice
  70. } from '@/api/device/device.js'
  71. import i18 from '@/utils/i18.js'
  72. export default {
  73. data: function() {
  74. return {
  75. current: 0,
  76. swiperDotIndex: 0,
  77. data: [{
  78. image: '/index/banner-index.png'
  79. }]
  80. }
  81. },
  82. computed: {
  83. imgUrl() {
  84. return getApp().globalData.config.imgUrl;
  85. }
  86. },
  87. onLoad: function() {},
  88. onShow() {
  89. uni.setNavigationBarTitle({
  90. title: this.$t('page.worktai')
  91. })
  92. },
  93. methods: {
  94. devicelist() {
  95. uni.navigateTo({
  96. url: '/pages/weitiandi/deviceList'
  97. });
  98. },
  99. i18(text) {
  100. return i18(text)
  101. },
  102. buleTeeth() {
  103. uni.navigateTo({
  104. url: '/pages/bluetooth/index/index'
  105. });
  106. },
  107. wifi() {
  108. uni.navigateTo({
  109. url: '/pages/bluetooth/index/wifi'
  110. });
  111. },
  112. toBind(qrcode) {
  113. bindDevice(qrcode).then(res => {
  114. let data = res.data;
  115. if (data != null) {
  116. let imei = res.data.imei;
  117. let ccid = res.data.ccid;
  118. let qrcode = res.data.qrcode;
  119. let uuid = res.data.uuid;
  120. this.$modal.showToast("绑定成功");
  121. } else {
  122. this.$modal.showToast("绑定失败");
  123. }
  124. })
  125. },
  126. scan() {
  127. let self = this;
  128. uni.scanCode({
  129. success: function(res) {
  130. console.log('条码类型:' + res.scanType);
  131. console.log('条码内容:' + res.result);
  132. getDeviceInfoFromQrcode(res.result).then(res => {
  133. if (res.data != null) {
  134. let imei = res.data.imei;
  135. let ccid = res.data.ccid;
  136. let qrcode = res.data.qrcode;
  137. let uuid = res.data.userId;
  138. if (uuid) {
  139. self.$modal.showToast("该设备已被绑定");
  140. } else {
  141. self.$modal.confirm("确认绑定该设备?").then(res => {
  142. self.toBind(qrcode)
  143. })
  144. }
  145. // uni.navigateTo({
  146. // url: '/pages/weitiandi/device/status?qrcode='+qrcode+'&id='+imei+'&ccid='+ccid
  147. // });
  148. } else {
  149. self.$modal.showToast("找不到设备,请联系管理员");
  150. }
  151. });
  152. }
  153. });
  154. },
  155. scan2() {
  156. let self = this;
  157. getDeviceInfoFromQrcode("http://wetiandi.com/index.php?do=wepay&sn=GD1B388803").then(res => {
  158. if (res.data != null) {
  159. let imei = res.data.imei;
  160. let ccid = res.data.ccid;
  161. let qrcode = res.data.qrcode;
  162. let uuid = res.data.userId;
  163. if (uuid) {
  164. self.$modal.showToast("该设备已被绑定");
  165. } else {
  166. self.$modal.confirm("确认绑定该设备?").then(res => {
  167. self.toBind(qrcode)
  168. })
  169. }
  170. // uni.navigateTo({
  171. // url: '/pages/weitiandi/device/status?qrcode='+qrcode+'&id='+imei+'&ccid='+ccid
  172. // });
  173. } else {
  174. self.$modal.showToast("找不到设备,请联系管理员");
  175. }
  176. });
  177. }
  178. }
  179. }
  180. </script>
  181. <style>
  182. .content {
  183. background-image: url('../static/images/new/starts/bg1.jpg');
  184. background-size: cover;
  185. background-repeat: no-repeat;
  186. inset: 0;
  187. position: absolute;
  188. }
  189. .swiper {
  190. height: 22vh;
  191. }
  192. .banner {
  193. height: 22vh;
  194. width: 100%;
  195. margin-top: 1vh
  196. }
  197. .swiper-box {
  198. height: 22vh;
  199. }
  200. .swiper-item {
  201. /* #ifndef APP-NVUE */
  202. display: flex;
  203. /* #endif */
  204. flex-direction: column;
  205. justify-content: center;
  206. align-items: center;
  207. color: #fff;
  208. height: 300rpx;
  209. line-height: 300rpx;
  210. }
  211. @media screen and (min-width: 500px) {
  212. .uni-swiper-dot-box {
  213. width: 400px;
  214. /* #ifndef APP-NVUE */
  215. margin: 0 auto;
  216. /* #endif */
  217. margin-top: 8px;
  218. }
  219. .image {
  220. width: 100%;
  221. }
  222. }
  223. .item {
  224. display: inline-block;
  225. width: 50%;
  226. position: relative;
  227. }
  228. .item image {
  229. height: 12vh;
  230. }
  231. .item-text {
  232. position: absolute;
  233. top: 30px;
  234. left: 50%;
  235. }
  236. </style>