property.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <view>
  3. <view class="card" >
  4. <view class="form">
  5. <view class="flex">
  6. <view class="need" >*</view>
  7. <view>请选择小区</view>
  8. </view>
  9. <view class="bg-gray padding-20 " @click="residentialShow=true">
  10. <input disabled type="text" placeholder="请选择您所在的小区" v-model="data.residentialName" />
  11. </view>
  12. </view>
  13. <view class="form">
  14. <view class="flex">
  15. <view class="need" >*</view>
  16. <view>报修位置</view>
  17. </view>
  18. <view class="bg-gray padding-20 " >
  19. <input type="text" placeholder="请输入报修的具体位置" v-model="data.reportPosition" />
  20. </view>
  21. </view>
  22. <view class="form ">
  23. <view class="flex">
  24. <view class="need" >*</view>
  25. <view>联系方式</view>
  26. </view>
  27. <view class="bg-gray padding-20 " >
  28. <input maxlength="11" type="number" placeholder="请输入您的联系方式" v-model="data.phone" />
  29. </view>
  30. </view>
  31. <view class="form">
  32. <view class="flex">
  33. <view class="need" >*</view>
  34. <view>预约时间</view>
  35. </view>
  36. <view class="bg-gray padding-20" @click="timeShow=true">
  37. <input disabled type="number" placeholder="请选择预约时间" v-model="dateTimeStr" />
  38. </view>
  39. </view>
  40. </view>
  41. <view class="card ">
  42. <view class="form" style="height: 320rpx;">
  43. <view class="bg-gray padding-10">
  44. <u-input v-model="data.reportDetail" type="textarea" maxlength="100" height="240" placeholder="请填写故障描述" style="width: 100%;line-height: 50rpx;"/>
  45. <!-- <textarea @click="showMask" v-model="data.reportDetail" maxlength="100" style="width: 100%;height: 270rpx;line-height: 50rpx;" placeholder="请填写故障描述"></textarea> -->
  46. <view class="text-right text-df text-gray padding-top-10">
  47. {{data.reportDetail.length}} / 100
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="card">
  53. <view class="text-center padding-20">
  54. <text>上传图片(选填,最多四张)</text>
  55. </view>
  56. <view >
  57. <view class="cu-form-group" style="padding: 20rpx 30rpx">
  58. <view class="grid col-4 grid-square flex-sub padding-left-10">
  59. <view class="bg-img" v-for="(item,index) in imgList" :key="index" @click="viewImage(index)" >
  60. <image :src="imgList[index]" mode="aspectFill"></image>
  61. <view class="cu-tag bg-red" @click.stop="DelImg(index)" >
  62. <text class='cuIcon-close' style="font-size: 20rpx;"></text>
  63. </view>
  64. </view>
  65. <view class="solids" @click="chooseImage" v-if="imgList.length<4">
  66. <text class='cuIcon-add ' style="font-size: 60rpx;color: #c9c9c9;"></text>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <view style="height: 110rpx;"></view>
  73. <view style="z-index: 999;" class=" footer-fixed" @click="submit">
  74. <view class="cu-btn flex text-lg bg-red-btn" style="padding: 46rpx 0;">
  75. 确定提交
  76. </view>
  77. </view>
  78. <u-mask z-index="99999" :show="maskShow" @click="maskShow = false">
  79. <view style="margin: 20rpx;" @click.stop="">
  80. <textarea @confirm="confirm" @keyboardheightchange="keyboardheightchange" v-model="data.reportDetail" value="" style="background-color: #FFFFFF;width: 100%;padding: 20rpx;box-sizing: border-box;" placeholder="请填写故障描述" />
  81. <view class="bg-white text-right text-df text-gray padding-10">
  82. {{data.reportDetail.length}} / 100
  83. </view>
  84. </view>
  85. </u-mask>
  86. <u-popup v-model="timeShow" mode="bottom" border-radius="20" :closeable="true" height="55%">
  87. <time-selector @getDateTime="timeConfirm"></time-selector>
  88. </u-popup>
  89. <u-select :default-value="defaultValue" value-name="residentialId" label-name="residentialName" @confirm="residentialConfirm" z-index="9999999" v-model="residentialShow" :list="residentialList"></u-select>
  90. </view>
  91. </template>
  92. <script>
  93. import timeSelector from '@/comps/mp-time/index.vue';
  94. var app=getApp()
  95. var that;
  96. export default {
  97. components:{
  98. timeSelector
  99. },
  100. data() {
  101. return {
  102. defaultValue:[],
  103. platform:'',
  104. maskShow:false,
  105. //图片回显
  106. imgList:[],
  107. data:{
  108. //处理状态:待处理
  109. handleStatus:0,
  110. //报修用户的memberId
  111. memberId:'',
  112. //userId
  113. userId:'',
  114. //小区id
  115. residentialId:'',
  116. //小区名字
  117. residentialName:'',
  118. //故障位置
  119. reportPosition:'',
  120. //预约时间区间
  121. beginTime:'',
  122. endTime:'',
  123. //联系方式
  124. phone:'',
  125. //故障详情描述
  126. reportDetail:'',
  127. //图片描述
  128. pic:''
  129. },
  130. base64_image:[],
  131. residentialShow:false,
  132. residentialList:[],
  133. timeShow:false,
  134. dateTimeStr:''
  135. }
  136. },
  137. onLoad() {
  138. this.initData()
  139. },
  140. onShow() {
  141. this.data.phone=getApp().globalData.member.tel
  142. },
  143. methods: {
  144. initData(){
  145. that=this
  146. //判断是ios还是安卓,ios键盘上移会挤压遮挡层
  147. this.platform=this.$u.os() || "android"
  148. //获取用户的userid
  149. this.data.userId=app.globalData.userId
  150. //获取用户的memberId
  151. try{
  152. that.data.memberId=app.globalData.member.id
  153. }catch(e){
  154. console.log(e);
  155. }
  156. if (this.$isEmpty(this.data.memberId)) {
  157. console.log("系统异常");
  158. app.globalData.oneFailHint("系统异常",function(){
  159. uni.navigateBack({
  160. delta:1
  161. })
  162. })
  163. return
  164. }
  165. //从缓存中获取房屋列表
  166. this.residentialList=uni.getStorageSync("residentialList")
  167. //从缓存中获取默认的小区名字和小区id
  168. this.data.residentialName=uni.getStorageSync("plotName")
  169. this.data.residentialId=uni.getStorageSync("residentialId")
  170. //社区选择器的默认值
  171. this.residentialList.forEach((item,index)=>{
  172. if (item.residentialId===this.data.residentialId) {
  173. this.defaultValue.push(index)
  174. return
  175. }
  176. })
  177. },
  178. submit(){
  179. if (this.$isEmpty(this.data.residentialName)) {
  180. this.$u.toast("请选择小区")
  181. return
  182. }
  183. if (this.$isEmpty(this.data.reportPosition)) {
  184. this.$u.toast("请填写具体位置")
  185. return
  186. }
  187. if (this.$isEmpty(this.data.phone)) {
  188. this.$u.toast("请输入联系方式")
  189. return
  190. }
  191. if (!this.$u.test.mobile(this.data.phone)) {
  192. this.$u.toast("请输入正确的联系方式")
  193. return
  194. }
  195. if (this.$isEmpty(this.data.beginTime)||this.$isEmpty(this.data.endTime)) {
  196. this.$u.toast("请选择预约时间")
  197. return
  198. }
  199. if (this.$util.createDate(this.data.beginTime).getTime()>
  200. this.$util.createDate(this.data.endTime).getTime()) {
  201. this.$u.toast("开始时间不能小于结束时间")
  202. return
  203. }
  204. if (this.$isEmpty(this.data.reportDetail)) {
  205. this.$u.toast("请输入故障描述")
  206. return
  207. }
  208. this.data.pic=JSON.stringify(this.base64_image)
  209. let operation='estateRepair/addEstateRepair'
  210. console.log(this.data);
  211. app.globalData.postRequest(this.data, operation, function (res) {
  212. if (res.data.add_result) {
  213. app.globalData.oneFailHint("提交成功");
  214. }else{
  215. app.globalData.oneFailHint("提交失败");
  216. }
  217. });
  218. },
  219. showMask(){
  220. console.log(this.platform);
  221. if (this.platform!='ios') {
  222. this.maskShow=true
  223. }
  224. },
  225. confirm(){
  226. this.maskShow=false
  227. },
  228. residentialConfirm(e){
  229. this.data.residentialId=e[0].value
  230. this.data.residentialName=e[0].label
  231. },
  232. keyboardheightchange(e){
  233. console.log(e.detail.height);
  234. console.log(this.maskShow);
  235. if (e.detail.height==0) {
  236. this.maskShow=false
  237. }
  238. },
  239. timeConfirm(e){
  240. this.timeShow=false
  241. this.data.beginTime=e.beginTime
  242. this.data.endTime=e.endTime
  243. this.dateTimeStr=this.data.beginTime+" 至 "+this.data.endTime
  244. },
  245. /**
  246. * 上传问题截图
  247. */
  248. chooseImage() {
  249. let that=this
  250. uni.chooseImage({
  251. count: 4-this.imgList.length,
  252. sizeType: ['original', 'compressed'],
  253. sourceType: ['album'],
  254. success: (res) => {
  255. const tempFilePaths = res.tempFilePaths;
  256. for (let index in tempFilePaths) {
  257. //图片回显
  258. that.imgList.push(tempFilePaths[index])
  259. //图片转为base64的图片
  260. uni.getFileSystemManager().readFile({
  261. filePath: tempFilePaths[index],
  262. //选择图片返回的相对路径
  263. encoding: 'base64',
  264. //编码格式
  265. success: res => {
  266. //成功的回调
  267. that.base64_image.push('data:image/jpeg;base64,' + res.data)
  268. }
  269. });
  270. }
  271. }
  272. });
  273. },
  274. /*预览图片*/
  275. viewImage(index) {
  276. uni.previewImage({
  277. urls: this.imgList,
  278. current: index
  279. });
  280. },
  281. /*删除图片*/
  282. DelImg(index) {
  283. uni.showModal({
  284. title: '提示',
  285. content: '确定要删除这张照片吗?',
  286. cancelText: '取消',
  287. confirmText: '确定',
  288. success: res => {
  289. if (res.confirm) {
  290. this.imgList.splice(index, 1)
  291. this.base64_image.splice(index,1)
  292. }
  293. }
  294. })
  295. },
  296. }
  297. }
  298. </script>
  299. <style lang="scss">
  300. .bg-gray{
  301. background-color: #f7f7f7;
  302. }
  303. .card{
  304. margin: 18rpx;
  305. border-radius: 20rpx;
  306. box-sizing: border-box;
  307. background-color: #FFFFFF;
  308. }
  309. .card .form{
  310. padding: 23rpx;
  311. }
  312. .need{
  313. font-size: 38rpx;
  314. font-weight: 800;
  315. color: #ff0000;
  316. padding-right: 10rpx;
  317. }
  318. </style>