machineLook.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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 class="tover" style="max-width: 400rpx;">{{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" style="padding-top: 30rpx;" @click="!item.batteryId?noCell():jumpUrl('/machineAndCell/map/map?id='+item.batteryId)">定位</view>
  90. <view class="fflex" style="padding-top: 30rpx;" @click="!item.batteryId?noCell():jumpUrl('/machineAndCell/BMS/BMS?id='+item.batteryId)">BMS</view>
  91. <view class="fflex" style="padding-top: 30rpx;" @click="!item.batteryId?noCell():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'" mode="aspectFit"></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 tover">{{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. noCell(){
  181. req.msg("暂无电池")
  182. },
  183. goback: function() {
  184. var pages = getCurrentPages();
  185. if(pages.length==1){
  186. uni.switchTab({
  187. url:'/pages/index/index'
  188. })
  189. }else{
  190. wx.navigateBack({
  191. delta: pages.length - 2
  192. })
  193. }
  194. },
  195. getP(type){
  196. let p = 0
  197. console.log('111')
  198. if(type==1){
  199. if(this.count.leaseCount == 0 || this.count.leaseCount == undefined){}
  200. else{
  201. return (this.count.leaseCount/(this.count.leaseCount+(this.count.noLeaseCount?this.count.noLeaseCount:0))).toFixed(4)*100
  202. }
  203. }
  204. if(type==2){
  205. if(this.count.noLeaseCount == 0 || this.count.noLeaseCount == undefined){}
  206. else{
  207. return (this.count.noLeaseCount/(this.count.leaseCount+(this.count.noLeaseCount?this.count.noLeaseCount:0))).toFixed(4)*100
  208. }
  209. }
  210. return p*100
  211. },
  212. jumpUrl(url){
  213. if(req.isLogins(true)){
  214. uni.navigateTo({
  215. url:url
  216. })
  217. }
  218. },
  219. queryTypeChange(val) {
  220. if (this.queryType == val) return false
  221. this.queryType = val
  222. this.queryType = val==-1?'':val
  223. this.getMachineList()
  224. },
  225. // 弹窗弹出
  226. openPop(item) {
  227. this.tempData = JSON.parse(JSON.stringify(item))
  228. this.showPop = true
  229. },
  230. closePop(){
  231. this.showPop = false
  232. },
  233. changePop(item){
  234. this.actMerchant = item
  235. this.closePop()
  236. this.getMachineList()
  237. },
  238. // 电池数量
  239. getTopNum(){
  240. console.log('getTopNum')
  241. req.getRequest(
  242. '/admin/v2/battery/count',
  243. {storeId:this.actMerchant.id},
  244. data => {
  245. this.count = data
  246. }
  247. )
  248. },
  249. // 获取电池列表
  250. getMachineList(isPage){
  251. if(!this.actMerchant||!this.actMerchant.id) return
  252. if(this.isQuerying) return
  253. else this.isQuerying = true
  254. if (!isPage) {
  255. this.page = 1
  256. }
  257. let queryParams = {
  258. page: this.page,
  259. limit: this.limit,
  260. }
  261. if(this.searchValue){
  262. queryParams.number=this.searchValue
  263. }
  264. if(this.queryType){
  265. queryParams.type = this.queryType
  266. }
  267. queryParams.storeId = this.actMerchant.id
  268. req.getRequest(
  269. '/admin/v2/battery/page',
  270. queryParams,
  271. data => {
  272. if (data != null && data.list.length > 0) {
  273. if (!isPage) {
  274. this.groupList = data.list
  275. } else {
  276. this.groupList = this.groupList.concat(data.list)
  277. }
  278. this.page++
  279. } else {
  280. if (!isPage)
  281. this.groupList = data.list
  282. else {}
  283. }
  284. uni.hideLoading()
  285. this.isQuerying = false
  286. }
  287. )
  288. },
  289. loadLeftData(res){
  290. this.getMerchantList(true)
  291. },
  292. getMerchantList(isPage){
  293. if (!isPage) {
  294. this.merchantPage = 1
  295. }
  296. let queryParams = {
  297. page: this.merchantPage,
  298. limit: this.merchantLimit,
  299. }
  300. queryParams.merchantId = this.merchantId?this.merchantId:req.getStorage('userInfo').merchantId?req.getStorage('userInfo').merchantId:null
  301. req.getRequest(
  302. '/admin/v2/store/page',
  303. queryParams,
  304. data => {
  305. if (data != null && data.list.length > 0) {
  306. if (!isPage) {
  307. this.merchantList = data.list
  308. } else {
  309. this.merchantList = this.merchantList.concat(data.list)
  310. }
  311. this.merchantPage++
  312. } else {
  313. if (!isPage)
  314. this.merchantList = data.list
  315. else {}
  316. }
  317. if(!isPage){
  318. if(this.actMerchant){
  319. }else{
  320. this.actMerchant = this.merchantList[0]
  321. }
  322. this.getMachineList()
  323. }
  324. }
  325. )
  326. },
  327. toLocation(item) {
  328. let plugin = requirePlugin('routePlan');
  329. let key = req.public.mapLBSKEY; //使用在腾讯位置服务申请的key
  330. let referer = '皮小店商家端'; //调用插件的app的名称
  331. // console.log("名称====" + referer);
  332. let endPoint = JSON.stringify({
  333. //终点
  334. 'name': item.devName,
  335. 'latitude': item.latitude,
  336. 'longitude':item.longitude
  337. });
  338. uni.navigateTo({
  339. url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint
  340. });
  341. },
  342. searchFn(){
  343. this.getMachineList()
  344. },
  345. saomaFn(){
  346. // 只允许通过相机扫码
  347. uni.scanCode({
  348. onlyFromCamera: false,
  349. success: (res) =>{
  350. console.log('条码类型:' + res.scanType);
  351. console.log('条码内容:' + res.result);
  352. // did设备id
  353. this.jumpUrl('/machineAndCell/cellSearch/cellSearch?storeId='+this.actMerchant.id+'&searchValue='+res.result+'&type='+this.queryType)
  354. }
  355. });
  356. }
  357. },
  358. mounted() {
  359. const systemInfo = uni.getSystemInfoSync();
  360. // px转换到rpx的比例
  361. let pxToRpxScale = 750 / systemInfo.windowWidth;
  362. let systems = {
  363. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  364. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  365. };
  366. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  367. this.systems = systems;
  368. },
  369. onPageScroll: function(e) {
  370. if (e.scrollTop > this.systems.barHeight) {
  371. this.isTop = 1;
  372. } else {
  373. this.isTop = 0;
  374. }
  375. }
  376. }
  377. </script>
  378. <style>
  379. @import "./machineLook.css";
  380. </style>