item.js 11 KB

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