瀏覽代碼

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

张延森 5 年之前
父節點
當前提交
378e281ce0
共有 3 個檔案被更改,包括 199 行新增44 行删除
  1. 93
    0
      src/components/achieveAvatar/index.js
  2. 54
    0
      src/components/achieveAvatar/index.scss
  3. 52
    44
      src/pages/activity/detail/assemble.js

+ 93
- 0
src/components/achieveAvatar/index.js 查看文件

@@ -0,0 +1,93 @@
1
+import Taro, { Component } from '@tarojs/taro'
2
+import { connect } from '@tarojs/redux'
3
+import * as actions from '@actions/user'
4
+import './index.scss'
5
+
6
+@connect(state => state.user, { ...actions })
7
+
8
+export default class Index extends Component {
9
+
10
+  state = {}
11
+  componentDidMount() {
12
+    const { user = {} } = this.props
13
+    console.log('111')
14
+    if (user.avatar && typeof this.props.onSuccess === 'function') {
15
+      this.props.onSuccess();
16
+    }
17
+  }
18
+  getUserInfo() {
19
+    const { dispatchUpdateUserInfo } = this.props
20
+    const sessionKey = Taro.getStorageSync('sessionKey')
21
+    Taro.getUserInfo({
22
+      lang: 'zh_CN',
23
+      success: res => {
24
+        console.log(res, "res")
25
+        const payload = Object.assign(res, { sessionKey })
26
+        // const { userInfo: { nickName, gender, country, city, province } } = payload
27
+        // App.zhuge.identify(nickName, {
28
+        //   '昵称': nickName,
29
+        //   '性别': gender == 1 ? '男' : '女',
30
+        //   '国家': country,
31
+        //   '省份': province,
32
+        //   '城市': city
33
+        // })
34
+        // 用户信息保存至服务器
35
+        dispatchUpdateUserInfo(payload).then(res => {
36
+          console.log('更新信息')
37
+          // this.toPage(true)
38
+          this.props.onSuccess();
39
+        })
40
+      },
41
+      fail: () => {
42
+        Taro.showToast({
43
+          title: '获取用户信息失败',
44
+          icon: 'none'
45
+        })
46
+        return
47
+        // this.toPage(false)
48
+      }
49
+    })
50
+  }
51
+  toPage(succed) {
52
+    const router = Taro.getStorageSync('router')
53
+    const { query, path } = router
54
+
55
+    if (!succed && path === 'pages/signin/index') {
56
+      return
57
+    }
58
+    if (path === 'pages/project/index' || path === 'pages/shop/index' || path === 'pages/person/index') {
59
+      Taro.switchTab({
60
+        url: '/' + path
61
+      })
62
+      return
63
+    }
64
+    Taro.reLaunch({
65
+      url: `/${path}?${query.params}`
66
+    })
67
+  }
68
+
69
+  renderMaskBanner() {
70
+    return (
71
+      <View>
72
+        <View className="avatar-page">
73
+          <View className="content">
74
+            <View className="title">请允许获取昵称、头像、地区及性别</View>
75
+            <Image className="touxiang" src={require('@assets/default-avatar.png')}></Image>
76
+            <View className="name">用户昵称</View>
77
+            <Button className="btn" open-type="getUserInfo" lang="zh_CN" onGetUserInfo={this.getUserInfo}>好</Button>
78
+          </View>
79
+        </View>
80
+      </View>
81
+    )
82
+  }
83
+  render() {
84
+    const { user = {} } = this.props
85
+
86
+    return (
87
+      <Block>
88
+        {this.renderMaskBanner()}
89
+        {/* {!user.avatar && this.renderMaskBanner()} */}
90
+      </Block>
91
+    )
92
+  }
93
+}

+ 54
- 0
src/components/achieveAvatar/index.scss 查看文件

@@ -0,0 +1,54 @@
1
+
2
+.avatar-page{
3
+  position: fixed;
4
+  width: 100vw;
5
+  height: 100vh;
6
+  left: 0;
7
+  top: 0;
8
+  z-index: 9999;
9
+  background: rgba(0, 0, 0, 0.22);
10
+  display: flex;
11
+  flex-direction: column;
12
+  justify-content: center;
13
+  align-items: center;
14
+  
15
+  .content {
16
+    width: 94vw;
17
+    height: 430px;
18
+    position: absolute;
19
+    left: 50%;
20
+    top: 50%;
21
+    margin-left: -47vw;
22
+    transform: translateY(-50%);
23
+    background-color: #fff;
24
+    border-radius: 12px;
25
+    padding: 40px;
26
+    text-align: center;
27
+    .title{
28
+      font-size: 34px;
29
+      color: #333;
30
+    }
31
+    .touxiang{
32
+      width: 110px;
33
+      height: 110px;
34
+      border-radius: 50%;
35
+      margin: 20px 0 10px 0;
36
+    }
37
+    .name{
38
+      font-size: 26px;
39
+      color: #333;
40
+    }
41
+  
42
+  
43
+    .btn{
44
+      width:290px;
45
+      height:90px;
46
+      background:rgba(187,156,121,1);
47
+      border-radius:12px;
48
+      font-size: 34px;
49
+      color: #fff;
50
+      line-height: 90px;
51
+      margin-top: 40px;
52
+    }
53
+  }
54
+}

