index.vue 8.1 KB

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