瀏覽代碼

Merge branch 'v3.5.1' of http://git.ycjcjy.com/zhiyuxing/miniapp-v3 into v3.5.1

许静 5 年之前
父節點
當前提交
90d5d9c050

+ 6
- 2
src/app.js 查看文件

@@ -164,6 +164,10 @@ class App extends Component {
164 164
         console.info('router2:', router)
165 165
         console.info('-----------')
166 166
         const { query: payload } = router
167
+
168
+        payload.path = router.path
169
+        payload.scene = router.scene
170
+
167 171
         // login
168 172
         login(payload, res => {
169 173
           // 获取未读消息
@@ -209,8 +213,8 @@ class App extends Component {
209 213
   componentDidMount() {
210 214
     console.info('app componentDidMount')
211 215
   }
212
-  componentWillMount() {
213
-    console.info('app componentWillMount')
216
+  componentWillMount(params) {
217
+    console.info('app componentWillMount', params)
214 218
   }
215 219
 
216 220
   getRouterParams() {

+ 2
- 2
src/pages/activity/detail/poster.js 查看文件

@@ -67,7 +67,7 @@ export default class Index extends Component {
67 67
         fontSize: 30,
68 68
         color: 'black',
69 69
         baseLine: 'middle',
70
-        lineNum: 2,
70
+        lineNum: 1,
71 71
         lineHeight: 48,
72 72
         // textAlign: 'center',
73 73
         width: 560,
@@ -80,7 +80,7 @@ export default class Index extends Component {
80 80
         fontSize: 28,
81 81
         color: '#999',
82 82
         baseLine: 'middle',
83
-        lineNum: 2,
83
+        lineNum: 1,
84 84
         lineHeight: 48,
85 85
         width: 560,
86 86
         zIndex: 999

+ 29
- 2
src/pages/card/index.js 查看文件

@@ -8,6 +8,7 @@ import BackHomeBtn from '@components/BackHomeBtn'
8 8
 import getUserPhone from '@utils/getUserPhone'
9 9
 import AchievePhone from '@components/achievePhone'
10 10
 import ready from '@utils/ready'
11
+import { sceneInShare } from '@utils/tools'
11 12
 
12 13
 import { ROLE_CODE } from '@constants/user'
13 14
 import { addCardUv, addCardShareNum, favorCard, cancelFavorCard } from '@services/card'
@@ -42,12 +43,27 @@ export default class Index extends Component {
42 43
 
43 44
   componentWillMount() {
44 45
     ready.queue(() => {
46
+
47
+      // 分享场景需要先授权手机, 再授权头像
48
+      const options = wx.getLaunchOptionsSync()
49
+      if (sceneInShare(options.scene)) {
50
+        const { person = {} } = this.props.userInfo || {}
51
+        if ((person.tel || person.phone) && (person.avatarurl || '').indexOf('wx.qlogo.cn') === -1) {
52
+          Taro.reLaunch({ url: '/pages/auth/index' })
53
+          return
54
+        }
55
+
56
+        this.setState({
57
+          grantPhoneVisible: true,
58
+        })
59
+      }
60
+
45 61
       this.initPageData()
46 62
     })
47 63
   }
48 64
   initPageData() {
49 65
     const router = Taro.getStorageSync('router')
50
-    const id = this.$router.params.id || router.query.id || '4604a792d575eb8187711625bd88832c'
66
+    const id = this.$router.params.id || router.query.id
51 67
 
52 68
     if (router.query.id) {
53 69
       this.setState({
@@ -402,6 +418,17 @@ export default class Index extends Component {
402 418
       modalStatus: false
403 419
     })
404 420
   }
421
+  
422
+  handleAuthPhoneSuccess = () => {
423
+    const { person = {} } = this.props.userInfo || {}
424
+    if ((person.avatarurl || '').indexOf('wx.qlogo.cn') === -1) {
425
+      Taro.reLaunch({ url: '/pages/auth/index' })
426
+      return
427
+    }
428
+
429
+    this.initPageData()
430
+  }
431
+
405 432
   render() {
406 433
     const { makePosterStatus, posterData, modalStatus, grantPhoneVisible } = this.state
407 434
     const { userInfo, cardInfo, projectDetail } = this.props
@@ -423,7 +450,7 @@ export default class Index extends Component {
423 450
         {makePosterStatus && (<Poster data={posterData} toggle={this.toggleVisiblePoster}></Poster>)}
424 451
         {
425 452
           (grantPhoneVisible && userInfo.person.personId && !userInfo.person.phone) &&
426
-          <AchievePhone user={userInfo.person} onSuccess={this.initPageData}></AchievePhone>
453
+          <AchievePhone user={userInfo.person} onSuccess={this.handleAuthPhoneSuccess}></AchievePhone>
427 454
         }
428 455
         {
429 456
           visibleConfirmModal && (

+ 2
- 2
src/pages/news/detail/poster.js 查看文件

@@ -67,7 +67,7 @@ export default class Index extends Component {
67 67
         fontSize: 30,
68 68
         color: 'black',
69 69
         baseLine: 'middle',
70
-        lineNum: 2,
70
+        lineNum: 1,
71 71
         lineHeight: 48,
72 72
         // textAlign: 'center',
73 73
         width: 560,
@@ -80,7 +80,7 @@ export default class Index extends Component {
80 80
         fontSize: 28,
81 81
         color: '#999',
82 82
         baseLine: 'middle',
83
-        lineNum: 2,
83
+        lineNum: 1,
84 84
         lineHeight: 48,
85 85
         width: 560,
86 86
         zIndex: 999

+ 13
- 6
src/pages/project/album/index.js 查看文件

@@ -24,9 +24,15 @@ export default class Index extends Component {
24 24
 
25 25
 
26 26
   componentWillMount () {
27
-    const { id = '369b7d7e5bc6e6b91f2e8f5e775035e2' } = this.$router.params
28
-    const { projectDetail: { buildingId }, dispatchProjectDetail } = this.props
29 27
 
28
+
29
+    const { id = '369b7d7e5bc6e6b91f2e8f5e775035e2', current } = this.$router.params
30
+    const { projectDetail: { buildingId }, dispatchProjectDetail } = this.props
31
+    if (current) {
32
+      this.setState({
33
+        current,
34
+      })
35
+    }
30 36
     if (!buildingId) {
31 37
       dispatchProjectDetail(id)
32 38
     }
@@ -59,14 +65,17 @@ export default class Index extends Component {
59 65
     const { projectDetail: { buildingApartment = [] } } = this.props
60 66
     const list = buildingApartment.filter(item => item.apartmentType === 'photo')
61 67
     const listimg = list.filter(item => item.buildingImgList.length > 0)
62
-    console.log(listimg, '--------------')
68
+
63 69
     const { current } = this.state
64 70
     const imgList = (listimg[current] || {}).buildingImgList || []
71
+
65 72
     let _photosImgs = imgList.map(img => img.url)
66 73
 
67 74
     return (
68 75
       <View className='photos'>
69 76
         <View className="around-tab">
77
+          {console.log(listimg, '-----listimg---------')}
78
+          {console.log(imgList, '-------imgList-------')}
70 79
           {listimg.map((item, index) => {
71 80
             const { apartmentName } = item || {}
72 81
             const buildingImgList = item.buildingImgList || []
@@ -76,15 +85,13 @@ export default class Index extends Component {
76 85
             return (
77 86
               <View
78 87
                 key={current}
79
-                className={`around-tab__item ${current === index ? 'active' : ''}`}
88
+                className={`around-tab__item ${current == index ? 'active' : ''}`}
80 89
                 onClick={() => this.setState({ current: index })}
81 90
               >
82 91
                 {buildingImgList.length > 0 && <View className="around-tab-text"> {`${apartmentName}(${buildingImgList.length})`} </View>}
83 92
               </View>
84 93
             )
85 94
 
86
-
87
-
88 95
           })}
89 96
         </View>
90 97
         <View className='photos__item'>

+ 47
- 68
src/pages/project/detail/index.js 查看文件

@@ -21,7 +21,7 @@ import dayjs from 'dayjs'
21 21
 import 'dayjs/locale/zh-cn' // 按需加载
22 22
 import ready from '@utils/ready'
23 23
 import Notice from '@components/Notice'
24
-import { getDownloadURL, getThumbnail } from '@utils/tools'
24
+import { getDownloadURL, getThumbnail, sceneInShare } from '@utils/tools'
25 25
 import { connect } from '@tarojs/redux'
26 26
 import { dispatchProjectDetail } from '@actions/project'
27 27
 import getUserPhone from '@utils/getUserPhone'
@@ -62,9 +62,22 @@ export default class Index extends Component {
62 62
   }
63 63
 
64 64
   componentWillMount() {
65
-    // const { id = '78c3dd489791dc1d29472fa344b08c45' } = this.$router.params
66
-
67 65
     ready.queue(() => {
66
+    
67
+      // 分享场景需要先授权手机, 再授权头像
68
+      const options = wx.getLaunchOptionsSync()
69
+      if (sceneInShare(options.scene)) {
70
+        const { person = {} } = this.props.userInfo || {}
71
+        if ((person.tel || person.phone) && (person.avatarurl || '').indexOf('wx.qlogo.cn') === -1) {
72
+          Taro.reLaunch({ url: '/pages/auth/index' })
73
+          return
74
+        }
75
+
76
+        this.setState({
77
+          grantPhoneVisible: true,
78
+        })
79
+      }
80
+
68 81
       this.initPageData()
69 82
     })
70 83
   }
@@ -102,16 +115,6 @@ export default class Index extends Component {
102 115
       })
103 116
     })
104 117
   }
105
-  componentDidMount() {
106
-    const options = wx.getLaunchOptionsSync()
107
-    const sceneList = [1011, 1012, 1013, 1031, 1032, 1036, 1047, 1048]
108
-
109
-    if (sceneList.indexOf(options.scene) != -1) {
110
-      this.setState({
111
-        grantPhoneVisible: true,
112
-      })
113
-    }
114
-  }
115 118
 
116 119
   loadHelpGroupList() {
117 120
     const { buildingId } = this.state
@@ -169,7 +172,7 @@ export default class Index extends Component {
169 172
     queryActivityList(payload).then(res => {
170 173
       console.log(res, 'Activity')
171 174
       this.setState({
172
-        activityList: res || []
175
+        activityList: res.list || []
173 176
       })
174 177
     })
175 178
   }
@@ -242,9 +245,10 @@ export default class Index extends Component {
242 245
     })
243 246
   }
244 247
 
245
-  toViewAlbum() {
248
+  toViewAlbum (index){
246 249
     const { buildingId } = this.state
247
-    this.navigateTo(`/pages/project/album/index?id=${buildingId}`)
250
+    console.log('1111111',index)
251
+    this.navigateTo(`/pages/project/album/index?id=${buildingId}&current=${index}` )
248 252
   }
249 253
 
250 254
   onViewFans() {
@@ -488,6 +492,16 @@ export default class Index extends Component {
488 492
     })
489 493
   }
490 494
 
495
+  handleAuthPhoneSuccess = () => {
496
+    const { person = {} } = this.props.userInfo || {}
497
+    if ((person.avatarurl || '').indexOf('wx.qlogo.cn') === -1) {
498
+      Taro.reLaunch({ url: '/pages/auth/index' })
499
+      return
500
+    }
501
+
502
+    this.initPageData()
503
+  }
504
+
491 505
   renderBottomMenu() {
492 506
     const { userInfo: { person: { personType } } } = this.props
493 507
     const { posterShow } = this.state
@@ -611,7 +625,7 @@ export default class Index extends Component {
611 625
             <View className='photos__type'>
612 626
               <View className='photos__type__title'>相册</View>
613 627
               <ScrollView scrollX>
614
-                <View className='photos__type__content' onClick={this.toViewAlbum}>
628
+                <View className='photos__type__content' >
615 629
 
616 630
                   <View className="around-tab">
617 631
                     {listimg.map((item, index) => {
@@ -622,19 +636,21 @@ export default class Index extends Component {
622 636
                       console.log(buildingImgUrl, 'buildingImgUrl')
623 637
 
624 638
                       // if (buildingImgUrl != null) {
625
-                      return (<View key={index + "listimg"}>
639
+                      return ( <View key={index + "listimg"}>
626 640
                         {buildingImgUrl != null && (<View
627 641
                           style={{ marginRight: '8px' }}
642
+                          
628 643
                         >
629 644
 
630 645
                           <View>
631
-                            <Image className='albumimg' src={getThumbnail(buildingImgList[0].url)} ></Image>
646
+                            <Image className='albumimg' src={getThumbnail(buildingImgList[0].url)} onClick={()=>this.toViewAlbum(index)}></Image>
632 647
                             <View style={{ width: '218rpx', display: 'flex', justifyContent: 'center' }} >
633 648
                               <View style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}> {apartmentName}  </View>
634 649
                               <View> ({buildingImgList.length})</View>
635 650
                             </View>
636 651
                           </View>
637
-                        </View>)}</View>
652
+                        </View>)}
653
+                        </View>
638 654
                       )
639 655
                       // }
640 656
 
@@ -851,40 +867,22 @@ export default class Index extends Component {
851 867
     )
852 868
   }
853 869
   renderActivities() {
854
-    // renderGroup () {
855
-    //   const { groupList } = this.state
856
-    //   return (
857
-    //     <Block>
858
-    //       {groupList.length > 0 &&
859
-    //         <View className="activity">
860
-    //           <View className="title">拼团活动</View>
861
-    //           <View
862
-    //             style={{ position: 'relative' }}>
863
-    //             <HelpGroupBanner
864
-    //               style={{ height: '250rpx' }}
865
-    //               indicatorDots={false}
866
-    //               list={groupList}
867
-    //               onClick={this.handleGroupClick}>
868
-    //             </HelpGroupBanner>
869
-    //           </View>
870
-    //         </View>
871
-    //       }
872
-    //     </Block>
873
-    //   )
874
-    // }
870
+
871
+ 
875 872
     const { activityList } = this.state
873
+   
876 874
     return (
877 875
       <Block>
878 876
         {
879 877
           activityList.length > 0 && (
880 878
             <View className="activity" >
881
-              {console.log(activityList, '----activityList-----')}
879
+           
882 880
               <View className="section-head">
883
-                <Text className="section-head__title">热门活动</Text>
884
-                <View className="section-head__more" onClick={this.handleActivityMoreClick}>
885
-                  更多活动<Text className="iconfont icon-more"></Text>
886
-                </View>
887
-              </View>
881
+                 <Text className="section-head__title" style={{margin: '10rpx 0 40rpx 35rpx'}}>热门活动</Text>
882
+                 <View className="section-head__more"  style={{marginRight: '20rpx'}} onClick={this.handleActivityMoreClick}>
883
+                   更多活动<Text className="iconfont icon-more"></Text>
884
+                 </View>
885
+               </View>
888 886
               <View
889 887
                 style={{ position: 'relative' }}>
890 888
                 <HelpGroupBanner
@@ -899,26 +897,7 @@ export default class Index extends Component {
899 897
 
900 898
               </View>
901 899
             </View>
902
-            // <View classN                                                                                                                                                                                                                                                                                                                                                                                                                                                    ame="house-type">
903
-            //   <View className="section-head">
904
-            //     <Text className="section-head__title">热门活动</Text>
905
-            //     <View className="section-head__more" onClick={this.handleActivityMoreClick}>
906
-            //       更多活动<Text className="iconfont icon-more"></Text>
907
-            //     </View>
908
-            //   </View>
909
-            //   <ScrollView scrollX>
910
-            //     <View className="house-type__list" style="margin-top:10px">
911
-            //       {
912
-            //         activityList.map(item => (
913
-            //           <View className="news-item" key={item.dynamicId} onClick={this.handActivityItemClick.bind(this, item.dynamicId)}>
914
-            //             <Image mode="widthFix" src={getThumbnail(item.imgUrl)} className="news-item__pic"></Image>
915
-            //             <View className="news-item__title">{item.title}</View>
916
-            //           </View>
917
-            //         ))
918
-            //       }
919
-            //     </View>
920
-            //   </ScrollView>
921
-            // </View>
900
+      
922 901
           )
923 902
         }
924 903
       </Block>
@@ -1045,7 +1024,7 @@ export default class Index extends Component {
1045 1024
       <Block>
1046 1025
         {
1047 1026
           (grantPhoneVisible && userInfo.person.personId && !userInfo.person.phone) &&
1048
-          <AchievePhone user={userInfo.person} onSuccess={this.initPageData}></AchievePhone>
1027
+          <AchievePhone user={userInfo.person} onSuccess={this.handleAuthPhoneSuccess}></AchievePhone>
1049 1028
         }
1050 1029
         {
1051 1030
           loaded && (

+ 2
- 1
src/pages/project/detail/poster.js 查看文件

@@ -70,7 +70,7 @@ export default class Index extends Component {
70 70
         fontSize: 28,
71 71
         color: '#999',
72 72
         baseLine: 'middle',
73
-        lineNum: 2,
73
+        lineNum: 1,
74 74
         lineHeight: 48,
75 75
         // textAlign: 'center',
76 76
         width: 560,
@@ -117,6 +117,7 @@ export default class Index extends Component {
117 117
         color: '#999',
118 118
         baseLine: 'middle',
119 119
         lineHeight: 48,
120
+        lineNum: 1,
120 121
         width: 150,
121 122
         zIndex: 11
122 123
       },

+ 1
- 1
src/pages/shop/record/index.js 查看文件

@@ -74,7 +74,7 @@ export default class Index extends Component {
74 74
 									<Image className="botttom_img" mode="aspectFill" src={item.image} />
75 75
 									<View className="bottom-right">
76 76
 										<View className="bottom-right-top">
77
-											<View className="product-name">{item.targetName}</View>
77
+											<View className="product-name" style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',width:'300rpx' }}>{item.targetName}</View>
78 78
 											<View className="product-score">{item.points}积分</View>
79 79
 										</View>
80 80
 										<View className="bottom-right-down">领取地址:{item.address}</View>

+ 1
- 0
src/pages/shop/record/index.scss 查看文件

@@ -61,6 +61,7 @@
61 61
 					width: 100%;
62 62
 					display: flex;
63 63
 					justify-content: space-between;
64
+			
64 65
 					.product-score{
65 66
 						color:rgba(255,59,51,1);
66 67
 					}

+ 17
- 4
src/utils/login.js 查看文件

@@ -2,9 +2,12 @@ import Taro from '@tarojs/taro';
2 2
 import { getStore } from '@tarojs/redux'
3 3
 import { USER_INFO } from '@constants/user'
4 4
 import { wxLogin } from '@services/login'
5
+import { sceneInShare } from '@utils/tools'
5 6
 import ready from '@utils/ready'
6 7
 let loading = false
7
-export default function (params, callback) {
8
+export default function (payload, callback) {
9
+  const { path, scene, ...params } = payload
10
+
8 11
   if (loading) {
9 12
     return
10 13
   }
@@ -34,9 +37,19 @@ export default function (params, callback) {
34 37
           callback && callback(data)
35 38
 
36 39
         } else {
37
-          Taro.reLaunch({
38
-            url: '/pages/auth/index'
39
-          })
40
+
41
+          // 非扫码进入项目详情或者卡片主页, 跳转到授权头像
42
+          // 否则不跳
43
+          const noAuthPages = [
44
+            'pages/project/detail/index',
45
+            'pages/card/index',
46
+          ]
47
+
48
+          if (noAuthPages.indexOf(path) === -1 || !sceneInShare(scene)) {
49
+            Taro.reLaunch({
50
+              url: '/pages/auth/index'
51
+            })
52
+          }
40 53
         }
41 54
         ready.open()
42 55
 

+ 12
- 0
src/utils/tools.js 查看文件

@@ -1,5 +1,17 @@
1 1
 import Taro from '@tarojs/taro';
2 2
 
3
+/**
4
+ * 是否分享场景(含扫码)
5
+ * @param {*} scene 
6
+ */
7
+export function sceneInShare(scene) {
8
+  return [1011, 1012, 1013, 1031, 1032, 1036, 1047, 1048].indexOf(scene) > -1
9
+}
10
+
11
+/**
12
+ * 造空数组
13
+ * @param {int}} n 
14
+ */
3 15
 export function times(n) {
4 16
   return n > 0 ? '*'.repeat(n - 1).split('*') : []
5 17
 }