123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- jqMultipleShow("click", ".navList", ".tab", ".con");
- var helpSuggestion = new Vue({
- el: "#dashboard",
- data: {
- btnLoading: false,
- isRequset:false,
- listQuery:{
- userId: '',
- pageNum:1,
- pageSize:10,
- },
- noMore:false,
- listRecord: 0,
- pageInput: '1',
- degree:'',
- isCheckedAll:false,
- messagesList:[],//新闻动态
- check:false,
- checklist:[],
- msgId:'',
- },
- computed: {
- pageTotal: function () {
- var total = Math.ceil(this.listRecord / this.listQuery.pageSize);
- return total > 0 ? total : 1;
- },
- showPageBtn: function () {
- var total = Math.ceil(this.listRecord / this.listQuery.pageSize);
- total = total > 0 ? total : 1;
- var index = this.listQuery.pageNum, arr = [];
- if (total <= 6) {
- for (var i = 1; i <= total; i++) {
- arr.push(i);
- }
- return arr;
- }
- if (index <= 3) return [1, 2, 3, 4, 5, 0, total];
- if (index >= total - 2) return [1, 0, total - 4, total - 3, total - 2, total - 1, total];
- return [1, 0, index - 2, index - 1, index, index + 1, index + 2, 0, total];
- }
- },
- methods: {
- toPagination: function (pageNum) {//点击切换分页
- if (pageNum <= this.pageTotal) {
- this.listQuery.pageNum = pageNum;
- this. GetMyPcMymessageInfo();
- }
- },
- checkNum: function () {//输入跳转分页
- if (this.pageInput > this.pageTotal) {
- this.pageInput = this.pageTotal;
- } else if (this.pageInput < 1) {
- this.pageInput = 1;
- }
- },
- GetMyPcCenterInfo:function(){
- var _self = this;
- SupplierApi.GetMymessageList(_self.listQuery,function (response) {
- if(response.code == 0){
- var data = response.data;
- if (data.results.length>0){
- _self.messagesList = data.results;
- _self.listRecord = data.totalRecord;
- _self.requestFlag = true;
- }else {
- _self.requestFlag = false;
- _self.listRecord = data.totalRecord;
- }
- }else{
- CAIMEI.Alert(response.msg, '确定', false);
- _self.requestFlag = false;
- }
- })
- },
- checkedItemFn:function(item){ //单选
- var _self = this;
- if(event.target.checked){
- _self.checklist.push(item.messageID);
- _self.msgId = _self.checklist.toString()+','
- }else {
- _self.checklist.splice(_self.checklist.indexOf(item.messageID), 1);
- _self.msgId = _self.checklist.toString()+','
- }
- if(_self.checklist.length==_self.messagesList.length){
- _self.isCheckedAll=true;
- }else {
- _self.isCheckedAll=false;
- }
- },
- checkedAllFn: function () { //全選
- var _self = this;
- _self.isCheckedAll = !_self.isCheckedAll;
- if (_self.isCheckedAll) {
- _self.checklist = [];
- _self.messagesList.forEach(function (item) {
- item.check = true;
- _self.checklist.push(item.messageID);
- _self.msgId = _self.checklist.toString()+','
- })
- }else{
- _self.messagesList.forEach(function(item){
- item.check = false;
- });
- _self.checklist = [];
- _self.msgId = ''
- }
- },
- deleteMessageFn: function(){//删除消息
- var _this =this;
- if(_this.messagesList==''){
- CAIMEI.Alert('暂无消息', '确定', false);
- }else if(_this.checklist.length==0) {
- CAIMEI.Alert('未选择任何消息', '确定', false);
- }else {
- PublicApi.deleteMessage({messageIds:_this.msgId},function (res) {
- if (res.code==0){
- CAIMEI.dialog('刪除成功');
- location.reload();
- }else {
- CAIMEI.Alert(res.msg, '确定', false);
- }
- })
- }
- },
- signMessageFn: function(){//标记为已读
- var _this =this;
- console.log(_this.checklist);
- console.log(_this.msgId);
- if(_this.messagesList==''){
- CAIMEI.Alert('暂无消息', '确定', false);
- }else if(_this.checklist.length==0){
- CAIMEI.Alert('未选择任何消息', '确定', false);
- }else {
- PublicApi.markAsRead({messageIds:_this.msgId},function (res) {
- if(res.code==0){
- CAIMEI.dialog('已读成功');
- location.reload();
- }else {
- CAIMEI.Alert(res.msg, '确定', false);
- }
- })
- }
- },
- showBadge:function(n){//处理标签
- var num ='';
- if(n>100){num = 99}else{num = n;}
- return num;
- },
- toFixedFn:function(text){//处理小数点后两位数
- return Number(text).toFixed(2);
- },
- },
- mounted: function () {
- if(globalUserData){
- this.listQuery.userId = globalUserData.userId;
- this.GetMyPcCenterInfo();
- }
- if(!isPC){
- $('footer').addClass("noneImportant");
- //移动端上垃加载更多
- $(window).on('scroll', function(){
- var scrollTop = $(this).scrollTop();
- var scrollHeight = $(document).height();
- var windowHeight = window.innerHeight;
- if (scrollTop + windowHeight >= scrollHeight) {
- //此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作
- var totalPage = Math.ceil(_self.listRecord / _self.listQuery.pageSize)?Math.ceil(_self.listRecord / _self.listQuery.pageSize):1;
- var next = _self.listQuery.pageNum+1;
- if(next <= totalPage){
- if (_self.requestFlag){
- _self.listQuery.pageNum = next;
- // 获取列表数据
- _self.GetMyPcMymessageInfo();
- }
- _self.requestFlag = false;
- }else{
- //到底了
- _self.noMore = true;
- $('footer').removeClass("noneImportant");
- }
- }
- });
- }
- }
- });
|