evaluate.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view>
  3. <view class="scores">
  4. <view class="li ddflex">
  5. <view class="label">专业评分</view>
  6. <view class="item ddflex fflex">
  7. <view class="star ddflex">
  8. <image v-for="(it, idx) in [2, 4, 6, 8, 10]" :key="idx" :src="recordScore >= it ? '../static/images/pf_star_h.png' : '../static/images/pf_star.png'" @tap="addRecordScores(idx)"></image>
  9. </view>
  10. <view>{{recordScore}}分</view>
  11. </view>
  12. </view>
  13. <view class="li ddflex">
  14. <view class="label">服务评分</view>
  15. <view class="item ddflex fflex">
  16. <view class="star ddflex">
  17. <image v-for="(it, idx) in [2, 4, 6, 8, 10]" :key="idx" :src="musicScore >= it ? '../static/images/pf_star_h.png' : '../static/images/pf_star.png'" @tap="addMusicScores(idx)"></image>
  18. </view>
  19. <view>{{musicScore}}分</view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="det" v-if="config.IS_SHOW_COMMENT_CARD==1 || config.IS_UPLOAD_IMG_EVALUATE_CARD==1">
  24. <view class="tits ddflex">我的评价<text>{{evaluateText.length}}/300</text></view>
  25. <textarea v-if="config.IS_SHOW_COMMENT_CARD==1" v-model="evaluateText" maxlength="300" placeholder="评价描述" placeholder-class="placeholder" class="texts"></textarea>
  26. <view class="imgbox dflex" v-if="config.IS_UPLOAD_IMG_EVALUATE_CARD==1">
  27. <view class="imgs" v-for="(item,index) in picList" :key="index">
  28. <image :src="item" mode="aspectFill" class="img" @click="preview(picList,index)"></image>
  29. <image src="../../static/pages/images/close3.png" class="clear" @click="delPic(index)"></image>
  30. </view>
  31. <view class="upload ddflex" @click="uploadProductImg()" v-if="picList.length < 9">
  32. <image src="../static/images/upload.png" mode="aspectFill"></image>
  33. <view>上传图片</view>
  34. </view>
  35. </view>
  36. </view>
  37. <view style="height: 140rpx;"></view>
  38. <view class="bot">
  39. <view class="btn" @click="updateScore">发表评价</view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. const app = getApp();
  45. const req = require('../../utils/request.js');
  46. const api = require('../../utils/api.js');
  47. const util = require('../../utils/util.js');
  48. export default {
  49. data() {
  50. return {
  51. picUrlss: req.public.picUrls,
  52. id: '',
  53. params: '',
  54. recordScore: 0,
  55. musicScore: 0,
  56. evaluateText: '',
  57. picList: [],
  58. bindType: '',
  59. config:{}
  60. };
  61. },
  62. onLoad(options) {
  63. this.id = options.id;
  64. this.getAbout()
  65. },
  66. methods: {
  67. getAbout() {
  68. var _this = this;
  69. req.getRequest('/api/other/config', {}, function(res) {
  70. _this.config = res;
  71. });
  72. },
  73. addRecordScores(index) {
  74. this.recordScore = (parseInt(index) + 1)*2;
  75. },
  76. addMusicScores(index) {
  77. this.musicScore = (parseInt(index) + 1)*2;
  78. },
  79. uploadProductImg() {
  80. let that = this;
  81. uni.chooseImage({
  82. count: this.picList.length-9,
  83. sizeType: ['original', 'compressed'],
  84. sourceType: ['album', 'camera'],
  85. success: function({ tempFilePaths }) {
  86. uni.showLoading({
  87. title: '上传中'
  88. });
  89. var promise = Promise.all(
  90. tempFilePaths.map(tempFilePath => {
  91. return new Promise(function(resolve, reject) {
  92. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  93. that.picList = that.picList.concat(res.src);
  94. console.log('that.picList==',that.picList)
  95. resolve()
  96. });
  97. });
  98. })
  99. );
  100. promise
  101. .then(function(results) {
  102. console.log(results);
  103. uni.hideLoading()
  104. })
  105. .catch(function(err) {
  106. console.log(err);
  107. uni.hideLoading()
  108. });
  109. }
  110. });
  111. },
  112. delPic(index) {
  113. let arr = this.picList;
  114. arr.splice(index, 1);
  115. this.picList = arr;
  116. },
  117. //预览图片
  118. previewImgss(list, index) {
  119. var src = list[index].file;
  120. let imgs = list.map(it => {
  121. if (it.file) {
  122. return it.file;
  123. }
  124. });
  125. uni.previewImage({
  126. current: src, // 当前显示图片的http链接
  127. urls: imgs
  128. });
  129. },
  130. updateScore() {
  131. let form = {
  132. bindId:this.id,
  133. type:2
  134. };
  135. form.specialityScore = this.recordScore
  136. form.serveScore = this.musicScore
  137. form.content = this.evaluateText
  138. form.evaluateImg = this.picList&&this.picList.length>0 ? this.picList.join(',') : ''
  139. if(!form.bindId) return req.msg('id不能为空')
  140. if(!form.specialityScore) return req.msg('请进行专业评分')
  141. if(!form.serveScore) return req.msg('请进行服务评分')
  142. if(!form.content&&this.config.IS_SHOW_COMMENT_CARD==1) return req.msg('请填写评价描述')
  143. req.postRequest('/api/evaluate/save', form, () => {
  144. req.msg('评价成功', () => {
  145. uni.navigateBack();
  146. });
  147. });
  148. }
  149. }
  150. };
  151. </script>
  152. <style>
  153. @import "./evaluate.css";
  154. </style>