cellSearch.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view style="overflow: hidden;">
  3. <view class="top-box">
  4. <view class="search-box ddflex">
  5. <image class="search-saoma" src="../../static/pages/images/saoma.png" @click="saomaFn()"></image>
  6. <view class="search-input ddflex fflex">
  7. <image class="search-input-icon" src="../../static/pages/images/search.png"></image>
  8. <input class="fflex" v-model="searchValue" confirm-type="search" @confirm="searchFn" placeholder="请输入编号查询"/>
  9. <view class="search-btn" @click="searchFn">搜索</view>
  10. </view>
  11. </view>
  12. </view>
  13. <view :style="'height: '+ (134) + 'rpx;'"></view>
  14. <!-- 电池 -->
  15. <view>
  16. <view class="cell-box" v-for="item,index in groupList">
  17. <view class="ddflex">
  18. <view style="margin-right: 35rpx;">
  19. <cell :width="99" :height="197" :soc="item.leaseStatus==1?50:100" :showsoc="false"></cell>
  20. </view>
  21. <view class="cell-info fflex">
  22. <view class="ddflex">
  23. <view class="cell-title">{{item.model}}</view>
  24. <view class="cell-state" :style="item.leaseStatus==1?'':'background-color: #0FCB27;'">{{item.leaseStatus==1?'已租':'空闲'}}</view>
  25. </view>
  26. <view class="cell-info ddflex">
  27. <view>电池Id:</view>
  28. <view>{{item.batteryId}}</view>
  29. </view>
  30. <view class="cell-info ddflex">
  31. <view>设备编号:</view>
  32. <view>{{item.number}}</view>
  33. </view>
  34. <view class="cell-info ddflex">
  35. <view>门店:</view>
  36. <view>{{item.storeName}}</view>
  37. </view>
  38. <view class="cell-info ddflex">
  39. <view>到期时间:</view>
  40. <view>{{item.blockDate}}</view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="cell-option ddflex">
  45. <view class="fflex" @click="jumpUrl('/machineAndCell/map/map?id='+item.batteryId)">定位</view>
  46. <view class="fflex" @click="jumpUrl('/machineAndCell/BMS/BMS?id='+item.batteryId)">BMS</view>
  47. <view class="fflex" @click="jumpUrl('/machineAndCell/cellDetail/cellDetail?id='+item.batteryId)">详情</view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. const app = getApp();
  55. const req = require("../../utils/request.js");
  56. import cell from "../../components/cell/index";
  57. export default {
  58. components: {
  59. cell,
  60. },
  61. props: {},
  62. data() {
  63. return {
  64. systems: {},
  65. isTop:0,
  66. userInfo:{},
  67. showPop: false,
  68. tempData: null,
  69. groupList: [],
  70. page: 1,
  71. limit: 10,
  72. searchValue:'',
  73. isQuerying:false,//正在查询数据
  74. queryType:'',
  75. merchantList: [],
  76. merchantPage: 1,
  77. merchantLimit: 10,
  78. actMerchant:null,//当前门店
  79. count:{},
  80. storeId:null
  81. }
  82. },
  83. onLoad(options) {
  84. this.storeId = options.storeId
  85. if(options.searchValue){
  86. this.searchValue = options.searchValue
  87. }
  88. if(options.type){
  89. this.queryType = options.type
  90. }
  91. this.getMachineList()
  92. },
  93. onShow() {
  94. },
  95. onReachBottom() {
  96. this.getMachineList(true)
  97. },
  98. methods: {
  99. jumpUrl(url){
  100. if(req.isLogins(true)){
  101. uni.navigateTo({
  102. url:url
  103. })
  104. }
  105. },
  106. queryTypeChange(val) {
  107. if (this.queryType == val) return false
  108. this.queryType = val
  109. this.queryType = val==-1?'':val
  110. this.getMachineList()
  111. },
  112. // 获取电池列表
  113. getMachineList(isPage){
  114. if(this.isQuerying) return
  115. else this.isQuerying = true
  116. if (!isPage) {
  117. this.page = 1
  118. }
  119. let queryParams = {
  120. page: this.page,
  121. limit: this.limit,
  122. }
  123. if(this.searchValue){
  124. queryParams.number=this.searchValue
  125. }
  126. if(this.queryType){
  127. queryParams.type = this.queryType
  128. }
  129. queryParams.storeId = this.storeId
  130. req.getRequest(
  131. '/admin/v2/battery/page',
  132. queryParams,
  133. data => {
  134. if (data != null && data.list.length > 0) {
  135. if (!isPage) {
  136. this.groupList = data.list
  137. } else {
  138. this.groupList = this.groupList.concat(data.list)
  139. }
  140. this.page++
  141. } else {
  142. if (!isPage)
  143. this.groupList = data.list
  144. else {}
  145. }
  146. uni.hideLoading()
  147. this.isQuerying = false
  148. }
  149. )
  150. },
  151. searchFn(){
  152. this.getMachineList()
  153. },
  154. saomaFn(){
  155. // 只允许通过相机扫码
  156. uni.scanCode({
  157. onlyFromCamera: false,
  158. success: (res) =>{
  159. console.log('条码类型:' + res.scanType);
  160. console.log('条码内容:' + res.result);
  161. // did设备id
  162. this.searchValue = res.result
  163. this.searchFn()
  164. }
  165. });
  166. }
  167. },
  168. mounted() {
  169. const systemInfo = uni.getSystemInfoSync();
  170. // px转换到rpx的比例
  171. let pxToRpxScale = 750 / systemInfo.windowWidth;
  172. let systems = {
  173. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  174. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  175. };
  176. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  177. this.systems = systems;
  178. },
  179. onPageScroll: function(e) {
  180. if (e.scrollTop > this.systems.barHeight) {
  181. this.isTop = 1;
  182. } else {
  183. this.isTop = 0;
  184. }
  185. }
  186. }
  187. </script>
  188. <style>
  189. @import "./cellSearch.css";
  190. </style>