cabinetDetail.vue 14 KB

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