Files
ctms-client/apis/ctms/notice.js
fm453 c62d15b288 首次完整推送,
V:1.20240808.006
2024-08-13 18:32:37 +08:00

69 lines
2.1 KiB
JavaScript

import request from './_utils/request.js'
import apis from './apis.json'
import constant from './_utils/constant.js'
import storage from './_utils/storage.js'
export default {
//列表
list: function(page = 0, psize = 10) {
var data = {
page: page,
psize: psize, //分页数据大小
};
var url = apis.NoticeList;
var header = {
'content-type': 'application/x-www-form-urlencoded'
};
return request({
'url': url,
'method': 'POST',
'data': data,
"headers": header,
'params': {}
}).then((res) => {
switch (res.code) {
default:
break;
case 0:
var notices = {};
var totalCount = 0;
storage.set(constant.noitceList, notices, 'page-' + page);
break;
case 200:
var notices = res.data.notices;
var totalCount = res.data.total;
storage.set(constant.noticeList, totalCount, 'total');
storage.set(constant.noitceList, notices, 'page-' + page);
for (var x in notices) {
storage.set(constant.noticeDetail, notices[x], notices[x].id);
}
break;
}
return res.data;
})
},
//详情
detail: function(id) {
var data = {
id: id
};
var url = apis.NoticeDetail;
return request({
'url': url,
'method': 'POST',
'data': data,
'params': {}
}).then((res) => {
if (res.code == 200) {
var notice = res.data;
storage.set(constant.noticeDetail, notice, id);
return res;
} else {
uni.showToast({
title: "信息获取失败!",
icon: "fail"
});
}
})
}
}