Blame view

src/pages/me/index.vue 9.38 KB
ce4c83ff   wxy   初始提交
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
  <template>
  <div class="me">
  <div class='head'>
    <div class='img'>
      <img @tap='tapAvatar' class='photo' :src='userInfo.avatarUrl' mode='aspectFill'>
      <img class='vip' v-if='vertified' src='/static/imgs/V.png'>
    </div>
    <div class='name'>{{userInfo.nickName}}</div>
    <div class='info'>{{'' || userInfo.firm_name}}</div>
    <div class='info' style='padding:0 30rpx;text-align:center;'>{{'' || userInfo.cate_name}}</div>
  </div>
  <div>
    <navigator class='nav-item' v-for="(item, i) in link_list" :key="i" :url="'../'+item.url+'/main'" hover-class='hover'>
      <img :src="'/static/imgs/'+ item.url + '.png'" :class='item.url'>
      {{item.title}}
      <div class='arrow'/>
      <span class="tips" v-if="item.tips==1">{{number}}</span>
    </navigator>
  </div>
  <!-- <div class='verify'><navigator url='../verify/main'>{{vertified?'重置认证信息':'认证为律师'}}</navigator></div> -->
  <div class='reset verify' v-if='vertified'><div @tap='unVerify'>重置认证信息</div></div>
  <div class='verify' v-else><navigator url='../verify/main'>认证为律师</navigator></div>
  
  <AvatarUpload :show='AvatarChanging' ref='AvatarUpload' @exit='exit' @confirm='uploadImg'/>
  </div>
  </template>
  
  <script>
  import AvatarUpload from '@/components/AvatarUpload'
  export default {
    components: {
      AvatarUpload
    },
    data() {
      return {
        userInfo: {},
        link_list: [
          { title: '我的消息', url: 'mynews', tips: '1' },
          { title: '我的回复', url: 'myreply', tips: '0' },
          { title: '我的评价', url: 'myassess', tips: '0' },
          { title: '我的讲座', url: 'mylecture', tips: '0' },
          { title: '考勤记录', url: 'attence', tips: '0' },
          { title: '值班证明', url: 'prove', tips: '0' },
          { title: '值班调班', url: 'schedule', tips: '0' },
          { title: '意见反馈', url: 'feedback', tips: '0' }
          // { title: '社区定位', url: 'test' },
          // { title: '获赞数', url: 'like' }
        ],
        vertified: false,
        AvatarChanging: false,
        uploading: false,
        hasMessage:false,
        number: ''
      }
    },
    methods: {
      tapAvatar(){
        if(this.uploading) return
        wx.showActionSheet({
          itemList: ['查看头像','更换头像'],
          success: res => {
            if(res.tapIndex === 0)
              wx.previewImage({urls:[this.userInfo.avatarUrl]})
            else this.changeAvatar()
          }
        })
        wx.setStorageSync('UploadAvatar_Tip_Showed', 3)
      },
      unVerify() {
        wx.showModal({
          title: '重置确认',
          content: '确定要重置吗?',
          success: res => {
            if (res.confirm) {
              wx.request({
                url: this.rootUrl + '/law/wxbinding',
                header: { 'content-type': 'application/x-www-form-urlencoded' },
                method: 'POST',
                data: { sessionID: wx.getStorageSync('sessionID') },
                success: res => {
                  if(res.statusCode=='500'){
                    this.service.getUnionId(this.rootAvatar,this.rootUrl).then(res=>{
                      this.unVerify()
                    })
                  }else{
                    if (res.data.status === '200') {
                      wx.setStorageSync('isVerify', false)
                      wx.removeStorageSync('userInfo')
                      this.refreshInfo()
                      wx.showModal({
                        title: '',
                        content: '当前账号没有绑定律师,请认证为律师',
                        showCancel: false,
                        success: () => wx.redirectTo({ url: '../verify/main' })
                      })
                    } else {
                      wx.showToast({ title: '解绑失败', icon: 'none' })
                    }
                  }
                },
                fail: res => wx.showToast({ title: '网络错误', icon: 'none' })
              })
            }
          }
        })
      },
      refreshInfo() {
        this.vertified = wx.getStorageSync('isVerify')
        this.userInfo = wx.getStorageSync(this.vertified ? 'userInfo' : 'wxInfo')
      },
      canIGetPos(){
        wx.request({
          url: this.rootUrl + '/law/position',
          success: res => {
            console.log(res)
            console.log(this.link_list)
            const link_list = this.link_list
            if( res.data === 0 ){
              if(link_list.length > 8)
                this.link_list = this.link_list.slice(0,5)
            } else {
              if(link_list.length < 9)
                this.link_list.push({ title: '社区定位', url: 'test' })
            }
          }
        })
      },
      changeAvatar(){
        wx.chooseImage({
          count: 1,
          sizeType: ['compressed'],
          sourceType: ['album', 'camera'],
          success: res => {
            this.AvatarChanging = true
            wx.hideTabBar()
            this.$refs.AvatarUpload.setInitialImg(res.tempFilePaths[0])
          }
        })
      },
      exit(){
        this.AvatarChanging = false
        wx.showTabBar()
      },
      uploadImg(src){
        wx.showModal({
          title:'',
          content: '确认上传新的头像吗?',
          success: res => {
            if(res.confirm){
              this.$refs.AvatarUpload.startWaiting()
              this.uploadImg_exec(src)
            }
          }
        })
      },
      uploadImg_exec(src){
        this.uploading = true
        console.log(src)
        wx.showLoading({ title: '正在上传' })
        wx.uploadFile({
          url: this.rootUrl + 'law/lawyerpic',
          filePath: src,
          formData: {sessionID: wx.getStorageSync('sessionID')},
          name: 'file',
          header: { 'content-type': 'multipart/form-data' },
          success: res => {
            if(new RegExp(/^Maximum upload size exceeded.*?/).test(JSON.parse(res.data).message)){
              console.log('图片文件过大')
              wx.hideLoading()
              wx.showModal({title:'上传失败',content:'图片文件过大,请选择较小的图片上传'})
              this.$refs.AvatarUpload.stopWaiting()
              this.$refs.AvatarUpload.back()
              this.uploading = false
            } else if (res.statusCode == '500')
              this.service.getUnionId(this.rootAvatar, this.rootUrl).then(() => this.uploadImg_exec(src))
            else if(res.data == 1){
              console.log('图片上传成功')
              wx.hideLoading()
              wx.showToast({ title: '上传成功' })
              this.service.getUnionId(this.rootAvatar, this.rootUrl).then(() => {
                this.refreshInfo()
                this.uploading = false
                this.exit()
                this.$refs.AvatarUpload.clear()
              })
            } else {
              console.log('图片上传失败')
              wx.hideLoading()
              wx.showToast({ title: '上传失败' })
              this.$refs.AvatarUpload.stopWaiting()
              this.$refs.AvatarUpload.back()
              this.uploading = false
            }
          }
        })
      },
      checkTip(){
        const num = wx.getStorageSync('UploadAvatar_Tip_Showed') || 1
        if( num < 3 )
          wx.showModal({
            title:'提示',
            content:'点击头像可进行修改或查看',
            showCancel: false,
            confirmText:'知道了',
            success: res => {
              if(res.confirm)
                wx.setStorageSync('UploadAvatar_Tip_Showed', num + 1)
            }
          })
      },
      getLawMessage(){
        wx.request({
          url: this.rootUrl + 'message/getUnReadMessage',
          method: 'get',
          data: { sessionID: wx.getStorageSync('sessionID') },
          success: res => {
            if(res.data>0){
              this.number = res.data
              console.log(this.number)
            }else{
              this.number = ''
            }
          }
        })
      }
    },
    onLoad() {
      this.getLawMessage()
    },
    onShow() {
      this.refreshInfo()
      this.canIGetPos()
      this.checkTip()
      this.getLawMessage()
    },
    onUnload(){
      this.number = ''
    }
  }
  </script>
  <style lang="stylus" scoped>
  .me
    width 100%
    min-height 100%
    Background()
    position absolute
  .head
    Flex(flex, center, center, column)
    Height_Width(400rpx, 100%)
    background themeColor
    color white
    .img
      position relative
      Flex(flex, center, center)
      .photo
        Height_Width(155rpx)
        border-radius 50%
        border 5rpx solid rgba(255,255,255,.8)
      .vip
        position absolute
        top 120rpx
        left 110rpx
        Height_Width(50rpx)
    .name
      Font(38rpx, 80rpx)
    .info
      Font(26rpx, 40rpx)
  .nav-item
    padding 0 25rpx
    Font(30rpx, 88rpx)
    Flex(flex,,center)
    background white
    border-bottom 1rpx solid #dedede
    position relative
    &:nth-child(5)
      margin-top 20rpx
      border-top 1rpx solid #dedede
    &:nth-child(8)
      margin-top 20rpx
      border-top 1rpx solid #dedede
    img
      Height_Width(38rpx)
      margin-right 25rpx
      &.attence
        width 40rpx
        margin-right 23rpx
      &.schedule
        width 36rpx
        margin-right 27rpx
    .arrow
      Height_Width(15rpx)
      Border(0, 0, 4rpx, 4rpx, #BBB)
      transform rotate(-135deg)
      margin 0 0 0 auto
  .verify
    margin 30rpx 0
    Height_Width(80rpx, 100%)
    padding 0 calc(((100% - 320rpx) / 2))
    BorderBox()
    navigator, div
      Height_Width(100%)
      background themeColor
      color white
      text-align center
      Font(36rpx, 80rpx)
  .reset
    div
      border 1rpx solid #DFDEE3
      color grey
      background white
  .tips
    display inline-block
    padding 0 14rpx
    background-color rgb(242,6,61)
    color #fff
    font-size 24rpx
    line-height 40rpx
    border-radius 20rpx
    position absolute
    right 55rpx
    top 24rpx
    text-align center
  </style>