complaint.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <view>
  3. <view class="p20 column">
  4. <view class="bg-white p30 radius16">
  5. <view class="bold">投诉类型<text class="color-price">*</text></view>
  6. <view class="justify-start align-center wrap mt20">
  7. <view v-for="(item,index) in cates" :key="index" :class="actsee==item.id?'active':'bg-light fs24 line'"
  8. @click="selectsee(item,index)" class="ptb20 plr30 mr20 radius12 mb20" >{{item.categoryName}}</view>
  9. </view>
  10. </view>
  11. <view class="bg-white p30 radius16 mt30">
  12. <view class="bold">投诉内容<text class="color-price">*</text></view>
  13. <view class="textinput">
  14. <textarea auto-height maxlength='500' placeholder="请输入内容" :value="fconsulting" @input='lookvalue' />
  15. </view>
  16. <view class="justify-between align-center">
  17. <view></view>
  18. <!-- <image src="/static/images/health/voice_icon.png" class="w48 h48"></image> -->
  19. <text class="fs24 color-text1">{{consultingNum}}/500</text>
  20. </view>
  21. </view>
  22. <!-- 多图上传 -->
  23. <view class="bg-white p30 radius16 mt30">
  24. <view class="bold">上传凭证(必传)<text class="color-price">*</text></view>
  25. <view class="justify-start align-center mt20">
  26. <view v-for="(item,index) in imgList" :key="index" @tap="viewImage" :data-url="imgList[index]"
  27. class="justify-start align-center ml20 img-item">
  28. <image :src="item" class="w120 h120 radius8 " mode="aspectFill"></image>
  29. <image class="close-img" src="@/static/images/close32.png" mode="" @tap.stop="delImg" :data-index="index"></image>
  30. </view>
  31. <view class="column align-center bg-light w208 h208 radius8 center" @tap="chooseImage" v-if="imgList.length<3">
  32. <u-icon name="plus" size="16"></u-icon>
  33. <view class="fs28">选择图片</view>
  34. </view>
  35. </view>
  36. <view class="justify-between fs24 color-text1 mt20">
  37. <view>最多上传3张图片</view>
  38. <view><text>{{imgList.length}}</text>/3</view>
  39. </view>
  40. </view>
  41. <view class="bg-white p30 radius16 mt30 align-center">
  42. <view class="bold mr20">联系方式<text class="color-price">*</text></view>
  43. <input maxlength='20' v-model="phone" placeholder="请输入您的手机号码或邮箱" class="flex-1"/>
  44. </view>
  45. <view class="h200"></view>
  46. </view>
  47. <view class="footer center">
  48. <view class="bg-color radius44 color-white h88 lh88 center" style="width: 90%;"
  49. @click="submit">提交</view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import {getuserlist,submitconsult} from '@/api/health.js'
  55. import {getCategory,submitComplaint} from '@/api/companyUser.js'
  56. export default {
  57. data() {
  58. return {
  59. cates:[],
  60. famaleurl:"/static/images/health/female_profile.png",
  61. maleurl:"/static/images/health/male_profile.png",
  62. actitem:null,
  63. type:null,
  64. consulting:null,
  65. consultingNum:0,
  66. actsee:null,
  67. phone:null,
  68. imgList:[],
  69. photos:[]
  70. }
  71. },
  72. onLoad() {
  73. this.getCategory()
  74. },
  75. methods: {
  76. getCategory(){
  77. getCategory().then(res=>{
  78. if(res.code==200){
  79. this.cates=res.data
  80. }else{
  81. uni.showToast({
  82. icon:'none',
  83. title:res.msg,
  84. });
  85. }
  86. },rej => {}
  87. );
  88. },
  89. submit(){
  90. if(this.actsee==null){
  91. uni.showToast({
  92. icon:'none',
  93. title:'请选择投诉类型!',
  94. });
  95. return
  96. }
  97. if(this.consulting==null){
  98. uni.showToast({
  99. icon:'none',
  100. title:'请输入投诉内容!',
  101. });
  102. return
  103. }
  104. if(this.imgList.length==0){
  105. uni.showToast({
  106. icon:'none',
  107. title:'请上传凭证!',
  108. });
  109. return
  110. }
  111. const data={
  112. type: this.actsee,
  113. content: this.consulting,
  114. url: this.photos,
  115. contact:this.phone
  116. }
  117. submitComplaint(data).then(res=>{
  118. if(res.code==200){
  119. uni.showToast({
  120. icon:'none',
  121. title:'提交成功',
  122. });
  123. setTimeout(function() {
  124. uni.$emit('refreshComplaint');
  125. uni.navigateBack({
  126. delta: 1
  127. })
  128. }, 500);
  129. }else{
  130. uni.showToast({
  131. icon:'none',
  132. title:res.msg,
  133. });
  134. }
  135. })
  136. },
  137. lookvalue(e){
  138. this.consulting=e.detail.value
  139. this.consultingNum=e.detail.cursor
  140. if(this.consultingNum==500){
  141. uni.showToast({
  142. icon:'none',
  143. title:'最大输入500字符!',
  144. });
  145. }
  146. },
  147. selectsee(item,index){
  148. this.actsee=item.id
  149. },
  150. // 选择上传的图片
  151. chooseImage() {
  152. console.log('图片')
  153. var that = this;
  154. uni.showActionSheet({
  155. itemList: ['相册', '拍照'],
  156. success: function(res) {
  157. if (res.tapIndex == 0) {
  158. //从相册选择
  159. that.chooseImageFunction('album')
  160. } else if (res.tapIndex == 1) {
  161. //拍照
  162. that.chooseImageFunction('camera')
  163. }
  164. },
  165. fail: function(res) {
  166. }
  167. });
  168. },
  169. chooseImageFunction: function(type) {
  170. var that = this;
  171. uni.chooseImage({
  172. count: 3, // 默认9
  173. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  174. sourceType: [type],
  175. success: (res) => {
  176. uni.uploadFile({
  177. url: uni.getStorageSync('requestPath')+'/app/common/uploadOSS', //仅为示例,非真实的接口地址
  178. filePath: res.tempFilePaths[0],
  179. name: 'file',
  180. formData: {
  181. 'user': 'test' // 上传附带参数
  182. },
  183. success: (uploadFileRes) => {
  184. // 根据接口具体返回格式 赋值具体对应url
  185. if (this.imgList.length != 0) {
  186. this.imgList = this.imgList.concat(res.tempFilePaths)
  187. } else {
  188. this.imgList = res.tempFilePaths
  189. }
  190. this.photos = this.photos.concat(JSON.parse(uploadFileRes.data).url)
  191. }
  192. });
  193. }
  194. });
  195. },
  196. // 查看图片
  197. viewImage(e) {
  198. uni.previewImage({
  199. urls: this.imgList,
  200. current: e.currentTarget.dataset.url
  201. });
  202. },
  203. // 删除上传的图片
  204. delImg(e) {
  205. var that = this;
  206. uni.showModal({
  207. title: '提示',
  208. content: '确定要删除照片吗?',
  209. cancelText: '取消',
  210. confirmText: '确定',
  211. success: res => {
  212. if (res.confirm) {
  213. that.imgList.splice(e.currentTarget.dataset.index, 1)
  214. this.photos.splice(e.currentTarget.dataset.index, 1);
  215. }
  216. },
  217. })
  218. },
  219. }
  220. }
  221. </script>
  222. <style scoped lang="scss">
  223. .peoplebox{
  224. white-space: nowrap;
  225. margin-top: 30rpx;
  226. ::-webkit-scrollbar {
  227. display: none;
  228. }
  229. .scroll-content{
  230. display: flex;
  231. flex-wrap: nowrap;
  232. }
  233. .item-list{
  234. padding: 20rpx 28rpx;
  235. width: fit-content;
  236. display: flex;
  237. justify-content: start;
  238. border-radius: 12rpx;
  239. margin-right: 20rpx;
  240. }
  241. .noact-box{
  242. background-color: #F5F7FA;
  243. }
  244. .act-box{
  245. background-color: #F0FAFF;
  246. border: 2rpx solid #008FD3;
  247. }
  248. }
  249. .line{
  250. border: 2rpx solid #F5F7FA;
  251. }
  252. .active{
  253. font-size: 24rpx;
  254. color: #008FD3;
  255. background: #F0FAFF;
  256. border: 2rpx solid #008FD3;
  257. }
  258. .img-item{
  259. position: relative;
  260. margin-right: 20upx;
  261. .close-img{
  262. width: 32upx;
  263. height: 32upx;
  264. position: absolute;
  265. top:2upx;
  266. right: 2upx;
  267. }
  268. }
  269. .textinput{
  270. margin-top: 30rpx;
  271. height:200rpx;
  272. overflow-y: scroll;
  273. }
  274. .footer{
  275. padding: 40rpx 0;
  276. width: 100%;
  277. position: fixed;
  278. bottom: 0;
  279. background-color: #fff;
  280. z-index:999
  281. }
  282. </style>