machineLook.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <view>
  3. <view class="top-box">
  4. <view class="top-title ddflex">
  5. <view :style="'height: '+ systems.navigationHeight+'rpx;padding-top:' + systems.ktxStatusHeight + 'rpx;'" class="ddflex" @click="goback">
  6. <image style="width: 48rpx;height: 48rpx;margin: auto;margin-right: 20rpx;" src="../../static/pages/images/back.png"></image>
  7. </view>
  8. <view v-if="!storeId&&actMerchant" @click="showPop=true" class="ddflex fflex" :style="'height: '+ systems.navigationHeight + 'rpx;padding-top:' + systems.ktxStatusHeight + 'rpx;'+'line-height: '+ systems.navigationHeight + 'rpx;'">
  9. <view>{{actMerchant.name}}</view>
  10. <image class="dow-ssicon" src="../../static/pages/images/dow-ssicon.png"></image>
  11. </view>
  12. <view v-else :style="'height: '+ systems.navigationHeight + 'rpx;padding-top:' + systems.ktxStatusHeight + 'rpx;'+'line-height: '+ systems.navigationHeight + 'rpx;'">设备</view>
  13. </view>
  14. <view class="search-box ddflex">
  15. <image class="search-saoma" src="../../static/pages/images/saoma.png" @click="saomaFn()"></image>
  16. <view class="search-input ddflex fflex">
  17. <image class="search-input-icon" src="../../static/pages/images/search.png"></image>
  18. <input class="fflex" v-model="searchValue" confirm-type="search" @confirm="searchFn" placeholder="请输入编号查询"/>
  19. <view class="search-btn" @click="searchFn">搜索</view>
  20. </view>
  21. </view>
  22. </view>
  23. <view :style="'height: '+ (systems.navigationHeight+systems.ktxStatusHeight+134) + 'rpx;'"></view>
  24. <!-- 机柜 -->
  25. <view class="machine-item" v-for="item,index in groupList" @click="jumpUrl('/machineAndCell/machineInfo/machineInfo?id='+item.devId)">
  26. <view class="ddflex" style="justify-content: space-between;">
  27. <view class="machine-title fflex tover">{{item.devName}}</view>
  28. <!-- <view class="state">在线</view> -->
  29. </view>
  30. <view class="machine-number">机柜编号:{{item.devId}}</view>
  31. <view class="machine-info ddflex">
  32. <view class="ddflex">
  33. <view class="margin-r40">温度:{{item.cabTemp?item.cabTemp:0}}℃</view>
  34. <view class="margin-r40">仓门数:{{item.doorCount?item.doorCount:0}}</view>
  35. <view class="margin-r40">电池数:{{item.batNum?item.batNum:0}}</view>
  36. </view>
  37. <view class="fflex tover" style="color: #2A82E4;text-align: right;">
  38. {{item.storeName?item.storeName:''}}
  39. </view>
  40. </view>
  41. <view class="address-box ddflex">
  42. <image class="address-icon" src="../../static/pages/images/address-icon.png"></image>
  43. <view class="fflex tover">{{item.address}}</view>
  44. <image @click.stop="toLocation(item)" class="daohang" src="../../static/pages/images/daohang.png"></image>
  45. </view>
  46. </view>
  47. <view v-if="groupList.length==0">
  48. <view class="nodata">
  49. <image :src="picUrlss+'empty.png'"></image>
  50. <text>暂无设备~</text>
  51. </view>
  52. </view>
  53. <left-pop v-if="showPop" :showPop="showPop" :btnColor="'#11BB8B'" :showBtn='false' title="解除提醒" width="460rpx"
  54. @closePop="closePop()" @popSubmit="popSubmit()">
  55. <view class="" style="height: 100%;flex-direction: column;display: flex;">
  56. <view @click="closePop()" class="pop-title ddflex" :style="'height: '+ systems.navigationHeight + 'rpx;padding-top:' + systems.ktxStatusHeight + 'rpx;'+'line-height: '+ systems.navigationHeight + 'rpx;'">
  57. <view>切换门店</view>
  58. <image class="change-ssicon" src="../../static/pages/images/change.png"></image>
  59. </view>
  60. <scroll-view :scroll-y="true" @scrolltolower="loadLeftData" class="pop-content fflex">
  61. <view :class="'pop-content-item '+(actMerchant.id==item.id?'pop-content-active':'')" v-for="(item,index) in merchantList" @click="changePop(item)">
  62. <view class="pop-content-name">{{item.name}}</view>
  63. <image class="pop-content-icon" src=""></image>
  64. </view>
  65. </scroll-view>
  66. </view>
  67. </left-pop>
  68. </view>
  69. </template>
  70. <script>
  71. const app = getApp();
  72. const req = require("../../utils/request.js");
  73. import leftPop from "../../components/left-pop/index";
  74. export default {
  75. components: {
  76. leftPop
  77. },
  78. props: {},
  79. data() {
  80. return {
  81. picUrlss: req.public.picUrls,
  82. systems: {},
  83. isTop:0,
  84. isUpdate: false,
  85. userInfo:{},
  86. showPop: false,
  87. tempData: null,
  88. groupList: [],
  89. page: 1,
  90. limit: 10,
  91. searchValue:'',
  92. isQuerying:false,//正在查询数据
  93. merchantList: [],
  94. merchantPage: 1,
  95. merchantLimit: 10,
  96. actMerchant:null,//当前门店
  97. merchantId:null,
  98. storeId:null
  99. }
  100. },
  101. onLoad(options) {
  102. this.merchantId = options.merchantId
  103. this.storeId = options.storeId
  104. // 判断当前登录用户身份
  105. if(req.isLogins(true)){
  106. if(!this.storeId){
  107. this.getMerchantList()
  108. }else{
  109. this.actMerchant={
  110. id:this.storeId
  111. }
  112. this.getMachineList()
  113. }
  114. }else{
  115. this.getMachineList()
  116. }
  117. },
  118. onShow() {
  119. this.setData({
  120. isUpdate: !this.isUpdate
  121. });
  122. },
  123. onReachBottom() {
  124. this.getMachineList(true)
  125. },
  126. methods: {
  127. goback: function() {
  128. var pages = getCurrentPages();
  129. if(pages.length==1){
  130. uni.switchTab({
  131. url:'/pages/index/index'
  132. })
  133. }else{
  134. wx.navigateBack({
  135. delta: pages.length - 2
  136. })
  137. }
  138. },
  139. jumpUrl(url){
  140. if(req.isLogins(true)){
  141. uni.navigateTo({
  142. url:url
  143. })
  144. }
  145. },
  146. // 弹窗弹出
  147. openPop(item) {
  148. this.tempData = JSON.parse(JSON.stringify(item))
  149. this.showPop = true
  150. },
  151. closePop(){
  152. this.showPop = false
  153. },
  154. changePop(item){
  155. this.actMerchant = item
  156. this.closePop()
  157. this.getMachineList()
  158. },
  159. // 获取机柜列表
  160. getMachineList(isPage){
  161. if(!this.actMerchant||!this.actMerchant.id) return
  162. if(this.isQuerying) return
  163. else this.isQuerying = true
  164. if (!isPage) {
  165. this.page = 1
  166. }
  167. let queryParams = {
  168. page: this.page,
  169. limit: this.limit,
  170. }
  171. if(this.searchValue){
  172. queryParams.devId=this.searchValue
  173. }
  174. queryParams.storeId = this.actMerchant.id
  175. req.getRequest(
  176. '/admin/v2/cab/page',
  177. queryParams,
  178. data => {
  179. if (data != null && data.list.length > 0) {
  180. if (!isPage) {
  181. this.groupList = data.list
  182. } else {
  183. this.groupList = this.groupList.concat(data.list)
  184. }
  185. this.page++
  186. } else {
  187. if (!isPage)
  188. this.groupList = data.list
  189. else {}
  190. }
  191. uni.hideLoading()
  192. this.isQuerying = false
  193. }
  194. )
  195. },
  196. loadLeftData(res){
  197. this.getMerchantList(true)
  198. },
  199. getMerchantList(isPage){
  200. if (!isPage) {
  201. this.merchantPage = 1
  202. }
  203. let queryParams = {
  204. page: this.merchantPage,
  205. limit: this.merchantLimit,
  206. }
  207. queryParams.merchantId = this.merchantId?this.merchantId:req.getStorage('userInfo').merchantId?req.getStorage('userInfo').merchantId:null
  208. req.getRequest(
  209. '/admin/v2/store/page',
  210. queryParams,
  211. data => {
  212. if (data != null && data.list.length > 0) {
  213. if (!isPage) {
  214. this.merchantList = data.list
  215. } else {
  216. this.merchantList = this.merchantList.concat(data.list)
  217. }
  218. this.merchantPage++
  219. } else {
  220. if (!isPage)
  221. this.merchantList = data.list
  222. else {}
  223. }
  224. if(!isPage){
  225. if(this.actMerchant){
  226. }else{
  227. this.actMerchant = this.merchantList[0]
  228. }
  229. this.getMachineList()
  230. }
  231. }
  232. )
  233. },
  234. toLocation(item) {
  235. let plugin = requirePlugin('routePlan');
  236. let key = req.public.mapLBSKEY; //使用在腾讯位置服务申请的key
  237. let referer = '皮小店商家端'; //调用插件的app的名称
  238. // console.log("名称====" + referer);
  239. let endPoint = JSON.stringify({
  240. //终点
  241. 'name': item.devName,
  242. 'latitude': item.latitude,
  243. 'longitude':item.longitude
  244. });
  245. uni.navigateTo({
  246. url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint
  247. });
  248. },
  249. searchFn(){
  250. this.getMachineList()
  251. },
  252. saomaFn(){
  253. // 只允许通过相机扫码
  254. uni.scanCode({
  255. onlyFromCamera: false,
  256. success: (res) =>{
  257. console.log('条码类型:' + res.scanType);
  258. console.log('条码内容:' + res.result);
  259. // did设备id
  260. this.searchValue = res.result
  261. this.searchFn()
  262. }
  263. });
  264. }
  265. },
  266. mounted() {
  267. const systemInfo = uni.getSystemInfoSync();
  268. // px转换到rpx的比例
  269. let pxToRpxScale = 750 / systemInfo.windowWidth;
  270. let systems = {
  271. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  272. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  273. };
  274. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  275. this.systems = systems;
  276. },
  277. onPageScroll: function(e) {
  278. if (e.scrollTop > this.systems.barHeight) {
  279. this.isTop = 1;
  280. } else {
  281. this.isTop = 0;
  282. }
  283. }
  284. }
  285. </script>
  286. <style>
  287. @import "./machineLook.css";
  288. </style>