Browse Source

添加复制

黎海 1 year ago
parent
commit
4f350d7844

+ 8 - 5
src/app.js

@@ -12,10 +12,7 @@ class App extends Component {
12
 
12
 
13
   }
13
   }
14
   onLaunch () {
14
   onLaunch () {
15
-    console.log('app启动');
16
-    if (!Taro.getStorageSync('session_key')) {
17
-      tool.toLogin();
18
-    }
15
+    
19
     
16
     
20
     // 保持屏幕常亮
17
     // 保持屏幕常亮
21
     Taro.setKeepScreenOn({
18
     Taro.setKeepScreenOn({
@@ -38,7 +35,13 @@ class App extends Component {
38
     if (params.s) {
35
     if (params.s) {
39
       Taro.setStorageSync('source_name', item.s)
36
       Taro.setStorageSync('source_name', item.s)
40
     }
37
     }
41
-    tool.reportLogin()
38
+    console.log('app启动');
39
+    if (!Taro.getStorageSync('session_key')) {
40
+      tool.toLogin();
41
+    }else{
42
+
43
+      tool.reportLogin()
44
+    }
42
     Taro.setKeepScreenOn({
45
     Taro.setKeepScreenOn({
43
       keepScreenOn: true
46
       keepScreenOn: true
44
     })
47
     })

+ 4 - 0
src/common/tool.js

@@ -21,6 +21,10 @@ const tool = {
21
               key: "user_id",
21
               key: "user_id",
22
               data: item.data.id
22
               data: item.data.id
23
             })
23
             })
24
+            setTimeout(res=>{
25
+
26
+              api.reportLogin()
27
+            },1000)
24
           })
28
           })
25
         } else {
29
         } else {
26
         }
30
         }

+ 87 - 12
src/pages/index/subpages/novel/index.jsx

@@ -1,5 +1,5 @@
1
 import { Component } from 'react'
1
 import { Component } from 'react'
2
-import { View, Text, Button, Image, scrollView, Input } from '@tarojs/components'
2
+import { View, Text, Button, Image, scrollView, Input, RichText } from '@tarojs/components'
3
 import * as api from '../../../../service/index'
3
 import * as api from '../../../../service/index'
4
 import tool from '../../../../common/tool'
4
 import tool from '../../../../common/tool'
5
 import Taro, { getCurrentInstance } from '@tarojs/taro'
5
 import Taro, { getCurrentInstance } from '@tarojs/taro'
@@ -12,12 +12,15 @@ export default class collection extends Component {
12
     booksinfo: {},
12
     booksinfo: {},
13
     is_collect: 0,//是否加入书架,0|1
13
     is_collect: 0,//是否加入书架,0|1
14
     likeBookList: [],
14
     likeBookList: [],
15
-    lastTime: 0
15
+    lastTime: 0,
16
+    isOpendDrectory: false,//是否打开目录
17
+    free_content: '',//免费章节
16
   }
18
   }
17
 
19
 
18
   componentWillMount () {
20
   componentWillMount () {
19
     this.getBookinfo()
21
     this.getBookinfo()
20
     this.getBookLike()
22
     this.getBookLike()
23
+    this.getAppConfig()
21
   }
24
   }
22
   componentDidShow () {
25
   componentDidShow () {
23
   }
26
   }
@@ -30,6 +33,15 @@ export default class collection extends Component {
30
       }
33
       }
31
     })
34
     })
32
   }
35
   }
36
+  getAppConfig () {
37
+    api.getAppConfig().then(res => {
38
+      if (res.code == 200) {
39
+        this.setState({
40
+          isOpendDrectory: res.data.status_chapter == 0 ? false : true
41
+        })
42
+      }
43
+    })
44
+  }
33
   getBookinfo () {
45
   getBookinfo () {
34
     let routers = this.$instance.router.params
46
     let routers = this.$instance.router.params
35
     api.getBookinfo({ book_id: routers.book_id }).then(res => {
47
     api.getBookinfo({ book_id: routers.book_id }).then(res => {
@@ -37,6 +49,8 @@ export default class collection extends Component {
37
         this.setState({
49
         this.setState({
38
           booksinfo: res.data.book_info[0],
50
           booksinfo: res.data.book_info[0],
39
           is_collect: res.data.is_collect
51
           is_collect: res.data.is_collect
52
+        }, () => {
53
+          this.getBookFreeContent()
40
         })
54
         })
41
       }
55
       }
42
     })
56
     })
@@ -112,6 +126,55 @@ export default class collection extends Component {
112
         }
126
         }
