property.vue 8.6 KB

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