dashboard.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. jqMultipleShow("click", ".navList", ".tab", ".con");
  2. var isPC = ($(window).width()>768);
  3. var dashboard = new Vue({
  4. el:'#dashboard',
  5. data:{
  6. isRequset:true,
  7. userId:'',
  8. homeData:'',
  9. formData:new FormData(),
  10. goodImage:'',
  11. shopinfo:{},
  12. promotions:{},
  13. rankingList:[],
  14. titleSshow:false,
  15. msgFlag:false,
  16. isShow:false,
  17. orderNumData:[],//统计订单金额
  18. paytotalfeeData:[]//统计订单数量
  19. },
  20. methods: {
  21. dashboardDataInfo:function(){
  22. var _this = this;
  23. SupplierApi.homePageData({userId:_this.userId},function (res) {
  24. if(res.code==0){
  25. _this.isRequset = false;
  26. _this.homeData = res.data;
  27. _this.goodImage = _this.homeData.user.image;
  28. _this.shopinfo = res.data.shop;
  29. _this.promotions = res.data.promotions;
  30. _this.rankingList = res.data.salesRankingList;
  31. if (res.data.unReadMessageCount>99){
  32. res.data.unReadMessageCount = '99+';
  33. _this.msgFlag = true
  34. }else if(res.data.unReadMessageCount == 0){
  35. _this.msgFlag = false
  36. }else {
  37. _this.msgFlag = true
  38. }
  39. _this.homeData.salesStatisticsList.map(function (item) {
  40. _this.orderNumData.push(item.orderQuantity);
  41. _this.paytotalfeeData.push(item.orderAmount);
  42. });
  43. _this.EchartsCreated2d();
  44. }else {
  45. _this.isRequset = true;
  46. }
  47. })
  48. },
  49. uploadGoodsImagesFn:function (event) {//更换头像
  50. var _this = this;
  51. var inputDOM = _this.$refs.goodImage;
  52. var file = inputDOM.files;
  53. _this.formData.append('file', file[0]);
  54. SupplierApi.uploadimg(_this.formData,function(response){
  55. _this.goodImage=response.data;
  56. event.target.value = '';
  57. SupplierApi.uploadAvatar({userId:_this.userId, image:_this.goodImage},function (res) {
  58. console.log(res)
  59. })
  60. });
  61. },
  62. toggleThisLadder: function(event){
  63. var el = event.currentTarget;
  64. if($(el).hasClass("on")){
  65. $(el).removeClass("on").siblings('.mFixed').hide();
  66. if(!isPC){looseBody();}
  67. }else{
  68. $(el).addClass("on").siblings('.mFixed').show();
  69. if(!isPC){fixedBody();}
  70. }
  71. },
  72. hideThisLadder: function(event){
  73. var el = event.currentTarget;
  74. $(el).parents('.priceTag').find('.tag').removeClass("on").siblings('.mFixed').hide();
  75. if(!isPC){looseBody();}
  76. },
  77. opentitle:function () {
  78. var _this = this;
  79. _this.titleSshow =!this.titleSshow;
  80. },
  81. perfect:function () {
  82. window.location.href='/supplier/setting/information.html';
  83. },
  84. EchartsCreated2d:function(){
  85. // 基于准备好的dom,初始化echarts实例
  86. var _this = this;
  87. var myChart = echarts.init(document.getElementById('StatisticsEacths'));
  88. var option = {
  89. tooltip: {
  90. trigger: 'axis',
  91. axisPointer: {
  92. type: 'cross',
  93. label: {
  94. backgroundColor: '#6a7985'
  95. }
  96. }
  97. },
  98. legend: {
  99. show: true,
  100. top: 0,
  101. right: '5%'
  102. },
  103. grid: {
  104. left: '3%',
  105. right: '4%',
  106. bottom: '3%',
  107. containLabel: true
  108. },
  109. xAxis: [{
  110. type: 'category',
  111. boundaryGap: false,
  112. data: ['近一个月','近三个月','近半年','近一年'],
  113. axisPointer: {
  114. type: 'shadow'
  115. }
  116. }],
  117. yAxis: [
  118. {
  119. type: 'value',
  120. name: '',
  121. axisTick: {
  122. show: true
  123. }
  124. },
  125. {
  126. type: 'value',
  127. name: '',
  128. axisTick: {
  129. show: true
  130. }
  131. }
  132. ],
  133. series: [
  134. {
  135. name: '订单金额(元)',
  136. type: 'line',
  137. smooth: true,
  138. symbolSize: 3,
  139. showSymbol: false,
  140. symbol: 'emptyCircle',
  141. lineStyle: { color: '#1667e1' },
  142. itemStyle: { color: '#1667e1', borderWidth: 3 },
  143. areaStyle: {
  144. color: {
  145. type: 'linear',
  146. x: 0,
  147. y: 0,
  148. x2: 0,
  149. y2: 1,
  150. colorStops: [
  151. {offset: 0, color: 'rgba(65, 125, 230, 0.2)'},// 0% 处的颜色
  152. {offset: 1, color: 'rgba(65, 125, 230, 0)' }// 100% 处的颜色
  153. ]
  154. }
  155. },
  156. data: _this.paytotalfeeData,
  157. animationDuration: 2000
  158. },
  159. {
  160. name: '订单量(笔)',
  161. type: 'line',
  162. smooth: true,
  163. symbolSize: 3,
  164. showSymbol: false,
  165. symbol: 'emptyCircle',
  166. lineStyle: { color: '#16e175' },
  167. itemStyle: { color: '#16e175', borderWidth: 3 },
  168. areaStyle: {
  169. color: {
  170. type: 'linear',
  171. x: 0,
  172. y: 0,
  173. x2: 0,
  174. y2: 1,
  175. colorStops: [
  176. { offset: 0, color: 'rgba(131, 242, 183, 0.2)' },// 0% 处的颜色
  177. { offset: 1, color: 'rgba(131, 242, 183, 0)'}// 100% 处的颜色
  178. ]
  179. }
  180. },
  181. data: _this.orderNumData,
  182. animationDuration: 2000
  183. }
  184. ]
  185. };
  186. // 使用刚指定的配置项和数据显示图表。
  187. myChart.setOption(option);
  188. window.onresize = myChart.resize;//移动适配
  189. }
  190. },
  191. mounted:function () {
  192. var _this = this;
  193. if(globalUserData) {
  194. _this.userId = globalUserData.userId;
  195. this.dashboardDataInfo();
  196. };
  197. }
  198. })