cabinetDetail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <view v-if="cabinetInfo.dev_id" class="main-view">
  3. <view class="content">
  4. <swiper v-if="shop_image.length!=0" class="swiper" :indicator-dots="true" :autoplay="true" :interval="2000"
  5. indicator-color="rgba(0, 0, 0, 0.3)" indicator-active-color="#000000" :duration="1000" circular>
  6. <swiper-item class="swiper-item" v-for="(item,index) in shop_image" :key="index">
  7. <img class="swiper-item-img" :src="item" />
  8. </swiper-item>
  9. </swiper>
  10. <img v-else class="bg-img" src="https://qiniu.bms16.com/FhRnr7rADHHsOFfpWO4duD15SgIt" alt="">
  11. </view>
  12. <view class="cabinet-detail">
  13. <view class="cabinet-name-view flex-row flex-between">
  14. <view class="cabinet-name">{{cabinetInfo.cabinet_name}}</view>
  15. <!-- <view class="distance">{{cabinetInfo.distance}}km</view> -->
  16. </view>
  17. <!-- <view v-if="tagList.length==0" class="no_battery">
  18. 无可用电池
  19. </view>
  20. <view class="flex-row" style="justify-content: center;">
  21. <view class="icon-box flex-row">
  22. <view v-for="(item, index) in tagList" class="item-tag flex-row">
  23. <text class="tag_name">
  24. {{item.main_tag_name ? (item.main_tag_name) : ''}}{{item.child_tag_name ? '/' + item.child_tag_name : ''}}·
  25. </text>
  26. <text class="tag_num">{{'x' + item.num}}</text>
  27. </view>
  28. </view>
  29. </view> -->
  30. <view class="flex-row flex-between">
  31. <view :class="isWorkTimer ? 'left_grid_2' : 'left_grid_1'">
  32. <view class="flex-row">
  33. <img class="icon_grid"
  34. :src="!isWorkTimer ? 'https://zxappfile.bms16.com/zx_admin/cab_timer.png' : 'https://zxappfile.bms16.com/zx_admin/cab_timer_work.png'">
  35. <view :class="isWorkTimer ? 'grid_text_1' : 'grid_text_rest' ">{{isWorkTimer ? '营业中' : '已休息'}}
  36. </view>
  37. </view>
  38. <view class="grid_text_2">
  39. {{cabinetInfo.work_begin_time!=null?cabinetInfo.work_begin_time:'00:00'}}-{{cabinetInfo.work_end_time!=null?cabinetInfo.work_end_time:'23:59'}}
  40. </view>
  41. </view>
  42. <view @tap="navToCabinet" class="right_grid flex-between">
  43. <view>
  44. <view class="cab_distance">
  45. 直线距您{{cabinetInfo.distance>1?(cabinetInfo.distance+'千米'):(cabinetInfo.distance*1000+'米')}}
  46. </view>
  47. <view class="cab_address">{{cabinetInfo.address}}</view>
  48. </view>
  49. <view>
  50. <img class="icon_grid_1" src="https://zxappfile.bms16.com/zx_admin/cab_nav.png">
  51. <view class="grid_nav">导航</view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="battery-list-view">
  57. <view class="battery-title flex-row flex-between">
  58. <text class="blod-text">格口详情</text>
  59. <text class="cabinet-ref">电柜编号:<text class="cabinet-ref-text"> {{cabinetInfo.dev_id}}</text></text>
  60. </view>
  61. <view class="battery-list-main flex-row flex-start">
  62. <view class="battery-list" v-for="(item, index) in batteryList" :key="item.unique">
  63. <!-- <block v-if="item.isReservation">
  64. <view class="battery-list-g">
  65. <view class="namber-view flex-row">
  66. <view class="namber namber-g">
  67. {{item.box_sn}}
  68. </view>
  69. </view>
  70. <view class="status-img-view flex-row">
  71. <img class="status-img" src="https://zxappfile.bms16.com/zx_admin/reservation.png"
  72. alt="">
  73. </view>
  74. <view class="tip-text tip-text-g1">已预约</view>
  75. </view>
  76. </block> -->
  77. <!-- 没有预约-->
  78. <!-- <block v-else> -->
  79. <!-- 空仓或者仓门不可用-->
  80. <view v-if="!item.cabinet_battery_sn||(item.fault_reason&&item.fault_reason.length>0)"
  81. :class="(item.fault_reason&&item.fault_reason.length>0)?'battery-list-s':'battery-list-g'">
  82. <!-- <view class="namber-view flex-row">
  83. <view
  84. :class="(item.fault_reason&&item.fault_reason.length>0)?'namber namber-s':'namber namber-g'">
  85. {{item.box_sn}}
  86. </view>
  87. </view> -->
  88. <view class="namber-view flex-row flex-between">
  89. <view
  90. :class="(item.fault_reason&&item.fault_reason.length>0)?'namber namber-s':'namber namber-g'">
  91. {{item.box_sn}}
  92. </view>
  93. <view v-if="item.tag_info != 'undefined' && item.tag_info && item.tag_info.length !== 0" class="tag_type_n">
  94. {{item.tag_info[0].main_tag_name ? (item.tag_info[0].main_tag_name) : ''}}{{item.tag_info[0].child_tag_name ? '/' + item.tag_info[0].child_tag_name : ''}}
  95. </view>
  96. </view>
  97. <view class="status-img-view flex-row">
  98. <img v-if="!item.cabinet_battery_sn&&!(item.fault_reason&&item.fault_reason.length>0)"
  99. class="status-img" src="https://qiniu.bms16.com/FtOgmvwtoUCVzEyxIau6-6i0hjLt"
  100. alt="">
  101. <img v-if="item.fault_reason&&item.fault_reason.length>0" class="status-img"
  102. src="https://qiniu.bms16.com/FmMGYfe7eRSQvM8zeKEVeSmzbArd" alt="">
  103. </view>
  104. <!-- <view class="battery-ref">124513215</view> -->
  105. <view v-if="!item.cabinet_battery_sn&&!(item.fault_reason&&item.fault_reason.length>0)"
  106. class="tip-text tip-text-g">空仓</view>
  107. <view v-if="item.fault_reason&&item.fault_reason.length>0" class="tip-text tip-text-u">
  108. {{item.fault_reason[0]}}
  109. </view>
  110. </view>
  111. <!-- 满电或者电量未满 -->
  112. <view v-else :class="(item.is_full_soc==1)?'battery-list-b':'battery-list-o'">
  113. <view class="namber-view flex-row flex-between">
  114. <view :class="(item.is_full_soc==1)?'namber namber-b':'namber namber-o'">{{item.box_sn}}
  115. </view>
  116. <view v-if="item.tag_info && item.tag_info.length !== 0" class="tag_type">
  117. {{item.tag_info[0].main_tag_name ? (item.tag_info[0].main_tag_name) : ''}}{{item.tag_info[0].child_tag_name ? '/' + item.tag_info[0].child_tag_name : ''}}
  118. </view>
  119. </view>
  120. <view class="status-img-view flex-row">
  121. <view v-if="item.cabinet_battery_sn" class="progress-bar-view">
  122. <progressView :soc="item.soc" :status="item.is_full_soc"></progressView>
  123. </view>
  124. <view v-if="item.cabinet_battery_sn" class="battery-number">
  125. {{item.battery_sn}}
  126. <!-- 0168 8256 9608 -->
  127. </view>
  128. </view>
  129. <view v-if="item.is_full_soc==1" class="tip-text tip-text-b">电池可用</view>
  130. <view v-else class="tip-text tip-text-o">待充满</view>
  131. </view>
  132. <!-- </block> -->
  133. </view>
  134. </view>
  135. </view>
  136. <scanBtn :dev_id="dev_id" :listData='listData' :cab_info="cabinetInfo" @refreshCabinet="refreshCabinet"
  137. @popPackageModel="clickPopPackageModel" ref="scanRef"></scanBtn>
  138. </view>
  139. </template>
  140. <script>
  141. import { getLocation, msg,strJoin } from '../../utils/util.js';
  142. import progressView from '@/component/progressView/progressView';
  143. const http = require('../../common/request.js');
  144. const config = require('../../common/config_gyq.js');
  145. const common = require('../../common/common.js');
  146. var user = require('../../common/user.js');
  147. var bluetooth = require('../../common/bluetooth.js');
  148. var cabinetDetailImpl = require('./cabinetDetailImpl.js');
  149. // const IndexBind = require('../index/model/indexBind.js');
  150. const DF_CAB_INFO_DONE = 10000; //机柜信息传输完成
  151. import scanBtn from '@/component/scanCabBtn/scanBtn';
  152. export default {
  153. components: {
  154. progressView,
  155. scanBtn
  156. },
  157. data() {
  158. return {
  159. dev_id: '',
  160. listData:{},
  161. isWorkTimer: true,
  162. tagList: [],
  163. batteryList: [], //电池列表
  164. isOpenBluetooth: false,
  165. isBluetooth: false, //存储蓝牙状态
  166. isShowToBuy: false,
  167. payType: 0,
  168. myLocation: {},
  169. reservation_info: [],
  170. cabinetInfo: {}, //机柜详情
  171. num: 0,
  172. is_scan: 0,
  173. fre_price: 0,
  174. online_status: 0, //0离线 1 在线
  175. wallet_money: 0, //钱包余额
  176. scan_dev_id: '', //扫码机柜id
  177. license_plate_number: '', //车牌号
  178. can_battery_num: 0, //可用电池数
  179. blueInfo: {}, //蓝牙信息
  180. cabBatterySn: '', //蓝牙换电需要的数据 cabinet_battery_sn
  181. shop_image: [],
  182. isShowAppoint: false,
  183. packType: 0,
  184. notShow: 0,
  185. car_info:{}
  186. };
  187. },
  188. /**
  189. * 生命周期函数--监听页面加载
  190. */
  191. onLoad: function(options) {
  192. this.notShow = options.notShow?options.notShow:1
  193. this.dev_id = options.dev_id
  194. const storedLocation = uni.getStorageSync('user_current_location');
  195. this.car_info = uni.getStorageSync('car_info') || {};
  196. const car_list = uni.getStorageSync('user_car_list') || null
  197. this.license_plate_number = car_list ? car_list.plate_number : ''
  198. const me = this
  199. if (storedLocation && storedLocation.longitude && storedLocation.latitude) {
  200. // 如果本地有存储的定位信息,则直接使用
  201. this.setData({
  202. myLocation: storedLocation
  203. });
  204. if (options && options.dev_id != '' && options.is_scan == 1) {
  205. this.is_scan = 1
  206. this.dev_id = options.dev_id
  207. }
  208. if (options && options.dev_id != '') {
  209. this.dev_id = options.dev_id
  210. this.loadCabinetDetail();
  211. }
  212. } else {
  213. // this.getLocationAndSave();
  214. }
  215. // bluetooth.initBluetooth()
  216. },
  217. /**
  218. * 生命周期函数--监听页面显示
  219. */
  220. onShow: function() {
  221. },
  222. methods: {
  223. clickClosePackage() {
  224. this.setData({
  225. isModelCenter: false
  226. })
  227. },
  228. clickPopPackageModel(e,notShow) {
  229. // console.log(e.packType,notShow,'sadasd');
  230. // this.notShow = notShow?notShow:this.notShow
  231. // if ((e.packType === 0&&this.notShow==1) || e.packType === 2) {
  232. // this.setData({
  233. // isModelCenter: true,
  234. // packType: e.packType
  235. // })
  236. // }
  237. // if (e.packType === 1) {
  238. // if (this.is_scan === 1) {
  239. // this.$refs.scanRef.loadNowCabinetDetail(this.dev_id)
  240. // }
  241. // }
  242. // if (e.packType === 3) {
  243. // if (this.is_scan === 1) {
  244. // this.getBindBattery(e)
  245. // }
  246. // }
  247. },
  248. getBindBattery(packInfo) {
  249. this.loadNowCabinetDetail(this.dev_id, this.myLocation, packInfo.order_sn, (bindSuccess) => {
  250. uni.showModal({
  251. title: '提示',
  252. content: '领取电池成功',
  253. confirmText: '确定',
  254. showCancel: false,
  255. success: function(res) {
  256. if (res.confirm) {
  257. setTimeout(() => {
  258. uni.switchTab({
  259. url: '/pages/index/index'
  260. });
  261. }, 1500)
  262. }
  263. },
  264. fail: function(res) {},
  265. complete: function(res) {},
  266. })
  267. })
  268. },
  269. async loadCabinetDetail() {
  270. //获取机柜信息
  271. const that = this
  272. var _can_num = 0
  273. let resp = await http.postApi(config.API_CABINET_INFO, {
  274. car_sn:this.car_info.car_sn,
  275. dev_id:this.dev_id,
  276. longitude: this.myLocation.longitude,
  277. latitude: this.myLocation.latitude,
  278. })
  279. if (resp.data.code === 200) {
  280. // const _batteryList = resp.data.data.boxList
  281. // // 计算可用电池数
  282. // for (let i = 0; i < _batteryList.length; i++) {
  283. // if (_batteryList[i].cabinet_battery_sn && (!(_batteryList[i].fault_reason &&
  284. // _batteryList[i].fault_reason.length > 0))) {
  285. // _can_num = _can_num + 1
  286. // }
  287. // }
  288. var cabinetInfo = resp.data.data.cabinetInfo
  289. cabinetInfo.work_begin_time = cabinetInfo.work_begin_time == null ? '00:00' : cabinetInfo
  290. .work_begin_time
  291. cabinetInfo.work_end_time = cabinetInfo.work_end_time == null ? '00:00' : cabinetInfo
  292. .work_end_time
  293. const isWorkTimer = cabinetDetailImpl.isWithinTimeRange(cabinetInfo.work_begin_time,
  294. cabinetInfo.work_end_time)
  295. var reservation_List = resp.data.data.cabinetInfo.reservation_info
  296. var box_list = resp.data.data.boxList
  297. // box_list = cabinetDetailImpl.getBoxReservation(box_list, reservation_List)
  298. console.log(box_list, "box_list")
  299. that.setData({
  300. reservation_info: reservation_List,
  301. isWorkTimer: isWorkTimer,
  302. tagList: resp.data.data.tagList,
  303. cabinetInfo: cabinetInfo,
  304. batteryList: box_list,
  305. listData:resp.data.data,
  306. online_status: cabinetInfo.online_status,
  307. can_battery_num: resp.data.data.can_exchange_num,
  308. shop_image: JSON.parse(cabinetInfo.imgs.split(',')) || []
  309. })
  310. } else {
  311. common.simpleToast(resp.data.msg)
  312. // setTimeout(() => {
  313. // uni.switchTab({
  314. // url: '/pages/index/index'
  315. // });
  316. // }, 1500)
  317. }
  318. },
  319. refreshCabinet() {
  320. this.loadCabinetDetail()
  321. },
  322. navToCabinet() {
  323. //导航去机柜
  324. const {
  325. latitude,
  326. longitude,
  327. cityname,
  328. address,
  329. cabinet_name
  330. } = this.cabinetInfo
  331. uni.openLocation({
  332. latitude: latitude - 0,
  333. longitude: longitude - 0,
  334. scale: 15,
  335. name: cabinet_name,
  336. address: address,
  337. success: function(res) {}
  338. });
  339. },
  340. getLocationAndSave: function() {
  341. const me = this;
  342. uni.getLocation({
  343. type: 'gcj02',
  344. success: function(res) {
  345. uni.hideLoading();
  346. var myLocation = {
  347. longitude: res.longitude,
  348. latitude: res.latitude
  349. }
  350. me.setData({
  351. myLocation: myLocation
  352. })
  353. uni.setStorageSync('user_current_location', myLocation);
  354. },
  355. fail: function(res) {
  356. uni.hideLoading();
  357. },
  358. complete: function(res) {
  359. uni.hideLoading();
  360. }
  361. });
  362. },
  363. loadNowCabinetDetail(dev_id, myLocation, order_sn, bindSuccess, bluetoothCallBack) {
  364. const timeNow = Date.now()
  365. const me = this
  366. const pData = {
  367. longitude: myLocation.longitude,
  368. latitude: myLocation.latitude,
  369. dev_id: dev_id || '',
  370. time: timeNow
  371. }
  372. http.postApi(config.API_DAYHIRE_CABINRT_CABINRT_INFO, pData, (resp) => {
  373. if (resp.data.code === 200) {
  374. online_status = resp.data.data.cabinetInfo.online_status
  375. const device = {
  376. device_type: "LSCabinet",
  377. bt_type: "",
  378. mac_id: resp.data.data.cabinetInfo.bt_mac,
  379. btid: resp.data.data.cabinetInfo.bt_mac,
  380. dev_id: resp.data.data.cabinetInfo.dev_id,
  381. key: decodeKey(resp.data.data.cabinetInfo.bt_sec),
  382. btkey: resp.data.data.cabinetInfo.bt_mac,
  383. bt_sec: decodeKey(resp.data.data.cabinetInfo.bt_sec),
  384. bt_mac: resp.data.data.cabinetInfo.bt_mac
  385. }
  386. console.log(online_status)
  387. if (online_status == 1) {
  388. console.log("bb设备数据", device)
  389. toBindBattery(DEVICE_TYPE_CABINET, '', dev_id, order_sn, bindSuccess)
  390. } else {
  391. console.log("aa设备数据", device)
  392. bluetoothCallBack(device)
  393. }
  394. } else {
  395. common.simpleToast(resp.data.msg)
  396. }
  397. })
  398. }
  399. }
  400. };
  401. </script>
  402. <style >
  403. @import './cabinetDetail.css';
  404. </style>