fenxiao_center.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. var hz_shang = dc("hz_shang");
  2. var wm2 = false;
  3. var isDiamond = false;
  4. hz_shang.style.display = 'inline-block';
  5. var barChart = echarts.init(document.getElementById('barChart'));
  6. var types = "7Day";
  7. var getOption = function(chartType) {
  8. var chartOption = {
  9. title: {
  10. subtext: '单位(元)'
  11. },
  12. tooltip: {
  13. trigger: 'axis'
  14. },
  15. grid: {
  16. x: 45,
  17. x2: 10,
  18. y: 60,
  19. y2: 25
  20. },
  21. toolbox: {
  22. show: false,
  23. feature: {
  24. saveAsImage: {
  25. show: true
  26. }
  27. }
  28. },
  29. calculable: true,
  30. xAxis: [{
  31. type: 'category',
  32. data: ['1日', '2日', '3日', '4日', '5日', '6日', '7日']
  33. }],
  34. yAxis: [{
  35. type: 'value'
  36. }],
  37. series: [{
  38. name: '收入',
  39. type: 'bar',
  40. itemStyle: {
  41. normal: {
  42. color: function(params) {
  43. var colorList = ['#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc'];
  44. return colorList[params.dataIndex]
  45. }
  46. }
  47. },
  48. label: {
  49. normal: {
  50. show: true,
  51. position: 'top'
  52. }
  53. },
  54. data: [0, 0, 0, 0, 0, 0, 0]
  55. }]
  56. };
  57. return chartOption
  58. };
  59. var getDiamondOption = function(chartType) {
  60. var chartOption = {
  61. title: {
  62. subtext: '单位(台)'
  63. },
  64. tooltip: {
  65. trigger: 'axis'
  66. },
  67. grid: {
  68. x: 45,
  69. x2: 10,
  70. y: 60,
  71. y2: 25
  72. },
  73. toolbox: {
  74. show: false,
  75. feature: {
  76. saveAsImage: {
  77. show: true
  78. }
  79. }
  80. },
  81. calculable: true,
  82. xAxis: [{
  83. type: 'category',
  84. data: ['1日', '2日', '3日', '4日', '5日', '6日', '7日']
  85. }],
  86. yAxis: [{
  87. type: 'value'
  88. }],
  89. series: [{
  90. name: '收入',
  91. type: 'bar',
  92. itemStyle: {
  93. normal: {
  94. color: function(params) {
  95. var colorList = ['#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc', '#55c0dc'];
  96. return colorList[params.dataIndex]
  97. }
  98. }
  99. },
  100. label: {
  101. normal: {
  102. show: true,
  103. position: 'top'
  104. }
  105. },
  106. data: [0, 0, 0, 0, 0, 0, 0]
  107. }]
  108. };
  109. return chartOption
  110. };
  111. mui.ready(function() {
  112. $.ajax(base_path+'/statistics/is_sales_man?dates=' + new Date().getTime(), {
  113. data: {},
  114. dataType: 'json',
  115. type: 'get',
  116. timeout: 15000,
  117. xhrFields: {
  118. withCredentials: true
  119. },
  120. crossDomain: true,
  121. success: function(dt) {
  122. if (dt.isRedirect) {
  123. location.href = dt.redirectURL;
  124. } else {
  125. if(dt.status) {
  126. var src='';
  127. if(dt.data.sRoleId==1){
  128. $("#yewu").show();
  129. src=base_path + "/statistics/sales_management.html";
  130. }else if(dt.data.sRoleId==2){
  131. $("#guanli").show();
  132. src=base_path + "/statistics/total_management.html";
  133. }
  134. mui('body').on('tap', '#guanli .mui-table-view-cell', function() {
  135. mui.openWindow({url: src});
  136. });
  137. }
  138. }
  139. },
  140. error: function(xhr, type, errorThrown) {
  141. //异常处理;
  142. console.log(xhr);
  143. }
  144. });
  145. document.querySelector('.loading-bg').style.display = 'none';
  146. fenxiao_center_data();
  147. pulldata();
  148. });
  149. mui.each(document.querySelectorAll('#tabbar-chart-bar .mui-control-item'), function(index, el) {
  150. el.addEventListener('tap', function() {
  151. switch(index) {
  152. case 0:
  153. types = "7Day";
  154. pulldata();
  155. break;
  156. case 1:
  157. types = "6Mon";
  158. pulldata();
  159. break;
  160. case 2:
  161. types = "Year";
  162. pulldata();
  163. break;
  164. default:
  165. break
  166. }
  167. }, false)
  168. });
  169. function pulldata() {
  170. var btnArray = ['否', '是'];
  171. var url = base_path + '/rebackStatic/statisInfo';
  172. var count = 1;
  173. if(isDiamond) {
  174. url = base_path + '/rebackStatic/getDiamondStaticsInfo';
  175. count = 2
  176. }
  177. $.ajax(url + '?dates=' + new Date().getTime(), {
  178. data: {
  179. "openid": "230",
  180. "type": types
  181. },
  182. dataType: 'json',
  183. type: 'post',
  184. timeout: 15000,
  185. xhrFields: {
  186. withCredentials: true
  187. },
  188. crossDomain: true,
  189. success: function(dt) {
  190. if (dt.isRedirect) {
  191. location.href = dt.redirectURL;
  192. } else {
  193. if(dt.status) {
  194. var counts = [];
  195. var dates = [];
  196. mui(dt.data).each(function(index) {
  197. if(count == 1) {
  198. counts[index] = accDiv(this.amount, 100)
  199. } else if(count == 2) {
  200. counts[index] = this.salesNumber
  201. }
  202. dates[index] = this.strDate
  203. });
  204. barChart.setOption({
  205. xAxis: {
  206. data: dates
  207. },
  208. series: [{
  209. name: '收入',
  210. data: counts
  211. }]
  212. })
  213. } else {
  214. mui.confirm(dt.message, ' ', btnArray, function(e) {
  215. if(e.index == 1) {
  216. setTimeout(function() {
  217. location.href = domanUrl + base_path + "/drp/indexPage?dates=" + new Date().getTime()
  218. }, 5000)
  219. }
  220. })
  221. }
  222. }
  223. },
  224. error: function(xhr, type, errorThrown) {
  225. console.log(xhr);
  226. }
  227. })
  228. };
  229. function fenxiao_center_data() {
  230. var btnArray = ['否', '是'];
  231. $.ajax(base_path + '/placeInfo/showPlaceInfoCenter?dates=' + new Date().getTime(), {
  232. dataType: 'json',
  233. type: 'post',
  234. timeout: 15000,
  235. xhrFields: {
  236. withCredentials: true
  237. },
  238. crossDomain: true,
  239. success: function(dt) {
  240. if (dt.isRedirect) {
  241. location.href = dt.redirectURL;
  242. } else {
  243. if(dt.status) {
  244. $('#salesName').html("下线 · 销量");
  245. if(dt.data.salesName) {
  246. isDiamond = true;
  247. barChart.setOption(getDiamondOption('bar'));
  248. $('#balanceLi').hide();
  249. $('#waitAccounts').hide()
  250. } else {
  251. isDiamond = false;
  252. barChart.setOption(getOption('bar'));
  253. $('#balanceLi').show();
  254. $('#waitAccounts').show()
  255. }
  256. $('#salesName').val(dt.data.salesName);
  257. document.querySelector('#to_accounts').innerHTML = accDiv(dt.data.unIncomeMoney, 100) + '元';
  258. document.querySelector('.total_money').innerHTML = accDiv(dt.data.totalMoney, 100) + '元';
  259. document.querySelector('.tx').innerHTML = '<img class="wechat_tx" src="' + dt.data.headImg + '">';
  260. if(dt.data.wm2 == "true") {
  261. wm2 = true;
  262. document.querySelector(".fenxiao_wm2").style.display = 'inline-block';
  263. document.querySelector(".fenxiao_share").style.display = 'inline-block'
  264. }
  265. document.querySelector('.role_name').innerHTML = dt.data.role;
  266. document.querySelector('.user_name').innerHTML = dt.data.userName;
  267. document.querySelector('.wechat_name').innerHTML = dt.data.nickName;
  268. var shareOpenid = dt.data.shareOpenid;
  269. var link = "https:" + domanUrl + base_path + "/drp/share2WM?shareOpenid=" + shareOpenid;
  270. window.repleFlag = false;
  271. window.wxFriend = {
  272. "appId": "",
  273. "imgUrl": '//s.iamberry.com/watero/images/shop/index.jpg',
  274. "link": link,
  275. "desc": "美国标准,4级净化,5档水温,废水比3:1,水质TDS智能显示。",
  276. "title": "Watero,美国高端净水专家,4级净化,5档水温,免安装饮水一体机。",
  277. "netError": "您的网络异常,请刷新重试!如多次刷新无效,请向我们反应 ~",
  278. "shareTimeSuccess": "分享成功",
  279. "shareTimeCancel": "已取消分享",
  280. "shareAppSuccess": "分享成功",
  281. "shareAppCancel": "已取消分享"
  282. };
  283. getConfig();
  284. pulldata()
  285. } else {
  286. mui.confirm(dt.message, ' ', btnArray, function(e) {
  287. if(e.index == 1) {
  288. setTimeout(function() {
  289. location.href = domanUrl + base_path + "/drp/indexPage?dates=" + new Date().getTime()
  290. }, 5000)
  291. }
  292. })
  293. }
  294. }
  295. },
  296. error: function(xhr, type, errorThrown) {
  297. console.log(xhr);
  298. }
  299. })
  300. };
  301. function tixian() {
  302. window.location.href = base_path + "/drp/withdrawalsList";
  303. };
  304. function getIncomeRecord() {
  305. window.location.href = base_path + "/drp/UnIncomeOrderList";
  306. };
  307. function shareH5() {
  308. window.location.href = "http://www.watero.cn/watero_wap_app_1.2/index.html";
  309. };
  310. function xialianlist() {
  311. if(wm2) {
  312. window.location.href = base_path + "/drp/xialianUser2";
  313. } else {
  314. window.location.href = base_path + "/drp/xialianUser";
  315. }
  316. };
  317. function weiruzhang() {
  318. if(wm2) {
  319. window.location.href = base_path + "/drp/UnIncomeOrderList";
  320. } else {
  321. window.location.href = base_path + "/drp/UnIncomeOrderList2";
  322. }
  323. };
  324. function fenxiao_wm2() {
  325. window.location.href = "/watero/wechat/drp/share2WM";
  326. };