From cdba7f5b73146f08112e706384ba954116075829 Mon Sep 17 00:00:00 2001 From: fengchengzhi Date: Wed, 25 Jul 2018 11:03:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E8=AF=B7=E6=B1=82=20?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/evaluation-model.js | 6 +- src/models/utils-model.js | 25 +-- src/view/service-evaluation.vue | 289 ++++++++++++++++---------------- 3 files changed, 159 insertions(+), 161 deletions(-) diff --git a/src/models/evaluation-model.js b/src/models/evaluation-model.js index 46bb0b4..7bf3279 100644 --- a/src/models/evaluation-model.js +++ b/src/models/evaluation-model.js @@ -12,7 +12,5 @@ export default { }), // 验证是否符合评价规则和有没有登录 getEvaluationNews: (params) => - utilsModel.config(evaluation.getEvaluationNews).request({ - params: params - }) -}; + utilsModel.config(evaluation.getEvaluationNews, params).request() +}; \ No newline at end of file diff --git a/src/models/utils-model.js b/src/models/utils-model.js index 9a423d9..642d845 100644 --- a/src/models/utils-model.js +++ b/src/models/utils-model.js @@ -9,14 +9,14 @@ import { // axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8';//配置请求头 // 添加一个请求拦截器 -axios.interceptors.request.use(function (config) { - console.log(config); - // config.headers. - return config; -}, function (error) { - // Do something with request error - return Promise.reject(error); -}); +// axios.interceptors.request.use(function (config) { +// console.log(config); + +// return config; +// }, function (error) { +// // Do something with request error +// return Promise.reject(error); +// }); // 添加一个响应拦截器 axios.interceptors.response.use(function (response) { @@ -83,13 +83,14 @@ const config = function (config, params) { // 全部接口带token obj = obj || {} obj.params = obj.params || {} - obj.params.token = localStorage.getItem('user_key') + // obj.params.token = localStorage.getItem('user_key') //整合请求配置 - const newConfig = Object.assign({}, obj || {}, config, { - url: url + let newConfig = Object.assign({}, obj || {}, config, { + url: url, }); - + console.log(newConfig) + // newConfig.headers.Authorization=params.token //执行http接口请求 return axios(newConfig).then(successCallback, errorCallback); } diff --git a/src/view/service-evaluation.vue b/src/view/service-evaluation.vue index a98c224..7488831 100644 --- a/src/view/service-evaluation.vue +++ b/src/view/service-evaluation.vue @@ -78,175 +78,174 @@ import { setTimeout } from "timers"; import model from "../models/evaluation-model.js"; import status from "./service-evaluation-status.vue"; -import { Alert,Toast } from 'vux' +import { Alert, Toast } from "vux"; export default { - data() { - return { - //保洁师姓名 - name: '哇哈哈', - //服务时间 - time: '2018-10-01 08:00-12:00', - tipShow: false, - timeScore: 0, - serviceScore: 0, - professionScore: 0, - content: "", - alertShow: false, - code: 4, - statusShow: false, - //提示信息 - alertTip: '请完整填写评价', - //用于判断是否可进行提交评论 - isCanEvaluation: false, - }; + data() { + return { + //保洁师姓名 + name: "哇哈哈", + //服务时间 + time: "2018-10-01 08:00-12:00", + tipShow: false, + timeScore: 0, + serviceScore: 0, + professionScore: 0, + content: "", + alertShow: false, + code: 4, + statusShow: false, + //提示信息 + alertTip: "请完整填写评价", + //用于判断是否可进行提交评论 + isCanEvaluation: false + }; + }, + components: { + status, + Alert, + Toast + }, + methods: { + //点击问号 + showTips() { + this.tipShow = true; }, - components: { - status, - Alert, - Toast, + //关闭提示 + closeTips() { + this.tipShow = false; }, - methods: { - //点击问号 - showTips() { - this.tipShow = true; - }, - //关闭提示 - closeTips() { - this.tipShow = false; - }, - //提示 - submit() { - if(!this.isCanEvaluation) return; - if ( - this.timeScore == 0 || - this.serviceScore == 0 || - this.professionScore == 0 - ) { - this.alertTip = '请完整填写评价' - this.alertShow = true; - setTimeout(() => { - this.alertShow = false; - }, 3000); - } else { - var strCookie = document.cookie; - var cookieName = "1hjz_mall_login_access_token="; - var token = strCookie.slice(cookieName.length); + //提示 + submit() { + if (!this.isCanEvaluation) return; + if ( + this.timeScore == 0 || + this.serviceScore == 0 || + this.professionScore == 0 + ) { + this.alertTip = "请完整填写评价"; + this.alertShow = true; + setTimeout(() => { + this.alertShow = false; + }, 3000); + } else { + var strCookie = document.cookie; + var cookieName = "1hjz_mall_login_access_token="; + var token = strCookie.slice(cookieName.length); - model - .add( - { - timeScore: this.timeScore, - serviceScore: this.serviceScore, - professionScore: this.professionScore, - content: this.content, - bookNo: this.getParam("bookNo") - }, - token - ) - .then(res => { - let code = res.code; - if (code == 0) { - //成功 - this.code = 0; - this.statusShow = true; - } else if (code == 1) { - //订单不存在 - this.alertTip = res.msg - this.alertShow = true; - setTimeout(() => { - this.alertShow = false; - }, 3000); - } else if (code == 2) { - //不可重复评价 - this.code = 2; - this.statusShow = true; - } else if (code == 3) { - //已过期 - this.code = 3; - this.statusShow = true; - } else if (code == 4) { - //账号不一致 - this.code = 4; - this.statusShow = true; - } - }); + model + .add( + { + timeScore: this.timeScore, + serviceScore: this.serviceScore, + professionScore: this.professionScore, + content: this.content, + bookNo: this.getParam("bookNo") + }, + token + ) + .then(res => { + let code = res.code; + if (code == 0) { + //成功 + this.code = 0; + this.statusShow = true; + } else if (code == 1) { + //订单不存在 + this.alertTip = res.msg; + this.alertShow = true; + setTimeout(() => { + this.alertShow = false; + }, 3000); + } else if (code == 2) { + //不可重复评价 + this.code = 2; + this.statusShow = true; + } else if (code == 3) { + //已过期 + this.code = 3; + this.statusShow = true; + } else if (code == 4) { + //账号不一致 + this.code = 4; + this.statusShow = true; } - }, - getParam(name) { - var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); - var url = window.location.href - url = window.location.href.substring(url.indexOf('?')+1,url.length) - var r = url.match(reg); - if (r != null) return unescape(r[2]); - return null; - }, - //返回上一页 - goBack() { - history.go(-1) - } + }); + } }, - mounted(){ - this.name = this.getParam("name") - this.time = this.getParam("bookTime") - this.code = this.getParam("code") - //判断用户是否登录 - model.getEvaluationNews(this.getParam("bookNo")) - .then(res => { - let code = res.code; - if (code == 0) { - //成功 - if (!res.response.userId){ - this.alertTip = res.msg - this.alertShow = true; - setTimeout(() => { - this.alertShow = false; - }, 3000); - } else { - this.isCanEvaluation = true - } - } else if (code == 1) { - this.code = 4; - this.statusShow = true; - } - }); + getParam(name) { + var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); + var url = window.location.href; + url = window.location.href.substring(url.indexOf("?") + 1, url.length); + var r = url.match(reg); + if (r != null) return unescape(r[2]); + return null; + }, + //返回上一页 + goBack() { + history.go(-1); } + }, + mounted() { + this.name = this.getParam("name"); + this.time = this.getParam("bookTime"); + this.code = this.getParam("code"); + //判断用户是否登录 + model.getEvaluationNews({ bookNo: this.getParam("bookNo") }).then(res => { + let code = res.code; + if (code == 0) { + //成功 + if (!res.response.userId) { + this.alertTip = res.msg; + this.alertShow = true; + setTimeout(() => { + this.alertShow = false; + }, 3000); + } else { + this.isCanEvaluation = true; + } + } else if (code == 1) { + this.code = 4; + this.statusShow = true; + } + }); + } };