| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- <template>
- <view>
- <view class="top-box">
- <view class="top-title" :style="'height: '+ systems.navigationHeight + 'rpx;padding-top:' + systems.ktxStatusHeight + 'rpx;'+'line-height: '+ systems.navigationHeight + 'rpx;'">
- <view v-if="!userInfo.storeId&&actMerchant" @click="showPop=true" class="ddflex">
- <view class="tover" style="max-width: 400rpx;">{{actMerchant.name}}</view>
- <image class="dow-ssicon" src="../../static/pages/images/dow-ssicon.png"></image>
- </view>
- <view v-else>机柜</view>
- </view>
- <view class="search-box ddflex">
- <image class="search-saoma" src="../../static/pages/images/saoma.png" @click="saomaFn()"></image>
- <view class="search-input ddflex fflex">
- <image class="search-input-icon" src="../../static/pages/images/search.png"></image>
- <input class="fflex" v-model="searchValue" confirm-type="search" @confirm="searchFn" placeholder="请输入编号查询"/>
- <view class="search-btn" @click="searchFn">搜索</view>
- </view>
- </view>
- </view>
-
- <view :style="'height: '+ (systems.navigationHeight+systems.ktxStatusHeight+134) + 'rpx;'"></view>
-
- <!-- 机柜 -->
- <view class="machine-item" v-for="item,index in groupList" @click="jumpUrl('/machineAndCell/machineInfo/machineInfo?id='+item.devId)">
- <view class="ddflex" style="justify-content: space-between;">
- <view class="machine-title fflex tover">{{item.devName}}</view>
- <!-- <view class="state">在线</view> -->
- </view>
- <view class="machine-number">机柜编号:{{item.devId}}</view>
- <view class="machine-info ddflex">
- <view class="ddflex">
- <view class="margin-r40">温度:{{item.cabTemp?item.cabTemp:0}}℃</view>
- <view class="margin-r40">仓门数:{{item.doorCount?item.doorCount:0}}</view>
- <view class="margin-r40">电池数:{{item.batNum?item.batNum:0}}</view>
- </view>
- <view class="fflex tover" style="color: #2A82E4;text-align: right;">
- {{item.storeName?item.storeName:''}}
- </view>
- </view>
- <view class="address-box ddflex">
- <image class="address-icon" src="../../static/pages/images/address-icon.png"></image>
- <view class="fflex tover">{{item.address}}</view>
- <image @click.stop="toLocation(item)" class="daohang" src="../../static/pages/images/daohang.png"></image>
- </view>
- </view>
-
- <view v-if="groupList.length==0">
- <view class="nodata">
- <image :src="picUrlss+'empty.png'"></image>
- <text>暂无设备~</text>
- </view>
- </view>
-
- <left-pop v-if="showPop" :showPop="showPop" :btnColor="'#11BB8B'" :showBtn='false' title="解除提醒" width="460rpx"
- @closePop="closePop()" @popSubmit="popSubmit()">
- <view class="" style="height: 100%;flex-direction: column;display: flex;">
- <view @click="closePop()" class="pop-title ddflex" :style="'height: '+ systems.navigationHeight + 'rpx;padding-top:' + systems.ktxStatusHeight + 'rpx;'+'line-height: '+ systems.navigationHeight + 'rpx;'">
- <view>切换门店</view>
- <image class="change-ssicon" src="../../static/pages/images/change.png"></image>
- </view>
- <scroll-view :scroll-y="true" @scrolltolower="loadLeftData" class="pop-content fflex">
- <view :class="'pop-content-item '+(actMerchant.id==item.id?'pop-content-active':'')" v-for="(item,index) in merchantList" @click="changePop(item)">
- <view class="pop-content-name tover">{{item.name}}</view>
- <image class="pop-content-icon" src=""></image>
- </view>
- </scroll-view>
- </view>
- </left-pop>
-
- <foot channel="machine" :isUpdate="isUpdate"></foot>
- </view>
- </template>
- <script>
- const app = getApp();
- const req = require("../../utils/request.js");
- import foot from "../../components/nav-bar/index";
- import leftPop from "../../components/left-pop/index";
- export default {
- components: {
- foot,
- leftPop
- },
- props: {},
- data() {
- return {
- picUrlss: req.public.picUrls,
- systems: {},
- isTop:0,
- isUpdate: false,
-
- userInfo:{},
-
- showPop: false,
- tempData: null,
-
- groupList: [],
- page: 1,
- limit: 10,
- searchValue:'',
- isQuerying:false,//正在查询数据
-
- merchantList: [],
- merchantPage: 1,
- merchantLimit: 10,
-
- actMerchant:null,//当前门店
- }
- },
- onLoad(options) {
- // 判断当前登录用户身份
- if(req.isLogins(true)){
- this.userInfo = req.getStorage('userInfo')
-
- if(!this.userInfo.storeId){
- this.getMerchantList()
- }else{
- this.actMerchant={
- id:this.userInfo.storeId
- }
- this.getMachineList()
- }
- }else{
- this.getMachineList()
- }
- uni.$on('reSetLogin',(data)=>{
- console.log('reSetLogin')
- this.actMerchant = null
- // 判断当前登录用户身份
- if(req.isLogins(true)){
- this.userInfo = req.getStorage('userInfo')
-
- if(!this.userInfo.storeId){
- this.getMerchantList()
- }else{
- this.actMerchant={
- id:this.userInfo.storeId
- }
- this.getMachineList()
- }
- }else{
- this.getMachineList()
- }
- })
- },
- onShow() {
- this.setData({
- isUpdate: !this.isUpdate
- });
- },
- onReachBottom() {
- this.getMachineList(true)
- },
- methods: {
- jumpUrl(url){
- if(req.isLogins(true)){
- uni.navigateTo({
- url:url
- })
- }
- },
- // 弹窗弹出
- openPop(item) {
- this.tempData = JSON.parse(JSON.stringify(item))
- this.showPop = true
- },
- closePop(){
- this.showPop = false
- },
- changePop(item){
- this.actMerchant = item
- this.closePop()
- this.getMachineList()
- },
- // 获取机柜列表
- getMachineList(isPage){
- if(!this.actMerchant||!this.actMerchant.id) return
- if(this.isQuerying) return
- else this.isQuerying = true
- if (!isPage) {
- this.page = 1
- }
- let queryParams = {
- page: this.page,
- limit: this.limit,
- }
- if(this.searchValue){
- queryParams.devId=this.searchValue
- }
- queryParams.storeId = this.actMerchant.id
- req.getRequest(
- '/admin/v2/cab/page',
- queryParams,
- data => {
- if (data != null && data.list.length > 0) {
- if (!isPage) {
- this.groupList = data.list
- } else {
- this.groupList = this.groupList.concat(data.list)
- }
- this.page++
- } else {
- if (!isPage)
- this.groupList = data.list
- else {}
- }
- uni.hideLoading()
- this.isQuerying = false
- }
- )
- },
- loadLeftData(res){
- this.getMerchantList(true)
- },
- getMerchantList(isPage){
- if (!isPage) {
- this.merchantPage = 1
- }
- let queryParams = {
- page: this.merchantPage,
- limit: this.merchantLimit,
- }
- queryParams.merchantId = req.getStorage('userInfo').merchantId?req.getStorage('userInfo').merchantId:null
- req.getRequest(
- '/admin/v2/store/page',
- queryParams,
- data => {
- if (data != null && data.list.length > 0) {
- if (!isPage) {
- this.merchantList = data.list
- } else {
- this.merchantList = this.merchantList.concat(data.list)
- }
- this.merchantPage++
- } else {
- if (!isPage)
- this.merchantList = data.list
- else {}
- }
- if(!isPage){
- if(this.actMerchant){
-
- }else{
- this.actMerchant = this.merchantList[0]
- }
- this.getMachineList()
- }
- }
- )
- },
- toLocation(item) {
- let plugin = requirePlugin('routePlan');
- let key = req.public.mapLBSKEY; //使用在腾讯位置服务申请的key
- let referer = '皮小店商家端'; //调用插件的app的名称
- // console.log("名称====" + referer);
- let endPoint = JSON.stringify({
- //终点
- 'name': item.devName,
- 'latitude': item.latitude,
- 'longitude':item.longitude
- });
- uni.navigateTo({
- url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint
- });
- },
- searchFn(){
- this.getMachineList()
- },
- saomaFn(){
- // 只允许通过相机扫码
- uni.scanCode({
- onlyFromCamera: false,
- success: (res) =>{
- console.log('条码类型:' + res.scanType);
- console.log('条码内容:' + res.result);
- // did设备id
- this.searchValue = res.result
- this.searchFn()
- }
- });
- }
- },
- mounted() {
- const systemInfo = uni.getSystemInfoSync();
- // px转换到rpx的比例
- let pxToRpxScale = 750 / systemInfo.windowWidth;
- let systems = {
- ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
- navigationHeight: 44 * pxToRpxScale // 导航栏的高度
- };
- systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
- this.systems = systems;
- },
- onPageScroll: function(e) {
- if (e.scrollTop > this.systems.barHeight) {
- this.isTop = 1;
- } else {
- this.isTop = 0;
- }
- }
- }
- </script>
- <style>
- @import "./machine.css";
- </style>
|