Procházet zdrojové kódy

机柜切换门店

xhj před 3 roky
rodič
revize
7d0c38945c

+ 36 - 15
pages/index/index.vue

@@ -99,9 +99,15 @@
 		</view>
 
 		<!-- 图表统计 -->
-		<view class="echart-box">
+		<view class="echart-box" v-if="storeRanking&&storeRanking.length>0">
 			<view class="echart-box-header ddflex">
 				<view class="echart-box-title">商家营业额排名</view>
+				<view class="echart-box-timeType ddflex">
+					<view :class="'echart-box-timeType-item '+(storeType==1?'echart-box-timeType-item-acitve':'')"
+						@click="storeTypeChange(1)">商户</view>
+					<view :class="'echart-box-timeType-item '+(storeType==2?'echart-box-timeType-item-acitve':'')"
+						@click="storeTypeChange(2)">门店</view>
+				</view>
 			</view>
 			<view>
 				<l-echart ref="chart2" @finished="init"></l-echart>
@@ -164,9 +170,11 @@
 				rpxTopxScale: 0,
 
 				timeType: 1, //统计时间 1.按日 2.按月 3.按季度
+				storeType:1,//营业额查询1.商家 2.门店
 				
 				statisticData:{},//统计数据
 				echartData:{},//曲线图
+				storeRanking:{},//营业额排行
 				
 				userInfo:{},
 
@@ -224,7 +232,8 @@
 							name: '订单数',
 							type: 'line',
 							data: [300, 270, 340, 344, 300, 320, 310],
-							barWidth: 10,
+							showSymbol: false,
+							smooth: true,
 							itemStyle: {
 								// 颜色
 								color: '#5F50E6',
@@ -236,7 +245,8 @@
 							name: '订单金额',
 							type: 'line',
 							data: [120, 102, 141, 174, 190, 250, 220],
-							barWidth: 10,
+							showSymbol: false,
+							smooth: true,
 							itemStyle: {
 								// 颜色
 								color: '#FF7D00',
@@ -248,7 +258,8 @@
 							name: '收益金额',
 							type: 'line',
 							data: [120, 102, 141, 174, 190, 250, 120],
-							barWidth: 10,
+							showSymbol: false,
+							smooth: true,
 							itemStyle: {
 								// 颜色
 								color: '#FFDC0F',
@@ -532,19 +543,12 @@
 		},
 		props: {},
 		onLoad: async function(options) {
-			QQMapWX.initMap();
-			req.getLocation(res => {
-				const to = {
-					latitude: res.latitude,
-					longitude: res.longitude
-				};
-				QQMapWX.reverseGeocoder(to, resp => {});
-			});
 		},
 
 		async onShow() {
 			await this.getEchartData()
 			await this.getStatisticData()
+			await this.getStoreData()
 			
 			this.init()
 			
@@ -569,7 +573,14 @@
 				if (this.timeType == val) return false
 				this.timeType = val
 				await this.getEchartData()
-				// await this.getStatisticData()
+				
+				this.init()
+			},
+			// 营业额切换
+			async storeTypeChange(val) {
+				if (this.storeType == val) return false
+				this.storeType = val
+				await this.getStoreData()
 				
 				this.init()
 			},
@@ -587,8 +598,8 @@
 				if (this.$refs.chart2) {
 					this.$refs.chart2.init(echarts, async chart => {
 						// let echartData = await this.getEchartData()
-						this.option2.yAxis[0].data = ['罗技', '刘涛', '陈楚生', '罗巧红', '李冰冰']
-						this.option2.series[0].data = [8125, 6802, 5622, 4588, 2458]
+						this.option2.yAxis[0].data = this.storeRanking.map(item=>{return item.name})
+						this.option2.series[0].data = this.storeRanking.map(item=>{return item.turnover})
 						chart.setOption(this.option2);
 					});
 				}
@@ -640,6 +651,16 @@
 					})
 				})
 			},
