cell.vue 11 KB

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