xujing 5 年前
父节点
当前提交
5334808a50
共有 3 个文件被更改,包括 186 次插入52 次删除
  1. 1
    0
      src/pages/project/detail/index.js
  2. 96
    16
      src/pages/shop/rule/index.js
  3. 89
    36
      src/pages/shop/rule/index.scss

+ 1
- 0
src/pages/project/detail/index.js 查看文件

@@ -89,6 +89,7 @@ export default class Index extends Component {
89 89
       // 没有找到 id , 再重新找一次
90 90
       if (!id) {
91 91
         getQrCodeParams(this.$router.params.scene).then(res => {
92
+          console.log(res,"扫码参数")
92 93
           this.setState({
93 94
             qrcodeParams: res
94 95
           })

+ 96
- 16
src/pages/shop/rule/index.js 查看文件

@@ -1,24 +1,29 @@
1 1
 import Taro, { Component } from '@tarojs/taro';
2
-import { getWindowHeight } from '@utils/style'
3 2
 import './index.scss'
4
-
3
+import { transferImage } from '@utils/tools'
5 4
 import ready from '@utils/ready'
6 5
 import { connect } from '@tarojs/redux'
7 6
 import * as actions from '@actions/shop'
8
-import dayjs from 'dayjs'
7
+import { View } from '@tarojs/components';
8
+import { queryUserInfo, doUserSignin } from '@services/user'
9
+const ruleBg = require('@assets/rulebg.png')
10
+
11
+@connect(state => ({ ...state.shop, ...state.user, ...state.city, }), { ...actions })
9 12
 
10
-@connect(state => ({ ...state.shop, ...state.user }), { ...actions })
11 13
 export default class Shop extends Component {
12 14
   config = {
13 15
     navigationBarTitleText: '积分规则'
14 16
   }
15 17
 
16 18
   state = {
17
-    pointRule: []
19
+    pointRule: [],
20
+    user: {},
18 21
   }
19 22
 
20 23
   componentWillMount() {
24
+    this.loadUserInfo()
21 25
     this.loadRecords()
26
+
22 27
   }
23 28
 
24 29
   loadRecords() {
@@ -29,6 +34,85 @@ export default class Shop extends Component {
29 34
       })
30 35
       Taro.hideLoading()
31 36
     })
37
+
38
+  }
39
+  loadUserInfo() {
40
+    queryUserInfo().then(user => {
41
+      this.setState({
42
+        user,
43
+      })
44
+    })
45
+  }
46
+  getBtnName(code) {
47
+    const { user: { havaSigned } } = this.state
48
+    switch (code) {
49
+      case 'checkin':
50
+        return havaSigned ? '已签到' : '签到'
51
+      case 'share-poster':
52
+        return '去分享'
53
+      case 'recommend-customer':
54
+        return '去推荐'
55
+      case 'signup-agent':
56
+        return '去授权'
57
+      case 'document_verify':
58
+        return '去提交'
59
+      default:
60
+        return '立即参与'
61
+    }
62
+  }
63
+  // 签到
64
+  doSign(pointsAmount) {
65
+    const { user: { id, havaSigned } } = this.state
66
+
67
+
68
+    if (havaSigned) {
69
+      return
70
+    }
71
+    doUserSignin({ id }).then(res => {
72
+      Taro.showToast({
73
+        title: `签到成功,获取${pointsAmount}积分`,
74
+        icon: 'none'
75
+      })
76
+      this.loadUserInfo()
77
+
78
+    })
79
+  }
80
+  handleItemClick(item) {
81
+    switch (item.code) {
82
+      case 'checkin':
83
+        this.doSign(item.pointsAmount)
84
+        return
85
+      case 'share-poster':
86
+        Taro.switchTab({
87
+          url: '/pages/project/index'
88
+        })
89
+        return
90
+      case 'recommend-customer':
91
+        Taro.navigateTo({
92
+          url: `/pages/agent/recommend/index?type=index&cityId=` + this.props.curCity.id
93
+        })
94
+        return
95
+      case 'signup-agent':
96
+        Taro.navigateTo({
97
+          url: '/pages/person/personDetail/index'
98
+        })
99
+        return
100
+      case 'document_verify':
101
+        Taro.navigateTo({
102
+          url: '/pages/person/profile/index'
103
+        })
104
+        return
105
+      default:
106
+        Taro.getApp().props.projectIndex = 2
107
+        Taro.switchTab({
108
+          url: `/pages/activity/activity`,
109
+          fail: res => {
110
+            Taro.getApp().props.projectIndex = 0
111
+          }
112
+        })
113
+        return
114
+    }
115
+
32 116
   }
33 117
 
34 118
   render() {
@@ -36,28 +120,24 @@ export default class Shop extends Component {
36 120
     const { pointRule } = this.state
37 121
 
38 122
     return (
39
-      <View className="page">
40
-        <View className='rule_title'>
41
-          <Text>积分项</Text>
42
-          <Text>奖励积分</Text>
43
-          <Text>说明</Text>
44
-        </View>
123
+      // <View className="page" style={`background: url(${transferImage(buildBg)}) no-repeat center;background-size: 100% 100%;`}>
124
+      <View className="page" >
125
+        <Image className="bg-img" src={transferImage(ruleBg)} mode='widthFix'></Image>
45 126
         <ScrollView
46 127
           scrollY
47 128
           scroll-with-animation
48 129
           enable-back-to-top
49 130
           className="list"
50 131
           style={{
51
-            height: '65vh'
132
+            maxHeight: '78vh'
52 133
           }}>
53 134
           {
54 135
             pointRule.length === 0 ? '' : (
55 136
               pointRule.map(item => (
56 137
                 <View className='rule_item' key={item.ruleId}>
57
-                  <Text>{item.ruleName}</Text>
58
-                  <Text>+{item.pointsAmount}</Text>
59
-                  <Text>{item.remark}</Text>
60
-                  {/* <Text>{dayjs(item.updateDate).format('YYYY-MM-DD HH:mm:ss')}</Text> */}
138
+                  <View className="item-name">{item.ruleName}<Text className="item-num">+{item.pointsAmount}</Text><Text className="jifen">积分</Text></View>
139
+                  <View className="item-rule">{item.remark}</View>
140
+                  <View className={this.getBtnName(item.code)=='已签到'?'yiqiandao':"item-btn"} onClick={this.handleItemClick.bind(this, item)}>{this.getBtnName(item.code)}</View>
61 141
                 </View>
62 142
               ))
63 143
             )

+ 89
- 36
src/pages/shop/rule/index.scss 查看文件

@@ -1,54 +1,107 @@
1 1
 @import "@styles/theme.scss";
2 2
 .page {
3 3
   position: relative;
4
-  background: #F2F2F2;
5 4
   width: 100%;
6 5
   height: 100%;
7
-  .rule_title {
8
-    position: fixed;
9
-    width: 100%;
10
-    left: 0%;
11
-    background: #fff;
12
-    color: #fd8000;
13
-    font-size: 28px;
14
-    display: flex;
15
-    justify-content: space-between;
16
-    align-items: center;
17
-    padding: 30px 90px;
18
-    box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.05);
19
-    font-weight:500;
6
+  .bg-img{
7
+    width: 100vw;
8
+    display: block;
20 9
   }
10
+  // .rule_title {
11
+  //   position: fixed;
12
+  //   width: 100%;
13
+  //   left: 0%;
14
+  //   background: #fff;
15
+  //   color: #fd8000;
16
+  //   font-size: 28px;
17
+  //   display: flex;
18
+  //   justify-content: space-between;
19
+  //   align-items: center;
20
+  //   padding: 30px 90px;
21
+  //   box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.05);
22
+  //   font-weight:500;
23
+  // }
21 24
   .list {
22 25
     position: absolute;
23
-    width: 100%;
24
-    top: 100px;
26
+    width: 690px;
27
+    left: 30px;
28
+    top: 560px;
29
+    background: #fff;
30
+    border-radius: 12px;
25 31
     .rule_item {
26 32
       position: relative;
27 33
       width: 100%;
28
-      text-align: center;
29
-      border-bottom: 2px solid rgba(151, 151, 151, 0.0865);
30
-      padding: 40px 12px;
31
-      display: inline-flex;
32
-      background: #fff;
33
-      Text {
34
-        width: 33.33%;
35
-        text-align: center;
36
-        float: left;
34
+      box-shadow:0px 1px 0px 0px rgba(0,0,0,0.08);
35
+      padding: 24px 20px 28px 20px;
36
+      .item-name{
37
+        font-size: 34px;
38
+        color: #333;
39
+        display: flex;
40
+        align-items: center;
41
+        margin-bottom: 16px;
42
+        .item-num{
43
+          font-size: 36px;
44
+          color: #FF8203;
45
+          margin: 0 6px 0 10px;
46
+        }
47
+        .jifen{
48
+          font-size: 24px;
49
+          color: #666;
50
+        }
37 51
       }
38
-      Text:nth-of-type(1){
39
-        color:rgba(0,0,0,1);
40
-        font-size: 30px;
41
-        font-weight:500;
52
+      .item-rule{
53
+        font-size: 24px;
54
+        color: #999;
55
+        width: 500px;
42 56
       }
43
-      Text:nth-of-type(2){
44
-        color:rgba(255,59,51,1);
45
-        font-size: 32px;
46
-        font-weight: 500;
57
+      .yiqiandao{
58
+        width:120px;
59
+        height:60px;
60
+        background:#d8d8d8;
61
+        border-radius:30px;
62
+        position: absolute;
63
+        right: 20px;
64
+        top: 24px;
65
+        color: #fff;
66
+        font-size: 26px;
67
+        text-align: center;
68
+        line-height: 60px;
69
+
47 70
       }
48
-      Text:nth-of-type(3){
49
-        color:rgba(0,0,0,0.33);
50
-        font-size: 24px;
71
+      .item-btn{
72
+        width:120px;
73
+        height:60px;
74
+        background:linear-gradient(180deg,rgba(255,222,131,1) 0%,rgba(255,129,2,1) 100%);
75
+        box-shadow:0px 12px 30px -8px rgba(255,131,5,0.5);
76
+        border-radius:30px;
77
+        position: absolute;
78
+        right: 20px;
79
+        top: 24px;
80
+        color: #fff;
81
+        font-size: 26px;
82
+        text-align: center;
83
+        line-height: 60px;
51 84
       }
85
+      // display: inline-flex;
86
+      // Text {
87
+      //   width: 33.33%;
88
+      //   text-align: center;
89
+      //   float: left;
90
+      // }
91
+      // Text:nth-of-type(1){
92
+      //   color:rgba(0,0,0,1);
93
+      //   font-size: 30px;
94
+      //   font-weight:500;
95
+      // }
96
+      // Text:nth-of-type(2){
97
+      //   color:rgba(255,59,51,1);
98
+      //   font-size: 32px;
99
+      //   font-weight: 500;
100
+      // }
101
+      // Text:nth-of-type(3){
102
+      //   color:rgba(0,0,0,0.33);
103
+      //   font-size: 24px;
104
+      // }
52 105
     }
53 106
   }
54 107
 }