铝交易,微信公众号
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

319 lines
6.3 KiB

11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
1 year ago
11 months ago
10 months ago
11 months ago
1 year ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  1. <template>
  2. <view class="trading-platform">
  3. <topbar showRight="0"></topbar>
  4. <view class="frame">
  5. <!--顶部栏-->
  6. <!--折线图-->
  7. <div ref="chartContainer" class="chart" style="width: 100%; height: 300px;">
  8. </div>
  9. <!-- 供应商 -->
  10. <view v-if="userShop" class="supplier">
  11. <view class="purchaser-title" style="">
  12. <!-- <span class="active"> {{ $t('other.orderList') }}</span> -->
  13. <span v-for="(item, index) in type" :class="actionIndex == index ? 'active' : 'noactive'"
  14. @click="actionIndexChange(index)">{{ item.name }}</span>
  15. </view>
  16. <view class="supplierList">
  17. <orderList :list="list" />
  18. </view>
  19. </view>
  20. <!-- 采购商 -->
  21. <view v-else class="purchaser">
  22. <!--切换现货/期货-->
  23. <view class="purchaser-title" style="">
  24. <span v-for="(item, index) in type" :class="actionIndex == index ? 'active' : 'noactive'"
  25. @click="actionIndexChange(index)">{{ item.name }}</span>
  26. </view>
  27. <view class="productList">
  28. <productList :list="list" />
  29. </view>
  30. </view>
  31. </view>
  32. <tabber select="1" />
  33. </view>
  34. </template>
  35. <script>
  36. import tabber from '@/components/base/tabbar.vue'
  37. import topbar from "@/components/base/topbar.vue";
  38. import {
  39. mapGetters
  40. } from 'vuex'
  41. import ProductList from "@/components/user/productList.vue";
  42. import OrderList from "@/pages_order/components/order/orderList.vue";
  43. import mixinList from '@/mixins/list.js'
  44. import * as echarts from 'echarts';
  45. export default {
  46. mixins: [mixinList],
  47. components: {
  48. OrderList,
  49. ProductList,
  50. topbar,
  51. tabber,
  52. },
  53. computed: {
  54. ...mapGetters(['userShop']),
  55. },
  56. data() {
  57. return {
  58. actionIndex: 0,
  59. mixinsListApi: 'getMyProductlist',
  60. type: [
  61. {
  62. name: this.$t('other.spotTrading')
  63. },
  64. {
  65. name: this.$t('other.futuresTrading')
  66. },
  67. ],
  68. chartData: [
  69. // {date: "08/16", value: 10},
  70. // {date: "08/17", value: 15},
  71. // {date: "08/18", value: 45},
  72. // {date: "08/19", value: 20},
  73. // {date: "08/20", value: 18},
  74. // {date: "08/21", value: 10},
  75. // {date: "08/22", value: 15},
  76. // {date: "08/23", value: 25},
  77. // {date: "08/24", value: 35},
  78. // {date: "08/25", value: 30},
  79. // {date: "08/26", value: 25},
  80. // {date: "08/27", value: 25},
  81. ],
  82. unit: '元/吨',
  83. }
  84. },
  85. onLoad() {
  86. if (this.userShop) {
  87. // 现货/期货列表
  88. this.mixinsListApi = 'productList'
  89. } else {
  90. // 交易平台挂单列表
  91. this.mixinsListApi = 'productlist'
  92. }
  93. this.queryParams.productType = this.actionIndex
  94. },
  95. mounted() {
  96. // this.getAlPrice()
  97. // setTimeout(() => {
  98. // this.initChart();
  99. // })
  100. },
  101. onShow() {
  102. this.getAlPrice()
  103. },
  104. methods: {
  105. getAlPrice() {
  106. this.$api('getAlPrice', res => {
  107. this.unit = res.result.unit
  108. this.chartData = res.result.data
  109. this.initChart(res.result.data)
  110. })
  111. },
  112. initChart(data) {
  113. var that = this;
  114. const chartContainer = this.$refs.chartContainer;
  115. if (!chartContainer) {
  116. console.error("Chart container not found");
  117. return;
  118. }
  119. const myChart = echarts.init(chartContainer);
  120. // 提取日期和数值
  121. const dates = data.map(item => item.date).splice(0, 48);
  122. const values = data.map(item => item.value).splice(0, 48);
  123. // 计算铝均价
  124. let sum = 0
  125. values.forEach(n => {
  126. sum += parseFloat(n)
  127. })
  128. console.log(sum);
  129. // 配置 ECharts
  130. const option = {
  131. backgroundColor: '#1B263B',
  132. title: {
  133. text: `${'铝均价' + (sum / values.length).toFixed(4)}`,
  134. right: '10%',
  135. top: '10%',
  136. textStyle: {
  137. color: '#fff',
  138. fontSize: 14
  139. }
  140. },
  141. tooltip: {
  142. trigger: 'axis',
  143. formatter: '{c0}',
  144. backgroundColor: '#3A506B',
  145. textStyle: {
  146. color: '#fff'
  147. }
  148. },
  149. grid: {
  150. left: '10%',
  151. right: '10%',
  152. bottom: '20%'
  153. },
  154. xAxis: {
  155. type: 'category',
  156. data: dates,
  157. axisLine: {
  158. lineStyle: {
  159. color: '#fff'
  160. }
  161. },
  162. axisLabel: {
  163. color: '#fff'
  164. }
  165. },
  166. yAxis: {
  167. type: 'value',
  168. axisLine: {
  169. lineStyle: {
  170. color: '#fff'
  171. }
  172. },
  173. axisLabel: {
  174. color: '#fff',
  175. formatter: function(value) {
  176. return value;
  177. }
  178. }
  179. },
  180. series: [{
  181. name: '长江',
  182. type: 'line',
  183. data: values,
  184. smooth: true,
  185. symbol: 'circle',
  186. symbolSize: 8,
  187. itemStyle: {
  188. color: '#4ECDC4'
  189. },
  190. lineStyle: {
  191. color: '#4ECDC4',
  192. width: 2
  193. },
  194. areaStyle: {
  195. color: 'rgba(78, 205, 196, 0.2)'
  196. },
  197. }]
  198. };
  199. myChart.setOption(option);
  200. },
  201. // 切换tab
  202. actionIndexChange(index) {
  203. // index为0时切换到现货交易,index为1时切换到期货交易
  204. this.actionIndex = index;
  205. this.queryParams.productType = this.actionIndex
  206. this.getData()
  207. },
  208. }
  209. }
  210. </script>
  211. <style scoped lang="scss">
  212. .trading-platform {
  213. background-image: url('../../static/image/index/1.png');
  214. padding-bottom: 100rpx;
  215. .frame {
  216. display: flex;
  217. flex-direction: column;
  218. justify-content: center;
  219. // height: calc(100vh - 120rpx - 120rpx);
  220. .chart {
  221. // height: 300px !important;
  222. background-color: #1B263B;
  223. /* 背景颜色 */
  224. }
  225. .supplier {
  226. // height: 70%;
  227. padding: 20rpx 20rpx;
  228. background-image: url('../../static/image/index/1.png');
  229. color: #FFF;
  230. font-size: 32rpx;
  231. .supplierList {
  232. margin-top: 20rpx;
  233. // height: 92%;
  234. overflow: auto;
  235. }
  236. .purchaser-title {
  237. // height: 8%;
  238. .active {
  239. text-decoration: underline;
  240. width: 80rpx;
  241. margin: 20rpx 20rpx 20rpx 20rpx;
  242. padding: 10rpx 20rpx;
  243. }
  244. .noactive {
  245. width: 80rpx;
  246. margin: 20rpx 20rpx 20rpx 20rpx;
  247. padding: 10rpx 20rpx;
  248. }
  249. }
  250. }
  251. .purchaser {
  252. // height: 60%;
  253. padding: 20rpx 0;
  254. color: #FFF;
  255. font-size: 32rpx;
  256. .purchaser-title {
  257. .active {
  258. text-decoration: underline;
  259. width: 80rpx;
  260. margin: 20rpx 20rpx 20rpx 20rpx;
  261. padding: 10rpx 20rpx;
  262. }
  263. .noactive {
  264. width: 80rpx;
  265. margin: 20rpx 20rpx 20rpx 20rpx;
  266. padding: 10rpx 20rpx;
  267. }
  268. }
  269. .productList {
  270. margin-top: 20rpx;
  271. // height: 60vh;
  272. overflow: auto;
  273. }
  274. }
  275. }
  276. }
  277. </style>