to_evaluate.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view>
  3. <view class="fllow_form">
  4. <view class="label key">{{i18n['是否解决问题']}}</view>
  5. <view class="form_right">
  6. <radio-group @change="radioChange" class="radiowarp">
  7. <view class="radiobox" v-for="(item, index) in type" :key="index">
  8. <radio :value="item.id" color="#0287FF" :checked="item.id === typeIndex" />
  9. <view>{{item.name}}</view>
  10. </view>
  11. </radio-group>
  12. </view>
  13. </view>
  14. <view class="fllow_form">
  15. <view class="label key">{{i18n['评分']}}</view>
  16. <view class="form_right">
  17. <uni-rate :value="comment_score" @change="onChange" />
  18. </view>
  19. </view>
  20. <view class="inp_warp" style="margin-top:0;">
  21. <view class="inp_title">{{i18n['附件']}}:</view>
  22. <view class="form_right" @click="uploadFiles">
  23. <view class="righttext">{{i18n['上传图片']}}</view>
  24. <view class="iconfont icon-arrows_right"></view>
  25. </view>
  26. </view>
  27. <view class="imglist" v-if="imgList.length != 0">
  28. <view class="imgbox" v-for="(item,index) in imgList" :key="index">
  29. <image src="/static/img/close.png" class="delimg" @click="delImg(index)" mode=""></image>
  30. <image :src="item.url" class="selfimg" mode=""></image>
  31. </view>
  32. </view>
  33. <view class="fllow_area">
  34. <view class="area_head key">{{i18n['情况描述']}}</view>
  35. <textarea v-model="comment_content" class="textself" :placeholder="i18n['情况描述']" placeholder-style="color:#999" />
  36. </view>
  37. <view class="button" @click="$noMultipleClicks(toSubEvaluate)">{{i18n['确定']}}</view>
  38. </view>
  39. </template>
  40. <script>
  41. import { BASE_URL, SIGN_NO } from '@/api/http.js'
  42. import { netAddEvaluate, uploadUrl } from '@/api/api.js'
  43. export default{
  44. data() {
  45. return{
  46. noClick:true, //防止 重复点击
  47. is_resolved:1, //1是 2否
  48. comment_score:1, //评分
  49. comment_content:'', //评价内容
  50. comment_files:'', //附件
  51. id:'',
  52. type:[],
  53. typeIndex:0,
  54. imgList:[],
  55. }
  56. },
  57. computed:{
  58. i18n() {
  59. return this.$t("evaluate")
  60. }
  61. },
  62. onShow() {
  63. this.type = this.i18n['type']
  64. uni.setNavigationBarTitle({
  65. title: this.i18n['去评价']
  66. })
  67. },
  68. onLoad(options) {
  69. this.id = options.id
  70. },
  71. methods:{
  72. //评分
  73. onChange(e) {
  74. console.log(e,'===')
  75. this.comment_score = e.value
  76. },
  77. radioChange(e) {
  78. console.log(e,'是否解决问题')
  79. this.is_resolved = e.detail.value
  80. },
  81. //上传图片
  82. uploadFiles() {
  83. uni.chooseImage({
  84. count: 9,
  85. success: (res) => {
  86. console.log(res)
  87. let file = res.tempFilePaths
  88. file.forEach(ele=>{
  89. this.toUpload(ele)
  90. })
  91. }
  92. })
  93. },
  94. toUpload(file) {
  95. uni.uploadFile({
  96. url:uploadUrl,
  97. name: 'file',
  98. header: {
  99. 'token': uni.getStorageSync('token'),
  100. 'sign-no': SIGN_NO
  101. },
  102. filePath: file,
  103. success: (res) => {
  104. let data = JSON.parse(res.data)
  105. if (data.code == 1) {
  106. this.imgList.push(data.data)
  107. } else {
  108. uni.showToast({
  109. title: '上传失败',
  110. icon: 'none'
  111. })
  112. }
  113. },
  114. fail: (err) => {
  115. console.log(err)
  116. }
  117. })
  118. },
  119. delImg(index) {
  120. this.imgList.splice(index, 1)
  121. },
  122. toSubEvaluate() {
  123. let arr = this.imgList
  124. let newArr = []
  125. arr.forEach(ele=>{
  126. newArr.push(ele.id)
  127. })
  128. let params = {
  129. id:this.id,
  130. is_resolved: this.is_resolved,
  131. comment_score: this.comment_score,
  132. comment_content: this.comment_content,
  133. comment_files: newArr.join(',')
  134. }
  135. netAddEvaluate(params).then(res=>{
  136. uni.showToast({
  137. title:res.msg,
  138. icon:'none'
  139. })
  140. setTimeout(()=>{
  141. uni.navigateBack({
  142. delta:1
  143. })
  144. },2000)
  145. })
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. .radiowarp{
  152. display: flex;
  153. justify-content: flex-end;
  154. align-items: center;
  155. .radiobox{
  156. display: flex;
  157. justify-content: center;
  158. align-items: center;
  159. radio{
  160. transform: scale(0.7);
  161. }
  162. }
  163. }
  164. .fllow_form {
  165. display: flex;
  166. justify-content: space-between;
  167. background-color: #fff;
  168. border-bottom: 1rpx solid #EAEAEA;
  169. padding:24rpx 45rpx 24rpx 50rpx;
  170. .label{
  171. font-size:26rpx;
  172. text{
  173. color:red;
  174. }
  175. }
  176. }
  177. .form_right{
  178. display: flex;
  179. justify-content: flex-end;
  180. align-items: center;
  181. color: #999;
  182. min-width:450rpx;
  183. text-align: right;
  184. .righttext{
  185. font-size:26rpx;
  186. }
  187. }
  188. .fllow_area {
  189. background-color: #fff;
  190. padding:24rpx 45rpx 24rpx 50rpx;
  191. margin-bottom: 30rpx;
  192. .area_head {
  193. height: 100rpx;
  194. font-size:26rpx;
  195. line-height: 100rpx;
  196. }
  197. .textself {
  198. width:660rpx;
  199. height: 230rpx;
  200. background:rgba(202, 202, 202, 0.2);
  201. box-sizing: border-box;
  202. padding:24rpx;
  203. font-size:26rpx;
  204. margin: 0 auto;
  205. border-radius: 20rpx;
  206. }
  207. }
  208. .inp_warp {
  209. padding:24rpx 45rpx 24rpx 50rpx;
  210. background: #fff;
  211. display: flex;
  212. justify-content: space-between;
  213. align-items: center;
  214. border-bottom: 1rpx solid #f5f5f5;
  215. .inp_title {
  216. font-size: 26rpx;
  217. color: #000;
  218. }
  219. .add_in{
  220. display: flex;
  221. justify-content: flex-end;
  222. align-items: center;
  223. font-size:26rpx;
  224. color:#14C2C1;
  225. .icon-jiahaocu{
  226. font-size:28rpx;
  227. color:#14c2c1;
  228. margin-right:5rpx;
  229. }
  230. }
  231. }
  232. .imglist {
  233. padding: 24rpx 34rpx;
  234. background: #fff;
  235. border-bottom: 1rpx solid #EAEAEA;
  236. display: flex;
  237. justify-content: flex-start;
  238. align-items: center;
  239. flex-wrap: wrap;
  240. .imgbox {
  241. width: 160rpx;
  242. height: 160rpx;
  243. margin-right: 14rpx;
  244. position: relative;
  245. margin-bottom: 24rpx;
  246. border: 1rpx solid #EAEAEA;
  247. &:nth-child(4n){
  248. margin-right:0;
  249. }
  250. .delimg {
  251. width: 32rpx;
  252. height: 32rpx;
  253. border-radius: 50%;
  254. position: absolute;
  255. right: -16rpx;
  256. top: -16rpx;
  257. background: rgba(0, 0, 0, 0.5);
  258. z-index: 2;
  259. }
  260. .selfimg {
  261. width: 160rpx;
  262. height: 160rpx;
  263. }
  264. }
  265. }
  266. </style>