evaluate.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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">
  24. <view class="tits ddflex">我的评价<text>{{evaluateText.length}}/300</text></view>
  25. <textarea v-model="evaluateText" maxlength="300" placeholder="评价描述" placeholder-class="placeholder" class="texts"></textarea>
  26. <view class="imgbox dflex">
  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. };
  60. },
  61. onLoad(options) {
  62. this.id = options.id;
  63. },
  64. methods: {
  65. addRecordScores(index) {
  66. this.recordScore = (parseInt(index) + 1)*2;
  67. },
  68. addMusicScores(index) {
  69. this.musicScore = (parseInt(index) + 1)*2;
  70. },
  71. uploadProductImg() {
  72. let that = this;
  73. uni.chooseImage({
  74. count: this.picList.length-9,
  75. sizeType: ['original', 'compressed'],
  76. sourceType: ['album', 'camera'],
  77. success: function({ tempFilePaths }) {
  78. uni.showLoading({
  79. title: '上传中'
  80. });
  81. var promise = Promise.all(
  82. tempFilePaths.map(tempFilePath => {
  83. return new Promise(function(resolve, reject) {
  84. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  85. that.picList = that.picList.concat(res.src);
  86. console.log('that.picList==',that.picList)
  87. uni.hideLoading();
  88. });
  89. });
  90. })
  91. );
  92. promise
  93. .then(function(results) {
  94. console.log(results);
  95. })
  96. .catch(function(err) {
  97. console.log(err);
  98. });
  99. }
  100. });
  101. },
  102. delPic(index) {
  103. let arr = this.picList;
  104. arr.splice(index, 1);
  105. this.picList = arr;
  106. },
  107. //预览图片
  108. previewImgss(list, index) {
  109. var src = list[index].file;
  110. let imgs = list.map(it => {
  111. if (it.file) {
  112. return it.file;
  113. }
  114. });
  115. uni.previewImage({
  116. current: src, // 当前显示图片的http链接
  117. urls: imgs
  118. });
  119. },
  120. updateScore() {
  121. let form = {
  122. bindId:this.id,
  123. type:2
  124. };
  125. form.specialityScore = this.recordScore
  126. form.serveScore = this.musicScore
  127. form.content = this.evaluateText
  128. form.evaluateImg = this.picList&&this.picList.length>0 ? this.picList.join(',') : ''
  129. if(!form.bindId) return req.msg('id不能为空')
  130. if(!form.specialityScore) return req.msg('请进行专业评分')
  131. if(!form.serveScore) return req.msg('请进行服务评分')
  132. if(!form.content) return req.msg('请填写评价描述')
  133. req.postRequest('/api/evaluate/save', form, () => {
  134. req.msg('评价成功', () => {
  135. uni.navigateBack();
  136. });
  137. });
  138. }
  139. }
  140. };
  141. </script>
  142. <style>
  143. @import "./evaluate.css";
  144. </style>