evaluate.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <view class="bg">
  3. <view class="header">
  4. <image class="image" :src="image"></image>
  5. <view class="right">
  6. <view class="title">{{title}}</view>
  7. <view class="spec">{{spec}}</view>
  8. </view>
  9. </view>
  10. <view class="rate">
  11. <view class="dec">描述相符</view>
  12. <!-- 自定义星星大小 -->
  13. <uni-rate class="start" active-color="#e64340" margin="10" size="30" :value="rate" @change="start"></uni-rate>
  14. </view>
  15. <view class="comment">
  16. <textarea @input="input" maxlength="300" placeholder="写满20字,有机会被选为优质评价被更多人看到哦~" placeholder-class="placeholder"></textarea>
  17. </view>
  18. <view class="bottom">
  19. <radio class="radio" color="#e64340" :checked='radio' @click="clickRadio" />公开</radio>
  20. <view class="dec">公开头像昵称,大家可以看到我</view>
  21. </view>
  22. <button class="button" @click="submit" type="warn">提交</button>
  23. </view>
  24. </template>
  25. <script>
  26. import uniRate from '@/components/uni-rate/uni-rate.vue'
  27. export default{
  28. computed:{
  29. },
  30. components: {
  31. uniRate
  32. },
  33. data(){
  34. return {
  35. order_id:0,
  36. product_id:0,
  37. title:'',
  38. image:'',
  39. spec:'',
  40. rate:5,
  41. radio:true,
  42. textarea:''
  43. }
  44. },
  45. onLoad(options) {
  46. this.title = options.title;
  47. this.image = options.image;
  48. this.spec = options.spec;
  49. this.order_id = options.order_id;
  50. this.product_id = options.product_id;
  51. },
  52. methods:{
  53. // 星星
  54. start(e) {
  55. this.rate = e.value;
  56. switch (this.rate) {
  57. case 3:
  58. this.radio = false;
  59. break;
  60. case 5:
  61. this.radio = true;
  62. break;
  63. }
  64. },
  65. // 单选
  66. clickRadio(e) {
  67. this.radio = !this.radio;
  68. },
  69. // 输入事件
  70. input(e) {
  71. this.textarea = e.detail.value;
  72. },
  73. // 提交
  74. async submit(){
  75. let data = this.$api.request('/order/comment', 'POST',
  76. {
  77. order_id:this.order_id,
  78. product_id:this.product_id,
  79. rate:this.rate,
  80. anonymous:!this.radio ? 1: 0,
  81. comment:this.textarea,
  82. });
  83. if (data) {
  84. let prePage = this.$api.prePage()
  85. if (prePage.tabCurrentIndex) {
  86. prePage.tabCurrentIndex = 0;
  87. }
  88. let that = this;
  89. setTimeout(function(){
  90. prePage.pullDownRefresh();
  91. uni.navigateBack();
  92. },2000)
  93. }
  94. }
  95. }
  96. }
  97. </script>
  98. <style lang="scss">
  99. page{
  100. background: #f5f5f5;
  101. }
  102. .bg{
  103. margin: 20rpx;
  104. border-radius: 20rpx;
  105. background-color: #ffffff;
  106. padding-bottom: 10rpx;
  107. }
  108. .header {
  109. padding: 20rpx;
  110. .image{
  111. width: 120rpx;
  112. height: 120rpx;
  113. }
  114. .right{
  115. display: inline-block;
  116. line-height: 45rpx;
  117. vertical-align: text-bottom;
  118. padding-bottom: 10rpx;
  119. width: 550rpx;
  120. padding-left:20rpx;
  121. .title{
  122. color: #707277;
  123. font-size: 33rpx;
  124. text-overflow: ellipsis;
  125. white-space: nowrap;
  126. overflow: hidden;
  127. }
  128. .spec{
  129. color: #91949a;
  130. font-size: 30rpx;
  131. }
  132. }
  133. }
  134. .rate{
  135. padding:0 20rpx 20rpx;
  136. .dec{
  137. display: inline-block;
  138. color: #707277;
  139. }
  140. .start{
  141. width: 400rpx;
  142. display: inline-block;
  143. }
  144. }
  145. .comment{
  146. padding: 20rpx;
  147. textarea{
  148. padding: 30rpx;
  149. background-color: #f5f5f5;
  150. width: 100%;
  151. }
  152. }
  153. .bottom{
  154. padding: 20rpx 20rpx 40rpx;
  155. .radio{
  156. vertical-align: bottom;
  157. float: left;
  158. }
  159. .dec{
  160. color: #91949a;
  161. float: right;
  162. }
  163. }
  164. .button{
  165. margin: 20rpx;
  166. }
  167. </style>