index.vue 9.8 KB

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