item.js 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. // pages/item/item.js
  2. import * as echarts from '../../ec-canvas/echarts';
  3. var timeData = [
  4. '2020/6/1', '2009/6/2', '2009/6/3', '2009/6/4', '2009/6/5', '2009/6/6', '2009/6/7', '2009/6/8', '2009/6/9', '2009/6/10',
  5. ];
  6. timeData = timeData.map(function (str) {
  7. return str.replace('2009/', '');
  8. });
  9. var app = getApp()
  10. function initChart(canvas, width, height, dpr, data) {
  11. const chart = echarts.init(canvas, null, {
  12. width: width,
  13. height: height,
  14. devicePixelRatio: dpr // new
  15. });
  16. canvas.setChart(chart);
  17. var option = {
  18. title: {//标题
  19. text: '',
  20. left: 'center'
  21. },
  22. renderAsImage: true, //支持渲染为图片模式
  23. color: ["#DF3E3E", "#80CDF8"],//图例图标颜色
  24. legend: {
  25. show: true,
  26. itemGap: 25,//每个图例间的间隔
  27. top: 30,
  28. x: 30,//水平安放位置,离容器左侧的距离 'left'
  29. z: 100,
  30. textStyle: {
  31. color: '#383838'
  32. },
  33. },
  34. grid: {//网格
  35. // left: 30,
  36. // top:100,
  37. containLabel: true,//grid 区域是否包含坐标轴的刻度标签
  38. },
  39. xAxis: {//横坐标
  40. type: 'category',
  41. // nameTextStyle: {//在name值存在下,设置name的样式
  42. // color: 'white',
  43. // fontStyle: 'normal'
  44. // },
  45. nameLocation:'end',
  46. splitLine: {//坐标轴在 grid 区域中的分隔线。
  47. show: true,
  48. lineStyle: {
  49. type: 'dashed',
  50. color: ['#2B2B2B']
  51. }
  52. },
  53. boundaryGap: false,//1.true 数据点在2个刻度直接 2.fals 数据点在分割线上,即刻度值上
  54. data: data.timeData,
  55. axisLine: {onZero: true},
  56. axisLabel: {
  57. textStyle: {
  58. fontSize: 13,
  59. color: '#5D5D5D'
  60. }
  61. }
  62. },
  63. dataZoom: [
  64. {
  65. type: 'slider',
  66. xAxisIndex: 0,
  67. filterMode: 'empty'
  68. },
  69. ],
  70. yAxis: {//纵坐标
  71. type: 'value',
  72. position:'right',
  73. // nameTextStyle:{//在name值存在下,设置name的样式
  74. // color:'red',
  75. // fontStyle:'normal'
  76. // },
  77. splitNumber: 5,//坐标轴的分割段数
  78. splitLine: {//坐标轴在 grid 区域中的分隔线。
  79. show: true,
  80. lineStyle: {
  81. type: 'dashed',
  82. color: ['#2B2B2B']
  83. }
  84. },
  85. axisLabel: {//坐标轴刻度标签
  86. // formatter: function (value) {
  87. // var xLable = [];
  88. // if (value == 20) {
  89. // xLable.push('25,883');
  90. // }
  91. // if (value == 40) {
  92. // xLable.push('26,035');
  93. // }
  94. // if (value == 60) {
  95. // xLable.push('26,187');
  96. // }
  97. // if (value == 80) {
  98. // xLable.push('26,339');
  99. // }
  100. // return xLable
  101. // },
  102. textStyle: {
  103. fontSize: 13,
  104. color: '#5D5D5D',
  105. }
  106. },
  107. // min: 0,
  108. // max: 100,
  109. },
  110. series: [{
  111. name: '实际',
  112. type: 'line',
  113. // smooth:true,
  114. data:data.actual,
  115. symbol: 'none',
  116. areaStyle: {
  117. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  118. offset: 0,
  119. color: '#DF3E3E'
  120. }, {
  121. offset: 1,
  122. color: '#1C1C1C'
  123. }])
  124. },
  125. itemStyle: {
  126. normal: {
  127. lineStyle: {
  128. color: '#DF3E3E'
  129. }
  130. }
  131. }
  132. }, {
  133. name: '预测',
  134. type: 'line',
  135. data: data.prediction,
  136. symbol: 'none',
  137. itemStyle: {
  138. normal: {
  139. lineStyle: {
  140. color: '#80CDF8'
  141. }
  142. }
  143. }
  144. }],
  145. };
  146. chart.setOption(option);
  147. return chart;
  148. }
  149. Page({
  150. /**
  151. * 页面的初始数据
  152. */
  153. data: {
  154. // 页面配置
  155. winWidth: 0,
  156. winHeight: 0,
  157. // tab切换
  158. currentTab: 0,
  159. button:"关注",
  160. ec: {
  161. onInit: initChart
  162. },
  163. chartData:{
  164. actual:[552,586,3555,4454,552,556,4455],
  165. prediction:[552,546,3585,4424,542,546,35,44,524,56,355,444,2224,421],
  166. timeData : [
  167. '2020/6/1', '2020/6/2', '2020/6/3', '2020/6/4', '2020/6/5', '2020/6/6', '2020/6/7', '2020/6/8', '2020/6/9', '2020/6/10','2020/6/11',
  168. '2020/6/12','2020/6/13','2020/6/14',
  169. ]
  170. },
  171. chartDatas:{
  172. actual:[572,556,3555,4744,552,576,3555],
  173. prediction:[352,246,385,2424,542,546,255],
  174. timeData : [
  175. '2020/6/1', '2020/6/2', '2020/6/3', '2020/6/4', '2020/6/5', '2020/6/6', '2020/6/7'
  176. ]
  177. },
  178. object:{
  179. title:"appl",
  180. Withtitle:"appl inc",
  181. Volume:"545455",
  182. float:"-5555"
  183. },
  184. aa:[
  185. {
  186. id:'0',
  187. from:"Investing.com 中文",
  188. nickName:"买入波音(BA.US)好时机?两个问题没解决之前劝你住手",
  189. reward:"今年迄今,美股航空板块受到公共卫生事件的冲击.....",
  190. time:"6天前"
  191. },
  192. {
  193. id:'1',
  194. from:"chinese.aljazeera.net",
  195. nickName: "波音裁员超1.2万人与警惕最坏时刻尚未到来",
  196. reward: "波音公司当地时间27日宣布,将在美国裁减超1...",
  197. time:"6天前"
  198. },
  199. {
  200. id:'2',
  201. from:"Investing.com 中文",
  202. nickName: "美股异动|波音737MAX客机恢复生产,盘前涨逾5%",
  203. reward: "Reuters.美股异动|波音(BA.US)737MAX客...",
  204. time:"5天前"
  205. },
  206. {
  207. id:'3',
  208. from:"Investing.com 中文",
  209. nickName:"买入波音(BA.US)好时机?两个问题没解决之前劝你住手",
  210. reward:"今年迄今,美股航空板块受到公共卫生事件的冲击.....",
  211. time:"6天前"
  212. },
  213. {
  214. id:'4',
  215. from:"chinese.aljazeera.net",
  216. nickName: "波音裁员超1.2万人与警惕最坏时刻尚未到来",
  217. reward: "波音公司当地时间27日宣布,将在美国裁减超1...",
  218. time:"6天前"
  219. },
  220. {
  221. id:'5',
  222. from:"Investing.com 中文",
  223. nickName: "美股异动|波音737MAX客机恢复生产,盘前涨逾5%",
  224. reward: "Reuters.美股异动|波音(BA.US)737MAX客...",
  225. time:"5天前"
  226. },
  227. {
  228. id:'6',
  229. from:"Investing.com 中文",
  230. nickName:"买入波音(BA.US)好时机?两个问题没解决之前劝你住手",
  231. reward:"今年迄今,美股航空板块受到公共卫生事件的冲击.....",
  232. time:"6天前"
  233. },
  234. {
  235. id:'7',
  236. from:"chinese.aljazeera.net",
  237. nickName: "波音裁员超1.2万人与警惕最坏时刻尚未到来",
  238. reward: "波音公司当地时间27日宣布,将在美国裁减超1...",
  239. time:"6天前"
  240. },
  241. {
  242. id:'8',
  243. from:"Investing.com 中文",
  244. nickName: "美股异动|波音737MAX客机恢复生产,盘前涨逾5%",
  245. reward: "Reuters.美股异动|波音(BA.US)737MAX客...",
  246. time:"5天前"
  247. },
  248. {
  249. id:'9',
  250. from:"Investing.com 中文",
  251. nickName:"买入波音(BA.US)好时机?两个问题没解决之前劝你住手",
  252. reward:"今年迄今,美股航空板块受到公共卫生事件的冲击.....",
  253. time:"6天前"
  254. },
  255. {
  256. id:'10',
  257. from:"chinese.aljazeera.net",
  258. nickName: "波音裁员超1.2万人与警惕最坏时刻尚未到来",
  259. reward: "波音公司当地时间27日宣布,将在美国裁减超1...",
  260. time:"6天前"
  261. },
  262. {
  263. id:'11',
  264. from:"Investing.com 中文",
  265. nickName: "美股异动|波音737MAX客机恢复生产,盘前涨逾5%",
  266. reward: "Reuters.美股异动|波音(BA.US)737MAX客...",
  267. time:"5天前"
  268. },
  269. {
  270. id:'12',
  271. from:"Investing.com 中文",
  272. nickName:"买入波音(BA.US)好时机?两个问题没解决之前劝你住手",
  273. reward:"今年迄今,美股航空板块受到公共卫生事件的冲击.....",
  274. time:"6天前"
  275. },
  276. {
  277. id:'13',
  278. from:"chinese.aljazeera.net",
  279. nickName: "波音裁员超1.2万人与警惕最坏时刻尚未到来",
  280. reward: "波音公司当地时间27日宣布,将在美国裁减超1...",
  281. time:"6天前"
  282. },
  283. {
  284. id:'14',
  285. from:"Investing.com 中文",
  286. nickName: "美股异动|波音737MAX客机恢复生产,盘前涨逾5%",
  287. reward: "Reuters.美股异动|波音(BA.US)737MAX客...",
  288. time:"5天前"
  289. },
  290. ],
  291. },
  292. catchTouchMove:function(res){
  293. return false
  294. },
  295. // 滑动切换tab
  296. bindChange: function(e) {
  297. var that = this;
  298. that.setData({
  299. currentTab: e.detail.current
  300. });
  301. },
  302. //点击新闻
  303. onFold:function(e){
  304. console.log( e.currentTarget.dataset.id);
  305. wx.navigateTo({
  306. url:"../news/news"
  307. });
  308. },
  309. // 点击tab切换
  310. swichNav: function(e) {
  311. var that = this;
  312. if (this.data.currentTab === e.target.dataset.current) {
  313. return false;
  314. } else {
  315. that.setData({
  316. currentTab: e.target.dataset.current
  317. })
  318. }
  319. },
  320. /**
  321. * 生命周期函数--监听页面加载
  322. */
  323. onLoad: function (options) {
  324. },
  325. /**
  326. * 生命周期函数--监听页面初次渲染完成
  327. */
  328. onReady: function () {
  329. },
  330. /**
  331. * 生命周期函数--监听页面显示
  332. */
  333. onShow: function () {
  334. },
  335. /**
  336. * 生命周期函数--监听页面隐藏
  337. */
  338. onHide: function () {
  339. },
  340. /**
  341. * 生命周期函数--监听页面卸载
  342. */
  343. onUnload: function () {
  344. },
  345. /**
  346. * 页面相关事件处理函数--监听用户下拉动作
  347. */
  348. onPullDownRefresh: function () {
  349. },
  350. /**
  351. * 页面上拉触底事件的处理函数
  352. */
  353. onReachBottom: function () {
  354. },
  355. /**
  356. * 用户点击右上角分享
  357. */
  358. onShareAppMessage: function () {
  359. }
  360. })