machine.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <view>
  3. <view class="top-box">
  4. <view class="top-title">
  5. <view v-if="!userInfo.storeId" @click="showPop=true" class="ddflex" :style="'height: '+ systems.navigationHeight + 'rpx;padding-top:' + systems.ktxStatusHeight + 'rpx;'+'line-height: '+ systems.navigationHeight + 'rpx;'">
  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. <left-pop v-if="showPop" :showPop="showPop" :btnColor="'#11BB8B'" :showBtn='false' title="解除提醒" width="460rpx"
  44. @closePop="closePop()" @popSubmit="popSubmit()">
  45. <view class="" style="height: 100%;flex-direction: column;display: flex;">
  46. <view @click="closePop()" class="pop-title ddflex" :style="'height: '+ systems.navigationHeight + 'rpx;padding-top:' + systems.ktxStatusHeight + 'rpx;'+'line-height: '+ systems.navigationHeight + 'rpx;'">
  47. <view>切换门店</view>
  48. <image class="change-ssicon" src="../../static/pages/images/change.png"></image>
  49. </view>
  50. <scroll-view :scroll-y="true" @scrolltolower="loadLeftData" class="pop-content fflex">
  51. <view :class="'pop-content-item '+(actMerchant.id==item.id?'pop-content-active':'')" v-for="(item,index) in merchantList" @click="changePop(item)">
  52. <view class="pop-content-name">{{item.name}}</view>
  53. <image class="pop-content-icon" src=""></image>
  54. </view>
  55. </scroll-view>
  56. </view>
  57. </left-pop>
  58. <foot channel="machine" :isUpdate="isUpdate"></foot>
  59. </view>
  60. </template>
  61. <script>
  62. const app = getApp();
  63. const req = require("../../utils/request.js");
  64. import foot from "../../components/nav-bar/index";
  65. import leftPop from "../../components/left-pop/index";
  66. export default {
  67. components: {
  68. foot,
  69. leftPop
  70. },
  71. props: {},
  72. data() {
  73. return {
  74. systems: {},
  75. isTop:0,
  76. isUpdate: false,
  77. userInfo:{},
  78. showPop: false,
  79. tempData: null,
  80. groupList: [],
  81. page: 1,
  82. limit: 10,
  83. searchValue:'',
  84. isQuerying:false,//正在查询数据
  85. merchantList: [],
  86. merchantPage: 1,
  87. merchantLimit: 10,
  88. actMerchant:null,//当前门店
  89. }
  90. },
  91. onLoad(options) {
  92. // 判断当前登录用户身份
  93. if(req.isLogins(true)){
  94. this.userInfo = req.getStorage('userInfo')
  95. if(!this.userInfo.storeId){
  96. this.getMerchantList()
  97. }
  98. }else{
  99. this.getMachineList()
  100. }
  101. },
  102. onShow() {
  103. this.setData({
  104. isUpdate: !this.isUpdate
  105. });
  106. },
  107. onReachBottom() {
  108. this.getMachineList(true)
  109. },
  110. methods: {
  111. jumpUrl(url){
  112. if(req.isLogins(true)){
  113. uni.navigateTo({
  114. url:url
  115. })
  116. }
  117. },
  118. // 弹窗弹出
  119. openPop(item) {
  120. this.tempData = JSON.parse(JSON.stringify(item))
  121. this.showPop = true
  122. },
  123. closePop(){
  124. this.showPop = false
  125. },
  126. changePop(item){
  127. this.actMerchant = item
  128. this.closePop()
  129. this.getMachineList()
  130. },
  131. // 获取机柜列表
  132. getMachineList(isPage){
  133. if(this.isQuerying) return
  134. else this.isQuerying = true
  135. if (!isPage) {
  136. this.page = 1
  137. }
  138. let queryParams = {
  139. page: this.page,
  140. limit: this.limit,
  141. }
  142. if(this.searchValue){
  143. queryParams.devId=this.searchValue
  144. }
  145. queryParams.storeId = this.actMerchant.id
  146. req.getRequest(
  147. '/admin/v2/cab/page',
  148. queryParams,
  149. data => {
  150. if (data != null && data.list.length > 0) {
  151. if (!isPage) {
  152. this.groupList = data.list
  153. } else {
  154. this.groupList = this.groupList.concat(data.list)
  155. }
  156. this.page++
  157. } else {
  158. if (!isPage)
  159. this.groupList = data.list
  160. else {}
  161. }
  162. uni.hideLoading()
  163. this.isQuerying = false
  164. }
  165. )
  166. },
  167. loadLeftData(res){
  168. this.getMerchantList(true)
  169. },
  170. getMerchantList(isPage){
  171. if (!isPage) {
  172. this.merchantPage = 1
  173. }
  174. let queryParams = {
  175. page: this.merchantPage,
  176. limit: this.merchantLimit,
  177. }
  178. queryParams.merchantId = req.getStorage('userInfo').merchantId?req.getStorage('userInfo').merchantId:null
  179. req.getRequest(
  180. '/admin/v2/store/page',
  181. queryParams,
  182. data => {
  183. if (data != null && data.list.length > 0) {
  184. if (!isPage) {
  185. this.merchantList = data.list
  186. } else {
  187. this.merchantList = this.merchantList.concat(data.list)
  188. }
  189. this.merchantPage++
  190. } else {
  191. if (!isPage)
  192. this.merchantList = data.list
  193. else {}
  194. }
  195. if(!isPage){
  196. if(this.actMerchant){
  197. }else{
  198. this.actMerchant = this.merchantList[0]
  199. }
  200. this.getMachineList()
  201. }
  202. }
  203. )
  204. },
  205. toLocation(item) {
  206. let plugin = requirePlugin('routePlan');
  207. let key = req.public.mapLBSKEY; //使用在腾讯位置服务申请的key
  208. let referer = '皮小店商家端'; //调用插件的app的名称
  209. // console.log("名称====" + referer);
  210. let endPoint = JSON.stringify({
  211. //终点
  212. 'name': item.devName,
  213. 'latitude': item.latitude,
  214. 'longitude':item.longitude
  215. });
  216. uni.navigateTo({
  217. url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint
  218. });
  219. },
  220. searchFn(){
  221. this.getMachineList()
  222. },
  223. saomaFn(){
  224. // 只允许通过相机扫码
  225. uni.scanCode({
  226. onlyFromCamera: false,
  227. success: (res) =>{
  228. console.log('条码类型:' + res.scanType);
  229. console.log('条码内容:' + res.result);
  230. // did设备id
  231. this.searchValue = res.result
  232. this.searchFn()
  233. }
  234. });
  235. }
  236. },
  237. mounted() {
  238. const systemInfo = uni.getSystemInfoSync();
  239. // px转换到rpx的比例
  240. let pxToRpxScale = 750 / systemInfo.windowWidth;
  241. let systems = {
  242. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  243. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  244. };
  245. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  246. this.systems = systems;
  247. },
  248. onPageScroll: function(e) {
  249. if (e.scrollTop > this.systems.barHeight) {
  250. this.isTop = 1;
  251. } else {
  252. this.isTop = 0;
  253. }
  254. }
  255. }
  256. </script>
  257. <style>
  258. @import "./machine.css";
  259. </style>