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

390 lines
9.8 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. console.log('onNeedPrivacyAuthorization');
  150. wx.onNeedPrivacyAuthorization(resolve => {
  151. console.log('onNeedPrivacyAuthorization');
  152. this.resolvePrivacyAuthorization = resolve
  153. this.$refs.showPrivacy.init(resolve)
  154. })
  155. }
  156. if (this.floorList.length < 1) this.getActorGoList()
  157. if(this.projectList.length < 1) this.getProjectList()
  158. },
  159. onReady() {
  160. this.$refs.form.setRules(this.rules);
  161. },
  162. methods: {
  163. //上传图片
  164. uploadImage() {
  165. let self = this
  166. this.$Oss.ossUploadImage({
  167. success(res) {
  168. self.form.image.push(res)
  169. }
  170. })
  171. },
  172. //打开图片操作菜单
  173. openImageMenu(index) {
  174. this.currentIndex = index
  175. this.$refs.actionSheet.open();
  176. },
  177. //用户选择了图片操作选项
  178. selectImageSheet(imageSheet) {
  179. let {
  180. id
  181. } = imageSheet
  182. if (id) {
  183. this.deleteImageAsList()
  184. } else {
  185. this.viewImageAsList()
  186. }
  187. },
  188. //查看图片
  189. viewImageAsList() {
  190. this.$utils.previewImage({
  191. current: this.currentIndex,
  192. urls: this.form.image
  193. })
  194. },
  195. //删除图片
  196. deleteImageAsList() {
  197. this.form.image = this.form.image.filter((_, index) => {
  198. return index != this.currentIndex
  199. })
  200. },
  201. //用户选择了楼栋
  202. floorConfirm(floor) {
  203. this.form.building = floor.value[0].name
  204. //获取楼栋对应的室号信息
  205. // this.getFloorList(floor.value[0].id)
  206. },
  207. //打开选择楼栋
  208. floorPickerOpen() {
  209. if(this.floorList.length == 0){
  210. return uni.showToast({ icon: 'none' , title: '暂无楼栋供用户选择' })
  211. }
  212. this.$refs.floorPicker.open();
  213. },
  214. // //用户选择了室号
  215. // roomConfirm(floor) {
  216. // this.form.room = floor.value[0].name
  217. // },
  218. // //打开选择室号
  219. // roomPickerOpen() {
  220. // if (!this.form.building) {
  221. // return uni.showToast({
  222. // icon: 'none',
  223. // title: '请先选择楼栋信息'
  224. // })
  225. // }
  226. // this.$refs.roomPicker.open();
  227. // },
  228. //用户选择了项目
  229. projectConfirm(project) {
  230. this.form.project = project.value[0].name
  231. },
  232. //打开选择项目
  233. projectPickerOpen() {
  234. if(this.projectList.length == 0){
  235. return uni.showToast({ icon: 'none' , title: '暂无项目供用户选择' })
  236. }
  237. this.$refs.projectPicker.open();
  238. },
  239. //提交报修
  240. submitRepair() {
  241. this.$refs.form.validate().then(res => {
  242. let images = this.form.image.join()
  243. if (this.userInfo && this.userInfo.isDai == '1') {
  244. this.cleanfrom() //清空表单内容
  245. return uni.showToast({ icon: 'none' , title: '维修员不能主动提交报修' })
  246. }
  247. this.$api('addSchoolOrder', {
  248. ...this.form,
  249. image: images
  250. }, res => {
  251. if (res.code == 200) {
  252. uni.showToast({
  253. icon: 'none',
  254. title: '申请报修成功'
  255. })
  256. this.cleanfrom()
  257. this.$refs.form.clearValidate();
  258. this.toRepairList()
  259. }
  260. })
  261. }).catch(errors => {})
  262. },
  263. //跳转到报修记录
  264. toRepairList() {
  265. uni.navigateTo({
  266. url: '/pages/repairList/repairList'
  267. })
  268. },
  269. //清除表单数据
  270. cleanfrom() {
  271. this.form = {
  272. building: '', //楼栋
  273. room: '', //室号
  274. project: '', //项目
  275. phone: '', //手机号
  276. name: '', //姓名
  277. context: '', //简介
  278. image: []
  279. }
  280. },
  281. //获取楼栋列表
  282. getActorGoList() {
  283. this.$api('getFloorList', res => {
  284. this.floorList.push(res.result)
  285. })
  286. },
  287. //获取室号列表
  288. // getFloorList(id) {
  289. // this.$api('getActorGoList', {
  290. // id
  291. // }, res => {
  292. // this.roomNumberList = []
  293. // if (res.result.length > 0 && this.form.room) this.form.room = res.result[0].name
  294. // this.roomNumberList.push(res.result)
  295. // })
  296. // }
  297. //获取项目列表
  298. getProjectList() {
  299. this.$api('getRepairList', res => {
  300. this.getRepairList = []
  301. this.projectList.push(res.result)
  302. console.log(this.projectList);
  303. })
  304. }
  305. },
  306. computed: {
  307. ...mapState(['userInfo']),
  308. },
  309. }
  310. </script>
  311. <style scoped>
  312. .bx {
  313. width: 96%;
  314. margin: 0rpx auto;
  315. }
  316. .repair-title {
  317. display: flex;
  318. align-items: center;
  319. justify-content: center;
  320. height: 100rpx;
  321. padding-top: 100rpx;
  322. }
  323. .repair-title text {
  324. font-size: 40rpx;
  325. font-weight: bold;
  326. height: 70rpx;
  327. border-bottom: 8rpx solid #3c9cff;
  328. }
  329. .image-list {
  330. width: 100%;
  331. display: flex;
  332. flex-wrap: wrap;
  333. padding-top: 20rpx;
  334. }
  335. .image-item,
  336. .upload {
  337. display: flex;
  338. align-items: center;
  339. justify-content: center;
  340. width: 24%;
  341. height: 174rpx;
  342. background: #f8f8f8;
  343. margin-left: 1%;
  344. border-radius: 15rpx;
  345. overflow: hidden;
  346. margin-bottom: 20rpx;
  347. }
  348. .image-item image {
  349. width: 100%;
  350. }
  351. /deep/ .uv-safe-area-inset-bottom {
  352. padding-bottom: 0 !important
  353. }
  354. </style>