add.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <view >
  3. <uni-forms ref="form" :model="datainfo">
  4. <view class="address">
  5. <view class="adrbox flex1 flexdc">
  6. <view class="flex1">
  7. <view class="chtop flexc">
  8. <view class="line"></view>
  9. <view class="tit">基本信息</view>
  10. <view class="flex1"></view>
  11. <view class="voice">
  12. <view class="flexc" @click="getVoiceFn">
  13. <image :src="voice"></image>
  14. 语音输入
  15. </view>
  16. </view>
  17. </view>
  18. <view class="plr15">
  19. </uni-forms-item>
  20. <!-- <uni-forms-item label="标题" required name="title">
  21. <view class="flexc">
  22. <uni-easyinput v-model="datainfo.title" :inputBorder='false' placeholder="请输入标题信息" />
  23. <view class="rimg"></view>
  24. </view>
  25. </uni-forms-item> -->
  26. <uni-easyinput type="textarea" maxlength="200" autoHeight v-model="datainfo.content" :inputBorder='false' placeholder="请详细描述您的投诉建议内容(最多可输入200字哦)" />
  27. <!-- <view class="voice mb28">
  28. <view class="flexc" @click="getVoiceFn">
  29. <image :src="voice"></image>
  30. 语音输入
  31. </view>
  32. </view> -->
  33. </view>
  34. <!-- 图片 -->
  35. <view class="imgs">
  36. <!-- <view class="img" @click="getPreview">
  37. <image :src="photo" class="pico"></image>
  38. <image :src="del" class="del" @click="getDelFn"></image>
  39. </view> -->
  40. <block v-if="phofile&&phofile.length">
  41. <view class="img" v-for="(ite,idx) in phofile" :key="idx" @click="getPreview(idx,phofile)">
  42. <image :src="baseUrl+ite" class="pico"></image>
  43. <image :src="del" class="del" @click.stop="getDelFn(idx)"></image>
  44. </view>
  45. </block>
  46. <view class="addbox" @click="getaddImage">
  47. <image :src="photo" class="pico"></image>
  48. <view>添加图片</view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="plr15 flex0 mt30">
  53. <view class="rhbtn " @click="getSubmit">提交信息</view>
  54. </view>
  55. </view>
  56. </view>
  57. </uni-forms>
  58. <loading></loading>
  59. <voice-input :voiceflag="voiceflag" @getVoice="getVoice" @getClose="getvoiceClose"></voice-input>
  60. </view>
  61. </template>
  62. <script>
  63. import config from '@/config.js'
  64. import { checkPermi,checkRole } from "@/utils/permission"; // 权限判断函数
  65. import {uploadIdentify,uploadmore} from '@/utils/common.js'
  66. import {suggestionAdd,suggestionlPut} from "@/api/work/news.js"
  67. import voiceInput from "@/news/components/popup/voice.vue"
  68. export default{
  69. components:{voiceInput},
  70. data(){
  71. return{
  72. rimg:require('@/static/images/rimg.png'),
  73. check: require('@/mine/static/check.png'),
  74. ncheck: require('@/mine/static/ncheck.png'),
  75. voice: require('@/work/static/voice.png'),
  76. photo:require("@/work/static/service/photo.png"),
  77. del:require('@/work/static/service/rdel.png'),
  78. datainfo:{
  79. // "suggestionId":"投诉建议ID",
  80. "title":"",//投诉建议标题
  81. "content":"",//投诉建议内容
  82. "images":"",//投诉照片
  83. // "status":"投诉建议状态:pending(待回复)、replied(已回复)",
  84. "replyContent":"",//投诉建议的回复内容
  85. // "type":"投诉建议类型",
  86. // "isPublic":"投诉建议是否公开:Y(公开)、N(不公开)",
  87. // "isDel":"是否删除:Y(删除)、N(不删除)"
  88. },
  89. phofile:[],
  90. baseUrl:config.baseUrl,
  91. voiceflag:false,
  92. }
  93. },
  94. onLoad: function() {
  95. },
  96. methods:{
  97. checkPermi,checkRole,
  98. getAddFn(){
  99. // this.$tab.navigateTo("/mine/pages/house/addaddress")
  100. },
  101. getVoiceFn(){
  102. this.voiceflag=true;
  103. },
  104. getvoiceClose(){
  105. this.voiceflag=false;
  106. },
  107. getVoice(data){
  108. this.datainfo.content=data;
  109. },
  110. getTabFn(val){
  111. this.tabval=val
  112. },
  113. getDataFn(){
  114. return
  115. var params={
  116. pageSize:this.pageSize,
  117. pageNum: this.pageNum,
  118. }
  119. params.noticeType=this.tabidx
  120. getNoticeList(params).then(res=>{
  121. if(res.code==200){
  122. }else{
  123. this.$toast(res.msg)
  124. }
  125. })
  126. },
  127. getSubmit(){
  128. var that=this;
  129. var params=JSON.parse(JSON.stringify(this.datainfo))
  130. var phofile=JSON.parse(JSON.stringify(this.phofile))
  131. if(phofile&&phofile.length){
  132. params.images=this.phofile.join(',');
  133. }
  134. if(!params.title){
  135. this.$toast("请输入标题")
  136. return
  137. }
  138. suggestionAdd(params).then(res=>{
  139. if(res.code==200){
  140. this.$toast("新增成功")
  141. setTimeout(function(){
  142. uni.$emit("refSuggestion")
  143. uni.navigateBack({
  144. delta:1
  145. })
  146. },1500)
  147. }
  148. })
  149. },
  150. getPreview(idx,arr) {
  151. var newArr=[];
  152. arr.forEach(ite=>{
  153. var ds=this.baseUrl+ite
  154. newArr.push(ds)
  155. })
  156. uni.previewImage({
  157. urls: newArr,
  158. current:idx,
  159. success: function(data) {},
  160. fail: function(err) {}
  161. });
  162. },
  163. getDelFn(idx){
  164. var that=this;
  165. uni.showModal({
  166. title: '确认删除',
  167. content: "是否确认删除",
  168. cancelText: '取消',
  169. confirmText: '确认',
  170. success: function(res) {
  171. if (res.confirm) {
  172. that.phofile.splice(idx,1)
  173. } else if (res.cancel) {
  174. }
  175. }
  176. });
  177. },
  178. getaddImage(e){
  179. let that = this;
  180. let file =[],count=9
  181. uni.chooseImage({
  182. // count: 1,
  183. success:function(res){
  184. let img= res.tempFilePaths;
  185. if(img.length + file.length > count){
  186. uni.showToast({
  187. title: '最多上传'+count+'张图片',
  188. icon: 'none',
  189. duration: 2000
  190. })
  191. }else{
  192. let imglen = res.tempFilePaths.length;
  193. var fuwufile = [];
  194. uploadmore('/common/upload',img,0,0,0,imglen,fuwufile,function(rs){
  195. that.phofile = that.phofile.concat(rs);
  196. })
  197. }
  198. }
  199. });
  200. },
  201. getSeep(){
  202. // #ifdef MP-WEIXIN
  203. wx.startRecord({
  204. success(res) {
  205. const tempFilePath = res.tempFilePath;
  206. wx.translateVoice({
  207. localId: tempFilePath,
  208. isShowProgressTips: 1,
  209. success(res) {
  210. const text = res.translateResult;
  211. console.log('识别结果:', text);
  212. }
  213. });
  214. }
  215. });
  216. // #endif
  217. }
  218. }
  219. }
  220. </script>
  221. <style>
  222. page{background: #F3F3F0;}
  223. </style>
  224. <style lang="scss" scoped>
  225. .address /deep/ .uni-forms-item{min-height: 106rpx;box-sizing: border-box;display: flex;align-items: center;margin-bottom: 0;border-bottom: 2rpx solid #E6E6E6;padding:10rpx 0;}
  226. .address /deep/ .uni-forms-item:last-child{border-bottom: none;}
  227. .address /deep/ .uni-forms-item__label{font-weight: bold;font-size: 26rpx;color: #222327;flex: 0 0 auto;width: auto !important;padding-left: 12rpx;}
  228. .address /deep/ .uni-easyinput{flex: 1;text-align: right;font-size: 26rpx;color: #222327;}
  229. .address /deep/ .uni-easyinput__content-textarea{min-height: 140rpx;font-size: 26rpx;
  230. border-radius: 10rpx;padding: 20rpx 14rpx;text-align: left;}
  231. .address /deep/ .uni-easyinput__placeholder-class{font-size: 26rpx;color: #AAAAAA;}
  232. .address /deep/ .uni-input-input{font-size: 26rpx;}
  233. .address /deep/ .uni-textarea-textarea{font-size: 26rpx;}
  234. .address /deep/ .is-required{font-size: 26rpx;color: #F40027;margin-right: 4rpx;}
  235. .address /deep/ .is-disabled{color: #222327;background-color: #ffffff !important;}
  236. .address{min-height: 100vh;padding: 20rpx 18rpx 30rpx;display: flex;flex-direction: column;}
  237. .adrbox{background: #FFFFFF;border-radius: 20rpx;padding-bottom: 100rpx;
  238. .rimg{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;
  239. image{width: 100%;height: 100%;}
  240. }
  241. &.mjbox{
  242. padding: 36rpx 24rpx 18rpx;
  243. .tit{font-weight: bold;font-size: 26rpx;color: #272727;padding-left: 18rpx;}
  244. .adrlist{
  245. view{font-weight: bold;font-size: 26rpx;color: #666666;min-width: 198rpx;padding: 0 10rpx;box-sizing: border-box;margin: 0 12rpx 24rpx;height: 64rpx;display: flex;align-items: center;justify-content: center;border-radius: 10rpx;border: 2rpx solid #C1C1C1;
  246. &.act{background: #DFEAFF;border: 2rpx solid #0256FD;color: #0256FD;}
  247. }
  248. }
  249. }
  250. .chtop{margin-bottom: 8rpx;padding-top: 32rpx;padding-right: 36rpx;
  251. .tit{font-weight: bold;font-size: 28rpx;color: #272727;}
  252. .line{width: 14rpx;height: 48rpx;background: #0256FD;border-radius:0 12rpx 12rpx 0;margin-right: 18rpx;}
  253. }
  254. .imgs{display: flex;align-items: center;flex-wrap: wrap;padding: 0 24rpx;
  255. .img{width: 142rpx;height:142rpx;border-radius: 20rpx;margin: 0 12rpx 20rpx 12rpx;position: relative;
  256. // &:nth-of-type(2n){margin-right: 0;}
  257. }
  258. .pico{width: 100%;height: 100%;border-radius: 20rpx;}
  259. .del{width: 24rpx;height: 24rpx;position: absolute;right: 0;top: 0;}
  260. .addbox{background: #F0F0F0;border-radius: 20rpx;display: flex;align-items: center;flex-direction: column;width: 142rpx;height:142rpx;justify-content: center;margin:0 12rpx 20rpx 12rpx;
  261. image{width: 48rpx;height: 42rpx;margin-bottom: 12rpx;}
  262. view{font-weight: 500;font-size: 24rpx;color: #666666;}
  263. }
  264. }
  265. .checkimg{width: 80rpx;height: 40rpx;margin-right: 8rpx;}
  266. }
  267. // margin-top: 40rpx;
  268. .voice{font-weight: 500;display: flex;justify-content:flex-end;align-items: center;font-size: 24rpx;color: #45CB99;
  269. image{width: 24rpx;height: 24rpx;margin-right: 8rpx;}
  270. }
  271. </style>