123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- const _Http = getApp().globalData.http,
- MFT = require("../../utils/matchingFeilType"),
- deleteMark = require("../../utils/deleteMark");
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- tabsTitle: "详情",
- rate: {
- nubmer: 5,
- text: "非常满意"
- },
- videoList: [],
- loading: false,
- isEvaluate: false
- },
- onLoad(options) {
- let auth = options.auth.split(","),
- dataAuth = '';
- if (auth.includes('团队内部数据分析') && auth.includes('经销商数据分析')) {
- dataAuth = 'all';
- } else {
- dataAuth = options.auth.includes('团队内部数据分析') ? '内部' : '经销商'
- };
- let viewData = options.auth.includes('团队内部数据分析') || options.auth.includes('经销商数据分析');
- this.setData({
- viewData,
- dataAuth,
- auth,
- sat_noticeid: options.id
- });
- this.queryNoticeMain(); //获取详情
- },
- /* 通告详情 */
- queryNoticeMain() {
- _Http.basic({
- "classname": "saletool.notice.notice",
- "method": "queryNoticeMain",
- "content": {
- "sat_noticeid": this.data.sat_noticeid
- }
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- if (this.data.viewData) this.queryReadRecord(); //查询数据
- let list = MFT.fileList(res.data.attinfos.filter(v => v.usetype != 'cover')), //过滤封面文件
- videoList = [], //视频附件列表
- attinfos = []; //其他附件
- list.forEach(v => v.fileType == 'video' ? videoList.push(v) : attinfos.push(v));
- res.data.attinfos = attinfos;
- this.setData({
- detailsData: res.data,
- videoList
- });
- const pages = getCurrentPages(),
- page = pages[pages.length - 2].route == 'pages/tabbar/home/index' ? pages[pages.length - 2] : pages[pages.length - 3];
- page.queryNoticeList(); //通知首页,更新已读数据
- });
- },
- /* 查询数据 */
- queryReadRecord() {
- _Http.basic({
- "classname": "saletool.notice.notice",
- "method": "queryReadRecord",
- "content": {
- "sat_noticeid": this.data.sat_noticeid
- }
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- let isEvaluate = false;
- if (res.data[0].score != 0) {
- this.rateChange({
- detail: res.data[0].score
- })
- isEvaluate = true;
- }
- this.setData({
- evaluate: res.data[0],
- isEvaluate
- })
- });
- },
- /* 评分 */
- rateChange({
- detail
- }) {
- let rate = {
- nubmer: detail,
- text: ""
- };
- switch (detail) {
- case 1:
- rate.text = '很不满意'
- break;
- case 2:
- rate.text = '不满意'
- break;
- case 3:
- rate.text = '一般'
- break;
- case 4:
- rate.text = '满意'
- break;
- case 5:
- rate.text = '非常满意'
- break;
- }
- this.setData({
- rate
- })
- },
- /* 文本框输入 */
- textInput({
- detail
- }) {
- this.setData({
- "evaluate.leavemessage": deleteMark.queryStr(detail.value)
- })
- },
- /* 提交建议 */
- submit() {
- if (this.data.isEvaluate) return wx.showToast({
- title: '您已提交过建议',
- icon: "none"
- })
- const evaluate = this.data.evaluate,
- that = this;
- if (evaluate.leavemessage.length > 0) {
- that.updateReadRecord()
- } else {
- wx.showModal({
- title: "提示",
- content: "通告评分(建议与反馈)没有完成,是否确认提交,提交后无法修改",
- success: res => {
- if (res.confirm) that.updateReadRecord()
- }
- })
- }
- },
- updateReadRecord() {
- this.setData({
- loading: true
- })
- _Http.basic({
- "classname": "saletool.notice.notice",
- "method": "updateReadRecord",
- "content": {
- "sat_noticeid": this.data.detailsData.sat_noticeid,
- "score": this.data.rate.nubmer,
- "leavemessage": this.data.evaluate.leavemessage
- }
- }).then(res => {
- this.setData({
- loading: false
- });
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- wx.showToast({
- title: '提交成功!',
- });
- this.setData({
- isEvaluate: true
- })
- })
- },
- /* tabs切换 */
- tabChange(e) {
- this.setData({
- tabsTitle: e.detail.title
- })
- },
- })
|