瀏覽代碼

help grounp photoUrl

xujing 5 年之前
父節點
當前提交
d3df981012

+ 1
- 0
src/constants/api.js 查看文件

@@ -44,6 +44,7 @@ export const API_CHAT_READED = resolvePath('chat/message')
44 44
 export const API_CARDS_LIST = resolvePath('cards')
45 45
 export const API_CARDS_APPLY = resolvePath('cards/apply')
46 46
 export const API_FORM_ID = resolvePath('formid')
47
+export const API_UPDATE_PHOTO = resolvePath('userInfo/updatePhoto')
47 48
 
48 49
 // project
49 50
 export const API_ITEMS_LIST = resolvePath('building/list')

+ 9
- 25
src/pages/activity/detail/assemble.js 查看文件

@@ -371,8 +371,9 @@ export default class Detail extends Component {
371 371
     }
372 372
   }
373 373
 
374
-  currentPageAndParams(shareFrom) {
375
-    const { id, recordId } = this.state
374
+  currentPageAndParams() {
375
+    // currentPageAndParams(shareFrom) {
376
+    const { id, recordId = '' } = this.state
376 377
     const { userInfo: { person: { personId, personType, userId } } } = this.props
377 378
     const consultant = personType == ROLE_CODE['CONSULTANT'] ? personId : ""
378 379
     const consultantId = personType == ROLE_CODE['CONSULTANT'] ? userId : ""
@@ -383,11 +384,11 @@ export default class Detail extends Component {
383 384
       `recommender=${personId}`,
384 385
       `consultant=${consultant}`,
385 386
       `consultantId=${consultantId}`,
387
+      `recordId=${recordId}`
386 388
     ]
387
-    if (recordId && shareFrom != 'menu') {
388
-      queryParams.push(`recordId=${recordId}`)
389
-    }
390
-
389
+    // if (recordId && shareFrom != 'menu') {
390
+    //   queryParams.push(`recordId=${recordId}`)
391
+    // }
391 392
     const res = [
392 393
       'pages/activity/detail/assemble',
393 394
       queryParams.join('&'),
@@ -399,7 +400,8 @@ export default class Detail extends Component {
399 400
 
400 401
   onShareAppMessage = (res) => {
401 402
     const { shares, detail: { groupActivityId, activityName, mainImg, buildingId } } = this.state
402
-    const currentPage = `/${this.currentPageAndParams(res.from).join('?')}`
403
+    const currentPage = `/${this.currentPageAndParams().join('?')}`
404
+    // const currentPage = `/${this.currentPageAndParams(res.from).join('?')}`
403 405
     const { userInfo: { person: { personId, personType, userId } } } = this.props
404 406
     const consultantId = personType == ROLE_CODE['CONSULTANT'] ? userId : ""
405 407
 
@@ -415,26 +417,8 @@ export default class Detail extends Component {
415 417
       data: '{}'
416 418
     }, 'group')
417 419
 
418
-    // savePoint({
419
-    //   event: 'share',
420
-    //   eventType: 'activity',
421
-    //   targetType: 'group',
422
-    //   propertyName: '拼团详情分享',
423
-    //   consultantId: consultantId,
424
-    //   sharePersonId: personId,
425
-    //   targetId: groupActivityId,
426
-    //   data: '{}'
427
-    // })
428 420
     const shareData = shares && shares.length ? shares[0] : { shareContentTitle: activityName, shareContentImg: mainImg };
429 421
 
430
-    // if (!shares || !shares.length) {
431
-    //   return {
432
-    //     title: shareData.shareContentTitle,
433
-    //     path: currentPage,//分享地址
434
-    //     imageUrl: shareData.shareContentImg
435
-    //   }
436
-    // }
437
-
438 422
     return {
439 423
       title: shareData.shareContentTitle,
440 424
       path: currentPage,//分享地址

+ 8
- 5
src/pages/activity/detail/assistance.js 查看文件

@@ -375,7 +375,8 @@ export default class Detail extends Component {
375 375
   }
376 376
 
377 377
   currentPageAndParams(shareFrom) {
378
-    const { id, initiateId } = this.state
378
+    // currentPageAndParams(shareFrom) {
379
+    const { id, initiateId = '' } = this.state
379 380
     const { userInfo: { person: { personId, personType, userId } } } = this.props
380 381
     const consultant = personType == ROLE_CODE['CONSULTANT'] ? personId : ""
381 382
     const consultantId = personType == ROLE_CODE['CONSULTANT'] ? userId : ""
@@ -386,11 +387,12 @@ export default class Detail extends Component {
386 387
       `recommender=${personId}`,
387 388
       `consultant=${consultant}`,
388 389
       `consultantId=${consultantId}`,
390
+      `initiateId=${initiateId}`
389 391
     ]
390 392
 
391
-    if (initiateId && shareFrom != 'menu') {
392
-      queryParams.push(`initiateId=${initiateId}`)
393
-    }
393
+    // if (initiateId && shareFrom != 'menu') {
394
+    //   queryParams.push(`initiateId=${initiateId}`)
395
+    // }
394 396
 
395 397
     const res = [
396 398
       'pages/activity/detail/assistance',
@@ -404,7 +406,8 @@ export default class Detail extends Component {
404 406
   onShareAppMessage = (res) => {
405 407
 
406 408
     const { shares, id, detail: { title, img, buildingId } } = this.state
407
-    const currentPage = `/${this.currentPageAndParams(res.from).join('?')}`
409
+    const currentPage = `/${this.currentPageAndParams().join('?')}`
410
+    // const currentPage = `/${this.currentPageAndParams(res.from).join('?')}`
408 411
     const { userInfo: { person: { personId, personType, userId } } } = this.props
409 412
     const consultantId = personType == ROLE_CODE['CONSULTANT'] ? userId : ""
410 413
     shareSavePoint({

+ 26
- 24
src/pages/card/index.js 查看文件

@@ -46,8 +46,6 @@ export default class Index extends Component {
46 46
     bound: false,
47 47
     grantPhoneVisible: false, // 授权电话
48 48
     grantAvatarVisible: false, // 授权头像
49
-    avatarImg: 'http://pic1.zhimg.com/50/v2-fce4f8a778fe3f24bca2cafc709b6847_hd.jpg',//头像路径
50
-    avatarPopVisible: false,
51 49
   }
52 50
 
53 51
   componentWillMount() {
@@ -68,10 +66,28 @@ export default class Index extends Component {
68 66
   }
69 67
 
70 68
   componentDidShow() {
69
+
71 70
     wx.setStorage({
72 71
       key: "from-card",
73 72
       data: "true"
74 73
     })
74
+    if (this.$router.params.loadInfo == 'need') {
75
+      Taro.navigateBack({ delta: 1 })
76
+      const { cardId } = this.state
77
+      const { dispatchCardInfo, dispatchProjectDetail } = this.props
78
+      Taro.showLoading()
79
+      dispatchCardInfo(cardId).then(res => {
80
+        Taro.hideLoading()
81
+        this.setState({
82
+          loaded: true,
83
+          isSave: res.isSave
84
+        })
85
+        let buildingId = (res.projects || [])[0]
86
+        if (buildingId) {
87
+          dispatchProjectDetail(buildingId)
88
+        }
89
+      })
90
+    }
75 91
   }
76 92
 
77 93
   initPageData() {
@@ -90,7 +106,6 @@ export default class Index extends Component {
90 106
         })
91 107
       })
92 108
     } else {
93
-
94 109
       this.setState({ cardId: id }, this.loadCardDetail)
95 110
       addCardUv(id)
96 111
     }
@@ -509,9 +524,9 @@ export default class Index extends Component {
509 524
       icon: 'none'
510 525
     })
511 526
   }
527
+
512 528
   // 选择图片
513 529
   bindAlbumClick(e) {
514
-    console.log('222222222222222')
515 530
 
516 531
     e.stopPropagation()
517 532
 
@@ -524,24 +539,16 @@ export default class Index extends Component {
524 539
       sourceType: ['album', 'camera'], //可选择性开放访问相册、相机
525 540
       success: res => {
526 541
         uploadFiles(res.tempFilePaths).then(data => {
527
-          this.setState({
528
-            avatarPopVisible: true,
529
-            avatarImg: data[0]
542
+          Taro.navigateTo({
543
+            url: `/pages/card/photo?photoUrl=${encodeURIComponent(data[0])}`
530 544
           })
531 545
         })
532 546
       },
533
-      complete: res => {
534
-        Taro.hideLoading()
535
-      }
536
-    })
537
-  }
538
-  saveBtn() {
539
-    this.setState({
540
-      avatarPopVisible: false,
541 547
     })
542 548
   }
549
+
543 550
   render() {
544
-    const { makePosterStatus, posterData, grantPhoneVisible, grantAvatarVisible, cardId, avatarImg } = this.state
551
+    const { makePosterStatus, posterData, grantPhoneVisible, grantAvatarVisible, cardId } = this.state
545 552
     const { userInfo, cardInfo, projectDetail } = this.props
546 553
     const { person: { personType, personId, phone, tel } } = userInfo
547 554
     const { unReadNum, picture, visitors, id, isReport } = cardInfo
@@ -573,13 +580,6 @@ export default class Index extends Component {
573 580
           grantAvatarVisible &&
574 581
           <AchieveAvatar user={userInfo.person} onSuccess={() => { this.setState({ grantAvatarVisible: false }) }} ></AchieveAvatar>
575 582
         }
576
-        {
577
-          avatarPopVisible &&
578
-          <View className="avatar-pop">
579
-            <Image src={avatarImg} className='avatar-img' onClick={this.bindAlbumClick} mode="aspectFill"></Image>
580
-            <Button className="save-btn" onClick={this.saveBtn}>保存</Button>
581
-          </View>
582
-        }
583 583
 
584 584
         {this.state.loaded && (
585 585
           <View className='mycard'>
@@ -589,7 +589,9 @@ export default class Index extends Component {
589 589
                 <View className='mycard__user__imgox'>
590 590
                   <Image className='mycard__user__img' src={picture} mode="widthFix"></Image>
591 591
                   <Image src={picture} mode="aspectFill" className='head__img'></Image>
592
-                  <Image src={require('@/assets/edit.png')} className='edit-img' onClick={this.bindAlbumClick} mode="aspectFill"></Image>
592
+                  {
593
+                    isSelf && <Image src={require('@/assets/edit.png')} className='edit-img' onClick={this.bindAlbumClick} mode="aspectFill"></Image>
594
+                  }
593 595
                 </View>
594 596
                 <Image src={require('@/assets/person/top.png')} className='top-img' mode="aspectFill"></Image>
595 597
               </View>

+ 62
- 0
src/pages/card/photo.js 查看文件

@@ -0,0 +1,62 @@
1
+import Taro, { Component } from '@tarojs/taro'
2
+import './index.scss'
3
+import { updatePhoto } from '@/services/card'
4
+import { connect } from '@tarojs/redux'
5
+
6
+@connect(
7
+  ({ user }) => ({ ...user })
8
+)
9
+
10
+export default class Panorama extends Component {
11
+  state = {
12
+    avatarImg: ''
13
+  }
14
+
15
+  // 选择图片
16
+  bindAlbumClick(e) {
17
+
18
+    e.stopPropagation()
19
+
20
+    Taro.showLoading({
21
+      title: '加载中',
22
+    })
23
+    Taro.chooseImage({
24
+      count: 1,
25
+      sizeType: ['original', 'compressed'],  //可选择原图或压缩后的图片
26
+      sourceType: ['album', 'camera'], //可选择性开放访问相册、相机
27
+      success: res => {
28
+        uploadFiles(res.tempFilePaths).then(data => {
29
+          this.setState({
30
+            avatarImg: data[0]
31
+          })
32
+        })
33
+      },
34
+      complete: res => {
35
+        Taro.hideLoading()
36
+      }
37
+    })
38
+  }
39
+  saveBtn() {
40
+    const { avatarImg } = this.state
41
+    const photoUrl = this.$router.params.photoUrl || avatarImg
42
+    const { userInfo: { person: { personId } } } = this.props
43
+    updatePhoto({ photoUrl }).then(res => {
44
+      // Taro.navigateBack({ delta: 1 })
45
+      Taro.redirectTo({ url: `/pages/card/index?id=${personId}&loadInfo=need` })
46
+    })
47
+  }
48
+
49
+  render() {
50
+
51
+    const { avatarImg } = this.state
52
+    const photoUrl = this.$router.params.photoUrl || avatarImg
53
+
54
+    return (
55
+      <View className="avatar-pop">
56
+        <Image src={photoUrl} className='avatar-img' onClick={this.bindAlbumClick} mode="aspectFill"></Image>
57
+        <Button className="save-btn" onClick={this.saveBtn}>保存</Button>
58
+      </View>
59
+
60
+    )
61
+  }
62
+}

+ 3
- 2
src/pages/person/index.js 查看文件

@@ -213,7 +213,7 @@ export default class Person extends Component {
213 213
 
214 214
   renderDetail() {
215 215
     const { users, menus, roleName } = this.state
216
-    const { user: { userInfo: { person: { org: { waterMark } = {} }, miniApp: { name } } } } = this.props
216
+    const { user: { userInfo: { person: { avatarurl, org: { waterMark } = {} }, miniApp: { name } } } } = this.props
217 217
 
218 218
     // const showQRCode = user.personType === ROLE_CODE['CONSULTANT'] || ROLE_CODE['ESTATE_AGENT'] || ROLE_CODE['CHANNEL_AGENT']
219 219
     // const isConsultant = user.personType == ROLE_CODE['CONSULTANT']
@@ -229,7 +229,8 @@ export default class Person extends Component {
229 229
           <View className="content">
230 230
             <View className="info-block">
231 231
               <View className="avatar" onClick={this.goPersonDetail}>
232
-                <Image className="info__headimg" src={users.avatar} />
232
+                <Image className="info__headimg" src={avatarurl} />
233
+                {/* <Image className="info__headimg" src={users.avatar} /> */}
233 234
                 <View className="info-intro">{roleName}</View>
234 235
               </View>
235 236
 

+ 6
- 0
src/routes.js 查看文件

@@ -149,6 +149,12 @@ const routes = [
149 149
     pkg: 'main',
150 150
     type: 'card',
151 151
   },
152
+  {
153
+    name: '更换头像',
154
+    page: 'pages/card/photo',
155
+    pkg: 'main',
156
+    type: 'card',
157
+  },
152 158
   {
153 159
     name: '我的客户',
154 160
     page: 'pages/person/myGuest/index',

+ 8
- 1
src/services/card.js 查看文件

@@ -7,7 +7,8 @@ import {
7 7
   API_CARDS_LIKE,
8 8
   API_FORM_ID,
9 9
   API_CARDS_SHARE,
10
-  API_CARD_FAVOR
10
+  API_CARD_FAVOR,
11
+  API_UPDATE_PHOTO
11 12
 } from '@/constants/api'
12 13
 
13 14
 
@@ -42,6 +43,12 @@ export const addCardUv = id => fetch({ url: `${API_CARDS_UV}/${id}`, method: 'PO
42 43
  */
43 44
 export const addLike = id => fetch({ url: `${API_CARDS_LIKE}/${id}`, method: 'POST' })
44 45
 
46
+/**
47
+ * 置业顾问换头像
48
+ * @param {*} payload
49
+ */
50
+export const updatePhoto = payload => fetch({ url: API_UPDATE_PHOTO, payload, method: 'PUT' })
51
+
45 52
 /**
46 53
  * 名片取消点赞
47 54
  * @param {*} id  名片id