+			// 获取营业额数据
+			getStoreData() {
+				return new Promise((r, j) => {
+					req.getRequest('/admin/v2/statistic/ranking', {type: this.storeType}, res => {
+						this.storeRanking = res
+						console.log('statistic ranking', res)
+						r(res)
+					})
+				})
+			},
 			// 获取图表数据
 			getStatisticData() {
 				return new Promise((r, j) => {

+ 1 - 0
pages/machine/machine.css

@@ -134,6 +134,7 @@
 .pop-content{
 	margin: 48rpx 30rpx 30rpx;
 	overflow: scroll;
+	width: calc(100% - 60rpx);
 }
 .pop-content::-webkit-scrollbar{
 	display: none;

+ 120 - 21
pages/machine/machine.vue

@@ -2,8 +2,8 @@
 	<view>
 		<view class="top-box">
 			<view class="top-title">
-				<view @click="showPop=true" class="ddflex" :style="'height: '+ systems.navigationHeight + 'rpx;padding-top:' + systems.ktxStatusHeight + 'rpx;'+'line-height: '+ systems.navigationHeight + 'rpx;'">
-					<view>白云科技门店</view>
+				<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;'">
+					<view>{{actMerchant.name}}</view>
 					<image class="dow-ssicon" src="../../static/pages/images/dow-ssicon.png"></image>
 				</view>
 			</view>
@@ -20,25 +20,25 @@
 		<view :style="'height: '+ (systems.navigationHeight+systems.ktxStatusHeight+134) + 'rpx;'"></view>
 		
 		<!-- 机柜 -->
-		<view class="machine-item" v-for="item in 10" @click="jumpUrl('/machineAndCell/machineInfo/machineInfo')">
+		<view class="machine-item" v-for="item,index in groupList" @click="jumpUrl('/machineAndCell/machineInfo/machineInfo')">
 			<view class="ddflex" style="justify-content: space-between;">
-				<view class="machine-title fflex tover">创业2街站</view>
+				<view class="machine-title fflex tover">{{item.devName}}</view>
 				<view class="state">在线</view>
 			</view>
-			<view class="machine-number">机柜编号:CHZD04TTCC200329109</view>
+			<view class="machine-number">机柜编号:{{item.devId}}</view>
 			<view class="machine-info ddflex">
 				<view class="ddflex">
-					<view class="margin-r40">温度:29℃</view>
-					<view class="margin-r40">仓门数:6</view>
-					<view class="margin-r40">电池数:4</view>
+					<view class="margin-r40">温度:{{item.cabTemp}}℃</view>
+					<view class="margin-r40">仓门数:{{item.doorCount}}</view>
+					<view class="margin-r40">电池数:{{item.batNum}}</view>
 				</view>
 				<view class="fflex tover" style="color: #2A82E4;text-align: right;">
-					白云科技
+					{{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">朝阳区金台路道家园1号</view>
+				<view class="fflex tover">{{item.address}}</view>
 				<image class="daohang" src="../../static/pages/images/daohang.png"></image>
 			</view>
 		</view>
@@ -47,15 +47,15 @@
 			@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>
+					<view>切换门店</view>
 					<image class="change-ssicon" src="../../static/pages/images/change.png"></image>
 				</view>
-				<view class="pop-content fflex">
-					<view :class="'pop-content-item '+(index==0?'pop-content-active':'')" v-for="(item,index) in 10">
-						<view class="pop-content-name">白云科技门店</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">{{item.name}}</view>
 						<image class="pop-content-icon" src=""></image>
 					</view>
-				</view>
+				</scroll-view>
 			</view>
 		</left-pop>
 		
@@ -81,12 +81,36 @@
 				isTop:0,
 				isUpdate: false,
 				
+				userInfo:{},
+				userType:0,//0管理员 1商家 2门店
+				
 				showPop: false,
 				tempData: null,
+				
+				groupList: [],
+				page: 1,
+				limit: 10,
+				searchValue:'',
+				isQuerying:false,//正在查询数据
+				
+				merchantList: [],
+				merchantPage: 1,
+				merchantLimit: 10,
+				
+				actMerchant:{},//当前门店
 			}
 		},
 		onLoad(options) {
-
+			// 判断当前登录用户身份
+			if(req.isLogins(true)){
+				this.userInfo = req.getStorage('userInfo')
+				
+				if(!this.userInfo.storeId){
+					this.getMerchantList()
+				}
+			}else{
+				this.getMachineList()
+			}
 		},
 		onShow() {
 			this.setData({
@@ -106,15 +130,90 @@
 				this.tempData = JSON.parse(JSON.stringify(item))
 				this.showPop = true
 			},
-			// 弹窗关闭
-			closePop() {
+			closePop(){
 				this.showPop = false
-				this.tempData = null
 			},
-			// 弹窗确认
-			popSubmit() {
+			changePop(item){
+				this.actMerchant = item
+				req.setStorage('default_merchant',item)
 				this.closePop()
+				this.getMachineList()
 			},
+			// 获取机柜列表
+			getMachineList(isPage){
+				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(req.getStorage('default_merchant')){
+								this.actMerchant = req.getStorage('default_merchant')
+							}else{
+								this.actMerchant = this.merchantList[0]
+							}
+							this.getMachineList()
+						}
+					}
+				)
+			}
 		},
 		mounted() {
 			const systemInfo = uni.getSystemInfoSync();

+ 23 - 15
pages/myMerchant/myMerchant.vue

@@ -1,36 +1,36 @@
 <template>
-	<view>
+	<view style="overflow: hidden;">
 		<!-- 搜索 -->
 		<view>
 			<view class="search-box ddflex">
 				<image class="search-icon" src="../../static/images/ssico.png"></image>
-				<input class="fflex" confirm-type="search" @confirm="searchFn" placeholder="请输入门店名称或电话"/>
+				<input class="fflex" v-model="searchValue" confirm-type="search" @confirm="searchFn" placeholder="请输入门店名称或电话"/>
 				<view class="search-btn" @click="searchFn">搜索</view>
 			</view>
 		</view>
 		
 		<view>
-			<view class="sjyy-item" v-for="item,index in 10">
+			<view class="sjyy-item" v-for="item,index in groupList" :key="index">
 				<view class="ddflex">
 					<view class="sjyy-header">
-						<image src="../../static/pages/images/wdsj.png"></image>
+						<image src="../../static/pages/images/wdmd.png"></image>
 					</view>
 					<view class="fflex">
 						<view class="sjyy-name ddflex">
-							<view>白云科技门店</view>
+							<view>{{item.name}}</view>
 							<!-- <view class="sjyy-name-label">我的门店</view> -->
 						</view>
-						<view class="sjyy-phone">顾勇(13815141671)</view>
+						<view class="sjyy-phone">{{item.linkman}}({{item.phone}})</view>
 					</view>
-					<view>
+					<view @click="goPhone(item.phone)" v-if="item.phone">
 						<image style="width: 48rpx;height: 48rpx;margin-left: 20rpx;" src="../../static/pages/images/call.png"></image>
 					</view>
 				</view>
 				<view class="sjyy-data ddflex">
 					<image style="width: 26rpx;height: 26rpx;margin-right: 10rpx;" src="../../static/pages/images/address-icon.png"></image>
-					<view class="tover fflex" style="font-size: 24rpx;line-height: 36rpx;color: #A8A5A5;">朝阳区金台路道家园1号</view>
+					<view class="tover fflex" style="font-size: 24rpx;line-height: 36rpx;color: #A8A5A5;">{{item.address}}</view>
 				</view>
-				<view class="sjyy-data ddflex">
+				<!-- <view class="sjyy-data ddflex">
 					<view class="sjyy-data-item fflex">
 						<view class="sssb-data sssb-color">10242.00</view>
 						<view class="sssb-label">累计收益</view>
@@ -43,20 +43,20 @@
 						<view class="sssb-data sssb-color">9154.00</view>
 						<view class="sssb-label">本月收益</view>
 					</view>
-				</view>
+				</view> -->
 				<view class="sjyy-data ddflex">
 					<view class="sjyy-data-item fflex">
-						<view class="sssb-data sssb-color">56</view>
+						<view class="sssb-data sssb-color">{{item.cabCount?item.cabCount:0}}</view>
 						<view class="sssb-label">机柜数</view>
 					</view>
 					<view class="sjyy-data-item fflex">
-						<view class="sssb-data sssb-color">50%</view>
+						<view class="sssb-data sssb-color">{{item.proportion?item.proportion:0}}%</view>
 						<view class="sssb-label">分润</view>
 					</view>
-					<view class="sjyy-data-item fflex" style="visibility: hidden;">
+					<!-- <view class="sjyy-data-item fflex" style="visibility: hidden;">
 						<view class="sssb-data sssb-color">5</view>
 						<view class="sssb-label">门店数</view>
-					</view>
+					</view> -->
 				</view>
 				<view class="ddflex" style="justify-content: space-between;margin-top: 30rpx;">
 					<view class="sjyy-btn" style="border: 2rpx solid #EB5C20;color: #EB5C20;" @click="jumpUrl()">查看订单</view>
@@ -82,9 +82,13 @@
 				limit: 3,
 				searchValue:'',
 				isQuerying:false,//正在查询数据
+				merchantId:null
 			}
 		},
 		onLoad(options) {
+			if(options.merchantId){
+				this.merchantId = options.merchantId
+			}
 			this.getDataList()
 		},
 		onShow() {
@@ -107,6 +111,7 @@
 				if(this.searchValue){
 					queryParams.name=this.searchValue
 				}
+				queryParams.merchantId = this.merchantId?this.merchantId:req.getStorage('userInfo').merchantId?req.getStorage('userInfo').merchantId:null
 				req.getRequest(
 					'/admin/v2/store/page',
 					queryParams,
@@ -130,7 +135,10 @@
 			},
 			searchFn(){
 				this.getDataList()
-			}
+			},
+			goPhone(phone) {
+				uni.makePhoneCall({ phoneNumber: phone }); // 传参带入号码即可
+			},
 		},
 		mounted() {
 			

+ 23 - 10
pages/myStore/myStore.vue

@@ -1,5 +1,5 @@
 <template>
-	<view>
+	<view style="overflow: hidden;">
 		<!-- 搜索 -->
 		<view>
 			<view class="search-box ddflex">
@@ -25,25 +25,25 @@
 		</view>
 		
 		<view>
-			<view class="sjyy-item" v-for="item,index in 10">
+			<view class="sjyy-item" v-for="item,index in groupList" :key="index" @click="toMerchant(item)">
 				<view class="ddflex">
 					<view class="sjyy-header">
 						<image src="../../static/pages/images/wdsj.png"></image>
 					</view>
 					<view class="fflex">
 						<view class="sjyy-name ddflex">
-							<view>宋秀兰</view>
-							<view class="sjyy-name-label">我的商家</view>
+							<view>{{item.name}}</view>
+							<view class="sjyy-name-label" v-if="item.isMy==1">我的商家</view>
 						</view>
-						<view class="sjyy-phone">13815141671</view>
+						<view class="sjyy-phone" v-if="item.phone">{{item.phone}}</view>
 					</view>
-					<view>
+					<view @click.stop="goPhone(item.phone)" v-if="item.phone">
 						<image style="width: 48rpx;height: 48rpx;margin-left: 20rpx;" src="../../static/pages/images/call.png"></image>
 					</view>
 				</view>
 				<view class="sjyy-data ddflex">
 					<image style="width: 26rpx;height: 26rpx;margin-right: 10rpx;" src="../../static/pages/images/address-icon.png"></image>
-					<view class="tover fflex" style="font-size: 24rpx;line-height: 36rpx;color: #A8A5A5;">朝阳区金台路道家园1号</view>
+					<view class="tover fflex" style="font-size: 24rpx;line-height: 36rpx;color: #A8A5A5;">{{item.address}}</view>
 				</view>
 				<!-- <view class="sjyy-data ddflex">
 					<view class="sjyy-data-item fflex">
@@ -61,15 +61,15 @@
 				</view> -->
 				<view class="sjyy-data ddflex">
 					<view class="sjyy-data-item fflex">
-						<view class="sssb-data sssb-color">56</view>
+						<view class="sssb-data sssb-color">{{item.cabCount?item.cabCount:0}}</view>
 						<view class="sssb-label">机柜数</view>
 					</view>
 					<view class="sjyy-data-item fflex">
-						<view class="sssb-data sssb-color">50%</view>
+						<view class="sssb-data sssb-color">{{item.proportion?item.proportion:0}}%</view>
 						<view class="sssb-label">分润</view>
 					</view>
 					<view class="sjyy-data-item fflex">
-						<view class="sssb-data sssb-color">5</view>
+						<view class="sssb-data sssb-color">{{item.storeCount?item.storeCount:0}}</view>
 						<view class="sssb-label">门店数</view>
 					</view>
 				</view>
@@ -110,6 +110,13 @@
 			this.getDataList(true)
 		},
 		methods: {
+			jumpUrl(url){
+				if(req.isLogins(true)){
+					uni.navigateTo({
+						url:url
+					})
+				}
+			},
 			getStatisticData() {
 				return new Promise((r, j) => {
 					req.getRequest('/admin/v2/statistic/top', {}, res => {
@@ -155,6 +162,12 @@
 			},
 			searchFn(){
 				this.getDataList()
+			},
+			goPhone(phone) {
+				uni.makePhoneCall({ phoneNumber: phone }); // 传参带入号码即可
+			},
+			toMerchant(item){
+				this.jumpUrl('/pages/myMerchant/myMerchant?merchantId='+item.id)
 			}
 		},
 		mounted() {

+ 209 - 60
pages/operationData/operationData.vue

@@ -43,14 +43,14 @@
 					<view class="echart-box-title">实时设备数据</view>
 				</view>
 				<view class="sssb-box ddflex">
-					<view class="sssb-item">
+					<view class="sssb-item fflex">
 						<view class="sssb-label">总数</view>
-						<view class="sssb-data">421台</view>
+						<view class="sssb-data">{{statisticData.batteryCount?statisticData.batteryCount:0}}台</view>
 					</view>
 					<view class="sssb-line"></view>
-					<view class="sssb-item">
+					<view class="sssb-item fflex">
 						<view class="sssb-label">使用总次数</view>
-						<view class="sssb-data">63889次</view>
+						<view class="sssb-data">{{statisticData.useCount?statisticData.useCount:0}}次</view>
 					</view>
 				</view>
 				<!-- <view class="sssb-box ddflex">
@@ -73,23 +73,23 @@
 				</view>
 				<view class="sssb-box ddflex">
 					<view class="sssb-item fflex">
-						<view class="sssb-data sssb-color">867.00</view>
+						<view class="sssb-data sssb-color">{{statisticData.totalTurnover?statisticData.totalTurnover:0}}</view>
 						<view class="sssb-label">营业总额</view>
 					</view>
 					<view class="sssb-line"></view>
 					<view class="sssb-item fflex">
-						<view class="sssb-data sssb-color">1915.00</view>
-						<view class="sssb-label">收益总额</view>
+						<view class="sssb-data sssb-color">{{statisticData.totalRefund?statisticData.totalRefund:0}}</view>
+						<view class="sssb-label">累计退款</view>
 					</view>
 				</view>
 				<view class="sssb-box ddflex">
 					<view class="sssb-item fflex">
-						<view class="sssb-data sssb-color">1915.00</view>
+						<view class="sssb-data sssb-color">{{statisticData.totalProfit?statisticData.totalProfit:0}}</view>
 						<view class="sssb-label">收益总额</view>
 					</view>
 					<view class="sssb-line"></view>
 					<view class="sssb-item fflex">
-						<view class="sssb-data sssb-color">1915.00</view>
+						<view class="sssb-data sssb-color">{{statisticData.useProfit?statisticData.useProfit:0}}</view>
 						<view class="sssb-label">可分账金额</view>
 					</view>
 				</view>
@@ -110,41 +110,41 @@
 			<view>
 				<view class="search-box ddflex">
 					<image class="search-icon" src="../../static/images/ssico.png"></image>
-					<input class="fflex" placeholder="请输入商家名称或电话"/>
-					<view class="search-btn">搜索</view>
+					<input class="fflex" v-model="searchValue" confirm-type="search" @confirm="searchFn" placeholder="请输入商家名称或电话"/>
+					<view class="search-btn" @click="searchFn">搜索</view>
 				</view>
 			</view>
 			<!-- 数据 -->
 			<view>
-				<view class="sjyy-item" v-for="item,index in 10">
+				<view class="sjyy-item" v-for="item,index in groupList" :key="index">
 					<view class="ddflex">
 						<view class="sjyy-header">
 							<image src="../../static/pages/images/wdsj.png"></image>
 						</view>
 						<view class="fflex">
-							<view class="sjyy-name">宋秀兰</view>
-							<view class="sjyy-phone">13815141671</view>
+							<view class="sjyy-name">{{item.name}}</view>
+							<view class="sjyy-phone">{{item.phone}}</view>
 						</view>
-						<view class="sjyy-btn" @click="jumpUrl('/pages/operationDataPersonal/operationDataPersonal')">运营情况</view>
+						<view class="sjyy-btn" @click="jumpUrl('/pages/operationDataPersonal/operationDataPersonal?merchantId='+item.id+'&totalTurnover='+item.totalTurnover+'&totalRefund='+item.totalRefund+'&totalProfit='+item.totalProfit+'&useProfit='+item.useProfit)">运营情况</view>
 					</view>
 					<view class="sjyy-data">
 						<view class="ddflex">
 							<view class="sjyy-data-item fflex">
-								<view class="sssb-data sssb-color">10242.00</view>
+								<view class="sssb-data sssb-color">{{item.totalTurnover?item.totalTurnover:0}}</view>
 								<view class="sssb-label">营业总额</view>
 							</view>
 							<view class="sjyy-data-item fflex">
-								<view class="sssb-data sssb-color">1242.00</view>
+								<view class="sssb-data sssb-color">{{item.totalRefund?item.totalRefund:0}}</view>
 								<view class="sssb-label">累计退款</view>
 							</view>
 						</view>
 						<view class="ddflex" style="margin-top: 40rpx;">
 							<view class="sjyy-data-item fflex">
-								<view class="sssb-data sssb-color">1915.00</view>
+								<view class="sssb-data sssb-color">{{item.totalProfit?item.totalProfit:0}}</view>
 								<view class="sssb-label">收益总额</view>
 							</view>
 							<view class="sjyy-data-item fflex">
-								<view class="sssb-data sssb-color">1915.00</view>
+								<view class="sssb-data sssb-color">{{item.useProfit?item.useProfit:0}}</view>
 								<view class="sssb-label">可分账金额</view>
 							</view>
 						</view>
@@ -159,45 +159,47 @@
 			<view>
 				<view class="search-box ddflex">
 					<image class="search-icon" src="../../static/images/ssico.png"></image>
-					<input class="fflex" placeholder="请输入门店名称或电话"/>
-					<view class="search-btn">搜索</view>
+					<input class="fflex" v-model="searchValue" confirm-type="search" @confirm="searchFn" placeholder="请输入门店名称或电话"/>
+					<view class="search-btn" @click="searchFn">搜索</view>
 				</view>
 			</view>
 			<!-- 数据 -->
 			<view>
-				<view class="sjyy-item" v-for="item,index in 10">
+				<view class="sjyy-item" v-for="item,index in groupList" :key="index">
 					<view class="ddflex">
 						<view class="sjyy-header">
 							<image src="../../static/pages/images/wdmd.png"></image>
 						</view>
 						<view class="fflex">
-							<view class="sjyy-name">白云科技门店</view>
-							<view class="sjyy-phone">顾勇(13815141671)</view>
+							<view class="sjyy-name">{{item.name}}</view>
+							<view class="sjyy-phone">{{item.linkman}}({{item.phone}})</view>
 						</view>
-						<view class="sjyy-btn" @click="jumpUrl('/pages/operationDataPersonal/operationDataPersonal')">运营情况</view>
+						<view class="sjyy-btn" 
+						@click="jumpUrl('/pages/operationDataPersonal/operationDataPersonal?storeId='+item.id+'&totalTurnover='+item.totalTurnover+'&totalRefund='+item.totalRefund+'&totalProfit='+item.totalProfit+'&useProfit='+item.useProfit)">
+						运营情况</view>
 					</view>
 					<view class="sjyy-data ddflex" style="padding: 20rpx;">
 						<image style="width: 26rpx;height: 26rpx;margin-right: 10rpx;" src="../../static/pages/images/address-icon.png"></image>
-						<view class="tover fflex" style="font-size: 24rpx;line-height: 36rpx;color: #A8A5A5;">朝阳区金台路道家园1号</view>
+						<view class="tover fflex" style="font-size: 24rpx;line-height: 36rpx;color: #A8A5A5;">{{item.address}}</view>
 					</view>
 					<view class="sjyy-data">
 						<view class="ddflex">
 							<view class="sjyy-data-item fflex">
-								<view class="sssb-data sssb-color">10242.00</view>
+								<view class="sssb-data sssb-color">{{item.totalTurnover?item.totalTurnover:0}}</view>
 								<view class="sssb-label">营业总额</view>
 							</view>
 							<view class="sjyy-data-item fflex">
-								<view class="sssb-data sssb-color">1242.00</view>
+								<view class="sssb-data sssb-color">{{item.totalRefund?item.totalRefund:0}}</view>
 								<view class="sssb-label">累计退款</view>
 							</view>
 						</view>
 						<view class="ddflex" style="margin-top: 40rpx;">
 							<view class="sjyy-data-item fflex">
-								<view class="sssb-data sssb-color">1915.00</view>
+								<view class="sssb-data sssb-color">{{item.totalProfit?item.totalProfit:0}}</view>
 								<view class="sssb-label">收益总额</view>
 							</view>
 							<view class="sjyy-data-item fflex">
-								<view class="sssb-data sssb-color">1915.00</view>
+								<view class="sssb-data sssb-color">{{item.useProfit?item.useProfit:0}}</view>
 								<view class="sssb-label">可分账金额</view>
 							</view>
 						</view>
@@ -227,9 +229,21 @@
 				pxToRpxScale: 0,
 				rpxTopxScale: 0,
 
+				merchantId:null,
+				storeId:null,
 
 				queryType: 1,
 				timeType: 1, //统计时间 1.按日 2.按月 3.按季度
+				
+				groupList: [],
+				page: 1,
+				limit: 10,
+				searchValue:'',
+				isQuerying:false,//正在查询数据
+				
+				echartData:{},//交易趋势图表
+				statisticData:{},
+				barEchartData:{},
 
 				// 交易趋势图表数据
 				option: {
@@ -240,11 +254,17 @@
 						},
 						confine: true
 					},
+					legend: {
+						data: ['订单数', '订单金额','收益金额'],
+						x: 'center', //可设定图例在左、右、居中
+						y: 'top', //可设定图例在上、下、居中
+						padding: [15, 0, 0, 0]
+					},
 					grid: {
 						left: 0,
 						right: 8,
-						bottom: 10,
-						top: 10,
+						bottom: 5,
+						top: 45,
 						containLabel: true
 					},
 					xAxis: [{
@@ -258,7 +278,7 @@
 						axisLabel: {
 							color: '#666666',
 							// interval: 0,
-
+				
 						}
 					}],
 					yAxis: [{
@@ -276,17 +296,45 @@
 						}
 					}],
 					series: [{
-						name: '订单',
-						type: 'line',
-						data: [],
-						barWidth: 10,
-						itemStyle: {
-							// 颜色
-							color: '#FF7D00',
-							// 给bar设置倒角
-							barBorderRadius: [15, 15, 0, 0]
-						}
-					}]
+							name: '订单数',
+							type: 'line',
+							data: [300, 270, 340, 344, 300, 320, 310],
+							showSymbol: false,
+							smooth: true,
+							itemStyle: {
+								// 颜色
+								color: '#5F50E6',
+								// 给bar设置倒角
+								barBorderRadius: [15, 15, 0, 0]
+							}
+						},
+						{
+							name: '订单金额',
+							type: 'line',
+							data: [120, 102, 141, 174, 190, 250, 220],
+							showSymbol: false,
+							smooth: true,
+							itemStyle: {
+								// 颜色
+								color: '#FF7D00',
+								// 给bar设置倒角
+								barBorderRadius: [15, 15, 0, 0]
+							}
+						},
+						{
+							name: '收益金额',
+							type: 'line',
+							data: [120, 102, 141, 174, 190, 250, 120],
+							showSymbol: false,
+							smooth: true,
+							itemStyle: {
+								// 颜色
+								color: '#FFDC0F',
+								// 给bar设置倒角
+								barBorderRadius: [15, 15, 0, 0]
+							}
+						},
+					]
 				},
 
 				// 近一周营业额度(元)图表数据
@@ -342,7 +390,10 @@
 								show: true,
 								position: 'top',
 								color: '#FF770F',
-								formatter: '¥{c}',
+								formatter: (res)=>{
+									if(res.value>0) return '¥'+res.value
+									else return ''
+								},
 							},
 						},
 						data: [285, 200, 285, 300, 285, 285, 320],
