machineLook.vue 8.6 KB

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