index.vue 9.6 KB

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