property.vue 9.3 KB

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