pinglun.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <view>
  3. <view style="width: 95%;height: 180upx;background: #FFFFFF; border-radius: 20upx;padding: 20upx;margin: 20upx;">
  4. <view style="display: flex;margin: 15upx 0 0 20upx;">
  5. <image :src="list.img" style="width: 20%; height: 120upx;"></image>
  6. <view style="margin-left: 20upx;width: 75%;">
  7. <view style="font-size: 34upx;color: #FF332F;font-weight: bold;margin-top: 10upx;">¥ {{list.price}}</view>
  8. <view style="width: 100%;margin-top: 10upx;font-size: 28upx;color: #333333;font-weight: 500;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">{{list.title}}</view>
  9. </view>
  10. </view>
  11. </view>
  12. <view style="background: #FFFFFF;padding: 20upx;margin: 20upx;width: 95%;border-radius: 20rpx;">
  13. <view style="font-size: 32rpx;color: #333333;">分享你的使用体验吧</view>
  14. <view class="orang-view">
  15. <view><textarea placeholder="写出您的感受,可以帮助更多小伙伴哦~" v-model="content" style="color: #999999;font-size: 26rpx;width: 100%;" /></view>
  16. </view>
  17. <view class="header-ping">
  18. <text class="quanbu2" style="font-weight: bold;">
  19. 服务评分
  20. </text>
  21. <view class="feedback-star-view">
  22. <text class="feedback-star" style="font-size: 42upx;" v-for="(value, key) in stars" :key="key" :class="key < score ? 'active' : ''"
  23. @tap="chooseStar(value)"></text>
  24. </view>
  25. <text style="color: #999999;font-size: 28upx;text-align: right;margin-left: 20upx;width: 24%;">{{evaluate}}</text>
  26. </view>
  27. <shmily-drag-image :list.sync="imageList"></shmily-drag-image>
  28. </view>
  29. <button style="background-color: #20C675;width: 690upx;color: #FFFFFF;border-radius: 20rpx;margin-top: 40rpx;" @click='addPinglun()'>发布评论</button>
  30. </view>
  31. </template>
  32. <script>
  33. import shmilyDragImage from '@/components/shmily-drag-image/shmily-drag-image.vue'
  34. export default {
  35. components: {
  36. shmilyDragImage
  37. },
  38. data() {
  39. return {
  40. stars: [1, 2, 3, 4, 5],
  41. imageList: [],
  42. userImage:'',
  43. userName:'',
  44. userId:'',
  45. content:'',
  46. list:[],
  47. evaluate:'',
  48. score: 0
  49. };
  50. },
  51. onLoad(d) {
  52. let ordersId = d.ordersId;
  53. this.userId = this.$queue.getData('userId');
  54. if(this.userId){
  55. this.getUserInfo();
  56. }
  57. if(ordersId){
  58. this.getListById(ordersId);
  59. }
  60. },
  61. methods: {
  62. chooseStar(e) {
  63. this.score = e;
  64. // 1非常差,2差,3,一般,4好,5非常好
  65. if(e==1){
  66. this.evaluate='非常不满意'
  67. }else if(e==2){
  68. this.evaluate='不满意'
  69. }else if(e==3){
  70. this.evaluate='一般满意'
  71. }else if(e==4){
  72. this.evaluate='满意'
  73. }else if(e==5){
  74. this.evaluate='非常满意'
  75. }
  76. },
  77. getUserInfo() {
  78. this.$Request.get("/app/user/selectUserById").then(res => {
  79. if (res.code == 0) {
  80. this.userName = res.data.userName
  81. this.userImage = res.data.avatar
  82. }
  83. });
  84. },
  85. getListById(id) {
  86. uni.showLoading({
  87. title: '加载中...'
  88. });
  89. this.$Request.getT('/app/orders/find?id=' + id).then(res => {
  90. if (res.status === 0) {
  91. this.list = res.data;
  92. }
  93. uni.hideLoading();
  94. });
  95. },
  96. addPinglun(){
  97. uni.showLoading({
  98. title: '加载中...'
  99. });
  100. var image = '';
  101. for (var i = 0; i < this.imageList.length; i++) {
  102. if(i === 0){
  103. image = this.imageList[i];
  104. }else{
  105. image = image + ',' + this.imageList[i];
  106. }
  107. }
  108. if(this.content == ''){
  109. uni.hideLoading();
  110. this.$queue.showToast('评论信息不能为空!');
  111. return;
  112. }
  113. if(this.score === 0){
  114. uni.hideLoading();
  115. this.$queue.showToast('评分不能为空');
  116. return;
  117. }
  118. var scoreType = 0;
  119. if(this.score === 1 || this.score === 2){
  120. scoreType = 3;
  121. }else if(this.score === 3){
  122. scoreType = 2;
  123. }else{
  124. scoreType = 1;
  125. }
  126. let data = {
  127. content:this.content,
  128. goodsId:this.list.goodsId,
  129. img:image,
  130. orderId:this.list.id,
  131. sku:this.list.detailJson,
  132. skuId:this.list.skuId,
  133. score:this.score,
  134. userHeader:this.userImage,
  135. scoreType:scoreType,
  136. userId:this.userId,
  137. userName:this.userName
  138. }
  139. this.$Request.postJson('/app/selfGoodsComment/save',data).then(res =>{
  140. if(res.status === 0){
  141. uni.showToast({
  142. title: '评论成功!'
  143. });
  144. setTimeout(res =>{
  145. uni.hideLoading();
  146. uni.navigateBack();
  147. },1000);
  148. }
  149. });
  150. }
  151. }
  152. };
  153. </script>
  154. <style>
  155. page {
  156. background-color: #F2F2F2;
  157. }
  158. .ping-img{
  159. width: 38upx;height: 38upx; vertical-align: text-top;margin-right: 14upx;
  160. }
  161. .orang-view{
  162. background: #F5F6F8; padding: 20upx;border-radius: 15upx;margin: 20upx 0 40upx;
  163. }
  164. .header-ping{
  165. display: flex;justify-content: space-around;padding-bottom: 20upx;
  166. }
  167. /* 星星 */
  168. @font-face {
  169. font-family: uniicons;
  170. font-weight: normal;
  171. font-style: normal;
  172. src: url('https://img-cdn-qiniu.dcloud.net.cn/fonts/uni.ttf') format('truetype');
  173. }
  174. .ping-view2{font-size: 24upx;color: #999999;margin-top:20upx;}
  175. .feedback-star {
  176. font-family: uniicons;
  177. margin-left: 18upx;
  178. color: #999999;
  179. }
  180. .feedback-star-view {
  181. margin-left: 0upx;
  182. margin-top: -2upx;
  183. }
  184. .feedback-star:after {
  185. content: '\e408';
  186. }
  187. .feedback-star.active {
  188. color: #20C675;
  189. }
  190. .feedback-star.active:after {
  191. content: '\e438';
  192. }
  193. /* 星星 */
  194. </style>