cabinetDetail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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 && 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" :cab_info="cabinetInfo" @refreshCabinet="refreshCabinet"
  137. @popPackageModel="clickPopPackageModel" ref="scanRef"></scanBtn>
  138. <view v-if="isModelCenter" class="model_center">
  139. <image class="pack_model" src="https://zxappfile.bms16.com/zx_client/buy_pack_model.png" />
  140. <view v-if="packType==0" class="pack_model_text">您还未购买换电套餐,需先完成购买后再扫码领取电池</view>
  141. <view v-if="packType==2" class="pack_model_text">您还未完成押金授权,现在前往押金授权?</view>
  142. <view v-if="packType==0" class="look_package" @tap="clickLookPackage">查看套餐</view>
  143. <view v-if="packType==2" class="look_package" @tap="clickMyPackage">去押金认证</view>
  144. <view class="line_view"></view>
  145. <image @tap="clickClosePackage" class="close_package"
  146. src="https://zxappfile.bms16.com/zx_client/close_package.png"></image>
  147. </view>
  148. </view>
  149. </template>
  150. <script>
  151. import { getLocation, msg,strJoin } from '../../utils/util.js';
  152. import progressView from '@/component/progressView/progressView';
  153. const http = require('../../common/request.js');
  154. const config = require('../../common/config_gyq.js');
  155. const common = require('../../common/common.js');
  156. var user = require('../../common/user.js');
  157. var bluetooth = require('../../common/bluetooth.js');
  158. var cabinetDetailImpl = require('./cabinetDetailImpl.js');
  159. // const IndexBind = require('../index/model/indexBind.js');
  160. const DF_CAB_INFO_DONE = 10000; //机柜信息传输完成
  161. import scanBtn from '@/component/scanCabBtn/scanBtn';
  162. export default {
  163. components: {
  164. progressView,
  165. scanBtn
  166. },
  167. data() {
  168. return {
  169. dev_id: '',
  170. listData:{},
  171. isWorkTimer: true,
  172. tagList: [],
  173. batteryList: [], //电池列表
  174. isOpenBluetooth: false,
  175. isBluetooth: false, //存储蓝牙状态
  176. isShowToBuy: false,
  177. payType: 0,
  178. myLocation: {},
  179. reservation_info: [],
  180. cabinetInfo: {}, //机柜详情
  181. num: 0,
  182. is_scan: 0,
  183. fre_price: 0,
  184. online_status: 0, //0离线 1 在线
  185. wallet_money: 0, //钱包余额
  186. scan_dev_id: '', //扫码机柜id
  187. license_plate_number: '', //车牌号
  188. can_battery_num: 0, //可用电池数
  189. blueInfo: {}, //蓝牙信息
  190. cabBatterySn: '', //蓝牙换电需要的数据 cabinet_battery_sn
  191. shop_image: [],
  192. isShowAppoint: false,
  193. isModelCenter: false,
  194. packType: 0,
  195. notShow: 0
  196. };
  197. },
  198. /**
  199. * 生命周期函数--监听页面加载
  200. */
  201. onLoad: function(options) {
  202. this.notShow = options.notShow?options.notShow:1
  203. this.dev_id = options.dev_id
  204. const storedLocation = uni.getStorageSync('user_current_location');
  205. const car_list = uni.getStorageSync('user_car_list') || null
  206. this.license_plate_number = car_list ? car_list.plate_number : ''
  207. const me = this
  208. if (storedLocation && storedLocation.longitude && storedLocation.latitude) {
  209. // 如果本地有存储的定位信息,则直接使用
  210. this.setData({
  211. myLocation: storedLocation
  212. });
  213. if (options && options.dev_id != '' && options.is_scan == 1) {
  214. this.is_scan = 1
  215. this.dev_id = options.dev_id
  216. }
  217. if (options && options.dev_id != '') {
  218. this.dev_id = options.dev_id
  219. this.loadCabinetDetail();
  220. }
  221. } else {
  222. this.getLocationAndSave();
  223. }
  224. bluetooth.initBluetooth()
  225. },
  226. /**
  227. * 生命周期函数--监听页面显示
  228. */
  229. onShow: function() {
  230. },
  231. methods: {
  232. clickLookPackage() {
  233. wx.switchTab({
  234. url: '/pages/packageCenter/packageCenter'
  235. })
  236. },
  237. clickMyPackage() {
  238. wx.navigateTo({
  239. url: '/pages/my/myPackage/myPackage'
  240. })
  241. },
  242. clickClosePackage() {
  243. this.setData({
  244. isModelCenter: false
  245. })
  246. },
  247. clickPopPackageModel(e,notShow) {
  248. console.log(e.packType,notShow,'sadasd');
  249. this.notShow = notShow?notShow:this.notShow
  250. if ((e.packType === 0&&this.notShow==1) || e.packType === 2) {
  251. this.setData({
  252. isModelCenter: true,
  253. packType: e.packType
  254. })
  255. }
  256. if (e.packType === 1) {
  257. if (this.is_scan === 1) {
  258. this.$refs.scanRef.loadNowCabinetDetail(this.dev_id)
  259. }
  260. }
  261. if (e.packType === 3) {
  262. if (this.is_scan === 1) {
  263. this.getBindBattery(e)
  264. }
  265. }
  266. },
  267. getBindBattery(packInfo) {
  268. this.loadNowCabinetDetail(this.dev_id, this.myLocation, packInfo.order_sn, (bindSuccess) => {
  269. uni.showModal({
  270. title: '提示',
  271. content: '领取电池成功',
  272. confirmText: '确定',
  273. showCancel: false,
  274. success: function(res) {
  275. if (res.confirm) {
  276. setTimeout(() => {
  277. uni.switchTab({
  278. url: '/pages/index/index'
  279. });
  280. }, 1500)
  281. }
  282. },
  283. fail: function(res) {},
  284. complete: function(res) {},
  285. })
  286. })
  287. },
  288. async loadCabinetDetail() {
  289. //获取机柜信息
  290. const that = this
  291. var _can_num = 0
  292. let resp = await http.postApi(config.API_CABINET_INFO, {
  293. dev_id:this.dev_id,
  294. longitude: this.myLocation.longitude,
  295. latitude: this.myLocation.latitude,
  296. })
  297. if (resp.data.code === 200) {
  298. const _batteryList = resp.data.data.boxList
  299. // 计算可用电池数
  300. for (let i = 0; i < _batteryList.length; i++) {
  301. if (_batteryList[i].cabinet_battery_sn && (!(_batteryList[i].fault_reason &&
  302. _batteryList[i].fault_reason.length > 0))) {
  303. _can_num = _can_num + 1
  304. }
  305. }
  306. var cabinetInfo = resp.data.data.cabinetInfo
  307. cabinetInfo.work_begin_time = cabinetInfo.work_begin_time == null ? '00:00' : cabinetInfo
  308. .work_begin_time
  309. cabinetInfo.work_end_time = cabinetInfo.work_end_time == null ? '00:00' : cabinetInfo
  310. .work_end_time
  311. const isWorkTimer = cabinetDetailImpl.isWithinTimeRange(cabinetInfo.work_begin_time,
  312. cabinetInfo.work_end_time)
  313. var reservation_List = resp.data.data.cabinetInfo.reservation_info
  314. var box_list = resp.data.data.boxList
  315. // box_list = cabinetDetailImpl.getBoxReservation(box_list, reservation_List)
  316. console.log(box_list, "box_list")
  317. that.setData({
  318. reservation_info: reservation_List,
  319. isWorkTimer: isWorkTimer,
  320. tagList: resp.data.data.tagList,
  321. cabinetInfo: cabinetInfo,
  322. batteryList: box_list,
  323. online_status: cabinetInfo.online_status,
  324. can_battery_num: _can_num,
  325. shop_image: JSON.parse(cabinetInfo.imgs.split(',')) || []
  326. })
  327. } else {
  328. common.simpleToast(resp.data.msg)
  329. setTimeout(() => {
  330. uni.switchTab({
  331. url: '/pages/index/index'
  332. });
  333. }, 1500)
  334. }
  335. },
  336. refreshCabinet() {
  337. this.loadCabinetDetail()
  338. },
  339. navToCabinet() {
  340. //导航去机柜
  341. const {
  342. latitude,
  343. longitude,
  344. cityname,
  345. address,
  346. cabinet_name
  347. } = this.cabinetInfo
  348. uni.openLocation({
  349. latitude: latitude - 0,
  350. longitude: longitude - 0,
  351. scale: 15,
  352. name: cabinet_name,
  353. address: address,
  354. success: function(res) {}
  355. });
  356. },
  357. getLocationAndSave: function() {
  358. const me = this;
  359. uni.getLocation({
  360. type: 'gcj02',
  361. success: function(res) {
  362. uni.hideLoading();
  363. var myLocation = {
  364. longitude: res.longitude,
  365. latitude: res.latitude
  366. }
  367. me.setData({
  368. myLocation: myLocation
  369. })
  370. uni.setStorageSync('user_current_location', myLocation);
  371. },
  372. fail: function(res) {
  373. uni.hideLoading();
  374. },
  375. complete: function(res) {
  376. uni.hideLoading();
  377. }
  378. });
  379. },
  380. loadNowCabinetDetail(dev_id, myLocation, order_sn, bindSuccess, bluetoothCallBack) {
  381. const timeNow = Date.now()
  382. const me = this
  383. const pData = {
  384. longitude: myLocation.longitude,
  385. latitude: myLocation.latitude,
  386. dev_id: dev_id || '',
  387. time: timeNow
  388. }
  389. http.postApi(config.API_DAYHIRE_CABINRT_CABINRT_INFO, pData, (resp) => {
  390. if (resp.data.code === 200) {
  391. online_status = resp.data.data.cabinetInfo.online_status
  392. const device = {
  393. device_type: "LSCabinet",
  394. bt_type: "",
  395. mac_id: resp.data.data.cabinetInfo.bt_mac,
  396. btid: resp.data.data.cabinetInfo.bt_mac,
  397. dev_id: resp.data.data.cabinetInfo.dev_id,
  398. key: decodeKey(resp.data.data.cabinetInfo.bt_sec),
  399. btkey: resp.data.data.cabinetInfo.bt_mac,
  400. bt_sec: decodeKey(resp.data.data.cabinetInfo.bt_sec),
  401. bt_mac: resp.data.data.cabinetInfo.bt_mac
  402. }
  403. console.log(online_status)
  404. if (online_status == 1) {
  405. console.log("bb设备数据", device)
  406. toBindBattery(DEVICE_TYPE_CABINET, '', dev_id, order_sn, bindSuccess)
  407. } else {
  408. console.log("aa设备数据", device)
  409. bluetoothCallBack(device)
  410. }
  411. } else {
  412. common.simpleToast(resp.data.msg)
  413. }
  414. })
  415. }
  416. }
  417. };
  418. </script>
  419. <style >
  420. @import './cabinetDetail.css';
  421. </style>