dashboard.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. ;
  2. var helpSuggestion = new Vue({
  3. el: "#dashboard",
  4. data: {
  5. btnLoading: false,
  6. isRequset:true,
  7. userId: 0,
  8. degree:'',
  9. userInfo:{},
  10. formData:new FormData(),
  11. unReadMessageCount:'',// 消息数
  12. confirmedCount:'',// 待確認數量
  13. paymentCount:'',// 待付款
  14. waitShipmentsCount:'',// 待发货
  15. shipmentsCount:'',// 已发货
  16. salesReturnCount:'',// 退货款
  17. productList:[],// 推荐商品
  18. newsList:[],// 新闻动态
  19. isShowBeansAlet:false,
  20. bgImagePath:'',// 根据类型显示图片标记
  21. beanNumber:100,
  22. couponNum:0,// 优惠券数量
  23. beansType:1
  24. },
  25. methods: {
  26. GetMyPcCenterInfo:function(){
  27. var _self = this;
  28. UserApi.GetMyPcCenterInfo({userId:_self.userId},function (response) {
  29. if(response.code == 0){
  30. var data = response.data;
  31. _self.userInfo = data.user;
  32. _self.degree = data.degree;
  33. _self.unReadMessageCount = _self.showBadge(data.unReadMessageCount);
  34. _self.confirmedCount = _self.showBadge(data.confirmedCount);
  35. _self.paymentCount = _self.showBadge(data.paymentCount);
  36. _self.waitShipmentsCount = _self.showBadge(data.waitShipmentsCount);
  37. _self.shipmentsCount = _self.showBadge(data.shipmentsCount);
  38. _self.salesReturnCount = _self.showBadge(data.salesReturnCount);
  39. _self.productList = data.homePageAdvertiseList;
  40. _self.newsList = data.homePageInfoList;
  41. _self.couponNum = data.couponNum;
  42. _self.isRequset = false;
  43. }else{
  44. CAIMEI.Alert(response.msg, '确定', false);
  45. _self.isRequset = false;
  46. }
  47. })
  48. },
  49. GetUserClubHome(){},
  50. uploadUserPuploadAvatar: function(event){//上传头像
  51. var _self = this;
  52. var inputDOM = _self.$refs.clubUseLogo;
  53. var file = inputDOM.files;
  54. _self.formData.append('file', file[0]);
  55. PublicApi.uploadimg(_self.formData,function(response){
  56. _self.userInfo.image = response.data;
  57. event.target.value = '';
  58. UserApi.UserPuploadAvatar({userId:_self.userId,image:response.data},function(res){
  59. if(res.code==0){
  60. _self.GetMyPcCenterInfo();
  61. }
  62. })
  63. });
  64. },
  65. orderListPath:function(index){
  66. window.location.href='/user/order/list.html?state='+index;
  67. },
  68. showBadge:function(n){//处理标签
  69. var num ='';
  70. if(n>100){num = 99}else{num = n;}
  71. return num;
  72. },
  73. toFixedFn:function(text){//处理小数点后两位数
  74. return Number(text).toFixed(2);
  75. },
  76. GetInitBeansInfo:function(){//初始化采美豆信息
  77. var _self = this;
  78. UserApi.GetUserObtainBeans({userId:_self.userId},function(response){
  79. if(response.code==0){
  80. _self.beansType = response.data.beansType;
  81. _self.beanNumber = response.data.num;
  82. _self.isShowBeansAlet = true;
  83. _self.handInitType(_self.beansType);
  84. }else{
  85. console.log('@=========>用户暂无采美豆推送~')
  86. }
  87. });
  88. },
  89. handInitType:function(type){//根据类型判断弹窗背景
  90. var _self = this;
  91. if(isPC){
  92. _self.bgImagePath ='/img/account/icon-beans-'+type+'@2x.png';
  93. }else {
  94. _self.bgImagePath ='/img/account/icon-beans-h5-'+type+'@2x.png';
  95. }
  96. console.log(this.bgImagePath)
  97. },
  98. handleClickCancel:function () {//关闭弹窗
  99. var _self = this;
  100. _self.isShowBeansAlet = false;
  101. }
  102. },
  103. mounted: function () {
  104. var _self = this;
  105. if(globalUserData){
  106. _self.userId = globalUserData.userId;
  107. _self.GetMyPcCenterInfo();
  108. _self.GetInitBeansInfo();
  109. _self.isShowBeansAlet = false;
  110. }
  111. }
  112. });