index.vue 23.2 KB
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 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612
<template>
<div class='affairs'>
<cover-view class='navbar'>
  <cover-view class='nav-item' @tap="nav(false,'事务处理汇报')" :class='{color: !move}' hover-class='hover'>事务处理汇报</cover-view>
  <cover-view class='nav-item' @tap="nav(true,'当天事务列表')" :class='{color: move}' hover-class='hover'>当天事务列表</cover-view>
  <cover-view class='slide' :class='{move: move}'></cover-view>
</cover-view>
<cover-view class='cover-view-blank'>
</cover-view>
<!-- <scroll-view scroll-y class="_report" :class="{'hide': move}"> -->
<form @submit='commit' class="_report" :class="{'hide': move}">
  <div class="list-input between">
    <span>值班街道</span>
    <picker :value='street.index' :range='street.columnOne' @change="pickerConfirm($event,'street')">
      <div hover-class='hover'>{{street.label}}</div>
    </picker>
  </div>
  <div class="list-input between">
    <span>值班社区</span>
    <picker :disabled="street.label=='点击选择街道'" @tap='warning' :value='community.index' :range='community.columnOne' @change="pickerConfirm($event,'community')">
      <div hover-class='hover'>{{community.label}}</div>
    </picker>
  </div>
  <div class="list-input">
    <span>当事人姓名</span>
    <input placeholder="请输入姓名" name='name' placeholder-style='color:#9B9B9B' :value='name' @input='name=service.Input($event)'>
  </div>
  <div class="list-input between" @tap="changeSex">
    <span>性别</span>
    <div hover-class='hover'>{{sex || '请选择性别'}}</div>
  </div>
  <div class="list-input">
    <span>年龄</span>
    <input type='number' placeholder="请输入年龄 (周岁)" name='age' placeholder-style='color:#9B9B9B' :value='age' @input='age=service.Input($event)'>
  </div>
  <div class="list-input">
    <span>地址 (可选)</span>
    <input placeholder="请输入详细地址" name='address' placeholder-style='color:#9B9B9B' :value='address' @input='address=service.Input($event)'>
  </div>
  <div class="list-input">
    <span>联系电话</span>
    <input type='number' placeholder="请输入联系电话" name='phone' placeholder-style='color:#9B9B9B' :value='phone' @input='phone=service.Input($event)'>
  </div>
  <div class='greytitle'>承办事务</div>
  <div class='textarea'>
    <textarea placeholder='请输入承办事务详情' name='detail' @input='detail=service.Input($event)' :value='detail' maxlength=10000 />
    <div>{{detail.length}}/10000</div>
  </div>
  <div class='greytitle'>律师处理结果</div>
  <div class='textarea'>
    <textarea placeholder='请输入处理结果详情' name='result' @input='result=service.Input($event)' :value='result' maxlength=10000 />
    <div>{{result.length}}/10000</div>
  </div>
  <div class='greytitle'>添加图片 (可选)</div>
  <div class="img-box" style='background:white;'>
    <div class='image' v-for="(item,i) in imgfiles" :key="i" @tap='previewImg(i)'>
      <img :src="item" mode='aspectFill'>
      <div @tap.stop='cancelImg(i)'><img src='/static/imgs/cancel.png'></div>
    </div>
    <div hover-class='fade' class='upload' @tap="chooseImage"><img src='data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTU3NDYzMDY5MzcyIiBjbGFzcz0iaWNvbiIgc3R5bGU9IiIgdmlld0JveD0iMCAwIDEwNTUgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjI1MDEiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNjUuOTM3NSIgaGVpZ2h0PSI2NCI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj5AZm9udC1mYWNlIHsgZm9udC1mYW1pbHk6IHJiaWNvbjsgc3JjOiB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kyLTQzLjMwOTAxMi00My4zMDkwMTItNDMuMzA5MDEycy00My4zMDkwMTIgMTkuMzU5OTg5LTQzLjMwOTAxMiA0My4zMDkwMTJsMCAxMDguMjcyNTMtMTA4LjI3MjUzIDBjLTIzLjk0OTAyMyAwLTQzLjMwOTAxMiAxOS40MzE2OTItNDMuMzA5MDEyIDQzLjM4MDcxNnMxOS40MzE2OTIgNDMuMzA5MDEyIDQzLjMwOTAxMiA0My4zMDkwMTJsMTA4LjI3MjUzIDAgMCAxMDguMjcyNTNjMCAyMy45NDkwMjMgMTkuNDMxNjkyIDQzLjM4MDcxNiA0My4zMDkwMTIgNDMuMzgwNzE2czQzLjMwOTAxMi0xOS40MzE2OTIgNDMuMzA5MDEyLTQzLjM4MDcxNmwwLTEwOC4yNzI1MyAxMDguMjcyNTMgMGMyMy45NDkwMjMgMCA0My4zMDkwMTItMTkuMzU5OTg5IDQzLjMwOTAxMi00My4zMDkwMTJTMTAzNS4wNDIzNjQgNzg0Ljg2ODI4NyAxMDExLjA5MzM0MSA3ODQuODY4Mjg3eiIgcC1pZD0iMjUwMyIgZmlsbD0iI0FFQUVBRSI+PC9wYXRoPjwvc3ZnPg=='></div>
  </div>
  <div class='greytitle'>添加小视频 (可选)</div>
  <div class="img-box" style='background:white; padding-bottom: 20rpx;'>
    <div v-if='videoSrc' class='image video'>
      <video :src='videoSrc' show-mute-btn id='myvideo'></video>
      <div @tap.stop='cancelVideo'><img src='/static/imgs/cancel.png'></div>
    </div>
    <div v-else hover-class='fade' class='upload' @tap="chooseVideo"><img src='data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTU3NDYzMDMyMTQ4IiBjbGFzcz0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3LjYyMyAwLTc1LjI0Ny0wLjAwNS0xMTIuODY5LTAuMDA0djM5LjAzMWgtOTMuNTl2OTMuNTlIOTMuNTY2Yy0wLjA0NCAxMTIuODYzLTAuMDI0IDIyNS43MjUtMC4wMDQgMzM4LjU5MiAwLjAwNSAxMS45ODIgMi44OTIgMjMuMzM4IDkuMDQ1IDMzLjYyMiAxNS41MDkgMjUuOTA0IDM4Ljg0OCAzOC4yMDIgNjguNzA1IDM4LjIxNyAxNjcuMzQ3IDAuMDcxIDMzNC42OTcgMC4wMzcgNTAyLjA0NCAwLjAzNyA0My41NzggMCA3OS4zNzEtMzUuNzY3IDc5LjM3MS03OS4zMTUgMC4wMDUtMTI4LjE2NSAwLjAwNS0yNTYuMzMzIDAtMzg0LjUwMy0wLjAwNi00My41MTUtMzUuODMtNzkuMjY2LTc5LjQxOC03OS4yNjZ6IiBmaWxsPSIjQUVBRUFFIiBwLWlkPSIyMjgwIj48L3BhdGg+PHBhdGggZD0iTTI3MC4wMSAzMjguNjY0aC05My41OTF2OTMuNTloLTgyLjgzdi05My41OUgtMC4wMDF2LTgyLjgzaDkzLjU5di05My41OWg4Mi44M3Y5My41OWg5My41OTF2NjguNDE1eiIgZmlsbD0iI0FFQUVBRSIgcC1pZD0iMjI4MSI+PC9wYXRoPjwvc3ZnPg=='></div>
  </div>
  <div class='commit'>
    <button form-type='submit' hover-class='fade' :disabled='commiting'>提交</button>
  </div>
