Blame view

lvdao-miniapp/pages/salesReporting/salesReporting.vue 5.6 KB
3f535f30   杨鑫   '初始'
1
2
3
  <template>
  	<view class="zhuti">
  		<view class="futi">
e5b57447   杨鑫   '分包问卷'
4
5
6
7
8
9
10
11
12
  			<!-- <view class="saleTian" @click="toSaleReport">上报线下销售数据</view> -->
  			<view class="" style="width: 96%;margin: 0 auto;background-color: #fff;border-radius: 20rpx;">
  				<view class="" style="width: 96%;margin: 0 auto;padding: 20rpx 20rpx;">
  					<view style="font-weight: bold;font-size: 28rpx;">线下销售数据</view>
  					<view class="cardMu">
  						<view class="cardOne">
  							<view class="title" style="font-size: 26rpx;">
  								今日销售金额
  							</view>
f0e7afbf   杨鑫   '最新'
13
14
  							<view class="num">{{todayRe}}</view>
  							<view>同比昨日<span>{{subtract}}</span></view>
e5b57447   杨鑫   '分包问卷'
15
16
17
18
19
20
21
22
  						</view>
  						<!-- <view class="cardOne">
  							<view class="title">
  								今日销售金额
  							</view>
  							<view class="num">10</view>
  							<view>同比昨日上升1</view>
  						</view> -->
3f535f30   杨鑫   '初始'
23
  					</view>
3f535f30   杨鑫   '初始'
24
  				</view>
e5b57447   杨鑫   '分包问卷'
25
26
27
  			</view>
  			<view class="" style="width: 96%;margin: 0 auto;background-color: #fff;border-radius: 20rpx;margin-top: 20rpx;">
  				<view class="" style="width: 96%;margin: 0 auto;padding: 20rpx 20rpx;">
f0e7afbf   杨鑫   '最新'
28
  					<view style="font-weight: bold;font-size: 28rpx;">营业额趋势(周)</view>
e5b57447   杨鑫   '分包问卷'
29
30
  					<view style="height: 300px;width: 100%;margin-top: 20rpx;">
  						<qiun-data-charts type="line" :opts="opts" :chartData="chartData" />
3f535f30   杨鑫   '初始'
31
  					</view>
3f535f30   杨鑫   '初始'
32
33
  				</view>
  			</view>
e5b57447   杨鑫   '分包问卷'
34
35
36
37
38
39
40
41
  			
  			<view class="" style="width: 96%;margin: 0 auto;background-color: #fff;border-radius: 20rpx;margin-top: 20rpx;">
  				<view class="" style="width: 96%;margin: 0 auto;padding: 20rpx 20rpx;">
  					<view style="font-weight: bold;font-size: 28rpx;">销量排名</view>
  					<view style="height: 300px;width: 100%;margin-top: 20rpx;">
  						<qiun-data-charts type="bar" :opts="opts1" :chartData="chartData1" />
  					</view>
  				</view>
3f535f30   杨鑫   '初始'
42
  			</view>
e5b57447   杨鑫   '分包问卷'
43
  			
3f535f30   杨鑫   '初始'
44
45
46
47
48
  		</view>
  	</view>
  </template>
  
  <script>
