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

291 lines
6.9 KiB

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
7 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
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
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
7 months ago
8 months ago
  1. <!-- 报修 -->
  2. <template>
  3. <view class="repair bx reserveSpace">
  4. <uv-form :model="form" :rules="rules" :useBeforeRead="true" ref="form" labelPosition="left" labelWidth="140">
  5. <uv-form-item label="楼栋" prop="form.building" borderBottom>
  6. <uv-input @focus="floorPickerOpen" placeholder="请选择楼层" v-model="form.building" border="none"
  7. :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="form.room" borderBottom>
  13. <uv-input @focus="roomPickerOpen" placeholder="请选择室号" v-model="form.room" border="none"
  14. :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="form.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="form.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="form.name" 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="form.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="form.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" :itemHeight="100" :round="20" 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. // 'form.name': {
  79. // type: 'string',
  80. // required: true,
  81. // message: '请填写姓名',
  82. // trigger: ['blur', 'change']
  83. // }
  84. },
  85. maxUpload: 4, //最大上传图片张数
  86. list: [ //图片操作菜单操作项
  87. {
  88. name: '查看图片',
  89. id: 0
  90. },
  91. {
  92. name: '删除图片',
  93. id: 1
  94. }
  95. ],
  96. currentIndex: undefined, //当前操作的图片索引
  97. floorList: [
  98. [{
  99. id: 0,
  100. label: '楼栋1'
  101. },
  102. {
  103. id: 1,
  104. label: '楼栋2'
  105. }
  106. ]
  107. ], //楼栋列表
  108. roomNumberList: [
  109. [{
  110. id: 0,
  111. label: 'A1001'
  112. },
  113. {
  114. id: 1,
  115. label: 'A1002'
  116. }
  117. ]
  118. ], //室号列表
  119. }
  120. },
  121. onShow(){
  122. if (wx.onNeedPrivacyAuthorization) {
  123. console.log('onNeedPrivacyAuthorization');
  124. wx.onNeedPrivacyAuthorization(resolve => {
  125. console.log('onNeedPrivacyAuthorization');
  126. this.resolvePrivacyAuthorization = resolve
  127. this.$refs.showPrivacy.init(resolve)
  128. })
  129. }
  130. },
  131. methods: {
  132. //上传图片
  133. uploadImage() {
  134. let self = this
  135. this.$Oss.ossUploadImage({
  136. success(res) {
  137. self.form.image.push(res)
  138. }
  139. })
  140. },
  141. //打开图片操作菜单
  142. openImageMenu(index) {
  143. this.currentIndex = index
  144. this.$refs.actionSheet.open();
  145. },
  146. //用户选择了图片操作选项
  147. selectImageSheet(imageSheet) {
  148. let {
  149. id
  150. } = imageSheet
  151. if (id) {
  152. this.deleteImageAsList()
  153. } else {
  154. this.viewImageAsList()
  155. }
  156. },
  157. //查看图片
  158. viewImageAsList() {
  159. this.$utils.previewImage({
  160. current: this.currentIndex,
  161. urls: this.form.images
  162. })
  163. },
  164. //删除图片
  165. deleteImageAsList() {
  166. this.form.images = this.form.images.filter((_, index) => {
  167. return index != this.currentIndex
  168. })
  169. },
  170. //用户选择了楼栋
  171. floorConfirm(floor) {
  172. this.form.building = floor.value[0].label
  173. },
  174. //打开选择楼栋
  175. floorPickerOpen() {
  176. this.$refs.floorPicker.open();
  177. },
  178. //用户选择了室号
  179. roomConfirm(floor) {
  180. this.form.room = floor.value[0].label
  181. },
  182. //打开选择室号
  183. roomPickerOpen() {
  184. this.$refs.roomPicker.open();
  185. },
  186. //提交报修
  187. submitRepair() {
  188. this.form.image = this.form.image.join()
  189. this.$api('addSchoolOrder', this.form, res => {
  190. if (res.code == 200) {
  191. uni.showToast({
  192. icon: 'none',
  193. title: '提交成功'
  194. });
  195. this.cleanForm()
  196. this.toRepairList()
  197. }
  198. })
  199. },
  200. //重置表单数据
  201. cleanForm() {
  202. this.form = {
  203. building: '', //楼栋
  204. room: '', //室号
  205. project: '', //项目
  206. phone: '', //手机号
  207. name: '', //姓名
  208. context: '', //简介
  209. image: [] //报修图片
  210. }
  211. },
  212. //跳转到报修记录
  213. toRepairList(){
  214. uni.switchTab({
  215. url: '/pages/repairList/repairList'
  216. })
  217. }
  218. }
  219. }
  220. </script>
  221. <style scoped>
  222. .bx {
  223. width: 96%;
  224. margin: 0rpx auto;
  225. }
  226. .repair-title {
  227. display: flex;
  228. align-items: center;
  229. justify-content: center;
  230. height: 100rpx;
  231. padding-top: 100rpx;
  232. }
  233. .repair-title text {
  234. font-size: 40rpx;
  235. font-weight: bold;
  236. height: 70rpx;
  237. border-bottom: 8rpx solid #3c9cff;
  238. }
  239. .image-list {
  240. width: 100%;
  241. display: flex;
  242. flex-wrap: wrap;
  243. padding-top: 20rpx;
  244. }
  245. .image-item,
  246. .upload {
  247. display: flex;
  248. align-items: center;
  249. justify-content: center;
  250. width: 24%;
  251. height: 174rpx;
  252. background: #f8f8f8;
  253. margin-left: 1%;
  254. border-radius: 15rpx;
  255. overflow: hidden;
  256. margin-bottom: 20rpx;
  257. }
  258. .image-item image {
  259. width: 100%;
  260. }
  261. </style>