</form>
<!--</scroll-view> 使用scroll-view解决textarea穿透顶部导航栏问题  -->
<div class='_list' :class="{'hide': !move}">
  <div class='title'>
    <div @tap='changeday(-1)' hover-class='shallow'>前一天</div>
    <!-- <div class='bold'>{{date[0]+'月'+date[1]+'日 星期'+week}}</div> -->
    <!-- <div class='bold'>{{curDate}}</div> -->
    <picker @tap="picker_active=true" @cancel="picker_active=false" @change="pickerConfirm($event,'date')" mode="date"
      :value="curDate">
      <div class="picker-box">
        <div>{{curDate}}</div>
        <div style='margin-left: 15rpx;' :class="picker_active ? 'triangle-color':'triangle'"/>
      </div>
    </picker>
    <div @tap='changeday(1)' hover-class='shallow'>后一天</div>
  </div>
  <navigator class='list-item' v-for='(item,i) in affairsList' :key='i' :url="'../affairDetail/main?ciid='+item.ciid" hover-class='hover'>
    <div class='name'>{{'当事人姓名:' + item.consultant_Name}}</div>
    <div class='affair'>{{item.consultant_question}}</div>
  </navigator>
  <div v-if='affairsList.length==0' class='empty'>{{curDate}} 无事务</div>
  <div class='commit'><div @tap="nav(false,'事务处理汇报')">添加事务处理</div></div>
