|
|
- <!-- 报修 -->
- <template>
- <view class="repair bx reserveSpace">
- <uv-form :model="form" :rules="rules" :useBeforeRead="true" ref="form" labelPosition="left" labelWidth="140">
-
- <uv-form-item label="楼栋" prop="form.building" borderBottom>
- <uv-input @focus="floorPickerOpen" placeholder="请选择楼层" v-model="form.building" border="none"
- :fontSize="30"></uv-input>
- <template v-slot:right>
- <uv-icon name="arrow-right"></uv-icon>
- </template>
- </uv-form-item>
-
- <uv-form-item label="室号" prop="form.room" borderBottom>
- <uv-input @focus="roomPickerOpen" placeholder="请选择室号" v-model="form.room" border="none"
- :fontSize="30"></uv-input>
- <template v-slot:right>
- <uv-icon name="arrow-right"></uv-icon>
- </template>
- </uv-form-item>
-
- <uv-form-item label="维修物品" prop="form.project" borderBottom>
- <uv-input v-model="form.project" placeholder="请填写维修物品的名称" :fontSize="30" border="none"></uv-input>
- </uv-form-item>
-
-
- <uv-form-item label="你的姓名" prop="form.name" borderBottom>
- <uv-input v-model="form.name" placeholder="请填写姓名" :fontSize="30" border="none"></uv-input>
- </uv-form-item>
-
- <uv-form-item label="你的电话" prop="form.name" borderBottom>
- <uv-input v-model="form.phone" placeholder="请填写电话号" border="none" :fontSize="30"></uv-input>
- </uv-form-item>
-
- <uv-form-item label="描述说明" prop="form.context" borderBottom>
- <uv-textarea v-model="form.context" :height="140" :maxlength="200" textStyle="font-size : 30rpx" count
- placeholder="请输入描述说明"></uv-textarea>
- </uv-form-item>
-
- <uv-form-item label="照片" prop="form.image" labelPosition="top">
- <view class="image-list">
- <view @click="openImageMenu(index)" v-for="(item,index) in form.image" :key="index"
- class="image-item">
- <image :src="item" mode="widthFix"></image>
- </view>
- <view v-if="form.image.length < maxUpload" @click="uploadImage" class="upload">
- <uv-icon name="camera-fill" color="#3c9cff" size="50"></uv-icon>
- </view>
- </view>
- </uv-form-item>
-
- <uv-button type="primary" text="提交" shape="circle" customStyle="margin-top: 10px"
- @click="submitRepair"></uv-button>
- </uv-form>
-
- <!-- 报修地址选择(楼栋) -->
- <uv-picker ref="floorPicker" :columns="floorList" :itemHeight="100" :round="20" keyName="label" title="选择楼栋"
- @confirm="floorConfirm"></uv-picker>
-
- <!-- 报修地址选择(室号) -->
- <uv-picker ref="roomPicker" :columns="roomNumberList" :itemHeight="100" :round="20" keyName="label" title="选择室号"
- @confirm="roomConfirm"></uv-picker>
-
- <!-- 图片操作菜单 -->
- <uv-action-sheet ref="actionSheet" :actions="list" :round="20" cancelText="取消" title="图片操作"
- @select="selectImageSheet"> </uv-action-sheet>
-
- <!-- 隐私政策 -->
- <PrivacyAgreementPoup ref="showPrivacy"></PrivacyAgreementPoup>
- </view>
- </template>
-
- <script>
- import PrivacyAgreementPoup from "@/components/PrivacyAgreementPoup/PrivacyAgreementPoup.vue";
- export default {
- name: 'Repair',
- components: {
- PrivacyAgreementPoup
- },
- data() {
- return {
- form: {
- building: '', //楼栋
- room: '', //室号
- project: '', //项目
- phone: '', //手机号
- name: '', //姓名
- context: '', //简介
- image: []
- },
- rules: { //参数校验
- // 'form.name': {
- // type: 'string',
- // required: true,
- // message: '请填写姓名',
- // trigger: ['blur', 'change']
- // }
- },
- maxUpload: 4, //最大上传图片张数
- list: [ //图片操作菜单操作项
- {
- name: '查看图片',
- id: 0
- },
- {
- name: '删除图片',
- id: 1
- }
- ],
- currentIndex: undefined, //当前操作的图片索引
- floorList: [
- [{
- id: 0,
- label: '楼栋1'
- },
- {
- id: 1,
- label: '楼栋2'
- }
- ]
- ], //楼栋列表
- roomNumberList: [
- [{
- id: 0,
- label: 'A1001'
- },
- {
- id: 1,
- label: 'A1002'
- }
- ]
- ], //室号列表
- }
- },
- onShow(){
- if (wx.onNeedPrivacyAuthorization) {
- console.log('onNeedPrivacyAuthorization');
- wx.onNeedPrivacyAuthorization(resolve => {
- console.log('onNeedPrivacyAuthorization');
- this.resolvePrivacyAuthorization = resolve
- this.$refs.showPrivacy.init(resolve)
- })
- }
- },
- methods: {
- //上传图片
- uploadImage() {
- let self = this
- this.$Oss.ossUploadImage({
- success(res) {
- self.form.image.push(res)
- }
- })
- },
-
- //打开图片操作菜单
- openImageMenu(index) {
- this.currentIndex = index
- this.$refs.actionSheet.open();
- },
-
- //用户选择了图片操作选项
- selectImageSheet(imageSheet) {
- let {
- id
- } = imageSheet
- if (id) {
- this.deleteImageAsList()
- } else {
- this.viewImageAsList()
- }
- },
-
- //查看图片
- viewImageAsList() {
- this.$utils.previewImage({
- current: this.currentIndex,
- urls: this.form.images
- })
- },
-
- //删除图片
- deleteImageAsList() {
- this.form.images = this.form.images.filter((_, index) => {
- return index != this.currentIndex
- })
- },
-
- //用户选择了楼栋
- floorConfirm(floor) {
- this.form.building = floor.value[0].label
- },
-
- //打开选择楼栋
- floorPickerOpen() {
- this.$refs.floorPicker.open();
- },
-
- //用户选择了室号
- roomConfirm(floor) {
- this.form.room = floor.value[0].label
- },
-
- //打开选择室号
- roomPickerOpen() {
- this.$refs.roomPicker.open();
- },
-
- //提交报修
- submitRepair() {
- this.form.image = this.form.image.join()
- this.$api('addSchoolOrder', this.form, res => {
- if (res.code == 200) {
- uni.showToast({
- icon: 'none',
- title: '提交成功'
- });
- this.cleanForm()
- this.toRepairList()
- }
- })
- },
-
- //重置表单数据
- cleanForm() {
- this.form = {
- building: '', //楼栋
- room: '', //室号
- project: '', //项目
- phone: '', //手机号
- name: '', //姓名
- context: '', //简介
- image: [] //报修图片
- }
- },
-
- //跳转到报修记录
- toRepairList(){
- uni.switchTab({
- url: '/pages/repairList/repairList'
- })
- }
- }
- }
- </script>
-
- <style scoped>
- .bx {
- width: 96%;
- margin: 0rpx auto;
- }
-
- .repair-title {
- display: flex;
- align-items: center;
- justify-content: center;
- height: 100rpx;
- padding-top: 100rpx;
- }
-
- .repair-title text {
- font-size: 40rpx;
- font-weight: bold;
- height: 70rpx;
- border-bottom: 8rpx solid #3c9cff;
- }
-
- .image-list {
- width: 100%;
- display: flex;
- flex-wrap: wrap;
- padding-top: 20rpx;
- }
-
- .image-item,
- .upload {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 24%;
- height: 174rpx;
- background: #f8f8f8;
- margin-left: 1%;
- border-radius: 15rpx;
- overflow: hidden;
- margin-bottom: 20rpx;
- }
-
- .image-item image {
- width: 100%;
- }
- </style>
|