machineLook.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <view style="overflow: hidden;">
  3. <view class="top-box">
  4. <view class="top-title ddflex">
  5. <view :style="'height: '+ systems.navigationHeight+'rpx;padding-top:' + systems.ktxStatusHeight + 'rpx;'" class="ddflex" @click="goback">
  6. <image style="width: 48rpx;height: 48rpx;margin: auto;margin-right: 20rpx;" src="../../static/pages/images/back.png"></image>
  7. </view>
  8. <view v-if="!storeId&&actMerchant" @click="showPop=true" class="ddflex fflex" :style="'height: '+ systems.navigationHeight + 'rpx;padding-top:' + systems.ktxStatusHeight + 'rpx;'+'line-height: '+ systems.navigationHeight + 'rpx;'">
  9. <view>{{actMerchant.name}}</view>
  10. <image class="dow-ssicon" src="../../static/pages/images/dow-ssicon.png"></image>
  11. </view>
  12. <view v-else :style="'height: '+ systems.navigationHeight + 'rpx;padding-top:' + systems.ktxStatusHeight + 'rpx;'+'line-height: '+ systems.navigationHeight + 'rpx;'">设备</view>
  13. </view>
  14. <view class="tab-box ddflex">
  15. <view class="fflex ddflex">
  16. <view :class="'tab-item fflex '+(queryType==''?'tab-item-active':'')" @click="queryTypeChange(-1)">
  17. <view>全部</view>
  18. <image class="tab-active-icon" src="../../static/images/tab_cur.png"></image>
  19. </view>
  20. <view :class="'tab-item fflex '+(queryType==2?'tab-item-active':'')" @click="queryTypeChange(2)">
  21. <view>未租</view>
  22. <image class="tab-active-icon" src="../../static/images/tab_cur.png"></image>
  23. </view>
  24. <view :class="'tab-item fflex '+(queryType==1?'tab-item-active':'')" @click="queryTypeChange(1)">
  25. <view>已租</view>
  26. <image class="tab-active-icon" src="../../static/images/tab_cur.png"></image>
  27. </view>
  28. </view>
  29. <view class="ddflex">
  30. <image class="saoma" src="../../static/pages/images/saoma.png" @click="saomaFn()"></image>
  31. <image class="sousuo" src="../../static/pages/images/search.png" @click="jumpUrl('/machineAndCell/cellSearch/cellSearch?storeId='+actMerchant.id+'&type='+queryType)"></image>
  32. </view>
  33. </view>
  34. </view>
  35. <view :style="'height: '+ (systems.navigationHeight+systems.ktxStatusHeight+106) + 'rpx;'"></view>
  36. <view class="ddflex state-box">
  37. <view class="state-item">
  38. <view class="ddflex">
  39. <view class="icon"></view>
  40. <view class="state-label">租赁中</view>
  41. </view>
  42. <view class="ddflex state-data">
  43. <view>{{count.leaseCount?count.leaseCount:0}}</view>
  44. <view>{{getP(1)}}%</view>
  45. </view>
  46. </view>
  47. <view class="state-item">
  48. <view class="ddflex">
  49. <view class="icon" style="background: #0FCB27;"></view>
  50. <view class="state-label">空闲</view>
  51. </view>
  52. <view class="ddflex fflex state-data">
  53. <view>{{count.noLeaseCount?count.noLeaseCount:0}}</view>
  54. <view>{{getP(2)}}%</view>
  55. </view>
  56. </view>
  57. </view>
  58. <!-- 电池 -->
  59. <view>
  60. <view class="cell-box" v-for="item,index in groupList">
  61. <view class="ddflex">
  62. <view style="margin-right: 35rpx;">
  63. <cell :width="99" :height="197" :soc="item.leaseStatus==1?50:100" :showsoc="false"></cell>
  64. </view>
  65. <view class="cell-info fflex">
  66. <view class="ddflex">
  67. <view class="cell-title">{{item.model}}</view>
  68. <view class="cell-state" :style="item.leaseStatus==1?'':'background-color: #0FCB27;'">{{item.leaseStatus==1?'已租':'空闲'}}</view>
  69. </view>
  70. <view class="cell-info ddflex">
  71. <view>电池Id:</view>
  72. <view>{{item.batteryId}}</view>
  73. </view>
  74. <view class="cell-info ddflex">
  75. <view>设备编号:</view>
  76. <view>{{item.number}}</view>
  77. </view>
  78. <view class="cell-info ddflex">
  79. <view>门店:</view>
  80. <view>{{item.storeName}}</view>
  81. </view>
  82. <view class="cell-info ddflex">
  83. <view>到期时间:</view>
  84. <view>{{item.blockDate}}</view>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="cell-option ddflex">
  89. <view class="fflex" @click="jumpUrl('/machineAndCell/map/map?id='+item.batteryId)">定位</view>
  90. <view class="fflex" @click="jumpUrl('/machineAndCell/BMS/BMS?id='+item.batteryId)">BMS</view>
  91. <view class="fflex" @click="jumpUrl('/machineAndCell/cellDetail/cellDetail?id='+item.batteryId)">详情</view>
  92. </view>
  93. </view>
  94. </view>
  95. <view v-if="groupList.length==0">
  96. <view class="nodata">
  97. <image :src="picUrlss+'empty.png'"></image>
  98. <text>暂无电池~</text>
  99. </view>
  100. </view>
  101. <left-pop v-if="showPop" :showPop="showPop" :btnColor="'#11BB8B'" :showBtn='false' title="解除提醒" width="460rpx"
  102. @closePop="closePop()" @popSubmit="popSubmit()">
  103. <view class="" style="height: 100%;flex-direction: column;display: flex;">
  104. <view @click="closePop()" class="pop-title ddflex" :style="'height: '+ systems.navigationHeight + 'rpx;padding-top:' + systems.ktxStatusHeight + 'rpx;'+'line-height: '+ systems.navigationHeight + 'rpx;'">
  105. <view>切换门店</view>
  106. <image class="change-ssicon" src="../../static/pages/images/change.png"></image>
  107. </view>
  108. <scroll-view :scroll-y="true" @scrolltolower="loadLeftData" class="pop-content fflex">
  109. <view :class="'pop-content-item '+(actMerchant.id==item.id?'pop-content-active':'')" v-for="(item,index) in merchantList" @click="changePop(item)">
  110. <view class="pop-content-name">{{item.name}}</view>
  111. <image class="pop-content-icon" src=""></image>
  112. </view>
  113. </scroll-view>
  114. </view>
  115. </left-pop>
  116. </view>
  117. </template>
  118. <script>
  119. const app = getApp();
  120. const req = require("../../utils/request.js");
  121. import cell from "../../components/cell/index";
  122. import leftPop from "../../components/left-pop/index";
  123. export default {
  124. components: {
  125. cell,
  126. leftPop
  127. },
  128. props: {},
  129. data() {
  130. return {
  131. picUrlss: req.public.picUrls,
  132. systems: {},
  133. isTop:0,
  134. isUpdate: false,
  135. userInfo:{},
  136. showPop: false,
  137. tempData: null,
  138. groupList: [],
  139. page: 1,
  140. limit: 10,
  141. searchValue:'',
  142. isQuerying:false,//正在查询数据
  143. queryType:'',
  144. merchantList: [],
  145. merchantPage: 1,
  146. merchantLimit: 10,
  147. actMerchant:null,//当前门店
  148. merchantId:null,
  149. storeId:null,
  150. count:{}
  151. }
  152. },
  153. onLoad(options) {
  154. this.merchantId = options.merchantId
  155. this.storeId = options.storeId
  156. // 判断当前登录用户身份
  157. if(req.isLogins(true)){
  158. if(!this.storeId){
  159. this.getMerchantList()
  160. }else{
  161. this.actMerchant={
  162. id:this.storeId
  163. }
  164. this.getMachineList()
  165. this.getTopNum()
  166. }
  167. }else{
  168. this.getMachineList()
  169. }
  170. },
  171. onShow() {
  172. this.setData({
  173. isUpdate: !this.isUpdate
  174. });
  175. },
  176. onReachBottom() {
  177. this.getMachineList(true)
  178. },
  179. methods: {
  180. goback: function() {
  181. var pages = getCurrentPages();
  182. if(pages.length==1){
  183. uni.switchTab({
  184. url:'/pages/index/index'
  185. })
  186. }else{
  187. wx.navigateBack({
  188. delta: pages.length - 2
  189. })
  190. }
  191. },
  192. getP(type){
  193. let p = 0
  194. console.log('111')
  195. if(type==1){
  196. if(this.count.leaseCount == 0 || this.count.leaseCount == undefined){}
  197. else{
  198. return (this.count.leaseCount/(this.count.leaseCount+(this.count.noLeaseCount?this.count.noLeaseCount:0))).toFixed(4)*100
  199. }
  200. }
  201. if(type==2){
  202. if(this.count.noLeaseCount == 0 || this.count.noLeaseCount == undefined){}
  203. else{
  204. return (this.count.noLeaseCount/(this.count.leaseCount+(this.count.noLeaseCount?this.count.noLeaseCount:0))).toFixed(4)*100
  205. }
  206. }
  207. return p*100
  208. },
  209. jumpUrl(url){
  210. if(req.isLogins(true)){
  211. uni.navigateTo({
  212. url:url
  213. })
  214. }
  215. },
  216. queryTypeChange(val) {
  217. if (this.queryType == val) return false
  218. this.queryType = val
  219. this.queryType = val==-1?'':val
  220. this.getMachineList()
  221. },
  222. // 弹窗弹出
  223. openPop(item) {
  224. this.tempData = JSON.parse(JSON.stringify(item))
  225. this.showPop = true
  226. },
  227. closePop(){
  228. this.showPop = false
  229. },
  230. changePop(item){
  231. this.actMerchant = item
  232. this.closePop()
  233. this.getMachineList()
  234. },
  235. // 电池数量
  236. getTopNum(){
  237. console.log('getTopNum')
  238. req.getRequest(
  239. '/admin/v2/battery/count',
  240. {storeId:this.actMerchant.id},
  241. data => {
  242. this.count = data
  243. }
  244. )
  245. },
  246. // 获取电池列表
  247. getMachineList(isPage){
  248. if(!this.actMerchant||!this.actMerchant.id) return
  249. if(this.isQuerying) return
  250. else this.isQuerying = true
  251. if (!isPage) {
  252. this.page = 1
  253. }
  254. let queryParams = {
  255. page: this.page,
  256. limit: this.limit,
  257. }
  258. if(this.searchValue){
  259. queryParams.number=this.searchValue
  260. }
  261. if(this.queryType){
  262. queryParams.type = this.queryType
  263. }
  264. queryParams.storeId = this.actMerchant.id
  265. req.getRequest(
  266. '/admin/v2/battery/page',
  267. queryParams,
  268. data => {
  269. if (data != null && data.list.length > 0) {
  270. if (!isPage) {
  271. this.groupList = data.list
  272. } else {
  273. this.groupList = this.groupList.concat(data.list)
  274. }
  275. this.page++
  276. } else {
  277. if (!isPage)
  278. this.groupList = data.list
  279. else {}
  280. }
  281. uni.hideLoading()
  282. this.isQuerying = false
  283. }
  284. )
  285. },
  286. loadLeftData(res){
  287. this.getMerchantList(true)
  288. },
  289. getMerchantList(isPage){
  290. if (!isPage) {
  291. this.merchantPage = 1
  292. }
  293. let queryParams = {
  294. page: this.merchantPage,
  295. limit: this.merchantLimit,
  296. }
  297. queryParams.merchantId = this.merchantId?this.merchantId:req.getStorage('userInfo').merchantId?req.getStorage('userInfo').merchantId:null
  298. req.getRequest(
  299. '/admin/v2/store/page',
  300. queryParams,
  301. data => {
  302. if (data != null && data.list.length > 0) {
  303. if (!isPage) {
  304. this.merchantList = data.list
  305. } else {
  306. this.merchantList = this.merchantList.concat(data.list)
  307. }
  308. this.merchantPage++
  309. } else {
  310. if (!isPage)
  311. this.merchantList = data.list
  312. else {}
  313. }
  314. if(!isPage){
  315. if(this.actMerchant){
  316. }else{
  317. this.actMerchant = this.merchantList[0]
  318. }
  319. this.getMachineList()
  320. }
  321. }
  322. )
  323. },
  324. toLocation(item) {
  325. let plugin = requirePlugin('routePlan');
  326. let key = req.public.mapLBSKEY; //使用在腾讯位置服务申请的key
  327. let referer = '皮小店商家端'; //调用插件的app的名称
  328. // console.log("名称====" + referer);
  329. let endPoint = JSON.stringify({
  330. //终点
  331. 'name': item.devName,
  332. 'latitude': item.latitude,
  333. 'longitude':item.longitude
  334. });
  335. uni.navigateTo({
  336. url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint
  337. });
  338. },
  339. searchFn(){
  340. this.getMachineList()
  341. },
  342. saomaFn(){
  343. // 只允许通过相机扫码
  344. uni.scanCode({
  345. onlyFromCamera: false,
  346. success: (res) =>{
  347. console.log('条码类型:' + res.scanType);
  348. console.log('条码内容:' + res.result);
  349. // did设备id
  350. this.jumpUrl('/machineAndCell/cellSearch/cellSearch?storeId='+this.actMerchant.id+'&searchValue='+res.result+'&type='+this.queryType)
  351. }
  352. });
  353. }
  354. },
  355. mounted() {
  356. const systemInfo = uni.getSystemInfoSync();
  357. // px转换到rpx的比例
  358. let pxToRpxScale = 750 / systemInfo.windowWidth;
  359. let systems = {
  360. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  361. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  362. };
  363. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  364. this.systems = systems;
  365. },
  366. onPageScroll: function(e) {
  367. if (e.scrollTop > this.systems.barHeight) {
  368. this.isTop = 1;
  369. } else {
  370. this.isTop = 0;
  371. }
  372. }
  373. }
  374. </script>
  375. <style>
  376. @import "./machineLook.css";
  377. </style>