Ver código fonte

优化图表

吴洪双 6 anos atrás
pai
commit
34002e2c4f
5 arquivos alterados com 51 adições e 40 exclusões
  1. 2 1
      configs/env.js
  2. 5 2
      manifest.json
  3. 6 0
      pages.json
  4. 17 14
      pages/Charts/mainStatistics.vue
  5. 21 23
      pages/User/merchantList.vue

+ 2 - 1
configs/env.js

@@ -9,7 +9,8 @@ let configs = {
 if (process.env.NODE_ENV === 'development') {
 	// 测试环境
 	configs = Object.assign(configs, {
-		baseUrl: 'http://127.0.0.1:8090',
+		baseUrl: 'https://app.sunzee.com.cn/ShenzeeServer',
+		// baseUrl: 'http://127.0.0.1:8090',
 	});
 }
 

+ 5 - 2
manifest.json

@@ -91,9 +91,12 @@
     "quickapp" : {},
     /* 小程序特有相关 */
     "mp-weixin" : {
-        "appid" : "",
+        "appid" : "wx53ee7fff5fbf546d",
         "setting" : {
-            "urlCheck" : false
+            "urlCheck" : true,
+            "es6" : true,
+            "postcss" : true,
+            "minified" : false
         },
         "usingComponents" : true
     },

+ 6 - 0
pages.json

@@ -36,6 +36,12 @@
 		    "style" : {
 				"navigationBarTitleText":"我的"
 			}
+		},
+		{
+			"path": "pages/Charts/elseStatistics",
+			"style": {
+				"navigationBarTitleText": "统计图表"
+			}
 		}
     ],
 	"globalStyle": {

+ 17 - 14
pages/Charts/mainStatistics.vue

@@ -101,24 +101,27 @@
 		computed: {
 			...mapState(['loginUser']),
 		},
-		onLoad(state){
+		onLoad(option){
 			this.init();
 		},
 		mounted() {
+			this.init();
 		},
 		methods: {
 			...mapActions('chart', ['getStatistics','getMainStatistics']),
-			init(){
+			async init(){
+				console.log("adminId:" + this.adminId)
+				console.log("equipmentId:" + this.equipmentId)
 				_self = this;
 				this.cWidth = uni.upx2px(750);
 				this.cHeight = uni.upx2px(500);
 				
-				this.getMainStatisticsData();
+				await this.getMainStatisticsData();
 				
-				this.initDateRang(new Date(),'day');
-				this.initDateRang(new Date(),'week');
-				this.initDateRang(new Date(),'month');
-				this.initDateRang(new Date(),'year');
+				await this.initDateRang(new Date(),'day');
+				await this.initDateRang(new Date(),'week');
+				await this.initDateRang(new Date(),'month');
+				await this.initDateRang(new Date(),'year');
 			},
 			initDateRang(day,chartType) {
 				const daystr = dateUtils.formateDate(day, 'yyyy/MM/dd');
@@ -138,7 +141,7 @@
 					this.endDate4 = dateUtils.formateDate(dateUtils.getCurrentYearLastDate(day), 'yyyy/MM/dd');
 				}
 				
-				this.getStatisticsData(chartType);
+				return this.getStatisticsData(chartType);
 			},
 			/**上一个 */
 			pre(chartType) {
@@ -211,8 +214,8 @@
 				if (this.equipmentId) {
 					param['equipmentId'] = this.equipmentId;
 				}
-				setTimeout(() => {
-					this.getStatistics(param)
+				// setTimeout(() => {
+				return this.getStatistics(param)
 						.then(data => {
 								uni.stopPullDownRefresh();
 								if(param['chartType']=='day'){
@@ -244,7 +247,7 @@
 								}
 							}
 						);
-				}, 0);
+				// }, 0);
 			},
 			initChart(canvasId, chartData){
 				return new uCharts({
@@ -284,7 +287,7 @@
 				});
 			},
 			getMainStatisticsData(){
-				setTimeout(() => {
+				// setTimeout(() => {
 					const param = {};
 					if(this.adminId){ // 子组件,则拿传过来的参
 						param['adminId'] = this.adminId;
@@ -295,7 +298,7 @@
 						param['equipmentId'] = this.equipmentId;
 					}
 					console.log('getMainStatisticsData:{}',param)
-					this.getMainStatistics(param)
+					return this.getMainStatistics(param)
 						.then(data => {
 							for (let bean of data) {
 								if(bean['categorie']==='day'){
@@ -314,7 +317,7 @@
 							uni.stopPullDownRefresh();
 						}
 						, _ => void uni.stopPullDownRefresh());
-				}, 0);
+				// }, 0);
 			},
 			touchLine1(e) {
 				if(canvaColumn1){

+ 21 - 23
pages/User/merchantList.vue

@@ -7,14 +7,12 @@
 						<view v-if="merchant.equipmentList.length==0" style="text-align: center;">暂无数据</view>
 						<view v-if="merchant.equipmentList.length>0">
 							<uni-collapse :accordion="true">
-								<uni-collapse-item title="总销售情况" @open="open">
-									<mainStatistics :adminId="merchant.id" style="padding: 20upx;"></mainStatistics>
-								</uni-collapse-item>
-								<view v-for="equipment in merchant.equipmentList" :key="equipment.id">
-									<uni-collapse-item :title="getEquipmentTitle(equipment)" @open="open">
-										<mainStatistics :equipmentId="equipment.id" style="padding: 20upx;"></mainStatistics>
-									</uni-collapse-item>
-								</view>
+								<uni-list>
+									<uni-list-item title="总销售情况" @click="openByAdmin(merchant.id)"/>
+									<view  v-for="equipment in merchant.equipmentList" :key="equipment.id">
+										<uni-list-item :title="getEquipmentTitle(equipment)" @click="openByEquipment(equipment.id)"/>
+									</view>
+								</uni-list>
 							</uni-collapse>	
 						</view>
 					</view>
@@ -25,14 +23,12 @@
 	<view v-else>
 		<view v-if="merchantList[0].equipmentList.length>1">
 			<uni-collapse :accordion="true">
-				<uni-collapse-item title="总销售情况" @open="open">
-					<mainStatistics :adminId="merchantList[0].id" style="padding: 20upx;"></mainStatistics>
-				</uni-collapse-item>
-				<view v-for="equipment in merchantList[0].equipmentList" :key="equipment.id">
-					<uni-collapse-item :title="getEquipmentTitle(equipment)" @open="open">
-						<mainStatistics :equipmentId="equipment.id" style="padding: 20upx;"></mainStatistics>
-					</uni-collapse-item>
-				</view>
+				<uni-list>
+					<uni-list-item title="总销售情况" @click="openByAdmin(merchantList[0].id)"/>
+					<view  v-for="equipment in merchantList[0].equipmentList" :key="equipment.id">
+						<uni-list-item :title="getEquipmentTitle(equipment)" @click="openByEquipment(equipment.id)"/>
+					</view>
+				</uni-list>
 			</uni-collapse>	
 		</view>
 		<view v-else style="text-align: center;">暂无数据</view>
@@ -74,13 +70,15 @@
 		},
 		methods: {
 			...mapActions('chart', ['getEquipmentListByUser']),
-			open(e){
-				for (let component of e.$children) {
-					if(component.$options.name=='mainStatistics'){
-						component.init();
-						return;
-					}
-				}
+			openByAdmin(adminId){
+				uni.navigateTo({
+					url: '/pages/Charts/elseStatistics?adminId=' + adminId,
+				});
+			},
+			openByEquipment(equipmentId){
+				uni.navigateTo({
+					url: '/pages/Charts/elseStatistics?equipmentId=' + equipmentId,
+				});
 			},
 			getMerchantTitle(merchant){
 				return merchant.name?merchant.name:merchant.username;