cell.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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 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}}</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" @click="jumpUrl('/machineAndCell/map/map?id='+item.batteryId)">定位</view>
  87. <view class="fflex" @click="jumpUrl('/machineAndCell/BMS/BMS?id='+item.batteryId)">BMS</view>
  88. <view class="fflex" @click="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">{{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. getP(type){
  192. let p = 0
  193. console.log('111')
  194. if(type==1){
  195. if(this.count.leaseCount == 0 || this.count.leaseCount == undefined){}
  196. else{
  197. return (this.count.leaseCount/(this.count.leaseCount+(this.count.noLeaseCount?this.count.noLeaseCount:0))).toFixed(4)*100
  198. }
  199. }
  200. if(type==2){
  201. if(this.count.noLeaseCount == 0 || this.count.noLeaseCount == undefined){}
  202. else{
  203. return (this.count.noLeaseCount/(this.count.leaseCount+(this.count.noLeaseCount?this.count.noLeaseCount:0))).toFixed(4)*100
  204. }
  205. }
  206. return p*100
  207. },
  208. jumpUrl(url){
  209. if(req.isLogins(true)){
  210. uni.navigateTo({
  211. url:url
  212. })
  213. }
  214. },
  215. queryTypeChange(val) {
  216. if (this.queryType == val) return false
  217. this.queryType = val
  218. this.queryType = val==-1?'':val
  219. this.getMachineList()
  220. },
  221. // 弹窗弹出
  222. openPop(item) {
  223. this.tempData = JSON.parse(JSON.stringify(item))
  224. this.showPop = true
  225. },
  226. closePop(){
  227. this.showPop = false
  228. },
  229. changePop(item){
  230. this.actMerchant = item
  231. this.closePop()
  232. this.getMachineList()
  233. this.getTopNum()
  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 = 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. this.getTopNum()
  321. }
  322. }
  323. )
  324. },
  325. saomaFn(){
  326. // 只允许通过相机扫码
  327. uni.scanCode({
  328. onlyFromCamera: false,
  329. success: (res) =>{
  330. console.log('条码类型:' + res.scanType);
  331. console.log('条码内容:' + res.result);
  332. // did设备id
  333. this.jumpUrl('/machineAndCell/cellSearch/cellSearch?storeId='+this.actMerchant.id+'&searchValue='+res.result+'&type='+this.queryType)
  334. }
  335. });
  336. }
  337. },
  338. mounted() {
  339. const systemInfo = uni.getSystemInfoSync();
  340. // px转换到rpx的比例
  341. let pxToRpxScale = 750 / systemInfo.windowWidth;
  342. let systems = {
  343. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  344. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  345. };
  346. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  347. this.systems = systems;
  348. },
  349. onPageScroll: function(e) {
  350. if (e.scrollTop > this.systems.barHeight) {
  351. this.isTop = 1;
  352. } else {
  353. this.isTop = 0;
  354. }
  355. }
  356. }
  357. </script>
  358. <style>
  359. @import "./cell.css";
  360. </style>