appraise.vue 11 KB

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