zhouwenxuan
2023-09-06 0b2357a173a2bc52f3532bfcf93ff31daf226231
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
<template>
    <view>
        <!-- 自定义导航栏 -->
        <view class="navBarBox fix">
            <!-- 状态栏占位 -->
            <view class="statusBar" :style="{ paddingTop: statusBarHeight + 'px' }"></view>
            <!-- 真正的导航栏内容 -->
            <view class="navBar">
                <view class="barText">叫应记录</view>
                <view >
                    <u-button type="text" @click="loginOut" style="color: blue;margin-right: 5px;">退出</u-button>
                </view>
            </view>
        </view>
    <div v-if="loading" style='display: flex;justify-content: center;position: absolute;width:100%;top: 40%;left: 0'>
      <u-loading-icon></u-loading-icon>
    </div>
        <!-- 页面内容 -->
        
    <scroll-view :scroll-top="scrollTop" scroll-y="true" class="responseList" @scrolltoupper="upper" v-if="responseList.length > 0"
                 @scrolltolower="lower" @scroll="scroll" lower-threshold="50">
            <view v-for="(item, index) in responseList" :key="index" class="itemContent" @click="toDetail(item)">
                <view class="contentRight"> 
          <view style="font-size: 14px">{{item.receiveUnit}}</view>
          <text><span style="margin-right: 4px">{{item.recipienterName}}</span>对<span style="margin:0 4px">[{{ item.title }}]</span>进行了“已安排部署”叫应。</text>
                </view>
        <view class="timeLeft">
          <text style="margin-right: 10px">{{item.time}}</text>
          <text>{{item.timeMin}}</text>
        </view>
            </view>
    </scroll-view>
        <view v-else>
            <u-empty
                mode="data"
                icon="http://cdn.uviewui.com/uview/empty/data.png"
                margin-top="50%">
            </u-empty>
        </view>
        <tabBar :currentPagePath="page"></tabBar>
    </view>
</template>
 
<script>
    import { getResponse, getDetail } from '../../../api/response.js'
    import tabBar from '../tabBarIndex.vue'
    export default {
        components:{
            tabBar
        },
        data() {
            return {
                data: {
                    pageIndex: 1,
                    pageSize: 10
                },
        total: 0,
        scrollTop: 0,
        loading: false,
                // 状态栏高度
                statusBarHeight: 0,
                responseList: [],
                page: 'pages/tabBar/response/response'
            }
        },
        onShow () {
      this.data.pageIndex = 1
            this.getResponseList();
        },
        onLoad() {
            //获取手机状态栏高度
            this.statusBarHeight = uni.getSystemInfoSync()['statusBarHeight'];
            uni.hideTabBar();
        },
        methods: {
            loginOut() {
                uni.clearStorageSync();
                uni.clearStorage();
                uni.navigateTo({
                    url: '/pages/index/index'
                })
            },
            getResponseList() {
        this.loading = true
                getResponse(this.data).then(res => {
                    if (res.code === 100) {
                        let list = res.data ? res.data : [];
            if (res.pageIndex != 1) {
              this.responseList = this.responseList.concat(list)
            } else {
              this.responseList = list;
            }
            this.total = res.total
                        if (this.responseList.length > 0) {
                            this.responseList.forEach((item, index) => {
                                this.responseList[index].time = item.responseTime.substring(0,10);
                                this.responseList[index].timeMin = item.responseTime.substring(10,19);
                                // this.responseList[index].content = item.receiveUnit + " " + item.recipienterName + " " + "在" + item.title + ' 进行了“已安排部署”叫应。';
                            })
                        }
                    }else {
            uni.$u.toast(res.msg)
                        this.responseList = [];
                    }
          this.loading = false
                }).catch(err=>{})
            },
            toDetail(item) {
                console.log("de",item)
                getDetail({id: item.id}).then(res => {
          console.log("response",res)
                    if(res.code == 100) {
                        uni.navigateTo({
                          url: `/pages/tabBar/notice/detail?data=` + encodeURIComponent(JSON.stringify(res.data))
                        })
                    }
                });
            },
            //下拉刷新
            onPullDownRefresh() {
                console.log('refresh');
                setTimeout(() => {
                    uni.stopPullDownRefresh();
                    this.getResponseList();
                }, 1000);
            },
 
      upper: function(e) {
        // console.log(e)
      },
      lower: function(e) {
        if (this.data.pageIndex * this.data.pageSize >= this.total){
          // uni.$u.toast('已加载全部数据')
          return
        }
        //并且让页码+1,调用获取数据的方法获取第二页数据
        this.data.pageIndex++
        //此处调用自己获取数据列表的方法
        this.getResponseList()
      },
      scroll: function(e) {
        // console.log(e)
      },
        }
    }
</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;
}
.fix{
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1;
}
.statusBar{
    background-color:lightgrey;
}
.responseList{
  display: flex;
  flex-direction: column;
  width: calc(100% - 24px);
  height: calc(100vh - 124px);
  margin: 12px 12px 0;
  background: #fff;
  border-radius: 5px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.05);
  
}
.itemContent{
  color: #333;
  margin-top: 15px;
  padding: 0 12px;
  border-bottom: 1px solid #ebebeb;
 
  .timeLeft{
    display: flex;
    align-items: center;
    justify-content: left;
    margin-bottom: 15px;
    color: #11cc21;
  }
  .contentRight{
    width: 100%;
    flex: 1;
      font-size: 16px;
    margin-bottom: 6px;
    view{
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    text{
      overflow: hidden;                //溢出内容隐藏
      text-overflow: ellipsis;        //文本溢出部分用省略号表示
      display: -webkit-box;            //特别显示模式
      -webkit-line-clamp: 2;            //行数
      line-clamp: 2;
      -webkit-box-orient: vertical;    //盒子中内容竖直排列
    }
  }
 
  // &:last-of-type{
  //   border-bottom: none;
  // }
}
</style>