艺易修小程序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.

411 lines
10 KiB

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