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

247 lines
5.8 KiB

10 months ago
  1. <!-- 报修 -->
  2. <template>
  3. <view class="repair bx reserveSpace">
  4. <!-- <view class="repair-title">
  5. <text>申请报修</text>
  6. </view> -->
  7. <uv-form :model="form" :rules="rules" :useBeforeRead="true" ref="form" labelPosition="left" labelWidth="100">
  8. <uv-form-item label="楼栋" prop="form.building" borderBottom>
  9. <uv-input @focus="floorPickerOpen" placeholder="请选择楼层" v-model="form.building" border="none" :fontSize="30"></uv-input>
  10. <template v-slot:right>
  11. <uv-icon name="arrow-right"></uv-icon>
  12. </template>
  13. </uv-form-item>
  14. <uv-form-item label="室号" prop="form.room" borderBottom>
  15. <uv-input @focus="roomPickerOpen" placeholder="请选择室号" v-model="form.room" border="none" :fontSize="30"></uv-input>
  16. <template v-slot:right>
  17. <uv-icon name="arrow-right"></uv-icon>
  18. </template>
  19. </uv-form-item>
  20. <uv-form-item label="项目" prop="form.project" borderBottom>
  21. <uv-input v-model="form.project" placeholder="请填写项目" :fontSize="30" border="none"></uv-input>
  22. </uv-form-item>
  23. <uv-form-item label="姓名" prop="form.name" borderBottom>
  24. <uv-input v-model="form.name" placeholder="请填写姓名" :fontSize="30" border="none"></uv-input>
  25. </uv-form-item>
  26. <uv-form-item label="简介" prop="form.intro" borderBottom>
  27. <uv-textarea v-model="form.intro" :height="140" :maxlength="200" textStyle="font-size : 30rpx" count
  28. placeholder="请输入内容"></uv-textarea>
  29. </uv-form-item>
  30. <uv-form-item label="电话号" prop="form.name" borderBottom>
  31. <uv-input v-model="form.phone" placeholder="请填写电话号" border="none" :fontSize="30"></uv-input>
  32. </uv-form-item>
  33. <uv-form-item label="照片" prop="form.images" labelPosition="top">
  34. <view class="image-list">
  35. <view @click="openImageMenu(index)" v-for="(item,index) in form.images" :key="index"
  36. class="image-item">
  37. <image :src="item" mode="widthFix"></image>
  38. </view>
  39. <view v-if="form.images.length < maxUpload" @click="uploadImage" class="upload">
  40. <uv-icon name="camera-fill" color="#3c9cff" size="50"></uv-icon>
  41. </view>
  42. </view>
  43. </uv-form-item>
  44. <uv-button type="primary" text="提交" shape="circle" customStyle="margin-top: 10px"
  45. @click="submitRepair"></uv-button>
  46. </uv-form>
  47. <!-- 报修地址选择(楼栋) -->
  48. <uv-picker ref="floorPicker" :columns="floorList" :itemHeight="100" :round="20" keyName="label" title="选择楼栋"
  49. @confirm="floorConfirm"></uv-picker>
  50. <!-- 报修地址选择(室号) -->
  51. <uv-picker ref="roomPicker" :columns="roomNumberList" :itemHeight="100" :round="20" keyName="label" title="选择室号"
  52. @confirm="roomConfirm"></uv-picker>
  53. <!-- 图片操作菜单 -->
  54. <uv-action-sheet ref="actionSheet" :actions="list" :round="20" cancelText="取消" title="图片操作"
  55. @select="selectImageSheet"> </uv-action-sheet>
  56. </view>
  57. </template>
  58. <script>
  59. export default {
  60. name: 'Repair',
  61. data() {
  62. return {
  63. form: {
  64. building: '', //楼栋
  65. room: '', //室号
  66. project: '', //项目
  67. phone: '', //手机号
  68. name: '', //姓名
  69. intro: '', //简介
  70. images: []
  71. },
  72. rules: { //参数校验
  73. 'form.name': {
  74. type: 'string',
  75. required: true,
  76. message: '请填写姓名',
  77. trigger: ['blur', 'change']
  78. }
  79. },
  80. maxUpload: 4, //最大上传图片张数
  81. list: [ //图片操作菜单操作项
  82. {
  83. name: '查看图片',
  84. id: 0
  85. },
  86. {
  87. name: '删除图片',
  88. id: 1
  89. }
  90. ],
  91. currentIndex: undefined, //当前操作的图片索引
  92. floorList: [
  93. [{
  94. id: 0,
  95. label: '楼栋1'
  96. },
  97. {
  98. id: 1,
  99. label: '楼栋2'
  100. }
  101. ]
  102. ], //楼栋列表
  103. roomNumberList: [
  104. [{
  105. id: 0,
  106. label: 'A1001'
  107. },
  108. {
  109. id: 1,
  110. label: 'A1002'
  111. }
  112. ]
  113. ], //室号列表
  114. }
  115. },
  116. methods: {
  117. //上传图片
  118. uploadImage(){
  119. let self = this
  120. this.$Oss.ossUploadImage({
  121. success(res){
  122. self.form.images.push(res)
  123. }
  124. })
  125. },
  126. //打开图片操作菜单
  127. openImageMenu(index) {
  128. this.currentIndex = index
  129. this.$refs.actionSheet.open();
  130. },
  131. //用户选择了图片操作选项
  132. selectImageSheet(imageSheet) {
  133. let {
  134. id
  135. } = imageSheet
  136. if (id) {
  137. this.deleteImageAsList()
  138. } else {
  139. this.viewImageAsList()
  140. }
  141. },
  142. //查看图片
  143. viewImageAsList() {
  144. this.$utils.previewImage({
  145. current: this.currentIndex,
  146. urls: this.form.images
  147. })
  148. },
  149. //删除图片
  150. deleteImageAsList() {
  151. this.form.images = this.form.images.filter((_, index) => {
  152. return index != this.currentIndex
  153. })
  154. },
  155. //用户选择了楼栋
  156. floorConfirm(floor) {
  157. this.form.building = floor.value[0].label
  158. },
  159. //打开选择楼栋
  160. floorPickerOpen() {
  161. this.$refs.floorPicker.open();
  162. },
  163. //用户选择了室号
  164. roomConfirm(floor) {
  165. this.form.room = floor.value[0].label
  166. },
  167. //打开选择室号
  168. roomPickerOpen() {
  169. this.$refs.roomPicker.open();
  170. },
  171. //提交报修
  172. submitRepair() {
  173. console.log(this.form);
  174. },
  175. }
  176. }
  177. </script>
  178. <style scoped>
  179. .bx {
  180. width: 96%;
  181. margin: 0rpx auto;
  182. }
  183. .repair-title {
  184. display: flex;
  185. align-items: center;
  186. justify-content: center;
  187. height: 100rpx;
  188. padding-top: 100rpx;
  189. }
  190. .repair-title text {
  191. font-size: 40rpx;
  192. font-weight: bold;
  193. height: 70rpx;
  194. border-bottom: 8rpx solid #3c9cff;
  195. }
  196. .image-list {
  197. width: 100%;
  198. display: flex;
  199. flex-wrap: wrap;
  200. padding-top: 20rpx;
  201. }
  202. .image-item,
  203. .upload {
  204. display: flex;
  205. align-items: center;
  206. justify-content: center;
  207. width: 24%;
  208. height: 174rpx;
  209. background: #f8f8f8;
  210. margin-left: 1%;
  211. border-radius: 15rpx;
  212. overflow: hidden;
  213. margin-bottom: 20rpx;
  214. }
  215. .image-item image {
  216. width: 100%;
  217. }
  218. </style>