cell.vue 10 KB

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