113
       })
127
       })
114
     })
128
     })
129
+
130
+  }
131
+  copyBookTips () {
132
+    Taro.setClipboardData({
133
+      data: this.state.booksinfo.intro,
134
+      success: function (res) {
135
+        Taro.showToast({
136
+          title: `复制成功`,
137
+          icon: 'none',
138
+          mask: true,
139
+        });
140
+      }
141
+    })
142
+  }
143
+  convertToPlainText(html) {
144
+    var temp = document.createElement("div");
145
+    temp.innerHTML = html;
146
+    var plainText = temp.textContent || temp.innerText;
147
+    plainText = plainText.replace(/ /g, " ");
148
+    plainText = plainText.replace(/…/g, "…");
149
+    plainText = plainText.replace(/—/g, "—");
150
+    plainText = plainText.replace(/“/g, "“");
151
+    plainText = plainText.replace(/”/g, "”");
152
+    return plainText;
153
+  }
154
+  getBookFreeContent () {
155
+    api.getBookFreeContent({ book_id: this.state.booksinfo.id }).then(res => {
156
+      if (res.code == 200) {
157
+        // const plainText = res.data.replace(/<[^>]+>/g, '');
158
+        const plainText = this.convertToPlainText(res.data)
159
+        this.setState({
160
+          free_content: plainText
161
+        })
162
+      }
163
+    })
164
+  }
165
+
166
+  copySelectedTips () {
167
+    const { free_content } = this.state;
168
+    Taro.setClipboardData({
169
+      data: free_content,
170
+      success: function (res) {
171
+        Taro.showToast({
172
+          title: `复制成功`,
173
+          icon: 'none',
174
+          mask: true,
175
+        });
176
+      }
177
+    })
115
   }
178
   }
116
 
179
 