</div>
</div>
</template>


<script>
export default {
  data() {
    return {
      move: false,
      name:'',
      sex: '',
      age:'',
      address: '',
      phone: '',
      detail: '',
      result: '',
      week: '一',
      affairsList: [],
      curDate: '',
      street: {
        columnOne: [],
        index: 0,
        arrStruct: [],
        label:'点击选择街道'
      },
      community: {
        columnOne: [],
        index: 0,
        arrStruct: [],
        label:'点击选择社区'
      },
      imgfiles: [],
      videoSrc: '',
      commiting: false,
      picker_active:false
    }
  },
  methods: {
    changeday(shift) {
      const curDateArr = this.curDate.split(/-/).map(Number)
      const curDateObj = new Date(curDateArr[0],curDateArr[1]-1,curDateArr[2])
      const date = new Date(curDateObj.getTime() + shift * 24 * 60 * 60 * 1000)
      this.getDailyAffairs(date)
    },
    commit(e) {
      if(this.commiting) return

      let inputs = this.service.filter(e.mp.detail.value)

      if (inputs.allowed) inputs = inputs.obj
      else return

      const street = this.street.label.replace('点击选择街道','')
      const community = this.community.label.replace('点击选择社区','')
      if (!this.service.checkEmptyInput([street,community,inputs.name,this.sex,inputs.age,inputs.phone,inputs.detail,inputs.result], ['街道','社区','当事人姓名', '性别', '年龄','联系电话', '承办事务', '处理结果'])) {
        return
      }
      if (!this.service.checkBadWords([inputs.detail, inputs.result], ['输入内容'])) {
        return
      }
      if(inputs.age > 127 || inputs.age < 0 || inputs.age % 1 !=0){
        wx.showModal({title: '提交失败',content: '请输入有效的年龄值',showCancel: false})
        return
      }
      if(!(/^1[3456789]\d{9}$/.test(inputs.phone))){
        // this.$notify.error({
        //   message: '手机号格式错误',
        // })
        wx.showModal({title: '提交失败',content: '请输入正确的手机号码',showCancel: false})
        return
      }
      wx.showModal({
        title:'',
        content: '确定要发布吗?',
        success: res => {
          if (res.confirm){
            this.execCommit(inputs)
          }
        }
      })
    },
    execCommit(inputs){
      wx.showLoading({ title: '正在上传' })
      this.commiting = true
      wx.request({
        url: this.rootUrl + '/con/addcon',
        method: 'POST',
        header: { 'content-type': 'application/x-www-form-urlencoded' },
        data: {
          SCID: this.community.arrStruct[this.community.index].value,
          sessionID: wx.getStorageSync('sessionID'),
          consultant_Name: inputs.name,
          consultant_Sex: this.sex == '男' ? 1 : 0,
          consultant_Age: inputs.age,
          consultant_address: inputs.address,
          consultant_Tel: inputs.phone,
          consultant_question: inputs.detail,
          consultant_Answer: inputs.result,
        },
        success: res => {
          if (res.statusCode == '500') {
            this.service.getUnionId(this.rootAvatar, this.rootUrl).then(res => {
              this.execCommit(inputs)
            })
          } else {
            if (res.data > 0) {
              if (this.imgfiles.length > 0)
                this.upLoadImgs(res.data)
              else if (this.videoSrc)
                this.uploadVideo(res.data)
              else
                this.uploadComplete()
            } else {
              wx.hideLoading()
              wx.showToast({ title: '上传失败 请检查上传内容', icon: 'none' })
              this.commiting = false
            }
          }
        },
        fail: res => {
          wx.hideLoading()
          wx.showToast({ title: '上传失败', icon: 'none' })
          this.commiting = false
        }
      })

    },
    uploadComplete(){
      wx.hideLoading()
      wx.showToast({ title: '上传成功' })
      setTimeout(() => {
        this.getDailyAffairs()
        this.nav(true, '当天事务列表')
        this.clearData()
        this.commiting = false
      }, 1500)
    },
    upLoadImgs(ciid) {
      wx.showLoading({ title: '正在上传图片' })
      const time = this.imgfiles.length
      let counter = time
      for(let i = 0; i < time; i++){
        wx.uploadFile({
          url: this.rootUrl + 'con/addfile',
          filePath: this.imgfiles[i],
          formData: {
            ciid,
            filetype: 0
          },
          name: 'file',
          header: {
            'content-type': 'multipart/form-data'
          },
          success: res => {
            if(res.data == 1)
              wx.showLoading({ title: `图片${i+1}上传成功` })
            else
              wx.showLoading({ title: `图片${i+1}上传失败` })

            if(--counter === 0){
              if(this.videoSrc)
                this.uploadVideo(ciid)
              else
                this.uploadComplete()
            }
          },
          fail: res => {
            wx.hideLoading()
            wx.showToast({title:'上传失败',icon: 'none'})
            this.commiting = false
          }
        })
      }
    },
    uploadVideo(ciid){
      wx.showLoading({title: '正在上传小视频'})
      wx.uploadFile({
        url: this.rootUrl + 'con/addfile',
        filePath: this.videoSrc,
        formData: {
          ciid,
          filetype: 1
        },
        name: 'file',
        header: {
          'content-type': 'multipart/form-data'
        },
        success: res => {
          if(res.data == 1)
            this.uploadComplete()
        }
      })
    },
    getDailyAffairs(date) {
      wx.showLoading({ title: '正在加载' })
      const theDate = date || new Date()
      this.curDate = this.service.formatDate(theDate)
      wx.request({
        url: this.rootUrl + '/con/getByDate',
        header: { 'content-type': 'application/x-www-form-urlencoded' },
        method: 'POST',
        data: {
          date: this.curDate,
          sessionID: wx.getStorageSync('sessionID')
        },
        success: res => {
          if (res.statusCode == '500') {
            console.log('eeee')
            this.service.getUnionId(this.rootAvatar, this.rootUrl).then(res => {
              console.log(res)
              this.getDailyAffairs(date)
            })
          } else {
            this.affairsList = []
            this.affairsList = res.data
            wx.hideLoading()
          }
        }
      })
    },
    nav(move, title) {
      this.move = move;
      wx.setNavigationBarTitle({ title: title });
    },
    changeSex() {
      wx.showActionSheet({
        itemList: ['男', '女'],
        success: res => this.sex = new Array('男', '女')[res.tapIndex]
      })
    },
    clearData(){
      this.name = ''
      this.sex = ''
      this.age = ''
      this.address = ''
      this.phone = ''
      this.detail = ''
      this.result = ''
      this.videoSrc = ''
      this.imgfiles = []
    },
    warning(){
      if(this.street.label=='点击选择街道'){
        wx.showToast({
          title:'请先选择街道',
          icon: 'none'
        })
      }
    },
    pickerConfirm(e, s) {
      switch (s) {
        case 'street': {
          const oldLabel = this.street.label
          this.street.index = e.mp.detail.value
          this.street.label = this.street.columnOne[this.street.index]
          if(oldLabel != this.street.label) this.getCommunity()
          break
        }
        case 'community': {
          this.community.index = e.mp.detail.value
          this.community.label = this.community.columnOne[this.community.index]
          break
        }
        case 'date': {
          this.getDailyAffairs(this.service.correctTime(e.mp.detail.value,'DateObj'))
          this.picker_active = false
          break
        }
      }
    },
    getCommunity(){
      wx.showLoading({ title: '加载社区列表' })
      wx.request({
        url: this.rootUrl + '/comm/getbyid/' + this.street.arrStruct[this.street.index].value,
        success: res => {
          this.community.columnOne = res.data.map(v=>v.comm_Name)
          this.community.arrStruct = res.data.map(v=>{return {label:v.comm_Name,value:v.scid}})
          this.community.index = 0
          this.community.label = this.community.columnOne[0]
          wx.hideLoading()
        }
      })
    },
    chooseImage() {
      const count = 6 - this.imgfiles.length
      if(count==0){
        if(!wx.showModal({
          title: '上传限制',
          content: '图片数量上限为6张\n请删除部分图片后再上传新图片',
          showCancel: false,
          success: res => {
            if(res.confirm){return false}
          }
        })){return}
      }
      wx.chooseImage({
        count,
        sizeType: ['compressed'],
        success: res => {
          this.imgfiles = this.imgfiles.concat(res.tempFilePaths)
        }
      })
    },
    cancelImg(i){
      wx.showModal({
        title:'',
        content: '放弃上传这张照片吗?',
        success: res => {
          if(res.confirm){
            this.imgfiles.splice(i, 1)
          }
        }
      })
    },
    previewImg(i){
      wx.previewImage({
        urls: this.imgfiles,
        current: this.imgfiles[i]
      })
    },
    chooseVideo() {
      wx.showModal({
        title:'',
        content:"为保证视频成功上传,请尽量选择'拍摄'方式,录制时长控制在20秒以内",
        success: res => {
          if(res.confirm){
            wx.chooseVideo({
              sourceType: ['album', 'camera'],
              maxDuration: 300,
              success: res => {
                console.log(res.tempFilePath,res.size)
                if(res.size < 1048500)
                  this.videoSrc = res.tempFilePath
                else
                  wx.showModal({title:'',content:'视频文件过大,请选择较小的视频'})
              }
            })
          }
        }
      })
    },
    cancelVideo(){
      wx.showModal({
        title:'',
        content: '放弃上传这个视频吗?',
        success: res => {
          if(res.confirm){
            this.videoSrc = ''
          }
        }
      })
    }
  },
  onLoad() {
    wx.request({
      url: this.rootUrl + '/street/all',
      success: res => {
        this.street.columnOne = res.data.map(v => v.street_Name)
        this.street.arrStruct = res.data.map(v => {
          return { label: v.street_Name, value: v.ssid }
        })
      }
    })
    this.getDailyAffairs()
  },
  onUnload() {
    this.move = false
    this.affairsList = []
    this.curDate = ''
  }
};
</script>
<style lang="stylus" scoped>
.affairs
  Background()
