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

347 lines
8.4 KiB

10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
9 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
9 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
9 months ago
9 months ago
10 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
9 months ago
10 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="room" borderBottom @click="roomPickerOpen">
  12. <uv-input placeholder="请选择室号" v-model="form.room" border="none" readonly :fontSize="30"></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="project" borderBottom>
  18. <uv-input v-model="form.project" placeholder="请填写维修物品的名称" :fontSize="30" border="none"></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-action-sheet ref="actionSheet" :actions="list" :round="20" safeAreaInsetBottom
  52. @select="selectImageSheet"> </uv-action-sheet>
  53. <!-- 隐私政策 -->
  54. <PrivacyAgreementPoup ref="showPrivacy"></PrivacyAgreementPoup>
  55. </view>
  56. </template>
  57. <script>
  58. import PrivacyAgreementPoup from "@/components/PrivacyAgreementPoup/PrivacyAgreementPoup.vue";
  59. export default {
  60. name: 'Repair',
  61. components: {
  62. PrivacyAgreementPoup
  63. },
  64. data() {
  65. return {
  66. form: {
  67. building: '', //楼栋
  68. room: '', //室号
  69. project: '', //项目
  70. phone: '', //手机号
  71. name: '', //姓名
  72. context: '', //简介
  73. image: []
  74. },
  75. rules: { //参数校验
  76. building: {
  77. type: 'string',
  78. required: true,
  79. message: '请选择楼栋',
  80. trigger: ['blur', 'change']
  81. },
  82. room: {
  83. type: 'string',
  84. required: true,
  85. message: '请选择室号',
  86. trigger: ['blur', 'change']
  87. },
  88. project: {
  89. type: 'string',
  90. required: true,
  91. message: '请填写维修物品',
  92. trigger: ['blur', 'change']
  93. },
  94. name: {
  95. type: 'string',
  96. required: true,
  97. message: '请填写姓名',
  98. trigger: ['blur', 'change']
  99. },
  100. phone: [{
  101. required: true,
  102. message: '请填写手机号',
  103. trigger: ['blur', 'change']
  104. }, {
  105. validator: (rule, value, callback) => {
  106. return uni.$uv.test.mobile(value);
  107. },
  108. message: '手机号格式错误',
  109. trigger: ['blur']
  110. }],
  111. context: {
  112. type: 'string',
  113. required: true,
  114. message: '请填写描述说明',
  115. trigger: ['blur', 'change']
  116. },
  117. image: {
  118. type: 'array',
  119. required: true,
  120. message: '请上传图片',
  121. trigger: ['blur', 'change']
  122. },
  123. },
  124. maxUpload: 4, //最大上传图片张数
  125. list: [ //图片操作菜单操作项
  126. {
  127. name: '查看图片',
  128. id: 0
  129. },
  130. {
  131. name: '删除图片',
  132. id: 1
  133. }
  134. ],
  135. currentIndex: undefined, //当前操作的图片索引
  136. floorList: [], //楼栋列表
  137. roomNumberList: [], //室号列表
  138. }
  139. },
  140. onShow() {
  141. if (wx.onNeedPrivacyAuthorization) {
  142. console.log('onNeedPrivacyAuthorization');
  143. wx.onNeedPrivacyAuthorization(resolve => {
  144. console.log('onNeedPrivacyAuthorization');
  145. this.resolvePrivacyAuthorization = resolve
  146. this.$refs.showPrivacy.init(resolve)
  147. })
  148. }
  149. if(this.floorList.length < 1){
  150. this.getActorGoList()
  151. }
  152. },
  153. onReady() {
  154. this.$refs.form.setRules(this.rules);
  155. },
  156. methods: {
  157. //上传图片
  158. uploadImage() {
  159. let self = this
  160. this.$Oss.ossUploadImage({
  161. success(res) {
  162. self.form.image.push(res)
  163. }
  164. })
  165. },
  166. //打开图片操作菜单
  167. openImageMenu(index) {
  168. this.currentIndex = index
  169. this.$refs.actionSheet.open();
  170. },
  171. //用户选择了图片操作选项
  172. selectImageSheet(imageSheet) {
  173. let { id } = imageSheet
  174. if (id) {
  175. this.deleteImageAsList()
  176. } else {
  177. this.viewImageAsList()
  178. }
  179. },
  180. //查看图片
  181. viewImageAsList() {
  182. this.$utils.previewImage({
  183. current: this.currentIndex,
  184. urls: this.form.image
  185. })
  186. },
  187. //删除图片
  188. deleteImageAsList() {
  189. this.form.image = this.form.image.filter((_, index) => {
  190. return index != this.currentIndex
  191. })
  192. },
  193. //用户选择了楼栋
  194. floorConfirm(floor) {
  195. this.form.building = floor.value[0].name
  196. this.getFloorList(floor.value[0].id)
  197. },
  198. //打开选择楼栋
  199. floorPickerOpen() {
  200. this.$refs.floorPicker.open();
  201. },
  202. //用户选择了室号
  203. roomConfirm(floor) {
  204. this.form.room = floor.value[0].name
  205. },
  206. //打开选择室号
  207. roomPickerOpen() {
  208. if(!this.form.building){
  209. return uni.showToast({
  210. icon : 'none',
  211. title: '请先选择楼栋信息'
  212. })
  213. }
  214. this.$refs.roomPicker.open();
  215. },
  216. //提交报修
  217. submitRepair() {
  218. this.$refs.form.validate().then(res => {
  219. let images = this.form.image.join()
  220. this.$api('addSchoolOrder', {
  221. ...this.form,
  222. image: images
  223. }, res => {
  224. if (res.code == 200) {
  225. uni.showToast({
  226. icon: 'none',
  227. title: '申请报修成功'
  228. })
  229. this.cleanfrom()
  230. this.$refs.form.clearValidate();
  231. this.toRepairList()
  232. }
  233. })
  234. }).catch(errors => {})
  235. },
  236. //跳转到报修记录
  237. toRepairList() {
  238. uni.navigateTo({
  239. url: '/pages/repairList/repairList'
  240. })
  241. },
  242. //清除表单数据
  243. cleanfrom() {
  244. this.form = {
  245. building: '', //楼栋
  246. room: '', //室号
  247. project: '', //项目
  248. phone: '', //手机号
  249. name: '', //姓名
  250. context: '', //简介
  251. image: []
  252. }
  253. },
  254. //获取楼栋列表
  255. getActorGoList() {
  256. this.$api('getFloorList', res => {
  257. this.floorList.push(res.result)
  258. })
  259. },
  260. //获取室号列表
  261. getFloorList(id) {
  262. this.$api('getActorGoList',{id},res => {
  263. this.roomNumberList = []
  264. if(res.result.length > 0 && this.form.room) this.form.room = res.result[0].name
  265. this.roomNumberList.push(res.result)
  266. })
  267. }
  268. }
  269. }
  270. </script>
  271. <style scoped>
  272. .bx {
  273. width: 96%;
  274. margin: 0rpx auto;
  275. }
  276. .repair-title {
  277. display: flex;
  278. align-items: center;
  279. justify-content: center;
  280. height: 100rpx;
  281. padding-top: 100rpx;
  282. }
  283. .repair-title text {
  284. font-size: 40rpx;
  285. font-weight: bold;
  286. height: 70rpx;
  287. border-bottom: 8rpx solid #3c9cff;
  288. }
  289. .image-list {
  290. width: 100%;
  291. display: flex;
  292. flex-wrap: wrap;
  293. padding-top: 20rpx;
  294. }
  295. .image-item,
  296. .upload {
  297. display: flex;
  298. align-items: center;
  299. justify-content: center;
  300. width: 24%;
  301. height: 174rpx;
  302. background: #f8f8f8;
  303. margin-left: 1%;
  304. border-radius: 15rpx;
  305. overflow: hidden;
  306. margin-bottom: 20rpx;
  307. }
  308. .image-item image {
  309. width: 100%;
  310. }
  311. /deep/ .uv-safe-area-inset-bottom {
  312. padding-bottom: 0 !important
  313. }
  314. </style>