index.vue 3.7 KB

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