.loadbg
  position absolute
  Height_Width(100%)
  background white
.navbar
  position fixed
  display flex
  top 0
  Height_Width(44px, 100%)
  background white
  z-index 9
  .nav-item
    Flex(flex, center)
    Font(16px,44px)
    // padding 14px 0
    width 50%
    text-align center
  .slide
    position absolute
    bottom 0
    Height_Width(4px, 40%)
    background themeColor
    margin-left 5%
    transition transform .2s
  .color
    color themeColor
  .move
    transform translateX(125%)
.cover-view-blank
  Height_Width(45px, 100%)
  position fixed
  top 0
  left 0
  background #CCC
  z-index 8
.img-box
  padding 0 30rpx
  .image
    position relative
    > img
      Height_Width(100%)
    div
      position absolute
      top 0
      right 0
      background rgba(0,0,0,.5)
      Height_Width(100% / 5)
      Flex(flex,center,center)
      border-radius 0 0 0 10rpx
      img
        Height_Width(60%)
  .upload
    Flex(flex,center,center)
    background #f5f5f5
    img
      Height_Width(40%)
  .video
    Height_Width(450rpx,100%)
    margin-right 0 !important
    video
      Height_Width(450rpx,100%)
    div
      Height_Width(60rpx,60rpx)
      background red
