dashboard.js 8.4 KB

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