add.vue 8.8 KB

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