evaluate.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="evaluate pb100" v-if="!loadding">
  3. <form @submit="formSubmit" @reset="formReset">
  4. <view class="evaluate-item p30" v-for="(item, index) in tableData" :key="index">
  5. <view class="product d-s-c">
  6. <view class="cover">
  7. <image :src="item.image.file_path" mode="aspectFit"></image>
  8. </view>
  9. <view class="info ml20">
  10. <view class="name f28">{{ item.product_name }}</view>
  11. <view class="price pt10 f22 red">
  12. ¥
  13. <text class="f40">{{ item.product_price }}</text>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="grade d-b-c p-30-0 mt30">
  18. <view :class="item.score == 10 ? 'flex-1 d-c-c active' : 'flex-1 d-c-c'" @click="gradeFunc(item, 10, index)">
  19. <view class="item d-c-c">
  20. <text class="icon iconfont icon-pingjiahaoping"></text>
  21. <text class="ml10">好评</text>
  22. </view>
  23. </view>
  24. <view :class="item.score == 20 ? 'flex-1 d-c-c active' : 'flex-1 d-c-c'" @click="gradeFunc(item, 20, index)">
  25. <view class="item d-c-c">
  26. <text class="icon iconfont icon-pingjiazhongping"></text>
  27. <text class="ml10">中评</text>
  28. </view>
  29. </view>
  30. <view :class="item.score == 30 ? 'flex-1 d-c-c active' : 'flex-1 d-c-c'" @click="gradeFunc(item, 30, index)">
  31. <view class="item d-c-c">
  32. <text class="icon iconfont icon-pingjiachaping"></text>
  33. <text class="ml10">差评</text>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="textarea-box d-s-c f28">
  38. <textarea class="p10 box-s-b border flex-1" v-model="item.content" placeholder="请输入评价内容" />
  39. </view>
  40. <view class="upload-list d-s-c" v-model="item.image_list">
  41. <view class="item" v-for="(imgs, img_num) in item.image_list" :key="img_num" @click="deleteImg(index, img_num)">
  42. <image :src="imgs.file_path" mode="aspectFit"></image>
  43. </view>
  44. <view class="item upload-btn d-c-c d-c" @click="openUpload(index)" v-if="item.image_list.length < 9">
  45. <text class="icon iconfont icon-xiangji"></text>
  46. <text class="gray9">上传图片</text>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="foot-btns"><button form-type="submit" class="btn-red">确认提交</button></view>
  51. </form>
  52. <!--上传图片-->
  53. <Upload v-if="isUpload" @getImgs="getImgsFunc"></Upload>
  54. </view>
  55. </template>
  56. <script>
  57. import Upload from '@/components/upload/upload.vue';
  58. export default {
  59. components: {
  60. Upload
  61. },
  62. data() {
  63. return {
  64. /*是否加载完成*/
  65. loadding: true,
  66. order_id: '',
  67. /*页面数据*/
  68. tableData: [],
  69. score: 10,
  70. /*是否打开上传图片*/
  71. isUpload: false,
  72. image_id: [],
  73. img: '/static/temp/photo.jpg',
  74. index: ''
  75. };
  76. },
  77. onLoad(e) {
  78. this.order_id = e.order_id;
  79. },
  80. mounted() {
  81. uni.showLoading({
  82. title: '加载中'
  83. });
  84. /*获取页面数据*/
  85. this.getData();
  86. },
  87. methods: {
  88. getData() {
  89. let self = this;
  90. let order_id = self.order_id;
  91. self._get(
  92. 'user.comment/order',
  93. {
  94. order_id: order_id
  95. },
  96. function(res) {
  97. self.tableData = res.data.productList;
  98. let b = self.tableData.forEach((item, index) => {
  99. self.tableData[index].score = 10;
  100. self.tableData[index].image_list = [];
  101. });
  102. self.loadding = false;
  103. uni.hideLoading();
  104. }
  105. );
  106. },
  107. /*选择评价*/
  108. gradeFunc(item, e, index) {
  109. item.score = e;
  110. this.$set(this.tableData, index, item);
  111. },
  112. /*提交*/
  113. formSubmit: function(e) {
  114. let self = this;
  115. let order_id = self.order_id;
  116. self._post(
  117. 'user.comment/order',
  118. {
  119. order_id: order_id,
  120. formData: JSON.stringify(this.tableData)
  121. },
  122. function(res) {
  123. self.showSuccess('评价成功!',function(){
  124. self.gotoPage('/pages/order/myorder', 'redirect');
  125. });
  126. }
  127. );
  128. },
  129. /*打开上传图片*/
  130. openUpload(index) {
  131. this.index = index;
  132. this.isUpload = true;
  133. },
  134. /*获取上传的图片*/
  135. getImgsFunc(e) {
  136. let self = this;
  137. if(e&&typeof(e)!='undefined'){
  138. let index = self.index;
  139. self.tableData[index].image_list = self.tableData[index].image_list.concat(e);
  140. }
  141. self.isUpload = false;
  142. },
  143. /*点击图片删除*/
  144. deleteImg(i,n){
  145. this.tableData[i].image_list.splice(n,1);
  146. }
  147. }
  148. };
  149. </script>
  150. <style>
  151. .evaluate {
  152. /* background: #eeeeee; */
  153. }
  154. .evaluate-item {
  155. margin-bottom: 20rpx;
  156. background: #ffffff;
  157. border-bottom: 1px solid #dddddd;
  158. }
  159. .product .cover,
  160. .product .cover image {
  161. width: 160rpx;
  162. height: 160rpx;
  163. }
  164. .evaluate .grade .item .iconfont {
  165. width: 60rpx;
  166. height: 60rpx;
  167. line-height: 60rpx;
  168. border-radius: 50%;
  169. font-size: 40rpx;
  170. color: #ffffff;
  171. text-align: center;
  172. }
  173. .evaluate .grade .item {
  174. height: 60rpx;
  175. padding-right: 20rpx;
  176. line-height: 60rpx;
  177. border-radius: 30rpx;
  178. transition: background-color 0.4s;
  179. }
  180. .evaluate .grade .flex-1:nth-child(1) .iconfont {
  181. background: #f42222;
  182. }
  183. .evaluate .grade .flex-1:nth-child(2) .iconfont {
  184. background: #f2b509;
  185. }
  186. .evaluate .grade .flex-1:nth-child(3) .iconfont {
  187. background: #999999;
  188. }
  189. .evaluate .grade .flex-1.active:nth-child(1) .item {
  190. background: #f42222;
  191. color: #ffffff;
  192. }
  193. .evaluate .grade .flex-1.active:nth-child(2) .item {
  194. background: #f2b509;
  195. color: #ffffff;
  196. }
  197. .evaluate .grade .flex-1.active:nth-child(3) .item {
  198. background: #999999;
  199. color: #ffffff;
  200. }
  201. </style>