property.vue 9.3 KB

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