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

303 lines
6.6 KiB

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