|
|
@@ -1,6 +1,7 @@
|
|
1
|
1
|
<template>
|
|
2
|
2
|
<view>
|
|
3
|
3
|
<u-modal :show="showModal" ref="uModal" :title="(editOrAdd === 'add' || editOrAdd === 'receptFormAdd') ? '新增' : '编辑'" :asyncClose="false" showCancelButton @cancel="closeDialog" cancelColor="#909399" :confirmText="'确定'" confirmColor="#2979ff" @confirm="confirm" @close="closeDialog" :closeOnClickOverlay="false">
|
|
|
4
|
+ <u--text type="info" text="输入型号可查看价格趋势"></u--text>
|
|
4
|
5
|
<view class="modal_wrap">
|
|
5
|
6
|
<text @click="handleBrandClick" class="item" :class="info.dictLabel ? 'brand' : 'brand placeholder'">{{ info.dictLabel || '品牌' }}</text>
|
|
6
|
7
|
<text class="divider">|</text>
|
|
|
@@ -19,8 +20,10 @@
|
|
19
|
20
|
</view>
|
|
20
|
21
|
<u--input v-if="editOrAdd === 'edit'" class="price" placeholder="价格" border="bottom" v-model="info.price" clearable></u--input>
|
|
21
|
22
|
<view class="charts_box" v-show="chartShow">
|
|
22
|
|
- <qiun-data-charts type="line" :chartData="chartData" canvasId="trendChart" :opts="opts" :ontouch="true"
|
|
23
|
|
- width="700rpx" height="200rpx" backgroundColor="#ffffff" />
|
|
|
23
|
+ <u--text type="primary" :text="`最大价格:${Math.max(...maxPrice)}元`"></u--text>
|
|
|
24
|
+ <u--text type="warning" :text="`最小价格:${Math.min(...minPrice)}元`"></u--text>
|
|
|
25
|
+ <qiun-data-charts type="line" :chartData="chartData" canvasId="trendChart" :opts="opts" :ontouch="true" tooltipFormat="tooltipFormatPrice"
|
|
|
26
|
+ width="700rpx" height="500rpx" backgroundColor="#ffffff" />
|
|
24
|
27
|
</view>
|
|
25
|
28
|
</u-modal>
|
|
26
|
29
|
<brandList ref="brandListRef" @selectedBrand="handleSelectedBrand"></brandList>
|
|
|
@@ -77,15 +80,14 @@ export default {
|
|
77
|
80
|
]
|
|
78
|
81
|
},
|
|
79
|
82
|
chartData:{},
|
|
|
83
|
+ color:[],
|
|
80
|
84
|
opts: {
|
|
81
|
|
- color: ["#f9ae3d"],
|
|
82
|
|
- padding: [10, 10, 0, 0],
|
|
83
|
|
- dataLabel: false,
|
|
84
|
|
- dataPointShape: false,
|
|
|
85
|
+ color: this.color,
|
|
|
86
|
+ padding: [20, 10, 20, 0],
|
|
|
87
|
+ dataLabel: true,
|
|
|
88
|
+ dataPointShape: true,
|
|
85
|
89
|
enableScroll: true,
|
|
86
|
|
- legend: {
|
|
87
|
|
- show: false
|
|
88
|
|
- },
|
|
|
90
|
+
|
|
89
|
91
|
xAxis: {
|
|
90
|
92
|
disableGrid: true,
|
|
91
|
93
|
scrollShow: true,
|
|
|
@@ -97,6 +99,20 @@ export default {
|
|
97
|
99
|
gridType: "dash",
|
|
98
|
100
|
dashLength: 7,
|
|
99
|
101
|
},
|
|
|
102
|
+ legend: {
|
|
|
103
|
+ show: false,
|
|
|
104
|
+ type: 'scroll',
|
|
|
105
|
+ orient: 'horizontal',
|
|
|
106
|
+ pageSize: 3,
|
|
|
107
|
+ pageIconSize: 12,
|
|
|
108
|
+ pageIconColor: '#666',
|
|
|
109
|
+ pageIconInactiveColor: '#ccc',
|
|
|
110
|
+ pageTextStyle: {
|
|
|
111
|
+ color: '#666',
|
|
|
112
|
+ fontSize: 12
|
|
|
113
|
+ },
|
|
|
114
|
+ bottom: 0
|
|
|
115
|
+ },
|
|
100
|
116
|
extra: {
|
|
101
|
117
|
line: {
|
|
102
|
118
|
type: "curve",
|
|
|
@@ -105,10 +121,16 @@ export default {
|
|
105
|
121
|
linearType: "custom",
|
|
106
|
122
|
onShadow: true,
|
|
107
|
123
|
animation: "horizontal"
|
|
|
124
|
+ },
|
|
|
125
|
+ tooltip:{
|
|
|
126
|
+ legendShow: true,
|
|
|
127
|
+ bgOpacity: 0.6
|
|
108
|
128
|
}
|
|
109
|
129
|
}
|
|
110
|
130
|
},
|
|
111
|
|
- chartShow: false
|
|
|
131
|
+ chartShow: false,
|
|
|
132
|
+ maxPrice: [],
|
|
|
133
|
+ minPrice: [],
|
|
112
|
134
|
}
|
|
113
|
135
|
},
|
|
114
|
136
|
watch: {
|
|
|
@@ -120,6 +142,125 @@ export default {
|
|
120
|
142
|
}
|
|
121
|
143
|
},
|
|
122
|
144
|
methods: {
|
|
|
145
|
+ getChartData() {
|
|
|
146
|
+ uni.$u.api.inquiryChart({
|
|
|
147
|
+ model: this.info.model,
|
|
|
148
|
+ }).then(res => {
|
|
|
149
|
+ if (res.code == 200) {
|
|
|
150
|
+ const response = res.data
|
|
|
151
|
+ this.maxPrice = []
|
|
|
152
|
+ this.minPrice = []
|
|
|
153
|
+ // const response = [
|
|
|
154
|
+ // {
|
|
|
155
|
+ // model:'AAA',
|
|
|
156
|
+ // list:[
|
|
|
157
|
+ // {
|
|
|
158
|
+ // recycleTime: '2023-07-30',
|
|
|
159
|
+ // price: 300,
|
|
|
160
|
+ // },
|
|
|
161
|
+ // {
|
|
|
162
|
+ // recycleTime: '2023-07-31',
|
|
|
163
|
+ // price: 500,
|
|
|
164
|
+ // },
|
|
|
165
|
+ // {
|
|
|
166
|
+ // recycleTime: '2023-08-01',
|
|
|
167
|
+ // price: null,
|
|
|
168
|
+ // },
|
|
|
169
|
+ // {
|
|
|
170
|
+ // recycleTime: '2023-08-02',
|
|
|
171
|
+ // price: 200,
|
|
|
172
|
+ // },
|
|
|
173
|
+ // {
|
|
|
174
|
+ // recycleTime: '2023-08-03',
|
|
|
175
|
+ // price: 300,
|
|
|
176
|
+ // }
|
|
|
177
|
+ // ]
|
|
|
178
|
+ // },
|
|
|
179
|
+ // {
|
|
|
180
|
+ // model:'BBB',
|
|
|
181
|
+ // list:[
|
|
|
182
|
+ // {
|
|
|
183
|
+ // recycleTime: '2023-08-01',
|
|
|
184
|
+ // price:400,
|
|
|
185
|
+ // },
|
|
|
186
|
+ // {
|
|
|
187
|
+ // recycleTime: '2023-08-02',
|
|
|
188
|
+ // price: 100,
|
|
|
189
|
+ // },
|
|
|
190
|
+ // {
|
|
|
191
|
+ // recycleTime: '2023-08-03',
|
|
|
192
|
+ // price: 200,
|
|
|
193
|
+ // }
|
|
|
194
|
+ // ]
|
|
|
195
|
+ // },
|
|
|
196
|
+ // {
|
|
|
197
|
+ // model:'CCC',
|
|
|
198
|
+ // list:[
|
|
|
199
|
+ // {
|
|
|
200
|
+ // recycleTime: '2023-08-01',
|
|
|
201
|
+ // price: 500,
|
|
|
202
|
+ // },
|
|
|
203
|
+ // {
|
|
|
204
|
+ // recycleTime: '2023-08-02',
|
|
|
205
|
+ // price: 400,
|
|
|
206
|
+ // },
|
|
|
207
|
+ // {
|
|
|
208
|
+ // recycleTime: '2023-08-03',
|
|
|
209
|
+ // price: 600,
|
|
|
210
|
+ // }
|
|
|
211
|
+ // ]
|
|
|
212
|
+ // }
|
|
|
213
|
+ // ]
|
|
|
214
|
+ this.color = []
|
|
|
215
|
+ const categories = []
|
|
|
216
|
+ const dateMap = {}
|
|
|
217
|
+ response.forEach(item => {
|
|
|
218
|
+ this.maxPrice.push(item.max)
|
|
|
219
|
+ this.minPrice.push(item.min)
|
|
|
220
|
+ item.list.forEach(i => {
|
|
|
221
|
+ if (!dateMap[i.recycleTime]) {
|
|
|
222
|
+ dateMap[i.recycleTime] = true
|
|
|
223
|
+ categories.push(i.recycleTime)
|
|
|
224
|
+ }
|
|
|
225
|
+ })
|
|
|
226
|
+ })
|
|
|
227
|
+ const series = response.map((item) => {
|
|
|
228
|
+ const color = this.getRandomColor()
|
|
|
229
|
+ this.color.push(color)
|
|
|
230
|
+ const data = categories.map(date => {
|
|
|
231
|
+ const itemData = item.list.find(i => i.recycleTime === date)
|
|
|
232
|
+ return itemData ? itemData.price : null
|
|
|
233
|
+ })
|
|
|
234
|
+ return {
|
|
|
235
|
+ name: item.model,
|
|
|
236
|
+ data: data,
|
|
|
237
|
+ setShadow: [
|
|
|
238
|
+ 3,
|
|
|
239
|
+ 8,
|
|
|
240
|
+ 15,
|
|
|
241
|
+ color
|
|
|
242
|
+ ],
|
|
|
243
|
+ }
|
|
|
244
|
+ })
|
|
|
245
|
+ this.opts.color = this.color
|
|
|
246
|
+ const chartData = {
|
|
|
247
|
+ categories: categories,
|
|
|
248
|
+ series: series
|
|
|
249
|
+ }
|
|
|
250
|
+ this.chartData = JSON.parse(JSON.stringify(chartData))
|
|
|
251
|
+ this.chartShow = true
|
|
|
252
|
+ }
|
|
|
253
|
+ })
|
|
|
254
|
+
|
|
|
255
|
+ },
|
|
|
256
|
+ getRandomColor(){
|
|
|
257
|
+ var letters = '0123456789ABCDEF';
|
|
|
258
|
+ var color = '#';
|
|
|
259
|
+ for (var i = 0; i < 6; i++) {
|
|
|
260
|
+ color += letters[Math.floor(Math.random() * 16)];
|
|
|
261
|
+ }
|
|
|
262
|
+ return color;
|
|
|
263
|
+ },
|
|
123
|
264
|
// 编辑回显
|
|
124
|
265
|
initData() {
|
|
125
|
266
|
this.$nextTick(()=>{
|
|
|
@@ -241,33 +382,6 @@ export default {
|
|
241
|
382
|
this.getChartData()
|
|
242
|
383
|
}
|
|
243
|
384
|
},
|
|
244
|
|
- getChartData() {
|
|
245
|
|
- uni.$u.api.inquiryChart({
|
|
246
|
|
- model: this.info.model,
|
|
247
|
|
- }).then(res => {
|
|
248
|
|
- if (res.code == 200) {
|
|
249
|
|
- const reverseData = res.data.reverse()
|
|
250
|
|
- let data = {
|
|
251
|
|
- categories: reverseData.map(item=>item.recycleTime),
|
|
252
|
|
- series: [
|
|
253
|
|
- {
|
|
254
|
|
- name: this.info.model+'价格',
|
|
255
|
|
- data: reverseData.map(item=>item.price),
|
|
256
|
|
- setShadow: [
|
|
257
|
|
- 3,
|
|
258
|
|
- 8,
|
|
259
|
|
- 15,
|
|
260
|
|
- "#f9ae3d"
|
|
261
|
|
- ],
|
|
262
|
|
- }
|
|
263
|
|
- ]
|
|
264
|
|
- }
|
|
265
|
|
- this.chartData = JSON.parse(JSON.stringify(data))
|
|
266
|
|
- this.chartShow = true
|
|
267
|
|
- }
|
|
268
|
|
- })
|
|
269
|
|
-
|
|
270
|
|
- },
|
|
271
|
385
|
}
|
|
272
|
386
|
};
|
|
273
|
387
|
</script>
|