property.vue 9.8 KB

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