machine.vue 8.6 KB

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