message.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. jqMultipleShow("click", ".navList", ".tab", ".con");
  2. var helpSuggestion = new Vue({
  3. el: "#dashboard",
  4. data: {
  5. btnLoading: false,
  6. isRequset:false,
  7. listQuery:{
  8. userId: '',
  9. pageNum:1,
  10. pageSize:10,
  11. },
  12. noMore:false,
  13. listRecord: 0,
  14. pageInput: '1',
  15. degree:'',
  16. isCheckedAll:false,
  17. messagesList:[],//新闻动态
  18. check:false,
  19. checklist:[],
  20. msgId:'',
  21. },
  22. computed: {
  23. pageTotal: function () {
  24. var total = Math.ceil(this.listRecord / this.listQuery.pageSize);
  25. return total > 0 ? total : 1;
  26. },
  27. showPageBtn: function () {
  28. var total = Math.ceil(this.listRecord / this.listQuery.pageSize);
  29. total = total > 0 ? total : 1;
  30. var index = this.listQuery.pageNum, arr = [];
  31. if (total <= 6) {
  32. for (var i = 1; i <= total; i++) {
  33. arr.push(i);
  34. }
  35. return arr;
  36. }
  37. if (index <= 3) return [1, 2, 3, 4, 5, 0, total];
  38. if (index >= total - 2) return [1, 0, total - 4, total - 3, total - 2, total - 1, total];
  39. return [1, 0, index - 2, index - 1, index, index + 1, index + 2, 0, total];
  40. }
  41. },
  42. methods: {
  43. toPagination: function (pageNum) {//点击切换分页
  44. if (pageNum <= this.pageTotal) {
  45. this.listQuery.pageNum = pageNum;
  46. this. GetMyPcMymessageInfo();
  47. }
  48. },
  49. checkNum: function () {//输入跳转分页
  50. if (this.pageInput > this.pageTotal) {
  51. this.pageInput = this.pageTotal;
  52. } else if (this.pageInput < 1) {
  53. this.pageInput = 1;
  54. }
  55. },
  56. GetMyPcCenterInfo:function(){
  57. var _self = this;
  58. SupplierApi.GetMymessageList(_self.listQuery,function (response) {
  59. if(response.code == 0){
  60. var data = response.data;
  61. if (data.results.length>0){
  62. _self.messagesList = data.results;
  63. _self.listRecord = data.totalRecord;
  64. _self.requestFlag = true;
  65. }else {
  66. _self.requestFlag = false;
  67. _self.listRecord = data.totalRecord;
  68. }
  69. }else{
  70. CAIMEI.Alert(response.msg, '确定', false);
  71. _self.requestFlag = false;
  72. }
  73. })
  74. },
  75. checkedItemFn:function(item){ //单选
  76. var _self = this;
  77. if(event.target.checked){
  78. _self.checklist.push(item.messageID);
  79. _self.msgId = _self.checklist.toString()+','
  80. }else {
  81. _self.checklist.splice(_self.checklist.indexOf(item.messageID), 1);
  82. _self.msgId = _self.checklist.toString()+','
  83. }
  84. if(_self.checklist.length==_self.messagesList.length){
  85. _self.isCheckedAll=true;
  86. }else {
  87. _self.isCheckedAll=false;
  88. }
  89. },
  90. checkedAllFn: function () { //全選
  91. var _self = this;
  92. _self.isCheckedAll = !_self.isCheckedAll;
  93. if (_self.isCheckedAll) {
  94. _self.checklist = [];
  95. _self.messagesList.forEach(function (item) {
  96. item.check = true;
  97. _self.checklist.push(item.messageID);
  98. _self.msgId = _self.checklist.toString()+','
  99. })
  100. }else{
  101. _self.messagesList.forEach(function(item){
  102. item.check = false;
  103. });
  104. _self.checklist = [];
  105. _self.msgId = ''
  106. }
  107. },
  108. deleteMessageFn: function(){//删除消息
  109. var _this =this;
  110. if(_this.messagesList==''){
  111. CAIMEI.Alert('暂无消息', '确定', false);
  112. }else if(_this.checklist.length==0) {
  113. CAIMEI.Alert('未选择任何消息', '确定', false);
  114. }else {
  115. PublicApi.deleteMessage({messageIds:_this.msgId},function (res) {
  116. if (res.code==0){
  117. CAIMEI.dialog('刪除成功');
  118. location.reload();
  119. }else {
  120. CAIMEI.Alert(res.msg, '确定', false);
  121. }
  122. })
  123. }
  124. },
  125. signMessageFn: function(){//标记为已读
  126. var _this =this;
  127. console.log(_this.checklist);
  128. console.log(_this.msgId);
  129. if(_this.messagesList==''){
  130. CAIMEI.Alert('暂无消息', '确定', false);
  131. }else if(_this.checklist.length==0){
  132. CAIMEI.Alert('未选择任何消息', '确定', false);
  133. }else {
  134. PublicApi.markAsRead({messageIds:_this.msgId},function (res) {
  135. if(res.code==0){
  136. CAIMEI.dialog('已读成功');
  137. location.reload();
  138. }else {
  139. CAIMEI.Alert(res.msg, '确定', false);
  140. }
  141. })
  142. }
  143. },
  144. showBadge:function(n){//处理标签
  145. var num ='';
  146. if(n>100){num = 99}else{num = n;}
  147. return num;
  148. },
  149. toFixedFn:function(text){//处理小数点后两位数
  150. return Number(text).toFixed(2);
  151. },
  152. },
  153. mounted: function () {
  154. if(globalUserData){
  155. this.listQuery.userId = globalUserData.userId;
  156. this.GetMyPcCenterInfo();
  157. }
  158. if(!isPC){
  159. $('footer').addClass("noneImportant");
  160. //移动端上垃加载更多
  161. $(window).on('scroll', function(){
  162. var scrollTop = $(this).scrollTop();
  163. var scrollHeight = $(document).height();
  164. var windowHeight = window.innerHeight;
  165. if (scrollTop + windowHeight >= scrollHeight) {
  166. //此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作
  167. var totalPage = Math.ceil(_self.listRecord / _self.listQuery.pageSize)?Math.ceil(_self.listRecord / _self.listQuery.pageSize):1;
  168. var next = _self.listQuery.pageNum+1;
  169. if(next <= totalPage){
  170. if (_self.requestFlag){
  171. _self.listQuery.pageNum = next;
  172. // 获取列表数据
  173. _self.GetMyPcMymessageInfo();
  174. }
  175. _self.requestFlag = false;
  176. }else{
  177. //到底了
  178. _self.noMore = true;
  179. $('footer').removeClass("noneImportant");
  180. }
  181. }
  182. });
  183. }
  184. }
  185. });