+ 52
- 44
src/pages/activity/detail/assemble.js 查看文件

@@ -3,6 +3,7 @@ import './index.scss'
3 3
 import Notice from '@components/Notice'
4 4
 import BackHomeBtn from '@components/BackHomeBtn'
5 5
 import AchievePhone from '@components/achievePhone'
6
+import AchieveAvatar from '@components/achieveAvatar'
6 7
 import Poster from '@components/Poster'
7 8
 import FormIdCollector from '@components/formIdCollector'
8 9
 import dayjs from 'dayjs'
@@ -72,7 +73,9 @@ export default class Detail extends Component {
72 73
     ready.queue(() => {
73 74
       // 必须授权电话
74 75
       if (this.toggleGrantPhone()) {
75
-        this.initPageData()
76
+        if (this.toggleGrantAvatar()) {
77
+          this.initPageData()
78
+        }
76 79
       }
77 80
     })
78 81
   }
@@ -394,7 +397,7 @@ export default class Detail extends Component {
394 397
         if (res.confirm) {
395 398
 
396 399
           // 必须授权头像
397
-          if (this.toggleGrantAvatar()) {            
400
+          if (this.toggleGrantAvatar()) {
398 401
             createGroupActivity({
399 402
               groupActivityId: detail.groupActivityId,
400 403
               personId: person.personId,
@@ -402,16 +405,16 @@ export default class Detail extends Component {
402 405
               phone: person.tel || person.phone,
403 406
               avatarurl: person.avatarurl,
404 407
             }).then(res => {
405
-                this.setState({
406
-                  recordDetail: res.taShareRecord,
407
-                  recordId: res.taShareRecord.recordId,
408
-                  memberList: res.shareChildRecordList || [],
409
-                  isStarter: true,
410
-                  groupState: res.taShareRecord.status,
411
-                }, () => cb && cb())
412
-              
408
+              this.setState({
409
+                recordDetail: res.taShareRecord,
410
+                recordId: res.taShareRecord.recordId,
411
+                memberList: res.shareChildRecordList || [],
412
+                isStarter: true,
413
+                groupState: res.taShareRecord.status,
414
+              }, () => cb && cb())
415
+
413 416
             }).catch(err => {
414
-              console.log(err,'11111111111111')
417
+              console.log(err, '11111111111111')
415 418
               Taro.showToast({
416 419
                 title: '发起失败: ' + err.message,
417 420
                 icon: 'none'
@@ -479,6 +482,7 @@ export default class Detail extends Component {
479 482
       groupState,
480 483
       actionSheetVisible,
481 484
       grantPhoneVisible,
485
+      grantAvatarVisible,
482 486
       posterTpls,
483 487
       posters,
484 488
       qrCode,
@@ -522,7 +526,11 @@ export default class Detail extends Component {
522 526
 
523 527
         {
524 528
           grantPhoneVisible &&
525
-          <AchievePhone user={userInfo.person} onSuccess={this.initPageData}></AchievePhone>
529
+          <AchievePhone user={userInfo.person} onSuccess={this.toggleGrantAvatar}></AchievePhone>
530
+        }
531
+        {
532
+          grantAvatarVisible &&
533
+          <AchieveAvatar user={userInfo.person} onSuccess={this.initPageData} ></AchieveAvatar>
526 534
         }
527 535
         <BackHomeBtn></BackHomeBtn>
528 536
         {
@@ -559,7 +567,7 @@ export default class Detail extends Component {
559 567
                       <Block>
560 568
                         <Image className="status__img" style="margin:12rpx auto 24rpx auto" src={getThumbnail(successImg)}></Image>
561 569
                         {
562
-                          verificationCode&&<View className="hexiaoma" style="margin:0 auto 40rpx auto">核销码: {verificationCode}</View>
570
+                          verificationCode && <View className="hexiaoma" style="margin:0 auto 40rpx auto">核销码: {verificationCode}</View>
563 571
                         }
564 572
                       </Block>
565 573
                     )
@@ -617,42 +625,42 @@ export default class Detail extends Component {
617 625
                 <View style="padding:0 40rpx 180rpx 40rpx">
618 626
                   <Image src={getThumbnail(detail.descImg)} mode="widthFix" style="width:100%;"></Image>
619 627
                 </View>
620
-                { (actState === ActBeforeStart||(isStarter && actState === ActInProcess && groupState === GroupInProcess)||(!isStarter && actState === ActInProcess && groupState != GroupInProcess )||(!isStarter && actState === ActInProcess && groupState === GroupInProcess))&&
621
-                <View className="btn-fixed">
622
-                  {
623
-                    actState === ActBeforeStart &&
624
-                    (<View className="nostart-btn"><FormIdCollector><Button className="nostart-btn" style="margin: auto">未开始</Button></FormIdCollector></View>)
625
-                  }
626
-                  {
627
-                    isStarter && actState === ActInProcess && groupState === GroupInProcess &&
628
-                    (<View className="assistance-btn"><FormIdCollector><Button className="assistance-btn" style="margin: auto" onClick={this.groupBuyInvite}>邀请好友拼团</Button></FormIdCollector></View>)
629
-                  }
630
-                  {
631
-                    !isStarter && actState === ActInProcess && groupState != GroupInProcess &&
628
+                {(actState === ActBeforeStart || (isStarter && actState === ActInProcess && groupState === GroupInProcess) || (!isStarter && actState === ActInProcess && groupState != GroupInProcess) || (!isStarter && actState === ActInProcess && groupState === GroupInProcess)) &&
629
+                  <View className="btn-fixed">
630
+                    {
631
+                      actState === ActBeforeStart &&
632
+                      (<View className="nostart-btn"><FormIdCollector><Button className="nostart-btn" style="margin: auto">未开始</Button></FormIdCollector></View>)
633
+                    }
634
+                    {
635
+                      isStarter && actState === ActInProcess && groupState === GroupInProcess &&
636
+                      (<View className="assistance-btn"><FormIdCollector><Button className="assistance-btn" style="margin: auto" onClick={this.groupBuyInvite}>邀请好友拼团</Button></FormIdCollector></View>)
637
+                    }
638
+                    {
639
+                      !isStarter && actState === ActInProcess && groupState != GroupInProcess &&
632 640
 
633
-                    <View className={groupState === GroupInProcess ? "set-btn" : "assistance-btn"} style="border:none">
634
-                      <FormIdCollector>
635
-                        <Button className={groupState === GroupInProcess ? "set-btn" : "assistance-btn"} onClick={this.startMine}>发起我的拼团</Button>
636
-                      </FormIdCollector>
637
-                    </View>
638
-                  }
639
-                  {
640
-                    !isStarter && actState === ActInProcess && groupState === GroupInProcess &&
641
-
642
-                    <View className="btn-box" style="margin: auto; padding: 0;">
643
-                      {
644
-                        (groupState === GroupInProcess && !isJoin) &&
645
-                        (<View className="assistance-btn"><FormIdCollector><Button className="assistance-btn" onClick={this.joinGroup}>立即参团</Button></FormIdCollector></View>)
646
-                      }                      
647
-                      <View className={groupState === GroupInProcess && !isJoin ? "set-btn" : "assistance-btn"} style="border:none">
641
+                      <View className={groupState === GroupInProcess ? "set-btn" : "assistance-btn"} style="border:none">
648 642
                         <FormIdCollector>
649
-                          <Button className={groupState === GroupInProcess && !isJoin ? "set-btn" : "assistance-btn"} onClick={this.startMine}>发起我的拼团</Button>
643
+                          <Button className={groupState === GroupInProcess ? "set-btn" : "assistance-btn"} onClick={this.startMine}>发起我的拼团</Button>
650 644
                         </FormIdCollector>
651 645
                       </View>
652
-                    </View>
646
+                    }
647
+                    {
648
+                      !isStarter && actState === ActInProcess && groupState === GroupInProcess &&
653 649
 
654
-                  }
655
-                </View>
650
+                      <View className="btn-box" style="margin: auto; padding: 0;">
651
+                        {
652
+                          (groupState === GroupInProcess && !isJoin) &&
653
+                          (<View className="assistance-btn"><FormIdCollector><Button className="assistance-btn" onClick={this.joinGroup}>立即参团</Button></FormIdCollector></View>)
654
+                        }
655
+                        <View className={groupState === GroupInProcess && !isJoin ? "set-btn" : "assistance-btn"} style="border:none">
656
+                          <FormIdCollector>
657
+                            <Button className={groupState === GroupInProcess && !isJoin ? "set-btn" : "assistance-btn"} onClick={this.startMine}>发起我的拼团</Button>
658
+                          </FormIdCollector>
659
+                        </View>
660
+                      </View>
661
+
662
+                    }
663
+                  </View>
656 664
                 }
657 665
               </ScrollView>
658 666