machine.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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"></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" placeholder="请输入编号查询"/>
  15. <view class="search-btn">搜索</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')">
  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}}℃</view>
  30. <view class="margin-r40">仓门数:{{item.doorCount}}</view>
  31. <view class="margin-r40">电池数:{{item.batNum}}</view>
  32. </view>
  33. <view class="fflex tover" style="color: #2A82E4;text-align: right;">
  34. {{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 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. userType:0,//0管理员 1商家 2门店
  79. showPop: false,
  80. tempData: null,
  81. groupList: [],
  82. page: 1,
  83. limit: 10,
  84. searchValue:'',
  85. isQuerying:false,//正在查询数据
  86. merchantList: [],
  87. merchantPage: 1,
  88. merchantLimit: 10,
  89. actMerchant:{},//当前门店
  90. }
  91. },
  92. onLoad(options) {
  93. // 判断当前登录用户身份
  94. if(req.isLogins(true)){
  95. this.userInfo = req.getStorage('userInfo')
  96. if(!this.userInfo.storeId){
  97. this.getMerchantList()
  98. }
  99. }else{
  100. this.getMachineList()
  101. }
  102. },
  103. onShow() {
  104. this.setData({
  105. isUpdate: !this.isUpdate
  106. });
  107. },
  108. methods: {
  109. jumpUrl(url){
  110. if(req.isLogins(true)){
  111. uni.navigateTo({
  112. url:url
  113. })
  114. }
  115. },
  116. // 弹窗弹出
  117. openPop(item) {
  118. this.tempData = JSON.parse(JSON.stringify(item))
  119. this.showPop = true
  120. },
  121. closePop(){
  122. this.showPop = false
  123. },
  124. changePop(item){
  125. this.actMerchant = item
  126. req.setStorage('default_merchant',item)
  127. this.closePop()
  128. this.getMachineList()
  129. },
  130. // 获取机柜列表
  131. getMachineList(isPage){
  132. if(this.isQuerying) return
  133. else this.isQuerying = true
  134. if (!isPage) {
  135. this.page = 1
  136. }
  137. let queryParams = {
  138. page: this.page,
  139. limit: this.limit,
  140. }
  141. if(this.searchValue){
  142. queryParams.devId=this.searchValue
  143. }
  144. queryParams.storeId = this.actMerchant.id
  145. req.getRequest(
  146. '/admin/v2/cab/page',
  147. queryParams,
  148. data => {
  149. if (data != null && data.list.length > 0) {
  150. if (!isPage) {
  151. this.groupList = data.list
  152. } else {
  153. this.groupList = this.groupList.concat(data.list)
  154. }
  155. this.page++
  156. } else {
  157. if (!isPage)
  158. this.groupList = data.list
  159. else {}
  160. }
  161. uni.hideLoading()
  162. this.isQuerying = false
  163. }
  164. )
  165. },
  166. loadLeftData(res){
  167. this.getMerchantList(true)
  168. },
  169. getMerchantList(isPage){
  170. if (!isPage) {
  171. this.merchantPage = 1
  172. }
  173. let queryParams = {
  174. page: this.merchantPage,
  175. limit: this.merchantLimit,
  176. }
  177. queryParams.merchantId = req.getStorage('userInfo').merchantId?req.getStorage('userInfo').merchantId:null
  178. req.getRequest(
  179. '/admin/v2/store/page',
  180. queryParams,
  181. data => {
  182. if (data != null && data.list.length > 0) {
  183. if (!isPage) {
  184. this.merchantList = data.list
  185. } else {
  186. this.merchantList = this.merchantList.concat(data.list)
  187. }
  188. this.merchantPage++
  189. } else {
  190. if (!isPage)
  191. this.merchantList = data.list
  192. else {}
  193. }
  194. if(!isPage){
  195. if(req.getStorage('default_merchant')){
  196. this.actMerchant = req.getStorage('default_merchant')
  197. }else{
  198. this.actMerchant = this.merchantList[0]
  199. }
  200. this.getMachineList()
  201. }
  202. }
  203. )
  204. }
  205. },
  206. mounted() {
  207. const systemInfo = uni.getSystemInfoSync();
  208. // px转换到rpx的比例
  209. let pxToRpxScale = 750 / systemInfo.windowWidth;
  210. let systems = {
  211. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  212. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  213. };
  214. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  215. this.systems = systems;
  216. },
  217. onPageScroll: function(e) {
  218. if (e.scrollTop > this.systems.barHeight) {
  219. this.isTop = 1;
  220. } else {
  221. this.isTop = 0;
  222. }
  223. }
  224. }
  225. </script>
  226. <style>
  227. @import "./machine.css";
  228. </style>