diff --git a/src/api/evaluation.js b/src/api/evaluation.js new file mode 100644 index 0000000..6202b12 --- /dev/null +++ b/src/api/evaluation.js @@ -0,0 +1,7 @@ +export default { + // -- 领取优惠券 -- + add: { + url: "/mall/web/evaluation/add", + method: "post" + } +}; diff --git a/src/models/evaluation-model.js b/src/models/evaluation-model.js new file mode 100644 index 0000000..9e67858 --- /dev/null +++ b/src/models/evaluation-model.js @@ -0,0 +1,13 @@ +import utilsModel from "./utils-model"; +import evaluation from "../api/evaluation.js"; + +export default { + // 获取优惠券信息 + add: (data, token) => + utilsModel.config(evaluation.add).request({ + data: data, + headers: { + "encodeToken": token + } + }) +}; diff --git a/src/view/service-evaluation-status.vue b/src/view/service-evaluation-status.vue index ac2a092..4386a90 100644 --- a/src/view/service-evaluation-status.vue +++ b/src/view/service-evaluation-status.vue @@ -2,9 +2,9 @@ \ No newline at end of file + + diff --git a/src/view/service-evaluation.vue b/src/view/service-evaluation.vue index 36ba103..668c411 100644 --- a/src/view/service-evaluation.vue +++ b/src/view/service-evaluation.vue @@ -2,56 +2,47 @@ \ No newline at end of file +import { setTimeout } from "timers"; +import model from "../models/evaluation-model.js"; +import status from "./service-evaluation-status.vue"; +export default { + data() { + return { + tipShow: false, + timeScore: 0, + serviceScore: 0, + professionScore: 0, + content: "", + alertShow: false, + code: 4, + statusShow: false + }; + }, + components: { + status + }, + methods: { + //点击问号 + showTips() { + this.tipShow = true; + }, + //关闭提示 + closeTips() { + this.tipShow = false; + }, + //提示 + submit() { + if ( + this.timeScore == 0 || + this.serviceScore == 0 || + this.professionScore == 0 + ) { + 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) { + let str = res.msg; + switch (str) { + case "已过期": + this.code = 2; + this.statusShow = true; + break; + case "不可重复评价": + this.code = 1; + this.statusShow = true; + break; + case "账号不一致": + this.code = 3; + this.statusShow = true; + break; + } + } + }); + } + }, + getParam(name) { + var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); + var r = window.location.search.substr(1).match(reg); + if (r != null) return unescape(r[2]); + return null; + } + } +}; + + +