machine.vue 8.7 KB

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