艺易修小程序24.08.21
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

388 lines
9.7 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. <!-- 报修 -->
  2. <template>
  3. <view class="repair bx reserveSpace">
  4. <uv-form :model="form" :rules="rules" errorType="toast" ref="form" labelPosition="left" labelWidth="140">
  5. <uv-form-item label="楼栋" prop="building" borderBottom @click="floorPickerOpen">
  6. <uv-input placeholder="请选择楼层" v-model="form.building" border="none" readonly :fontSize="30"></uv-input>
  7. <template v-slot:right>
  8. <uv-icon name="arrow-right"></uv-icon>
  9. </template>
  10. </uv-form-item>
  11. <uv-form-item label="维修项目" prop="project" borderBottom @click="projectPickerOpen">
  12. <uv-input v-model="form.project" placeholder="请填写维修物品的名称" readonly :fontSize="30" border="none"></uv-input>
  13. <template v-slot:right>
  14. <uv-icon name="arrow-right"></uv-icon>
  15. </template>
  16. </uv-form-item>
  17. <uv-form-item label="室号" prop="room" borderBottom>
  18. <uv-input placeholder="请选择室号" v-model="form.room" border="none" :fontSize="30"></uv-input>
  19. </uv-form-item>
  20. <uv-form-item label="你的姓名" prop="name" borderBottom>
  21. <uv-input v-model="form.name" placeholder="请填写姓名" :fontSize="30" border="none"></uv-input>
  22. </uv-form-item>
  23. <uv-form-item label="你的电话" prop="phone" borderBottom>
  24. <uv-input v-model="form.phone" placeholder="请填写电话号" border="none" :fontSize="30"></uv-input>
  25. </uv-form-item>
  26. <uv-form-item label="描述说明" prop="context" borderBottom>
  27. <uv-textarea v-model="form.context" :height="140" :maxlength="200" textStyle="font-size : 30rpx" count
  28. placeholder="请输入描述说明"></uv-textarea>
  29. </uv-form-item>
  30. <uv-form-item label="照片" prop="image" labelPosition="top">
  31. <view class="image-list">
  32. <view @click="openImageMenu(index)" v-for="(item,index) in form.image" :key="index"
  33. class="image-item">
  34. <image :src="item" mode="widthFix"></image>
  35. </view>
  36. <view v-if="form.image.length < maxUpload" @click="uploadImage" class="upload">
  37. <uv-icon name="camera-fill" color="#3c9cff" size="50"></uv-icon>
  38. </view>
  39. </view>
  40. </uv-form-item>
  41. <uv-button type="primary" text="提交" shape="circle" customStyle="margin-top: 10px"
  42. @click="submitRepair"></uv-button>
  43. </uv-form>
  44. <!-- 报修地址选择(楼栋) -->
  45. <uv-picker ref="floorPicker" :columns="floorList" :round="20" :itemHeight="100" keyName="name" title="选择楼栋"
  46. @confirm="floorConfirm"></uv-picker>
  47. <!-- 报修地址选择(室号) -->
  48. <!-- <uv-picker ref="roomPicker" :columns="roomNumberList" :itemHeight="100" :round="20" keyName="name" title="选择室号"
  49. @confirm="roomConfirm"></uv-picker> -->
  50. <!-- 维修项目选择 -->
  51. <uv-picker ref="projectPicker" :columns="projectList" :itemHeight="100" :round="20" keyName="name" title="选择维修项目"
  52. @confirm="projectConfirm"></uv-picker>
  53. <!-- 图片操作菜单 -->
  54. <uv-action-sheet ref="actionSheet" :actions="list" :round="20" safeAreaInsetBottom @select="selectImageSheet">
  55. </uv-action-sheet>
  56. <!-- 隐私政策 -->
  57. <PrivacyAgreementPoup ref="showPrivacy"></PrivacyAgreementPoup>
  58. </view>
  59. </template>
  60. <script>
  61. import {
  62. mapState
  63. } from 'vuex'
  64. import PrivacyAgreementPoup from "@/components/PrivacyAgreementPoup/PrivacyAgreementPoup.vue";
  65. export default {
  66. name: 'Repair',
  67. components: {
  68. PrivacyAgreementPoup
  69. },
  70. data() {
  71. return {
  72. form: {
  73. building: '', //楼栋
  74. room: '', //室号
  75. project: '', //项目
  76. phone: '', //手机号
  77. name: '', //姓名
  78. context: '', //简介
  79. image: []
  80. },
  81. rules: { //参数校验
  82. building: {
  83. type: 'string',
  84. required: true,
  85. message: '请选择楼栋',
  86. trigger: ['blur', 'change']
  87. },
  88. room: {
  89. type: 'string',
  90. required: true,
  91. message: '请选择室号',
  92. trigger: ['blur', 'change']
  93. },
  94. project: {
  95. type: 'string',
  96. required: true,
  97. message: '请填写维修物品',
  98. trigger: ['blur', 'change']
  99. },
  100. name: {
  101. type: 'string',
  102. required: true,
  103. message: '请填写姓名',
  104. trigger: ['blur', 'change']
  105. },
  106. phone: [{
  107. required: true,
  108. message: '请填写手机号',
  109. trigger: ['blur', 'change']
  110. }, {
  111. validator: (rule, value, callback) => {
  112. return uni.$uv.test.mobile(value);
  113. },
  114. message: '手机号格式错误',
  115. trigger: ['blur']
  116. }],
  117. context: {
  118. type: 'string',
  119. required: true,
  120. message: '请填写描述说明',
  121. trigger: ['blur', 'change']
  122. },
  123. image: {
  124. type: 'array',
  125. required: true,
  126. message: '请上传图片',
  127. trigger: ['blur', 'change']
  128. },
  129. },
  130. maxUpload: 4, //最大上传图片张数
  131. list: [ //图片操作菜单操作项
  132. {
  133. name: '查看图片',
  134. id: 0
  135. },
  136. {
  137. name: '删除图片',
  138. id: 1
  139. }
  140. ],
  141. currentIndex: undefined, //当前操作的图片索引
  142. floorList: [], //楼栋列表
  143. // roomNumberList: [], //室号列表
  144. projectList : [], //项目列表
  145. }
  146. },
  147. onShow() {
  148. if (wx.onNeedPrivacyAuthorization) {
  149. wx.onNeedPrivacyAuthorization(resolve => {
  150. this.resolvePrivacyAuthorization = resolve
  151. this.$refs.showPrivacy.init(resolve)
  152. })
  153. }
  154. if (this.floorList.length < 1) this.getActorGoList()
  155. if(this.projectList.length < 1) this.getProjectList()
  156. },
  157. onReady() {
  158. this.$refs.form.setRules(this.rules);
  159. },
  160. methods: {
  161. //上传图片
  162. uploadImage() {
  163. let self = this
  164. this.$Oss.ossUploadImage({
  165. success(res) {
  166. self.form.image.push(res)
  167. }
  168. })
  169. },
  170. //打开图片操作菜单
  171. openImageMenu(index) {
  172. this.currentIndex = index
  173. this.$refs.actionSheet.open();
  174. },
  175. //用户选择了图片操作选项
  176. selectImageSheet(imageSheet) {
  177. let {
  178. id
  179. } = imageSheet
  180. if (id) {
  181. this.deleteImageAsList()
  182. } else {
  183. this.viewImageAsList()
  184. }
  185. },
  186. //查看图片
  187. viewImageAsList() {
  188. this.$utils.previewImage({
  189. current: this.currentIndex,
  190. urls: this.form.image
  191. })
  192. },
  193. //删除图片
  194. deleteImageAsList() {
  195. this.form.image = this.form.image.filter((_, index) => {
  196. return index != this.currentIndex
  197. })
  198. },
  199. //用户选择了楼栋
  200. floorConfirm(floor) {
  201. this.form.building = floor.value[0].name
  202. //获取楼栋对应的室号信息
  203. // this.getFloorList(floor.value[0].id)
  204. },
  205. //打开选择楼栋
  206. floorPickerOpen() {
  207. if(this.floorList.length == 0){
  208. return uni.showToast({ icon: 'none' , title: '暂无楼栋供用户选择' })
  209. }
  210. this.$refs.floorPicker.open();
  211. },
  212. // //用户选择了室号
  213. // roomConfirm(floor) {
  214. // this.form.room = floor.value[0].name
  215. // },
  216. // //打开选择室号
  217. // roomPickerOpen() {
  218. // if (!this.form.building) {
  219. // return uni.showToast({
  220. // icon: 'none',
  221. // title: '请先选择楼栋信息'
  222. // })
  223. // }
  224. // this.$refs.roomPicker.open();
  225. // },
  226. //用户选择了项目
  227. projectConfirm(project) {
  228. this.form.project = project.value[0].name
  229. },
  230. //打开选择项目
  231. projectPickerOpen() {
  232. if(this.projectList.length == 0){
  233. return uni.showToast({ icon: 'none' , title: '暂无项目供用户选择' })
  234. }
  235. this.$refs.projectPicker.open();
  236. },
  237. //提交报修
  238. submitRepair() {
  239. this.$refs.form.validate().then(res => {
  240. let images = this.form.image.join()
  241. if (this.userInfo && this.userInfo.isDai == '1') {
  242. this.cleanfrom() //清空表单内容
  243. return uni.showToast({ icon: 'none' , title: '维修员不能主动提交报修' })
  244. }
  245. this.$api('addSchoolOrder', {
  246. ...this.form,
  247. image: images
  248. }, res => {
  249. if (res.code == 200) {
  250. uni.showToast({
  251. icon: 'none',
  252. title: '申请报修成功'
  253. })
  254. this.cleanfrom()
  255. this.$refs.form.clearValidate();
  256. this.toRepairList()
  257. }
  258. })
  259. }).catch(errors => {})
  260. },
  261. //跳转到报修记录
  262. toRepairList() {
  263. uni.navigateTo({
  264. url: '/pages/repairList/repairList'
  265. })
  266. },
  267. //清除表单数据
  268. cleanfrom() {
  269. this.form = {
  270. building: '', //楼栋
  271. room: '', //室号
  272. project: '', //项目
  273. phone: '', //手机号
  274. name: '', //姓名
  275. context: '', //简介
  276. image: []
  277. }
  278. },
  279. //获取楼栋列表
  280. getActorGoList() {
  281. this.$api('getFloorList', res => {
  282. this.floorList.push(res.result)
  283. })
  284. },
  285. //获取室号列表
  286. // getFloorList(id) {
  287. // this.$api('getActorGoList', {
  288. // id
  289. // }, res => {
  290. // this.roomNumberList = []
  291. // if (res.result.length > 0 && this.form.room) this.form.room = res.result[0].name
  292. // this.roomNumberList.push(res.result)
  293. // })
  294. // }
  295. //获取项目列表
  296. getProjectList() {
  297. this.$api('getRepairList', res => {
  298. this.getRepairList = []
  299. this.projectList.push(res.result)
  300. console.log(this.projectList);
  301. })
  302. }
  303. },
  304. computed: {
  305. ...mapState(['userInfo']),
  306. },
  307. }
  308. </script>
  309. <style scoped>
  310. .bx {
  311. width: 96%;
  312. margin: 0rpx auto;
  313. }
  314. .repair-title {
  315. display: flex;
  316. align-items: center;
  317. justify-content: center;
  318. height: 100rpx;
  319. padding-top: 100rpx;
  320. }
  321. .repair-title text {
  322. font-size: 40rpx;
  323. font-weight: bold;
  324. height: 70rpx;
  325. border-bottom: 8rpx solid #3c9cff;
  326. }
  327. .image-list {
  328. width: 100%;
  329. display: flex;
  330. flex-wrap: wrap;
  331. padding-top: 20rpx;
  332. }
  333. .image-item,
  334. .upload {
  335. display: flex;
  336. align-items: center;
  337. justify-content: center;
  338. width: 24%;
  339. height: 174rpx;
  340. background: #f8f8f8;
  341. margin-left: 1%;
  342. border-radius: 15rpx;
  343. overflow: hidden;
  344. margin-bottom: 20rpx;
  345. }
  346. .image-item image {
  347. width: 100%;
  348. }
  349. /deep/ .uv-safe-area-inset-bottom {
  350. padding-bottom: 0 !important
  351. }
  352. </style>