@@ -409,7 +460,10 @@
 								show: true,
 								position: 'top',
 								color: '#FF770F',
-								formatter: '¥{c}',
+								formatter: (res)=>{
+									if(res.value>0) return '¥'+res.value
+									else return ''
+								},
 							},
 						},
 						data: [285, 200, 285, 300, 285, 285, 320],
@@ -426,7 +480,7 @@
 			}
 		},
 		onLoad(options) {
-
+			this.getStatisticData()
 		},
 		onShow() {
 
@@ -442,30 +496,38 @@
 			queryTypeChange(val) {
 				if (this.queryType == val) return false
 				this.queryType = val
+				if(this.queryType==1){
+					this.getStatisticData()
+				}
+				if(this.queryType==2||this.queryType==3){
+					this.getDataList()
+					this.searchValue = ''
+				}
 			},
 			// 统计时间切换
 			timeTypeChange(val) {
 				if (this.timeType == val) return false
 				this.timeType = val
+				this.getStatisticData()
 			},
 			init() {
 				this.$refs.chart.init(echarts, async chart => {
 					// let echartData = await this.getEchartData()
-					this.option.xAxis[0].data = ['04-04', '04-05', '04-06', '04-07', '04-08', '04-09', '04-10']
-					this.option.yAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
-					this.option.xAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
-					this.option.series[0].data = [100, 270, 340, 344, 300, 320, 310]
+					this.option.legend.itemHeight = 10 * this.rpxTopxScale
+					this.option.legend.itemWidth = 40 * this.rpxTopxScale
+					this.option.xAxis[0].data = this.echartData.orderList.map(item=>{return item.showTime})
+					this.option.series[0].data = this.echartData.orderList.map(item=>{return item.orderCount})
+					this.option.series[1].data = this.echartData.profitList.map(item=>{return item.profit})
+					this.option.series[2].data = this.echartData.turnoverList.map(item=>{return item.turnover})
 					chart.setOption(this.option);
 				});
 				if (this.$refs.chart2) {
 					this.$refs.chart2.init(echarts, async chart => {
 						// let echartData = await this.getEchartData()
-						this.option2.xAxis[0].data = ['04-04', '04-05', '04-06', '04-07', '04-08', '04-09',
-							'04-10'
-						]
+						this.option2.xAxis[0].data = this.echartData.orderList.map(item=>{return item.showTime})
 						this.option2.yAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
 						this.option2.xAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
-						this.option2.series[0].data = [300, 270, 340, 344, 300, 320, 310]
+						this.option2.series[0].data = this.echartData.orderList.map(item=>{return item.orderCount})
 						this.option2.series[0].label.normal.fontSize = 13 * this.rpxTopxScale
 						chart.setOption(this.option2);
 					});
@@ -473,17 +535,104 @@
 				if (this.$refs.chart3) {
 					this.$refs.chart3.init(echarts, async chart => {
 						// let echartData = await this.getEchartData()
-						this.option3.xAxis[0].data = ['04-04', '04-05', '04-06', '04-07', '04-08', '04-09',
-							'04-10'
-						]
+						this.option3.xAxis[0].data = this.echartData.profitList.map(item=>{return item.showTime})
 						this.option3.yAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
 						this.option3.xAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
-						this.option3.series[0].data = [300, 270, 340, 344, 300, 320, 310]
+						this.option3.series[0].data = this.echartData.profitList.map(item=>{return item.profit})
 						this.option3.series[0].label.normal.fontSize = 13 * this.rpxTopxScale
 						chart.setOption(this.option3);
 					});
 				}
-			}
+			},
+			
+			
+			
+			getDataList(isPage) {
+				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.name=this.searchValue
+				}
+				let api = '/admin/v2/merchant/pageDate'
+				if(this.queryType==2){
+					api = '/admin/v2/merchant/pageDate'
+				}
+				if(this.queryType==3){
+					api = '/admin/v2/store/pageData'
+				}
+				req.getRequest(
+					api,
+					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
+					}
+				)
+			},
+			searchFn(){
+				this.getDataList()
+			},
+			
+			// 获取运营数据-交易趋势
+			async getStatisticData(){
+				await this.getEchartData()
+				await this.getTopData()
+				await this.getBarEchartData()
+				this.init()
+			},
+			getEchartData() {
+				return new Promise((r, j) => {
+					req.getRequest('/admin/v2/statistic/chart', {type: this.timeType}, res => {
+						this.echartData = res
+						console.log('statistic chart', res)
+						r(res)
+					})
+				})
+			},
+			// 获取统计数据
+			getTopData() {
+				return new Promise((r, j) => {
+					req.getRequest('/admin/v2/statistic/top', {}, res => {
+						console.log('statistic top', res)
+						this.statisticData = res
+						r(res)
+					})
+				})
+			},
+			getBarEchartData() {
+				return new Promise((r, j) => {
+					let merchantId = this.merchantId?this.merchantId:req.getStorage('userInfo').merchantId?req.getStorage('userInfo').merchantId:''
+					let storeId = this.storeId?this.storeId:req.getStorage('userInfo').storeId?req.getStorage('userInfo').storeId:''
+					let pData = {
+						merchantId:merchantId,
+						storeId:storeId
+					}
+					req.getRequest('/admin/v2/statistic/histogram', pData, res => {
+						this.barEchartData = res
+						console.log('statistic chart', res)
+						r(res)
+					})
+				})
+			},
 		},
 		mounted() {
 			const systemInfo = uni.getSystemInfoSync();

+ 47 - 30
pages/operationDataPersonal/operationDataPersonal.vue

@@ -7,24 +7,24 @@
 			</view>
 			<view class="sssb-box ddflex">
 				<view class="sssb-item fflex">
-					<view class="sssb-data sssb-color">867.00</view>
+					<view class="sssb-data sssb-color">{{totalTurnover?totalTurnover:0}}</view>
 					<view class="sssb-label">营业总额</view>
 				</view>
 				<view class="sssb-line"></view>
 				<view class="sssb-item fflex">
-					<view class="sssb-data sssb-color">1915.00</view>
+					<view class="sssb-data sssb-color">{{totalRefund?totalRefund:0}}</view>
 					<view class="sssb-label">累计退款</view>
 				</view>
 			</view>
 			<view class="sssb-box ddflex">
 				<view class="sssb-item fflex">
 					<view class="sssb-label">收益总额</view>
-					<view class="sssb-data sssb-color">1915.00</view>
+					<view class="sssb-data sssb-color">{{totalProfit?totalProfit:0}}</view>
 				</view>
 				<view class="sssb-line"></view>
 				<view class="sssb-item fflex">
 					<view class="sssb-label">可分账金额</view>
-					<view class="sssb-data sssb-color">1915.00</view>
+					<view class="sssb-data sssb-color">{{useProfit?useProfit:0}}</view>
 				</view>
 			</view>
 			<view style="margin-top: 30rpx;height:500rpx">
@@ -56,6 +56,14 @@
 				isTop: 0,
 				pxToRpxScale: 0,
 				rpxTopxScale: 0,
+				
+				merchantId:null,
+				storeId:null,
+				
+				totalTurnover:0,
+				totalRefund :0,
+				totalProfit:0,
+				useProfit :0,
 
 
 				// 近一周营业额度(元)图表数据
@@ -195,7 +203,17 @@
 			}
 		},
 		onLoad(options) {
-
+			if(options.merchantId){
+				this.merchantId = options.merchantId
+			}
+			if(options.storeId){
+				this.storeId = options.storeId
+			}
+			this.totalTurnover = options.totalTurnover?options.totalTurnover:0
+			this.totalRefund = options.totalRefund?options.totalRefund:0
+			this.totalProfit = options.totalProfit?options.totalProfit:0
+			this.useProfit = options.useProfit?options.useProfit:0
+			this.getStatisticData()
 		},
 		onShow() {
 
@@ -213,12 +231,10 @@
 				if (this.$refs.chart2) {
 					this.$refs.chart2.init(echarts, async chart => {
 						// let echartData = await this.getEchartData()
-						this.option2.xAxis[0].data = ['04-04', '04-05', '04-06', '04-07', '04-08', '04-09',
-							'04-10'
-						]
+						this.option2.xAxis[0].data = this.echartData.orderList.map(item=>{return item.showTime})
 						this.option2.yAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
 						this.option2.xAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
-						this.option2.series[0].data = [300, 270, 340, 344, 300, 320, 310]
+						this.option2.series[0].data = this.echartData.orderList.map(item=>{return item.orderCount})
 						this.option2.series[0].label.normal.fontSize = 13 * this.rpxTopxScale
 						chart.setOption(this.option2);
 					});
@@ -226,37 +242,38 @@
 				if (this.$refs.chart3) {
 					this.$refs.chart3.init(echarts, async chart => {
 						// let echartData = await this.getEchartData()
-						this.option3.xAxis[0].data = ['04-04', '04-05', '04-06', '04-07', '04-08', '04-09',
-							'04-10'
-						]
+						this.option3.xAxis[0].data = this.echartData.profitList.map(item=>{return item.showTime})
 						this.option3.yAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
 						this.option3.xAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
-						this.option3.series[0].data = [300, 270, 340, 344, 300, 320, 310]
+						his.option3.series[0].data = this.echartData.profitList.map(item=>{return item.profit})
 						this.option3.series[0].label.normal.fontSize = 13 * this.rpxTopxScale
 						chart.setOption(this.option3);
 					});
 				}
-			}
+			},
+			async getStatisticData(){
+				await this.getBarEchartData()
+				this.init()
+			},
+			getBarEchartData() {
+				return new Promise((r, j) => {
+					let merchantId = this.merchantId?this.merchantId:''
+					let storeId = this.storeId?this.storeId:''
+					let pData = {
+						merchantId:merchantId,
+						storeId:storeId
+					}
+					req.getRequest('/admin/v2/statistic/histogram', pData, res => {
+						this.barEchartData = res
+						console.log('statistic chart', res)
+						r(res)
+					})
+				})
+			},
 		},
 		mounted() {
-			const systemInfo = uni.getSystemInfoSync();
-			// px转换到rpx的比例
-			let pxToRpxScale = 750 / systemInfo.windowWidth;
-			this.pxToRpxScale = pxToRpxScale
-			this.rpxTopxScale = systemInfo.windowWidth / 750
-			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>