zhouwenxuan
2023-07-25 22f0e04d34f19aac857e25627343dff9a2542057
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<template>
    <view>
        <!-- 自定义导航栏 -->
        <view class="navBarBox fix">
            <!-- 状态栏占位 -->
            <view class="statusBar" :style="{ paddingTop: statusBarHeight + 'px' }"></view>
            <!-- 真正的导航栏内容 -->
            <view class="navBar">
                <u-icon name="arrow-left" color="black" size="17" @click="goBack" />
                <view class="barText">响应措施反馈</view>
            </view>
        </view>
        <view class="measureCard">
            <view class="head">
                <u-form :model="form" ref="uForm" label-width="100px">
                    <u-form-item label="信息标题 :" ></u-form-item>
                    <u-form-item label="发布单位 :"></u-form-item>
                    <u-form-item label="发布时间 :"></u-form-item>
                    <u-form-item label="反馈时间 :"></u-form-item>
                </u-form>
            </view>
            <view class="first">
                <text style="font-size: 16px;margin-bottom: 20px;font-weight: 600;">基础措施</text>
                <view v-for="(item, index) in measureList" :key="index" style="margin-left: 18px;margin-bottom:10px; font-size:16px;">
                    <text style="margin-top: 15px;">{{item.name}}</text>
                </view>
            </view>
            <view class="second">
                <text style="font-size: 16px;margin-bottom: 20px;font-weight: 600;">补充措施</text>
                <u--textarea style="margin-top: -5px;" v-model="measures" disabled="true" placeholder="请输入内容" ></u--textarea>
            </view>
            <view class="third">
                <view v-for="(item, index) in images" :key="index">
                    <u-image @click="previewSqs(item,index)" style="margin: 5px; 5px" width="230rpx" height="230rpx" :src="item.url"></u-image>
                </view>
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        components:{
            
        },
        data() {
            return {
                statusBarHeight: [],
                fileList1: [],
                nameList: [],
                checkboxValue1: '',
                measures: "111",
                type: 'textarea',
                border: true,
                height: 100,
                autoHeight: true,
                measureList: [
                    {
                        name: '苹果',
                    },
                    {
                        name: '香蕉',
                    },
                    {
                        name: '橙子',
                    }
                ],
                images: [
                    {
                        url: 'https://img2.baidu.com/it/u=638285213,1746517464&fm=253&fmt=auto&app=120&f=JPEG?w=1422&h=800'
                    },
                    
                ]
            }
        },
        onLoad() {
            //获取手机状态栏高度
            this.statusBarHeight = uni.getSystemInfoSync()['statusBarHeight'];
            uni.hideTabBar();
        },
        methods: {
            goBack() {
                uni.navigateBack({
                    url:'/pages/tabBar/responsivity/villageResponsivity'
                });
            },
            
            checkboxChange(n) {
                console.log('change', n);
            },
            // 删除图片
            deletePic(event) {
                this[`fileList${event.name}`].splice(event.index, 1)
                this.nameList.splice(event.index,1)
                console.log("name",this.nameList)
            },
            // 新增图片
            async afterRead(event) {
                // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
                let lists = [].concat(event.file)
                let fileListLen = this[`fileList${event.name}`].length
                console.log("list",lists)
                lists.map((item) => {
                    this.nameList.push({name: item.name});
                    this[`fileList${event.name}`].push({
                        ...item,
                        status: 'uploading',
                        message: '上传中'
                    })
                })
                console.log("nameList",this.nameList)
                for (let i = 0; i < lists.length; i++) {
                    const result = await this.uploadFilePromise(lists[i].url)
                    let item = this[`fileList${event.name}`][fileListLen]
                    this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
                        status: 'success',
                        message: '',
                        url: result
                    }))
                    fileListLen++
                }
            },
            uploadFilePromise(url) {
                return new Promise((resolve, reject) => {
                    let a = uni.uploadFile({
                        url: 'http://www.example.com', // 仅为示例,非真实的接口地址
                        filePath: url,
                        name: 'file',
                        formData: {
                            user: 'test'
                        },
                        success: (res) => {
                            setTimeout(() => {
                                resolve(res.data.data)
                            }, 1000)
                        }
                    });
                })
            },
            //预览图片
            previewSqs(item,index) {
                let imgs = [];
                for (let i = 0; i < this.images.length; i++) {
                    imgs.push(this.images[i].url)
                }
                console.log("预览",imgs)
                uni.previewImage({
                    urls: imgs,
                    current: index,
                    indicator: 'number',
                    loop: true
                })
            },
        }
    }
 
</script>
 
<style lang='scss' scoped>
.navBarBox .navBar {
  background-color:#fff;
  height: 50px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  box-shadow: 0 3px 12px rgba(0,0,0,0.05);
}
.barText{
  /* margin-left: 20px; */
  text-align: center;
  width: 85%;
  font-size: 16px;
  /* text-align: center; */
  font-weight: 600;
}
 
.measureCard{
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: 0 3px 12px rgba(0,0,0,0.05);
    margin: 12px 12px 20px;
    border-radius: 5px;
    padding: 30px 12px;
}
.fix{
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1;
}
.statusBar{
    background-color:lightgrey;
}
.first{
    display: flex;
    flex-direction: column;
}
.second{
    display: flex;
    flex-direction: column;
    margin-top: 50px;
}
.third{
    display: flex;
    flex-wrap: wrap;
    margin-top: 30px;
    margin-bottom: 50px;
}
/deep/ .u-upload__button{
    background-color: white;
}
.pic{
    display: flex;
    flex-direction: column;
    background-color: rgb(242,242,242);
    margin-top: 5px;
    font-size: 14px;
}
 
.measures{
    margin-top: 50px 12px 0;
    padding: 0 12px;
    
    .measureBtn{
        border-radius: 5px;
        box-shadow: 0 3px 12px rgba(33,239,102,0.4);
    }
}
.head{
    margin-top: -20px;
    margin-bottom: 20px;
    line-height: 15px;
}
</style>