._list, ._report
  position absolute
  min-height 100%
  width 100%
  padding-top 44px
  BorderBox()
  Background()
  z-index 0
// ._report
//   // position fixed
//   // top 44px
//   // left 0
//   position absolute
//   min-height 100%
//   padding-top 44px
//   BorderBox()
//   Background()
//   width 100%
//   z-index 0
  // -webkit-overflow-scrolling touch //解决scroll-view滑动不灵敏问题
.textarea
  padding 0 30rpx 30rpx 30rpx
  Font(30rpx, 40rpx)
  background-color #fff
  border-bottom 1rpx solid #dedede
  textarea
    height 200rpx
    width 100%
    padding 10rpx
    box-sizing border-box
    border-radius 10rpx
    background #eee
  div
    margin-top 15rpx
    text-align right
    color #888
    font-size 28rpx
._list
  > .title
    Flex(flex, space-between, center)
    Font(32rpx, 80rpx)
    color #333
    background #eee
    >div
      padding 0 20rpx
    picker
      text-align center
      Font(32rpx, 80rpx, bold)
      .picker-box
        height 80rpx
        Flex(flex, , center)
      .triangle
        Triangle(down, 24rpx, 14rpx, #666)
      .triangle-color
        Triangle(up, 24rpx, 14rpx, #666)
    .shallow
      background #AAA
  .list-item
    padding 30rpx
    border-bottom 1rpx solid #dedede
    background white
    .name
      Font(30rpx, 40rpx)
      color themeColor
      margin-bottom 10rpx
    .affair
      margin-top 20rpx
      Font(28rpx, 30rpx)
      overflow hidden
      text-overflow ellipsis
      display -webkit-box
      -webkit-line-clamp 3
      -webkit-box-orient vertical
  .empty
    Font(32rpx, 500rpx)
    text-align center
</style>