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

339 lines
8.3 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 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" cancelText="取消" title="图片操作"
  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 {
  174. id
  175. } = imageSheet
  176. if (id) {
  177. this.deleteImageAsList()
  178. } else {
  179. this.viewImageAsList()
  180. }
  181. },
  182. //查看图片
  183. viewImageAsList() {
  184. this.$utils.previewImage({
  185. current: this.currentIndex,
  186. urls: this.form.images
  187. })
  188. },
  189. //删除图片
  190. deleteImageAsList() {
  191. this.form.images = this.form.images.filter((_, index) => {
  192. return index != this.currentIndex
  193. })
  194. },
  195. //用户选择了楼栋
  196. floorConfirm(floor) {
  197. this.form.building = floor.value[0].name
  198. this.getFloorList(floor.value[0].id)
  199. },
  200. //打开选择楼栋
  201. floorPickerOpen() {
  202. this.$refs.floorPicker.open();
  203. },
  204. //用户选择了室号
  205. roomConfirm(floor) {
  206. this.form.room = floor.value[0].name
  207. },
  208. //打开选择室号
  209. roomPickerOpen() {
  210. this.$refs.roomPicker.open();
  211. },
  212. //提交报修
  213. submitRepair() {
  214. this.$refs.form.validate().then(res => {
  215. let images = this.form.image.join()
  216. this.$api('addSchoolOrder', {
  217. ...this.form,
  218. image: images
  219. }, res => {
  220. if (res.code == 200) {
  221. uni.showToast({
  222. icon: 'none',
  223. title: '申请报修成功'
  224. })
  225. this.cleanfrom()
  226. this.$refs.form.clearValidate();
  227. this.toRepairList()
  228. }
  229. })
  230. }).catch(errors => {})
  231. },
  232. //跳转到报修记录
  233. toRepairList() {
  234. uni.navigateTo({
  235. url: '/pages/repairList/repairList'
  236. })
  237. },
  238. //清除表单数据
  239. cleanfrom() {
  240. this.form = {
  241. building: '', //楼栋
  242. room: '', //室号
  243. project: '', //项目
  244. phone: '', //手机号
  245. name: '', //姓名
  246. context: '', //简介
  247. image: []
  248. }
  249. },
  250. //获取楼栋列表
  251. getActorGoList() {
  252. this.$api('getFloorList', res => {
  253. this.floorList.push(res.result)
  254. })
  255. },
  256. //获取室号列表
  257. getFloorList(id) {
  258. this.$api('getActorGoList',{id},res => {
  259. this.roomNumberList = []
  260. if(res.result.length > 0 && this.form.room) this.form.room = res.result[0].name
  261. this.roomNumberList.push(res.result)
  262. })
  263. }
  264. }
  265. }
  266. </script>
  267. <style scoped>
  268. .bx {
  269. width: 96%;
  270. margin: 0rpx auto;
  271. }
  272. .repair-title {
  273. display: flex;
  274. align-items: center;
  275. justify-content: center;
  276. height: 100rpx;
  277. padding-top: 100rpx;
  278. }
  279. .repair-title text {
  280. font-size: 40rpx;
  281. font-weight: bold;
  282. height: 70rpx;
  283. border-bottom: 8rpx solid #3c9cff;
  284. }
  285. .image-list {
  286. width: 100%;
  287. display: flex;
  288. flex-wrap: wrap;
  289. padding-top: 20rpx;
  290. }
  291. .image-item,
  292. .upload {
  293. display: flex;
  294. align-items: center;
  295. justify-content: center;
  296. width: 24%;
  297. height: 174rpx;
  298. background: #f8f8f8;
  299. margin-left: 1%;
  300. border-radius: 15rpx;
  301. overflow: hidden;
  302. margin-bottom: 20rpx;
  303. }
  304. .image-item image {
  305. width: 100%;
  306. }
  307. </style>