铝交易,微信公众号
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.

316 lines
6.1 KiB

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