hz-zhhq-app/pages/comment/comment.vue

139 lines
3.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view>
<view>
<!-- 头部 -->
<!-- <view class="title-header">
<view class="nav-btn" @click="jump()">
<img src="img/back.png" alt="">
</view>
<view class="btn-header">
<h1 class="">{{wenzi.length>0 ? '评价详情' : '发表评价'}}</h1>
</view>
<view class="nav-btn">
</view>
</view> -->
<!-- 评价 -->
<view class="msg">
<view class="score">
<span>满意度</span>
<image class="star0" v-if="!dis" v-for="(item,index) in 5" :key="index" :src="index >= num?star0:star1" alt=""
@click="imgsm(index)">
<image class="star0" v-if="dis" v-for="(item,index) in 5" :key="index" :src="index >= num?star0:star1" alt="">
</view>
<textarea :disabled="dis" name="" id="" @keydown="textChange" @blur="longblur(wenzi)" v-model="wenzi" placeholder="请填写评价..."
maxlength="200"></textarea>
</view>
<view class="btn" @click="(num>0 && wenzi.length>0 ) ? handel() : ''" :style="{background:(num>0 && wenzi.length>0) ? '#00CE47' : '#7AE5BC'}"
v-if="isSee == 0">
<span>发表评价</span></view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
star0: "/static/imgs/star0.png",
star1: "/static/imgs/star1.png",
num: -1,
wenzi: "",
id: "",
isSee: "",
dis: false,
isShow: false
};
},
methods: {
isEmojiCharacter(substring) {
for (var i = 0; i < substring.length; i++) {
var hs = substring.charCodeAt(i);
if (0xd800 <= hs && hs <= 0xdbff) {
if (substring.length > 1) {
var ls = substring.charCodeAt(i + 1);
var uc = ((hs - 0xd800) * 0x400) + (ls - 0xdc00) + 0x10000;
if (0x1d000 <= uc && uc <= 0x1f77f) {
return true
}
}
} else if (substring.length > 1) {
var ls = substring.charCodeAt(i + 1);
if (ls == 0x20e3) {
return true
}
} else {
if (0x2100 <= hs && hs <= 0x27ff) {
return true
} else if (0x2B05 <= hs && hs <= 0x2b07) {
return true
} else if (0x2934 <= hs && hs <= 0x2935) {
return true
} else if (0x3297 <= hs && hs <= 0x3299) {
return true
} else if (hs == 0xa9 || hs == 0xae || hs == 0x303d || hs == 0x3030 || hs == 0x2b55 || hs == 0x2b1c || hs ==
0x2b1b || hs == 0x2b50) {
return true
}
}
}
},
longblur(text) {
var self = this;
if (this.isEmojiCharacter(text)) {
mui.toast("不能输入表情", {
duration: "long"
});
self.wenzi = "";
return 2
}
var reg = new RegExp(
/^([\u4E00-\uFA29]|[\uE7C7-\uE7F3]|[a-zA-Z0-9]){1}([\u4E00-\uFA29]|[\uE7C7-\uE7F3]|[a-zA-Z0-9_-]|[".!?_%;)《()》(+=“-,。 ]){0,}$/
);
var reg3 = new RegExp(/^[0-9]+$/);
if ((reg.test(text) == false && text != '') || (reg3.test(text) == true && text != '')) {
if (text == self.wenzi) {
mui.toast("请填写正确的评价", {
duration: "long"
});
self.wenzi = ""
}
}
},
imgsm(index) {
this.num = index + 1
},
jump() {
history.length == 1 ? window.location.href = "./index.html" : window.history.go(-1)
},
textChange() {
var self = this;
if (self.num && self.wenzi && self.id) this.isShow = true;
else this.isShow = false
},
handel() {
// var self = this;
// request.saveHaircutComment({
// detailId: self.id,
// satisfiedLevel: self.num,
// commentContent: self.wenzi
// }, function(res) {
// if (res.returnCode == 1) {
// mui.toast("评价成功", {
// duration: "long"
// });
// setTimeout(function() {
// window.location.href = "./myapplication-9.1.html"
// }, 2000)
// } else mui.toast("评论失败,请重试", {
// duration: "long"
// })
// })
}
}
}
</script>
<style lang="scss">
@import url("../../static/css/comment.css");
</style>