3f535f30   杨鑫   '初始'
49
50
51
  	export default {
  		data() {
  			return {
e5b57447   杨鑫   '分包问卷'
52
53
  				chart: null,
  				chartData: {},
f0e7afbf   杨鑫   '最新'
54
55
  				todayRe:0,
  				subtract:0,
e5b57447   杨鑫   '分包问卷'
56
  				opts: {
f0e7afbf   杨鑫   '最新'
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
  		     color: ["#3CA272"],
  		           padding: [15,10,0,15],
  		           enableScroll: false,
  		           legend: {},
  		           xAxis: {
  		             disableGrid: true,
  					  fontSize: 10, // 设置X轴字体大小
  		           },
  		           yAxis: {
  		             gridType: "dash",
  		             dashLength: 2
  		           },
  		           extra: {
  		             line: {
  		               type: "curve",
  		               width: 2,
  		               activeType: "hollow"
  		             }
  		           }
  		     
  	   },
e5b57447   杨鑫   '分包问卷'
78
79
  				chartData1: {},
  				opts1: {
f0e7afbf   杨鑫   '最新'
80
  					color: ["#3CA272"
e5b57447   杨鑫   '分包问卷'
81
82
83
84
85
86
87
88
89
  					],
  					padding: [15, 30, 0, 5],
  					enableScroll: false,
  					legend: {},
  					xAxis: {
  						boundaryGap: "justify",
  						disableGrid: false,
  						min: 0,
  						axisLine: false,
f0e7afbf   杨鑫   '最新'
90
91
92
93
94
  				AllyDecimals: false,
  
  					},
  					yAxis: {
  						
e5b57447   杨鑫   '分包问卷'
95
  					},
e5b57447   杨鑫   '分包问卷'
96
97
98
99
100
101
102
103
104
105
106
107
  					extra: {
  						bar: {
  							type: "stack",
  							width: 30,
  							meterBorde: 1,
  							meterFillColor: "#FFFFFF",
  							activeBgColor: "#000000",
  							activeBgOpacity: 0.08,
  							categoryGap: 2
  						}
  					}
  				}
3f535f30   杨鑫   '初始'
108
109
  			}
  		},
e5b57447   杨鑫   '分包问卷'
110
111
112
  		onReady() {
  			this.getServerData();
  		},
3f535f30   杨鑫   '初始'
113
  		mounted() {
e5b57447   杨鑫   '分包问卷'
114
  
3f535f30   杨鑫   '初始'
115
116
117
  		},
  		methods: {
  			getServerData() {
0fd8b750   杨鑫   '最新落地1'
118
119
  			 let ids = uni.getStorageSync('user').phone
  				this.$http.sendRequest(`/cereSalesReporting/salesStatistics/${ids}`, 'GET',{},1).then(res => {
f0e7afbf   杨鑫   '最新'
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
  				  this.subtract = res.data.data.subtract	
  				  this.todayRe = res.data.data.todayRe	
  				  let salesRankingCate = []
  				  let salesRankingSeries =[]
  				   res.data.data.salesRanking.map(item=>{
  					   salesRankingCate.push(item.productName)
  					   salesRankingSeries.push(item.salesQuantity)
  				   })
  				  let objList = {
  				  	categories:salesRankingCate,
  				  	series: [{
  				  			name: "数量",
  				  			data: salesRankingSeries,
  				  		}
  				  	]
  				  }
  				  
  				  let turnoverDetailSeries =[]
  				  let objMsg ={
  				  						  name:'销售额',
  				  						  data:[0,0,0,0,0,0,0]
  				  }
  				  res.data.data.sameDaySalesVOS.map(item=>{
  					
  					
  					if(this.getWeekday(item.saleTime) == '周一'){
  						objMsg.data[0] = item.price 
  					}else if(this.getWeekday(item.saleTime) == '周二'){
  						objMsg.data[1] = item.price 
  					}else if(this.getWeekday(item.saleTime) == '周三'){
  						objMsg.data[2] = item.price 
  					}else if(this.getWeekday(item.saleTime) == '周四'){
  						objMsg.data[3] = item.price 
  					}else if(this.getWeekday(item.saleTime) == '周五'){
  						objMsg.data[4] = item.price 
  					}else if(this.getWeekday(item.saleTime) == '周六'){
  						objMsg.data[5] = item.price 
  					}else if(this.getWeekday(item.saleTime) == '周天'){
  						objMsg.data[6] = item.price 
  					}
  				
  				  					   
  				  })
  				  turnoverDetailSeries.push(objMsg)
  				  this.chartData1 = JSON.parse(JSON.stringify(objList))
  				  let qushi = {
  				  	categories: ["周一", "周二", "周三", "周四", "周五", "周六","周天"],
  				  	series: turnoverDetailSeries
  				  }
  				  this.chartData = JSON.parse(JSON.stringify(qushi))
  				  
  				})
  		
  			
  			},
  			getWeekday(dateString) {
  			    // 解析日期字符串
  			    const date = new Date(dateString)
  			    
  			    // 检查日期是否有效
  			    if (isNaN(date)) {
  			        throw new Error('无效的日期格式。请使用 "YYYY-M-D" 或 "YYYY-MM-DD" 格式。')
  			    }
  			
  			    // 定义星期的中文表示
  			    const weekdays = ["周一", "周二", "周三", "周四", "周五", "周六","周天"]
  			
  			    // 获取星期几(0-6)
  			    const dayIndex = date.getDay()
  			
  			    return weekdays[dayIndex]
e5b57447   杨鑫   '分包问卷'
191
192
193
194
195
196
197
  			},
  			// 跳转到销售上报页面
  			toSaleReport(){
  				uni.navigateTo({
  					url:'/pages/saleReport/saleReport'
  				})
  			},
3f535f30   杨鑫   '初始'
198
199
200
201
202
203
204
  		}
  	}
  </script>
  
  <style lang="scss" scoped>
  	@import 'salesReporting.scss';
  </style>