machine.vue 9.3 KB

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