item.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  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: data.color
  120. }, {
  121. offset: 1,
  122. color: '#1C1C1C'
  123. }])
  124. },
  125. itemStyle: {
  126. normal: {
  127. lineStyle: {
  128. color: data.color
  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. color:""
  171. },
  172. chartDatas:{
  173. actual:[572,556,3555,4744,552,576,3555],
  174. prediction:[352,246,385,2424,542,546,255],
  175. timeData : [
  176. '2020/6/1', '2020/6/2', '2020/6/3', '2020/6/4', '2020/6/5', '2020/6/6', '2020/6/7'
  177. ],
  178. color:""
  179. },
  180. object:{
  181. title:"appl",
  182. Withtitle:"appl inc",
  183. Volume:"545455",
  184. float:"-5555",
  185. color:'crimson',
  186. },
  187. aa:[
  188. {
  189. id:'0',
  190. from:"Investing.com 中文",
  191. nickName:"买入波音(BA.US)好时机?两个问题没解决之前劝你住手",
  192. reward:"今年迄今,美股航空板块受到公共卫生事件的冲击.....",
  193. time:"6天前"
  194. },
  195. {
  196. id:'1',
  197. from:"chinese.aljazeera.net",
  198. nickName: "波音裁员超1.2万人与警惕最坏时刻尚未到来",
  199. reward: "波音公司当地时间27日宣布,将在美国裁减超1...",
  200. time:"6天前"
  201. },
  202. {
  203. id:'2',
  204. from:"Investing.com 中文",
  205. nickName: "美股异动|波音737MAX客机恢复生产,盘前涨逾5%",
  206. reward: "Reuters.美股异动|波音(BA.US)737MAX客...",
  207. time:"5天前"
  208. },
  209. {
  210. id:'3',
  211. from:"Investing.com 中文",
  212. nickName:"买入波音(BA.US)好时机?两个问题没解决之前劝你住手",
  213. reward:"今年迄今,美股航空板块受到公共卫生事件的冲击.....",
  214. time:"6天前"
  215. },
  216. {
  217. id:'4',
  218. from:"chinese.aljazeera.net",
  219. nickName: "波音裁员超1.2万人与警惕最坏时刻尚未到来",
  220. reward: "波音公司当地时间27日宣布,将在美国裁减超1...",
  221. time:"6天前"
  222. },
  223. {
  224. id:'5',
  225. from:"Investing.com 中文",
  226. nickName: "美股异动|波音737MAX客机恢复生产,盘前涨逾5%",
  227. reward: "Reuters.美股异动|波音(BA.US)737MAX客...",
  228. time:"5天前"
  229. },
  230. {
  231. id:'6',
  232. from:"Investing.com 中文",
  233. nickName:"买入波音(BA.US)好时机?两个问题没解决之前劝你住手",
  234. reward:"今年迄今,美股航空板块受到公共卫生事件的冲击.....",
  235. time:"6天前"
  236. },
  237. {
  238. id:'7',
  239. from:"chinese.aljazeera.net",
  240. nickName: "波音裁员超1.2万人与警惕最坏时刻尚未到来",
  241. reward: "波音公司当地时间27日宣布,将在美国裁减超1...",
  242. time:"6天前"
  243. },
  244. {
  245. id:'8',
  246. from:"Investing.com 中文",
  247. nickName: "美股异动|波音737MAX客机恢复生产,盘前涨逾5%",
  248. reward: "Reuters.美股异动|波音(BA.US)737MAX客...",
  249. time:"5天前"
  250. },
  251. {
  252. id:'9',
  253. from:"Investing.com 中文",
  254. nickName:"买入波音(BA.US)好时机?两个问题没解决之前劝你住手",
  255. reward:"今年迄今,美股航空板块受到公共卫生事件的冲击.....",
  256. time:"6天前"
  257. },
  258. {
  259. id:'10',
  260. from:"chinese.aljazeera.net",
  261. nickName: "波音裁员超1.2万人与警惕最坏时刻尚未到来",
  262. reward: "波音公司当地时间27日宣布,将在美国裁减超1...",
  263. time:"6天前"
  264. },
  265. {
  266. id:'11',
  267. from:"Investing.com 中文",
  268. nickName: "美股异动|波音737MAX客机恢复生产,盘前涨逾5%",
  269. reward: "Reuters.美股异动|波音(BA.US)737MAX客...",
  270. time:"5天前"
  271. },
  272. {
  273. id:'12',
  274. from:"Investing.com 中文",
  275. nickName:"买入波音(BA.US)好时机?两个问题没解决之前劝你住手",
  276. reward:"今年迄今,美股航空板块受到公共卫生事件的冲击.....",
  277. time:"6天前"
  278. },
  279. {
  280. id:'13',
  281. from:"chinese.aljazeera.net",
  282. nickName: "波音裁员超1.2万人与警惕最坏时刻尚未到来",
  283. reward: "波音公司当地时间27日宣布,将在美国裁减超1...",
  284. time:"6天前"
  285. },
  286. {
  287. id:'14',
  288. from:"Investing.com 中文",
  289. nickName: "美股异动|波音737MAX客机恢复生产,盘前涨逾5%",
  290. reward: "Reuters.美股异动|波音(BA.US)737MAX客...",
  291. time:"5天前"
  292. },
  293. ],
  294. },
  295. catchTouchMove:function(res){
  296. return false
  297. },
  298. // 滑动切换tab
  299. bindChange: function(e) {
  300. var that = this;
  301. that.setData({
  302. currentTab: e.detail.current
  303. });
  304. },
  305. //点击新闻
  306. onFold:function(e){
  307. console.log( e.currentTarget.dataset.id);
  308. wx.navigateTo({
  309. url:"../news/news"
  310. });
  311. },
  312. // 点击tab切换
  313. swichNav: function(e) {
  314. var that = this;
  315. if (this.data.currentTab === e.target.dataset.current) {
  316. return false;
  317. } else {
  318. that.setData({
  319. currentTab: e.target.dataset.current
  320. })
  321. }
  322. },
  323. /**
  324. * 生命周期函数--监听页面加载
  325. */
  326. onLoad: function (options) {
  327. console.log(JSON.parse(options.row))
  328. var title = "object.title"
  329. var Withtitle ="object.Withtitle"
  330. var Volume = "object.Volume"
  331. var float ="object.float"
  332. var color='object.color'
  333. var chartData="chartData.color"
  334. var chartDatas="chartDatas.color"
  335. this.setData({
  336. [title]:JSON.parse(options.row).title,
  337. [Withtitle]:JSON.parse(options.row).subtitle,
  338. [Volume]:JSON.parse(options.row).digital,
  339. [float]:JSON.parse(options.row).Increase,
  340. [color]:JSON.parse(options.row).color,
  341. [chartData]:JSON.parse(options.row).color,
  342. [chartDatas]:JSON.parse(options.row).color,
  343. button:JSON.parse(options.row).keep,
  344. })
  345. },
  346. /**
  347. * 生命周期函数--监听页面初次渲染完成
  348. */
  349. onReady: function () {
  350. },
  351. /**
  352. * 生命周期函数--监听页面显示
  353. */
  354. onShow: function () {
  355. },
  356. /**
  357. * 生命周期函数--监听页面隐藏
  358. */
  359. onHide: function () {
  360. },
  361. /**
  362. * 生命周期函数--监听页面卸载
  363. */
  364. onUnload: function () {
  365. },
  366. /**
  367. * 页面相关事件处理函数--监听用户下拉动作
  368. */
  369. onPullDownRefresh: function () {
  370. },
  371. /**
  372. * 页面上拉触底事件的处理函数
  373. */
  374. onReachBottom: function () {
  375. },
  376. /**
  377. * 用户点击右上角分享
  378. */
  379. onShareAppMessage: function () {
  380. }
  381. })