index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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 class="container">
  15. <view class="item" @click="buleTeeth">
  16. <image :src = "imgUrl+'/index/bluetooth.png'"/>
  17. <view class="item-text">{{i18('蓝牙连接')}}</view>
  18. </view>
  19. <view class="item" @click="scan">
  20. <image :src = "imgUrl+'/index/scan.png'"/>
  21. <view class="item-text">{{i18('扫码绑定')}}</view>
  22. </view>
  23. <view class="item" @click="devicelist">
  24. <image :src = "imgUrl+'/index/device-2.png'"/>
  25. <view class="item-text">{{i18('设备列表')}}</view>
  26. </view>
  27. <view class="item" @click="wifi">
  28. <image :src = "imgUrl+'/index/bluetooth.png'"/>
  29. <view class="item-text">{{i18('WIFI配网')}}</view>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import { getDeviceInfoFromQrcode,bindDevice } from '@/api/device/device.js'
  36. import i18 from '@/utils/i18.js'
  37. export default {
  38. data:function(){
  39. return {
  40. current: 0,
  41. swiperDotIndex: 0,
  42. data: [{
  43. image: '/index/banner-index.png'
  44. }
  45. ]
  46. }
  47. },
  48. computed: {
  49. imgUrl() {
  50. return getApp().globalData.config.imgUrl;
  51. }
  52. },
  53. onLoad: function() {
  54. },
  55. onShow(){
  56. uni.setNavigationBarTitle({
  57. title: this.$t('page.worktai')
  58. })
  59. },
  60. methods:{
  61. devicelist(){
  62. uni.navigateTo({
  63. url: '/pages/weitiandi/deviceList'
  64. });
  65. },
  66. i18(text){
  67. return i18(text)
  68. },
  69. buleTeeth(){
  70. uni.navigateTo({
  71. url: '/pages/bluetooth/index/index'
  72. });
  73. },
  74. wifi(){
  75. uni.navigateTo({
  76. url: '/pages/bluetooth/index/wifi'
  77. });
  78. },
  79. toBind(qrcode){
  80. bindDevice(qrcode).then(res=>{
  81. let data = res.data;
  82. if(data != null){
  83. let imei = res.data.imei;
  84. let ccid = res.data.ccid;
  85. let qrcode = res.data.qrcode;
  86. let uuid = res.data.uuid;
  87. this.$modal.showToast("绑定成功");
  88. }else{
  89. this.$modal.showToast("绑定失败");
  90. }
  91. })
  92. },
  93. scan(){
  94. let self = this;
  95. uni.scanCode({
  96. success: function (res) {
  97. console.log('条码类型:' + res.scanType);
  98. console.log('条码内容:' + res.result);
  99. getDeviceInfoFromQrcode(res.result).then(res=>{
  100. if(res.data != null){
  101. let imei = res.data.imei;
  102. let ccid = res.data.ccid;
  103. let qrcode = res.data.qrcode;
  104. let uuid = res.data.userId;
  105. if(uuid){
  106. self.$modal.showToast("该设备已被绑定");
  107. }else{
  108. self.$modal.confirm("确认绑定该设备?").then(res=>{
  109. self.toBind(qrcode)
  110. })
  111. }
  112. // uni.navigateTo({
  113. // url: '/pages/weitiandi/device/status?qrcode='+qrcode+'&id='+imei+'&ccid='+ccid
  114. // });
  115. }else{
  116. self.$modal.showToast("找不到设备,请联系管理员");
  117. }
  118. });
  119. }
  120. });
  121. },
  122. scan2(){
  123. let self = this;
  124. getDeviceInfoFromQrcode("http://wetiandi.com/index.php?do=wepay&sn=GD1B388803").then(res=>{
  125. if(res.data != null){
  126. let imei = res.data.imei;
  127. let ccid = res.data.ccid;
  128. let qrcode = res.data.qrcode;
  129. let uuid = res.data.userId;
  130. if(uuid){
  131. self.$modal.showToast("该设备已被绑定");
  132. }else{
  133. self.$modal.confirm("确认绑定该设备?").then(res=>{
  134. self.toBind(qrcode)
  135. })
  136. }
  137. // uni.navigateTo({
  138. // url: '/pages/weitiandi/device/status?qrcode='+qrcode+'&id='+imei+'&ccid='+ccid
  139. // });
  140. }else{
  141. self.$modal.showToast("找不到设备,请联系管理员");
  142. }
  143. });
  144. }
  145. }
  146. }
  147. </script>
  148. <style>
  149. .content {
  150. background: rgb(249, 252, 255);
  151. inset: 0;
  152. position: absolute;
  153. }
  154. .swiper {
  155. height: 22vh;
  156. }
  157. .banner{
  158. height: 22vh;
  159. width: 100%;
  160. margin-top:1vh
  161. }
  162. .swiper-box {
  163. height: 22vh;
  164. }
  165. .swiper-item {
  166. /* #ifndef APP-NVUE */
  167. display: flex;
  168. /* #endif */
  169. flex-direction: column;
  170. justify-content: center;
  171. align-items: center;
  172. color: #fff;
  173. height: 300rpx;
  174. line-height: 300rpx;
  175. }
  176. @media screen and (min-width: 500px) {
  177. .uni-swiper-dot-box {
  178. width: 400px;
  179. /* #ifndef APP-NVUE */
  180. margin: 0 auto;
  181. /* #endif */
  182. margin-top: 8px;
  183. }
  184. .image {
  185. width: 100%;
  186. }
  187. }
  188. .item{
  189. display: inline-block;
  190. width: 50%;
  191. position: relative;
  192. }
  193. .item image{
  194. height: 12vh;
  195. }
  196. .item-text{
  197. position: absolute;
  198. top:30px;
  199. left: 50%;
  200. }
  201. </style>