| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446 |
- <template>
- <div class="write-comments">
- <div class="content">
- <div class="crumbs">
- <nuxt-link to="/user-center" class="item-a">{{$t('comments.personalCenter')}}</nuxt-link>
- <span class="arrow">></span>
- <span class="item-span" v-if="isComm == 0">{{$t('comments.postComment')}}</span>
- <span class="item-span" v-if="isComm == 1">{{$t('comments.commentDetails')}}</span>
- </div>
- <div class="comments-con">
- <!-- 待评价 -->
- <div v-if="orderItemProds.length > 0">
- <div class="comments-box" v-for="(item,index) in orderItemProds" :key="index">
- <div class="goods-msg">
- <div class="img">
- <img v-if="item.pic" :src="item.pic" alt @error="handlePicError"/>
- <img v-else src="~/assets/img/def.png" alt />
- </div>
- <a
- class="name"
- href="javascript:void(0);"
- @click="toProdDetail(item.prodId)"
- >{{item.prodName}}</a>
- <div v-if="item.skuName" class="sku">{{$t('comments.specification')}}: {{item.skuName}}</div>
- <div class="order-number">
- {{$t('comments.orderNumber')}}:
- <a
- href="javascript:void(0);"
- @click="toOrderDetail(item.orderNumber)"
- class="number"
- >{{item.orderNumber}}</a>
- </div>
- <div class="deal-time">
- {{$t('comments.transactionTime')}}:
- <span class="number">{{item.payTime}}</span>
- </div>
- </div>
- <div class="operation">
- <div class="item" aria-disabled="true">
- <div class="tit">{{$t('comments.productRating')}}</div>
- <!-- 评分星级: -->
- <div class="star-box">
- <!-- <span class="text">商品评分</span> -->
- <span class="stars">
- <i
- :class="[item.score > 0?'star':'star-gray']"
- @click="prodComm(1,item.orderItemId)"
- ></i>
- <i
- :class="[item.score > 1?'star':'star-gray']"
- @click="prodComm(2,item.orderItemId)"
- ></i>
- <i
- :class="[item.score > 2?'star':'star-gray']"
- @click="prodComm(3,item.orderItemId)"
- ></i>
- <i
- :class="[item.score > 3?'star':'star-gray']"
- @click="prodComm(4,item.orderItemId)"
- ></i>
- <i
- :class="[item.score > 4?'star':'star-gray']"
- @click="prodComm(5,item.orderItemId)"
- ></i>
- </span>
- </div>
- <!-- <div class="star-box">
- <span class="text">店铺服务</span>
- <span class="stars">
- <i :class="[storeCommNum > 0?'star':'star-gray']" @click="storeComm(1)"></i>
- <i :class="[storeCommNum > 1?'star':'star-gray']" @click="storeComm(2)"></i>
- <i :class="[storeCommNum > 2?'star':'star-gray']" @click="storeComm(3)"></i>
- <i :class="[storeCommNum > 3?'star':'star-gray']" @click="storeComm(4)"></i>
- <i :class="[storeCommNum > 4?'star':'star-gray']" @click="storeComm(5)"></i>
- </span>
- </div>
- <div class="star-box">
- <span class="text">物流服务</span>
- <span class="stars">
- <i :class="[logCommNum > 0?'star':'star-gray']" @click="logComm(1)"></i>
- <i :class="[logCommNum > 1?'star':'star-gray']" @click="logComm(2)"></i>
- <i :class="[logCommNum > 2?'star':'star-gray']" @click="logComm(3)"></i>
- <i :class="[logCommNum > 3?'star':'star-gray']" @click="logComm(4)"></i>
- <i :class="[logCommNum > 4?'star':'star-gray']" @click="logComm(5)"></i>
- </span>
- </div>-->
- </div>
- <!-- <div class="item">
- <div class="tit">大众评价</div>
- <div class="comments">
- <div class="c-item active">产品质量很好</div>
- <div class="c-item">细节做工很棒</div>
- <div class="c-item">快递运输快</div>
- <div class="c-item">卖家服务很好</div>
- <div class="c-item">价格很便宜</div>
- </div>
- </div>-->
- <div class="item">
- <div class="tit">{{$t('comments.specificDescription')}}</div>
- <div class="des-box">
- <textarea
- v-model="item.content"
- class="des"
- maxlength="150"
- :placeholder="$t('comments.provideYourComments')"
- ></textarea>
- <div class="des-tip">{{$t('comments.enterUpTo150Characters')}}</div>
- </div>
- </div>
- <div class="item">
- <div class="tit">{{$t('comments.uploadImages')}}</div>
- <div class="img-box">
- <mul-pic-upload v-model="item.imgs" :limit="9" />
- <div class="img-des">( {{$t('comments.uploadUpTo9Photos')}} )</div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- /待评价 -->
- <!-- 已评价 -->
- <div class="comments-box" v-if="isComm == 1">
- <div class="goods-msg">
- <div class="img">
- <img v-if="orderItem.pic" :src="orderItem.pic" alt @error="handlePicError"/>
- <img v-else src="~/assets/img/def.png" alt />
- </div>
- <a
- class="name"
- href="javascript:void(0);"
- @click="toProdDetail(orderItem.prodId)"
- >{{orderItem.prodName}}</a>
- <div v-if="orderItem.skuName" class="sku">{{$t('comments.specification')}}: {{orderItem.skuName}}</div>
- <div class="order-number">
- {{$t('comments.orderNumber')}}:
- <a
- href="javascript:void(0);"
- @click="toOrderDetail(orderItem.orderNumber)"
- class="number"
- >{{orderItem.orderNumber}}</a>
- </div>
- <div class="deal-time">
- {{$t('comments.transactionTime')}}:
- <span class="number">{{orderItem.recTime}}</span>
- </div>
- </div>
- <div class="operation">
- <div class="item" aria-disabled="true">
- <div class="tit">{{$t('comments.productRating')}}</div>
- <!-- 评分星级: -->
- <div class="star-box">
- <span class="stars">
- <i :class="[prodCommNum > 0?'star':'star-gray']" @click="prodComm(1)"></i>
- <i :class="[prodCommNum > 1?'star':'star-gray']" @click="prodComm(2)"></i>
- <i :class="[prodCommNum > 2?'star':'star-gray']" @click="prodComm(3)"></i>
- <i :class="[prodCommNum > 3?'star':'star-gray']" @click="prodComm(4)"></i>
- <i :class="[prodCommNum > 4?'star':'star-gray']" @click="prodComm(5)"></i>
- </span>
- </div>
- </div>
- <div class="item" style="margin-top: -15px;">
- <div class="tit">{{$t('comments.specificDescription')}}</div>
- <div class="des-content">
- <span>{{content}}</span>
- </div>
- </div>
- <div class="item">
- <div class="tit">{{$t('comments.commentsOnPictures')}}</div>
- <div class="img-box" v-if="pics.length">
- <div class="file-img" v-for="(item, index) in pics" :key="index">
- <img :src="item" alt />
- </div>
- </div>
- <div class="des-content" style="color: #999;" v-if="!pics.length">{{$t('comments.none')}}</div>
- </div>
- </div>
- </div>
- <!-- /已评价 -->
- <div class="btn-box">
- <a href="javascript:void(0);" v-if="isComm == 0" @click="submitComm()" class="btn">{{$t('comments.postComment')}}</a>
- <div class="agree-box" v-if="isComm == 0" @click="checkAgree">
- <input
- type="checkbox"
- :class="['checkbox',isAnonymous?'checked': 'default']"
- class="checkbox default"
- />
- <span class="text">{{$t('comments.anonymousOrNot')}}</span>
- </div>
- <a href="javascript:void(0);" v-if="isComm == 1" @click="cancel()" class="btn back">{{$t('comments.backToList')}}</a>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import MulPicUpload from '~/components/mul-pic-upload'
- export default {
- data () {
- return {
- orderItemId: 0,
- orderItem: {},
- prodCommNum: 0,
- storeCommNum: 0,
- logCommNum: 0,
- pics: [],
- imgs: '',
- content: '',
- isAnonymous: false,
- isComm: this.$route.query.isComm,
- orderNumber: this.$route.query.orderNumber, //订单号
- orderItemProds: [], //订单商品信息
- submitCommCount: 0 // 已经提交了的评价数
- }
- },
- created () {
- this.orderItemId = this.$route.query.orderItemId || 0
- // this.getOrderItem(this.orderItemId)
- },
- mounted () {
- this.isComm = this.$route.query.isComm
- this.orderItemId = this.$route.query.orderItemId || 0
- // this.getUserInfo()
- if (this.isComm == 0) {
- this.getOrderItems(this.orderNumber)
- } else if (this.isComm == 1) {
- this.getOrderItem(this.orderItemId)
- this.getComm(this.orderItemId)
- } else {
- this.isComm = 0
- }
- },
- components: {
- MulPicUpload
- },
- methods: {
- /**
- * 加载默认图片
- */
- handlePicError(e){
- e.target.src=require('@/assets/img/def.png')
- },
- /**
- * 改变商品评分
- */
- prodComm (num, orderItemId) {
- if (this.isComm == 1) {
- return
- }
- this.orderItemProds.forEach(orderItem => {
- if (orderItemId == orderItem.orderItemId) {
- orderItem.score = num
- }
- })
- },
- /**
- * 改变店铺评分
- */
- storeComm (num) {
- if (this.isComm == 1) {
- return
- }
- this.storeCommNum = num
- },
- /**
- * 改变物流评分
- */
- logComm (num) {
- if (this.isComm == 1) {
- return
- }
- this.logCommNum = num
- },
- /**
- * 获取商品评价
- */
- getComm (orderItemId) {
- this.$axios.get('/p/prodComm/getProdComment', {
- params: {
- orderItemId: orderItemId
- }
- })
- .then(({ data }) => {
- this.content = data.content
- this.prodCommNum = data.score
- if (data.pics) {
- this.pics = data.pics.split(",")
- }
- })
- },
- /**
- * 获取多个商品详情
- */
- getOrderItems (orderNumber) {
- this.$axios.get('/p/myOrder/getOrderItems', {
- params: {
- orderNumber: orderNumber
- }
- }).then(({ data }) => {
- console.log(data);
- for (var i = 0; i < data.length; i++) {
- data[i].images = [];
- data[i].content = "";
- data[i].score = 5;
- data[i].evaluate = 0;
- }
- this.orderItemProds = data
- })
- },
- /**
- * 获取单个商品详情
- */
- getOrderItem (orderItemId) {
- this.$axios.get('/p/myOrder/getOrderItem', {
- params: {
- orderItemId: orderItemId
- }
- }).then(({ data }) => {
- console.log(data);
- this.orderItem = data
- })
- },
- /**
- * 提交评论
- */
- submitComm () {
- var allFill = true;
- for (var i = 0; i < this.orderItemProds.length; i++) {
- var cont = this.orderItemProds[i].content.trim();
- if (cont == "") {
- this.$message({
- message: this.$t('comments.evaluationCannotBeEmpty'),
- type: 'warning',
- duration: 1000,
- })
- allFill = false;
- break;
- }
- }
- if (allFill) {
- for (var i = 0; i < this.orderItemProds.length; i++) {
- let prodComm = {
- orderItemId: this.orderItemProds[i].orderItemId,
- score: this.orderItemProds[i].score,
- content: this.orderItemProds[i].content,
- isAnonymous: this.isAnonymous ? 1 : 0,
- evaluate: this.orderItemProds[i].score == 3 ? 1 : this.orderItemProds[i].score < 3 ? 2 : 0,
- prodId: this.orderItemProds.prodId,
- pics: this.orderItemProds[i].imgs,
- }
- this.$axios.post('/p/prodComm', prodComm)
- .then(({ data }) => {
- this.submitCommCount += 1
- if (this.submitCommCount == this.orderItemProds.length) {
- this.$message({
- message: this.$t('comments.submitCommentSuccessfully'),
- type: 'success',
- duration: 1000,
- onClose: () => {
- this.$router.push({ path: '/user-center/uc-comments' })
- }
- })
- }
- })
- }
- }
- },
- /**
- * 跳转订单详情
- */
- toOrderDetail (orderNumber) {
- this.$router.push({ path: '/order-detail', query: { orderNumber: orderNumber } })
- },
- /**
- * 跳转店铺页
- */
- // toOrderDetail (shopId) {
- // this.$router.push({ path: '/shopIndex?pn=', query: { shopId: shopId } })
- // },
- /**
- * 是否匿名
- */
- checkAgree () {
- this.isAnonymous = !this.isAnonymous
- },
- /**
- * 跳转到商品详情页
- */
- toProdDetail (prodId) {
- this.$router.push({ path: '/detail/' + prodId })
- },
- /**
- * 返回
- */
- cancel () {
- this.$router.push({ path: '/user-center/uc-comments', query: { isComm: 1 } })
- },
- }
- }
- </script>
- <style scoped src='~/assets/css/write-comments.css'></style>
- <style>
- .write-comments .el-upload--picture-card {
- background-color: #fff;
- border: 1px solid #eee;
- border-radius: 0;
- width: 112px;
- height: 112px;
- line-height: 112px;
- margin: 0 0 15px 15px;
- }
- .write-comments .el-upload--picture-card:hover {
- border-color: #eee;
- }
- .write-comments .el-upload--picture-card i {
- margin-top: -35px;
- font-size: 20px;
- color: #999;
- }
- .write-comments .el-upload-list--picture-card .el-upload-list__item {
- border: 1px solid #eee;
- border-radius: 0;
- width: 112px;
- height: 112px;
- margin: 0 0 15px 15px;
- }
- .write-comments .el-icon-plus{
- width:20px;
- height:20px;
- }
- </style>
|