appraise.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <app-layout>
  3. <view v-if="is_show" class='appraise-box'>
  4. <form class='form-box'>
  5. <view v-for='item in appraiseData' :key='item.id' class='item-box'>
  6. <view class='dir-left-nowrap'>
  7. <view class='box-grow-0'>
  8. <image class='goods_pic' mode="aspectFill" :src='item.goods_pic_url'></image>
  9. </view>
  10. <view class='box-grow-1 dir-left-nowrap cross-center'>
  11. <text class='box-grow-1 t-omit goods_name'>{{item.goods_name}}</text>
  12. <view class="box-grow-0" @click='checkedChange(item)'>
  13. <image v-if='item.is_anonymous' class='check-icon'
  14. src='/static/image/icon/order/icon-checkbox-checked.png'></image>
  15. <image v-else class='check-icon' src='/static/image/icon/form-er.png'></image>
  16. </view>
  17. <view @click='checkedChange(item)' class='anonymous-text box-grow-0'>匿名评价</view>
  18. </view>
  19. </view>
  20. <view class='dir-left-nowrap grade-box'>
  21. <view @click='grade(gradeItem,item,index)' v-for='(gradeItem, index) in item.grade'
  22. :key='gradeItem.id'
  23. class='dir-top-nowrap box-grow-1 cross-center main-center grade-item'>
  24. <image v-if="gradeItem.id == 1" class='grade-icon'
  25. :src='gradeItem.active ? scoreImg.score_1_active : scoreImg.score_1'></image>
  26. <image v-if="gradeItem.id == 2" class='grade-icon'
  27. :src='gradeItem.active ? scoreImg.score_2_active : scoreImg.score_2'></image>
  28. <image v-if="gradeItem.id == 3" class='grade-icon'
  29. :src='gradeItem.active ? scoreImg.score_3_active : scoreImg.score_3'></image>
  30. <text :style="{'color':gradeItem.active ? gradeItem.text_color : ''}"
  31. class="title"
  32. :class="{'active-title': gradeItem.active ? true : false}">
  33. {{gradeItem.title}}
  34. </text>
  35. </view>
  36. </view>
  37. <view class='content-box'>
  38. <view class='box-grow-1'>
  39. <textarea class='content' v-model="item.content" placeholder="请输入评价内容" auto-height></textarea>
  40. </view>
  41. </view>
  42. <view class='image-box'>
  43. <app-upload-image
  44. :sign='item.id'
  45. @imageEvent='imageEvent'
  46. :count="6"
  47. :maxNum='maxNum'>
  48. </app-upload-image>
  49. </view>
  50. </view>
  51. <button v-if='appraiseData.length' class='btn' @click="formSubmit">提交</button>
  52. </form>
  53. </view>
  54. </app-layout>
  55. </template>
  56. <script>
  57. import { mapGetters, mapState } from "vuex";
  58. import AppUploadImage from "../../../components/basic-component/app-upload-image/app-upload-image.vue";
  59. export default {
  60. components: {
  61. 'app-upload-image': AppUploadImage,
  62. },
  63. data() {
  64. return {
  65. id: null,
  66. maxNum: 6, //最大图片上传数量
  67. appraiseData: [],
  68. is_show: false,
  69. }
  70. },
  71. computed: {
  72. ...mapState({
  73. scoreImg: state => state.mallConfig.__wxapp_img.mall,
  74. })
  75. },
  76. methods: {
  77. getOrderDetail() {
  78. let self = this;
  79. self.$showLoading();
  80. self.$request({
  81. url: self.$api.order.detail,
  82. data: {
  83. id: this.id
  84. }
  85. }).then(response => {
  86. self.$hideLoading();
  87. if (response.code === 0) {
  88. let detail = response.data.detail;
  89. let appraise = [];
  90. detail.detail.forEach(function (item) {
  91. appraise.push({
  92. id: item.id,
  93. goods_pic_url: item.goods_info.pic_url ? item.goods_info.pic_url : item.goods.goodsWarehouse.cover_pic,
  94. goods_name: item.goods.goodsWarehouse.name,
  95. content: '',
  96. pic_list: [],
  97. grade: [
  98. {
  99. id: 3,
  100. title: '好评',
  101. active: true,
  102. text_color: '#ff4544'
  103. },
  104. {
  105. id: 2,
  106. title: '中评',
  107. active: false,
  108. text_color: '#ff964a'
  109. },
  110. {
  111. id: 1,
  112. title: '差评',
  113. active: false,
  114. text_color: '#606e78'
  115. },
  116. ],
  117. grade_level: 3,
  118. is_anonymous: false,
  119. })
  120. });
  121. self.appraiseData = appraise;
  122. self.is_show = true;
  123. } else {
  124. uni.showModal({
  125. title: '',
  126. content: response.msg,
  127. showCancel: false,
  128. });
  129. uni.navigateBack();
  130. }
  131. }).catch(() => {
  132. self.$hideLoading();
  133. });
  134. },
  135. // 上传图片
  136. imageEvent(e) {
  137. let self = this;
  138. let sign = e.sign;
  139. let imageList = e.imageList;
  140. self.appraiseData.forEach(item => {
  141. if (item.id === sign) {
  142. item.pic_list = imageList;
  143. return false;
  144. }
  145. });
  146. this.appraiseData = self.appraiseData;
  147. },
  148. // 订单评分
  149. grade(gradeItem, item, index) {
  150. item.grade.forEach(aItem => {
  151. aItem.active = false;
  152. });
  153. gradeItem.active = true;
  154. if (index == 0) {
  155. item.grade_level = 3;
  156. }
  157. if (index == 1) {
  158. item.grade_level = 2;
  159. }
  160. if (index == 2) {
  161. item.grade_level = 1;
  162. }
  163. },
  164. checkedChange(item) {
  165. item.is_anonymous = !item.is_anonymous;
  166. },
  167. formSubmit() {
  168. let self = this;
  169. uni.showLoading({title: '提交中'});
  170. self.$request({
  171. url: self.$api.order.appraise,
  172. method: 'post',
  173. data: {
  174. appraiseData: JSON.stringify(self.appraiseData),
  175. order_id: self.id,
  176. },
  177. }).then(response => {
  178. uni.hideLoading();
  179. if (response.code === 0) {
  180. uni.redirectTo({
  181. url: `/pages/order/appraise-finish/index?id=${self.id}`,
  182. });
  183. } else {
  184. uni.showModal({
  185. title: '',
  186. content: response.msg,
  187. showCancel: false
  188. })
  189. }
  190. }).catch(() => {
  191. uni.hideLoading();
  192. });
  193. },
  194. // 输入框事件
  195. inputEvent(value) {
  196. let self = this;
  197. let id = value.id;
  198. let content = value.value;
  199. self.appraiseData.forEach(item => {
  200. if (item.id == id) {
  201. item.content = content;
  202. return;
  203. }
  204. });
  205. this.appraiseData = self.appraiseData
  206. }
  207. },
  208. onLoad(options) { this.$commonLoad.onload(options);
  209. this.id = options.id;
  210. this.getOrderDetail();
  211. }
  212. }
  213. </script>
  214. <style lang="scss" scoped>
  215. .appraise-box {
  216. margin: 24#{rpx};
  217. }
  218. .form-box .item-box {
  219. border-radius: 15#{rpx};
  220. background-color: #ffffff;
  221. padding: 24#{rpx} 20#{rpx};
  222. width: 100%;
  223. margin-bottom: 24#{rpx};
  224. }
  225. .form-box .goods_pic {
  226. width: 100#{rpx};
  227. height: 100#{rpx};
  228. }
  229. .form-box .goods_name {
  230. margin-left: 16#{rpx};
  231. }
  232. .form-box .anonymous-text {
  233. font-size: $uni-font-size-weak-two;
  234. color: $uni-general-color-two;
  235. }
  236. .form-box .grade-box {
  237. margin: 32#{rpx} 24#{rpx};
  238. }
  239. .form-box .grade-icon {
  240. width: 68#{rpx};
  241. height: 68#{rpx};
  242. }
  243. .form-box .grade-item {
  244. height: 100%;
  245. }
  246. .form-box .grade-item .title {
  247. margin-top: 12#{rpx};
  248. }
  249. .form-box .grade-item .active-title {
  250. color: $uni-important-color-red;
  251. }
  252. .form-box .content-box {
  253. background-color: $uni-weak-color-two;
  254. margin-top: 20#{rpx};
  255. padding: 24#{rpx} 24#{rpx} 0;
  256. border-top-left-radius: 5#{rpx};
  257. border-top-right-radius: 5#{rpx};
  258. }
  259. .form-box .content {
  260. height: 100%;
  261. width: 100%;
  262. }
  263. .form-box .image-box {
  264. padding: 24#{rpx};
  265. background-color: $uni-weak-color-two;
  266. border-bottom-left-radius: 5#{rpx};
  267. border-bottom-right-radius: 5#{rpx};
  268. }
  269. .form-box .btn {
  270. background-color: $uni-important-color-red;
  271. border-radius: 40#{rpx};
  272. color: #fff;
  273. width: 100%;
  274. margin-top: 50#{rpx};
  275. }
  276. .form-box .check-icon {
  277. width: 28#{rpx};
  278. height: 28#{rpx};
  279. margin-right: 8#{rpx};
  280. margin-top: 5#{rpx};
  281. }
  282. </style>