index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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>
  28. </view>
  29. </template>
  30. <script>
  31. import { getDeviceInfoFromQrcode } from '@/api/device/device.js'
  32. import i18 from '@/utils/i18.js'
  33. export default {
  34. data:function(){
  35. return {
  36. current: 0,
  37. swiperDotIndex: 0,
  38. data: [{
  39. image: '/index/banner-index.png'
  40. }
  41. ]
  42. }
  43. },
  44. computed: {
  45. imgUrl() {
  46. return getApp().globalData.config.imgUrl;
  47. }
  48. },
  49. onLoad: function() {
  50. },
  51. onShow(){
  52. },
  53. methods:{
  54. devicelist(){
  55. uni.navigateTo({
  56. url: '/pages/bluetooth/index/index'
  57. });
  58. },
  59. i18(text){
  60. return i18(text)
  61. },
  62. buleTeeth(){
  63. uni.navigateTo({
  64. url: '/pages/bluetooth/index/index'
  65. });
  66. },
  67. scan(){
  68. if(window.location.href.indexOf("localhost") != -1){
  69. this.scan2();
  70. }else{
  71. uni.navigateTo({
  72. url: '/pages/weitiandi/device/scan'
  73. });
  74. }
  75. // uni.scanCode({
  76. // success: function (res) {
  77. // console.log('条码类型:' + res.scanType);
  78. // console.log('条码内容:' + res.result);
  79. // getDeviceInfoFromQrcode(res.result).then(res=>{
  80. // if(res.data != null){
  81. // let imei = res.data.imei;
  82. // let ccid = res.data.ccid;
  83. // uni.navigateTo({
  84. // url: '/pages/weitiandi/device/index?id='+imei+'&ccid='+ccid
  85. // });
  86. // }
  87. // });
  88. // }
  89. // });
  90. },
  91. scan2(){
  92. getDeviceInfoFromQrcode("http://wetiandi.com/app/index.php?i=1&j=1&c=entry&m=wdl_shopping&do=wepay&sn=GD1B342399").then(res=>{
  93. if(res.data != null){
  94. let imei = res.data.imei;
  95. let ccid = res.data.ccid;
  96. let qrcode = res.data.qrcode;
  97. uni.navigateTo({
  98. url: '/pages/weitiandi/device/status?qrcode='+qrcode+'&id='+imei+'&ccid='+ccid
  99. });
  100. }
  101. });
  102. }
  103. }
  104. }
  105. </script>
  106. <style>
  107. .content {
  108. background: rgb(249, 252, 255);
  109. inset: 0;
  110. position: absolute;
  111. }
  112. .swiper {
  113. height: 22vh;
  114. }
  115. .banner{
  116. height: 22vh;
  117. width: 100%;
  118. margin-top:1vh
  119. }
  120. .swiper-box {
  121. height: 22vh;
  122. }
  123. .swiper-item {
  124. /* #ifndef APP-NVUE */
  125. display: flex;
  126. /* #endif */
  127. flex-direction: column;
  128. justify-content: center;
  129. align-items: center;
  130. color: #fff;
  131. height: 300rpx;
  132. line-height: 300rpx;
  133. }
  134. @media screen and (min-width: 500px) {
  135. .uni-swiper-dot-box {
  136. width: 400px;
  137. /* #ifndef APP-NVUE */
  138. margin: 0 auto;
  139. /* #endif */
  140. margin-top: 8px;
  141. }
  142. .image {
  143. width: 100%;
  144. }
  145. }
  146. .item{
  147. display: inline-block;
  148. width: 50%;
  149. position: relative;
  150. }
  151. .item image{
  152. height: 12vh;
  153. }
  154. .item-text{
  155. position: absolute;
  156. top:30px;
  157. left: 50%;
  158. }
  159. </style>