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

353 lines
8.2 KiB

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