117
   render () {
180
   render () {
@@ -122,23 +185,30 @@ export default class collection extends Component {
122
             <Image className='book-img' src={this.state.booksinfo.img}></Image>
185
             <Image className='book-img' src={this.state.booksinfo.img}></Image>
123
             <View className='top-right'>
186
             <View className='top-right'>
124
               <View className='book-title'>{tool.ellipsis(this.state.booksinfo.name, 15)}</View>
187
               <View className='book-title'>{tool.ellipsis(this.state.booksinfo.name, 15)}</View>
125
-              <View className='book-visit-num'>{this.state.booksinfo.paly_cnt}览</View>
188
+              <View className='book-visit-num'>{this.state.booksinfo.paly_cnt}览</View>
126
             </View>
189
             </View>
127
             <View className='share update-active' onClick={e => (this.copyCode())}>
190
             <View className='share update-active' onClick={e => (this.copyCode())}>
128
               <Image className='share-img' mode='widthFix' src='https://video-img.fyshark.com/1684206675357shykahfgl.png'></Image>
191
               <Image className='share-img' mode='widthFix' src='https://video-img.fyshark.com/1684206675357shykahfgl.png'></Image>
129
             </View>
192
             </View>
130
           </View>
193
           </View>
131
           <View className='book-tips'>
194
           <View className='book-tips'>
132
-            <View className='book-tips-title'>书籍简介</View>
195
+            <View className='book-tips-title'>
196
+              书籍简介
197
+              <Image className='book-tips-copy' onClick={e => (this.copyBookTips())} src='https://video-img.fyshark.com/1686882094575dahkn.png'></Image>
198
+            </View>
133
             <View className='book-tips-content'>{this.state.booksinfo.intro} </View>
199
             <View className='book-tips-content'>{this.state.booksinfo.intro} </View>
134
           </View>
200
           </View>
135
-          <View className='directory' onClick={e => (this.toDirectory())}>
136
-            <View className='directory-left'>
137
-              <Image className='directory-icon' src='https://video-img.fyshark.com/1683618704652dadda%20.png'></Image>
138
-              <View className='derectory-title'>查看目录</View>已更新到{this.state.booksinfo.album_cnt}章
201
+          {
202
+            this.state.isOpendDrectory &&
203
+            <View className='directory' onClick={e => (this.toDirectory())}>
204
+              <View className='directory-left'>
205
+                <Image className='directory-icon' src='https://video-img.fyshark.com/1683618704652dadda%20.png'></Image>
206
+                <View className='derectory-title'>查看目录</View>已更新到{this.state.booksinfo.album_cnt}章
207
+              </View>
208
+              <Image className='directory-right-icon' src='https://video-img.fyshark.com/1683618693594ddada%20.png'></Image>
139
             </View>
209
             </View>
140
-            <Image className='directory-right-icon' src='https://video-img.fyshark.com/1683618693594ddada%20.png'></Image>
141
-          </View>
210
+          }
211
+
142
           <View className='like'>
212
           <View className='like'>
143
             <View className='like-tips'>
213
             <View className='like-tips'>
144
               <View className='lick-title'>猜你喜欢</View>
214
               <View className='lick-title'>猜你喜欢</View>
@@ -159,8 +229,13 @@ export default class collection extends Component {
159
             </View>
229
             </View>
160
           </View>
230
           </View>
161
           <View className='selected'>
231
           <View className='selected'>
162
-            <View className='selected-title'>精选内容</View>
163
-            <View className='selected-text'>{this.state.booksinfo.short_name}</View>
232
+            <View className='selected-title'>
233
+              精选内容
234
+              <Image className='book-tips-copy' onClick={e => (this.copySelectedTips())} src='https://video-img.fyshark.com/1686882094575dahkn.png'></Image>
235
+            </View>
236
+            <RichText
237
+              className='selected-text'
238
+              nodes={tool.ellipsis(this.state.free_content, 80)}></RichText>
164
           </View>
239
           </View>
165
           <View className='console'>
240
           <View className='console'>
166
             <View className='console-content'>
241
             <View className='console-content'>

+ 14 - 0
src/pages/index/subpages/novel/index.less

@@ -49,10 +49,17 @@
49
       margin-top: 40px;
49
       margin-top: 40px;
50
 
50
 
51
       .book-tips-title {
51
       .book-tips-title {
52
+        display: flex;
53
+        align-items: center;
52
         font-size: 32px;
54
         font-size: 32px;
53
         font-family: PingFang SC;
55
         font-family: PingFang SC;
54
         font-weight: bold;
56
         font-weight: bold;
55
         color: #363636;
57
         color: #363636;
58
+        .book-tips-copy{
59
+          width: 50px;
60
+          height: 50px;
61
+          display: block;
62
+        }
56
       }
63
       }
57
 
64
 
58
       .book-tips-content {
65
       .book-tips-content {
@@ -161,6 +168,13 @@
161
         font-family: PingFang SC;
168
         font-family: PingFang SC;
162
         font-weight: 800;
169
         font-weight: 800;
163
         color: #363636;
170
         color: #363636;
171
+        display: flex;
172
+        align-items: center;
173
+        .book-tips-copy{
174
+          width: 50px;
175
+          height: 50px;
176
+          display: block;
177
+        }
164
       }
178
       }
165
 
179
 
166
       .selected-text {
180
       .selected-text {

+ 19 - 5
src/pages/index/subpages/novelText/index.jsx

@@ -42,7 +42,8 @@ export default class collection extends Component {
42
     selectVip: 0,//当前选择的充值
42
     selectVip: 0,//当前选择的充值
43
     isIos: false,
43
     isIos: false,
44
     pay_status: 1,//是否绑定口令
44
     pay_status: 1,//是否绑定口令
45
-    code:''
45
+    code: '',
46
+    isOpendDrectory: false,//是否打开目录
46
   }
47
   }
47
 
48
 
48
   componentWillMount () {
49
   componentWillMount () {
@@ -54,6 +55,7 @@ export default class collection extends Component {
54
     } else {
55
     } else {
55
       this.getBookCatalogue()
56
       this.getBookCatalogue()
56
       this.getShopList()
57
       this.getShopList()
58
+      this.getAppConfig()
57
     }
59
     }
58
     let that = this
60
     let that = this
59
     Taro.getSystemInfo({
61
     Taro.getSystemInfo({
@@ -68,6 +70,15 @@ export default class collection extends Component {
68
   }
70
   }
69
   componentDidShow () {
71
   componentDidShow () {
70
   }
72
   }
73
+  getAppConfig () {
74
+    api.getAppConfig().then(res => {
75
+      if (res.code == 200) {
76
+        this.setState({
77
+          isOpendDrectory: res.data.status_chapter == 0 ? false : true
78
+        })
79
+      }
80
+    })
81
+  }
71
   getBookCatalogue () {
82
   getBookCatalogue () {
72
     Taro.showLoading({
83
     Taro.showLoading({
73
       title: '加载中',
84
       title: '加载中',
@@ -324,10 +335,13 @@ export default class collection extends Component {
324
                     <Image className='console-img' src='https://video-img.fyshark.com/1683623105394hsikah.png'></Image>
335
                     <Image className='console-img' src='https://video-img.fyshark.com/1683623105394hsikah.png'></Image>
325
                     上一章
336
                     上一章
326
                   </View>
337
                   </View>
327
-                  <View className='console-content' onClick={e => (this.directory())}>
328
-                    <Image className='console-img' src='https://video-img.fyshark.com/1683623271853dhjkdhjl.png'></Image>
329
-                    目录
330
-                  </View>
338
+                  {
339
+                    this.state.isOpendDrectory &&
340
+                    <View className='console-content' onClick={e => (this.directory())}>
341
+                      <Image className='console-img' src='https://video-img.fyshark.com/1683623271853dhjkdhjl.png'></Image>
342
+                      目录
343
+                    </View>
344
+                  }
331
                   <View className='console-right' style={this.state.booksinfo.content_next_id == 0 ? 'opacity: 0.3;' : ''} onClick={e => (this.next())}>
345
                   <View className='console-right' style={this.state.booksinfo.content_next_id == 0 ? 'opacity: 0.3;' : ''} onClick={e => (this.next())}>
332
                     下一章
346
                     下一章
333
                     <Image className='console-img' src='https://video-img.fyshark.com/1683623282017shiojh.png'></Image>
347
                     <Image className='console-img' src='https://video-img.fyshark.com/1683623282017shiojh.png'></Image>

+ 30 - 5
src/pages/mine/index.jsx

@@ -46,6 +46,15 @@ export default class collection extends Component {
46
   }
46
   }
47
 
47
 
48
   componentWillMount () {
48
   componentWillMount () {
49
+    tt.getUserInfo({
50
+      withCredentials: true,
51
+      success (res) {
52
+        console.log(`getUserInfo 调用成功 ${res.userInfo}`, res);
53
+      },
54
+      fail (res) {
55
+        console.log(`getUserInfo 调用失败`);
56
+      },
57
+    });
49
     this.getAppConfig()
58
     this.getAppConfig()
50
   }
59
   }
51
   componentDidShow () {
60
   componentDidShow () {
@@ -71,12 +80,28 @@ export default class collection extends Component {
71
     })
80
     })
72
   }
81
   }
73
   getUserInfo () {
82
   getUserInfo () {
83
+    let that = this 
74
     api.getUserInfo().then(res => {
84
     api.getUserInfo().then(res => {
75
       Taro.hideLoading()
85
       Taro.hideLoading()
76
       if (res.code == 200) {
86
       if (res.code == 200) {
77
-        this.setState({
78
-          userInfo: res.data
79
-        })
87
+        tt.getUserInfo({
88
+          withCredentials: true,
89
+          success (item) {
90
+            res.data.head_img = item.userInfo.avatarUrl
91
+            res.data.user_name = item.userInfo.nickName
92
+            that.setState({
93
+              userInfo: res.data
94
+            })
95
+          },
96
+          fail (item) {
97
+            console.log(res.data,'res.data');
98
+            that.setState({
99
+              userInfo: res.data
100
+            })
101
+            console.log(`getUserInfo 调用失败`);
102
+          },
103
+        });
104
+        
80
       }
105
       }
81
     })
106
     })
82
   }
107
   }
@@ -94,7 +119,7 @@ export default class collection extends Component {
94
       url: item.url
119
       url: item.url
95
     })
120
     })
96
   }
121
   }
97
-  onShareAppMessage(res) {
122
+  onShareAppMessage (res) {
98
     if (res.from === 'button') {
123
     if (res.from === 'button') {
99
       // 来自页面内转发按钮
124
       // 来自页面内转发按钮
100
       console.log(res.target)
125
       console.log(res.target)
@@ -107,7 +132,7 @@ export default class collection extends Component {
107
         videoTopics: ["hello", "hi"],
132
         videoTopics: ["hello", "hi"],
108
         withVideoId: true,
133
         withVideoId: true,
109
       },
134
       },
110
-      success(res) {
135
+      success (res) {
111
         /* res结构:{errMsg: string, videoId: string } */
136
         /* res结构:{errMsg: string, videoId: string } */
112
         console.log(res.videoId);
137
         console.log(res.videoId);
113
         tt.navigateToVideoView({
138
         tt.navigateToVideoView({

+ 1 - 1
src/pages/mine/subpages/makeMoney/index.jsx

@@ -35,7 +35,7 @@ export default class collection extends Component {
35
           isNext = false
35
           isNext = false
36
         }
36
         }
37
         this.setState({
37
         this.setState({
38
-          earningslist: [...res.data.earningslist, ...this.state.earningslist],
38
+          earningslist: [...this.state.earningslist, ...res.data.earningslist],
39
           add_sum: res.data.add_sum,
39
           add_sum: res.data.add_sum,
40
           already_sum: res.data.already_sum,
40
           already_sum: res.data.already_sum,
41
           now_sum: res.data.now_sum,
41
           now_sum: res.data.now_sum,

+ 26 - 8
src/pages/mine/subpages/team/index.jsx

@@ -32,14 +32,32 @@ export default class collection extends Component {
32
     })
32
     })
33
   }
33
   }
34
   teamEnqueue () {
34
   teamEnqueue () {
35
+    let that = this
35
     if (this.state.my_role_status == 0) {
36
     if (this.state.my_role_status == 0) {
36
-      api.teamEnqueue({ input_str: this.state.my_code }).then(res => {
37
-        if (res.code == 200) {
38
-          this.getTeamInfo()
39
-        } else {
40
-          Taro.showToast({ icon: 'none', title: res.msg });
41
-        }
42
-      })
37
+      tt.getUserInfo({
38
+        withCredentials: true,
39
+        success (item) {
40
+          let params = {
41
+            user_img: item.userInfo.avatarUrl,
42
+            user_name: item.userInfo.nickName
43
+          }
44
+          api.modifyUser(params).then(item => {
45
+            if (item.code == 200) {
46
+              api.teamEnqueue({ input_str: that.state.my_code }).then(res => {
47
+                if (res.code == 200) {
48
+                  that.getTeamInfo()
49
+                } else {
50
+                  Taro.showToast({ icon: 'none', title: res.msg });
51
+                }
52
+              })
53
+            }
54
+          })
55
+        },
56
+        fail (res) {
57
+          Taro.showToast({ icon: 'none', title: '团队绑定失败!' });
58
+        },
59
+      });
60
+
43
     } else {
61
     } else {
44
       Taro.setClipboardData({
62
       Taro.setClipboardData({
45
         data: this.state.my_code,
63
         data: this.state.my_code,
@@ -72,7 +90,7 @@ export default class collection extends Component {
72
               </View>
90
               </View>
73
               :
91
               :
74
               <View>
92
               <View>
75
-                <View className='title'>团队邀请码:</View>
93
+                <View className='title'>我的邀请码:</View>
76
                 <View className='code'>{this.state.my_code}</View>
94
                 <View className='code'>{this.state.my_code}</View>
77
               </View>
95
               </View>
78
           }
96
           }

+ 2 - 0
src/pages/mine/subpages/vipDetail/index.less

@@ -120,10 +120,12 @@
120
 
120
 
121
       .purchase-list {
121
       .purchase-list {
122
         margin-top: 38px;
122
         margin-top: 38px;
123
+        flex-wrap: wrap;
123
         display: flex;
124
         display: flex;
124
         justify-content: space-between;
125
         justify-content: space-between;
125
 
126
 
126
         .purchase-info {
127
         .purchase-info {
128
+          margin-top: 20px;
127
           position: relative;
129
           position: relative;
128
           width: 212px;
130
           width: 212px;
129
           padding: 54px 0 26px 0;
131
           padding: 54px 0 26px 0;

+ 1 - 1
src/pages/mine/subpages/withdrawal/index.jsx

@@ -154,7 +154,7 @@ export default class collection extends Component {
154
               <View className='results-tips'>原因:{this.state.extract_text}</View>
154
               <View className='results-tips'>原因:{this.state.extract_text}</View>
155
             </View>
155
             </View>
156
           }
156
           }
157
-          <View className='withdrawal-title'>支付宝提现</View>
157
+          <View className='withdrawal-title'>提现</View>
158
           <View className='withdrawal-content'>
158
           <View className='withdrawal-content'>
159
             {
159
             {
160
               this.state.vip_list.map((item, index) => (
160
               this.state.vip_list.map((item, index) => (

+ 14 - 0
src/service/index.js

@@ -198,4 +198,18 @@ export const getCheckoutBookCode = data =>
198
     method: 'POST',
198
     method: 'POST',
199
     data,
199
     data,
200
   });
200
   });
201
+//修改用户信息
202
+export const modifyUser = data =>
203
+  Request({
204
+    url: '/api/modify_user',
205
+    method: 'POST',
206
+    data,
207
+  });
208
+//复制免费章节
209
+export const getBookFreeContent = data =>
210
+  Request({
211
+    url: '/api/get_book_free_content',
212
+    method: 'POST',
213
+    data,
214
+  });
201
 
215