张延森 hace 5 años
padre
commit
96131be423

+ 1
- 1
src/components/taro-plugin-canvas/index.js Ver fichero

@@ -158,7 +158,7 @@ export default class CanvasDrawer extends Component {
158 158
       })
159 159
       .catch((err) => {
160 160
         Taro.hideLoading();
161
-        Taro.showToast({ icon: 'none', title: err.errMsg || '下载图片失败' });
161
+        Taro.showToast({ icon: 'none', title: err.message || err.errMsg || '下载图片失败' });
162 162
         console.error(err);
163 163
         if (!onCreateFail) {
164 164
           console.warn('您必须实现 taro-plugin-canvas 组件的 onCreateFail 方法,详见文档 https://github.com/chuyun/taro-plugin-canvas#fail');

+ 47
- 42
src/components/taro-plugin-canvas/utils/tools.js Ver fichero

@@ -150,48 +150,53 @@ export function downloadImageAndInfo(image, index, toRpxFunc) {
150 150
   return new Promise((resolve, reject) => {
151 151
     const { x, y, url, zIndex } = image;
152 152
     const imageUrl = url;
153
-    // 下载图片
154
-    downImage(imageUrl, index)
155
-      // 获取图片信息
156
-      .then(imgPath => getImageInfo(imgPath, index))
157
-      .then(({ imgPath, imgInfo }) => {
158
-        // 根据画布的宽高计算出图片绘制的大小,这里会保证图片绘制不变形
159
-        let sx;
160
-        let sy;
161
-        const borderRadius = image.borderRadius || 0;
162
-        const setWidth = image.width;
163
-        const setHeight = image.height;
164
-        const width = toRpxFunc(imgInfo.width);
165
-        const height = toRpxFunc(imgInfo.height);
166 153
 
167
-        if (width / height <= setWidth / setHeight) {
168
-          sx = 0;
169
-          sy = (height - ((width / setWidth) * setHeight)) / 2;
170
-        } else {
171
-          sy = 0;
172
-          sx = (width - ((height / setHeight) * setWidth)) / 2;
173
-        }
174
-        let result = {
175
-          type: 'image',
176
-          borderRadius,
177
-          borderWidth: image.borderWidth,
178
-          borderColor: image.borderColor,
179
-          zIndex: typeof zIndex !== 'undefined' ? zIndex : index,
180
-          imgPath,
181
-          sx,
182
-          sy,
183
-          sw: (width - (sx * 2)),
184
-          sh: (height - (sy * 2)),
185
-          x,
186
-          y,
187
-          w: setWidth,
188
-          h: setHeight,
189
-        }
190
-        resolve(result);
191
-      })
192
-      .catch(err => {
193
-        console.log(err);
194
-        reject(err)
195
-      });
154
+    if (!url) {
155
+      reject(new Error('未找到图片信息'))
156
+    } else {
157
+      // 下载图片
158
+      downImage(imageUrl, index)
159
+        // 获取图片信息
160
+        .then(imgPath => getImageInfo(imgPath, index))
161
+        .then(({ imgPath, imgInfo }) => {
162
+          // 根据画布的宽高计算出图片绘制的大小,这里会保证图片绘制不变形
163
+          let sx;
164
+          let sy;
165
+          const borderRadius = image.borderRadius || 0;
166
+          const setWidth = image.width;
167
+          const setHeight = image.height;
168
+          const width = toRpxFunc(imgInfo.width);
169
+          const height = toRpxFunc(imgInfo.height);
170
+
171
+          if (width / height <= setWidth / setHeight) {
172
+            sx = 0;
173
+            sy = (height - ((width / setWidth) * setHeight)) / 2;
174
+          } else {
175
+            sy = 0;
176
+            sx = (width - ((height / setHeight) * setWidth)) / 2;
177
+          }
178
+          let result = {
179
+            type: 'image',
180
+            borderRadius,
181
+            borderWidth: image.borderWidth,
182
+            borderColor: image.borderColor,
183
+            zIndex: typeof zIndex !== 'undefined' ? zIndex : index,
184
+            imgPath,
185
+            sx,
186
+            sy,
187
+            sw: (width - (sx * 2)),
188
+            sh: (height - (sy * 2)),
189
+            x,
190
+            y,
191
+            w: setWidth,
192
+            h: setHeight,
193
+          }
194
+          resolve(result);
195
+        })
196
+        .catch(err => {
197
+          console.log(err);
198
+          reject(err)
199
+        });
200
+    }
196 201
   });
197 202
 }

+ 3
- 7
src/pages/activity/activity.js Ver fichero

@@ -23,24 +23,20 @@ export default class active extends Component {
23 23
     current: 0,
24 24
   }
25 25
 
26
-
27 26
   handleClick(value) {
28 27
     this.setState({
29 28
       current: value
30 29
     })
31
-  }  
30
+  }
32 31
 
33 32
   renderLogin() {
34 33
     return <Authorize></Authorize>
35 34
   }
36 35
 
37 36
   render() {
38
-    const { user } = this.state
39
-    // if (!user || !user.phone) {
40
-    //   return this.renderLogin()
41
-    // }
37
+    const { person: { phone } } = this.props.user.userInfo
42 38
 
43
-    return (!user || !user.phone) ? this.renderLogin() : (
39
+    return !phone ? this.renderLogin() : (
44 40
       <View style="height:100vh">
45 41
         <AtTabs className="tab-box" scroll current={this.state.current} tabList={[{ title: '热门活动' }, { title: '最新资讯' }]} onClick={this.handleClick.bind(this)}>
46 42
           <AtTabsPane current={this.state.current} index={0} >

+ 12
- 11
src/pages/activity/assemblePage.js Ver fichero

@@ -6,8 +6,6 @@ import AssembleItem from './assembleItem'
6 6
 import { savePoint, updatePoint } from '@services/common'
7 7
 import { connect } from '@tarojs/redux'
8 8
 
9
-let pageIndex = 1
10
-
11 9
 @connect(state => state.city)
12 10
 export default class Index extends Component {
13 11
 
@@ -19,7 +17,8 @@ export default class Index extends Component {
19 17
     list: [],
20 18
     hasMore: true,
21 19
     isEmpty: false,
22
-    recordId: null
20
+    recordId: null,
21
+    pageIndex: 1,
23 22
   }
24 23
 
25 24
   componentWillMount() {
@@ -44,7 +43,6 @@ export default class Index extends Component {
44 43
   loadList(pageNumber) {
45 44
     const { curCity: { id: cityId } } = this.props
46 45
     const payload = { pageSize: 10, pageNumber }
47
-    console.log(payload)
48 46
 
49 47
     const { params: { buildingId, from } } = this.$router
50 48
     if (cityId) {
@@ -65,31 +63,34 @@ export default class Index extends Component {
65 63
     console.log(item, "data")
66 64
 
67 65
     Taro.navigateTo({
68
-      url: '/pages/activity/detail/assemble?id=' + item.groupActivityId+'&initiateId='+item.recordId
66
+      url: '/pages/activity/detail/assemble?id=' + item.groupActivityId+'&recordId='+item.recordId
69 67
     })
70
-
71
-
72 68
   }
73 69
 
74 70
   onPullDownRefresh = async (rest) => {
75
-    const { records, list, total } = await this.loadList(1);
71
+    const { records, list, total, current } = await this.loadList(1);
76 72
     const _list = records || list || []
77 73
     this.setState({
78 74
       list: _list,
79 75
       isEmpty: total == 0,
76
+      pageIndex: current,
80 77
       hasMore: _list.length >= total ? false : true
81 78
     })
82 79
     rest && rest()
83 80
   }
84 81
 
85 82
   onScrollToLower = async (fn) => {
86
-    const { list } = this.state;
87
-    pageIndex++
88
-    const { records, list: list1, total } = await this.loadList(pageIndex);
83
+    const { list, pageIndex } = this.state;
84
+    
85
+    const { records, list: list1, total, current } = await this.loadList(pageIndex + 1);
89 86
     const _list = records || list1 || []
87
+
88
+    console.log('---list-->', list, _list)
89
+
90 90
     const newList = list.concat(_list)
91 91
     this.setState({
92 92
       list: newList,
93
+      pageIndex: current,
93 94
       hasMore: newList.length >= total ? false : true
94 95
     });
95 96
     fn && fn();

+ 8
- 7
src/pages/activity/assistancePage.js Ver fichero

@@ -6,8 +6,6 @@ import AssistanceItem from './assistanceItem'
6 6
 import { savePoint, updatePoint } from '@services/common'
7 7
 import { connect } from '@tarojs/redux'
8 8
 
9
-let pageIndex = 1
10
-
11 9
 @connect(state => state.city)
12 10
 export default class Index extends Component {
13 11
 
@@ -19,7 +17,8 @@ export default class Index extends Component {
19 17
     list: [],
20 18
     hasMore: true,
21 19
     isEmpty: false,
22
-    recordId: null
20
+    recordId: null,
21
+    pageIndex: 1,
23 22
   }
24 23
 
25 24
   componentWillMount() {
@@ -72,24 +71,26 @@ export default class Index extends Component {
72 71
   }
73 72
 
74 73
   onPullDownRefresh = async (rest) => {
75
-    const { records, list, total } = await this.loadList(1);
74
+    const { records, list, total, current } = await this.loadList(1);
76 75
     const _list = records || list || []
77 76
     this.setState({
78 77
       list: _list,
79 78
       isEmpty: total == 0,
79
+      pageIndex: current,
80 80
       hasMore: _list.length >= total ? false : true
81 81
     })
82 82
     rest && rest()
83 83
   }
84 84
 
85 85
   onScrollToLower = async (fn) => {
86
-    const { list } = this.state;
87
-    pageIndex++
88
-    const { records, list: list1, total } = await this.loadList(pageIndex);
86
+    const { list, pageIndex } = this.state;
87
+
88
+    const { records, list: list1, total, current } = await this.loadList(pageIndex + 1);
89 89
     const _list = records || list1 || []
90 90
     const newList = list.concat(_list)
91 91
     this.setState({
92 92
       list: newList,
93
+      pageIndex: current,
93 94
       hasMore: newList.length >= total ? false : true
94 95
     });
95 96
     fn && fn();

+ 8
- 12
src/pages/activity/detail/assemble.js Ver fichero

@@ -211,18 +211,14 @@ export default class Detail extends Component {
211 211
 
212 212
       // WxParse.wxParse('article', 'html', res.desc, this.$scope, 0)
213 213
 
214
-      // savePoint({
215
-      //   event: 'detail',
216
-      //   eventType: 'group',
217
-      //   propertyName: '拼团详情',
218
-      //   buildingId: res.buildingId,
219
-      //   targetId: res.groupActivityId,
220
-      //   data: '{}'
221
-      // }).then(res1 => {
222
-      //   this.setState({
223
-      //     recordId: res1.recordId
224
-      //   })
225
-      // })
214
+      savePoint({
215
+        event: 'detail',
216
+        eventType: 'group',
217
+        propertyName: '拼团详情',
218
+        buildingId: res.taShareActivity.buildingId,
219
+        targetId: id,
220
+        data: '{"recordId":"'+recordId+'"}'
221
+      }).then(() => {})
226 222
     })
227 223
   }
228 224
 

+ 8
- 12
src/pages/activity/detail/assistance.js Ver fichero

@@ -213,18 +213,14 @@ export default class Detail extends Component {
213 213
 
214 214
       // WxParse.wxParse('article', 'html', res.desc, this.$scope, 0)
215 215
 
216
-      // savePoint({
217
-      //   event: 'detail',
218
-      //   eventType: 'help',
219
-      //   propertyName: '助力详情',
220
-      //   buildingId: res.buildingId,
221
-      //   targetId: res.helpActivityId,
222
-      //   data: '{}'
223
-      // }).then(res1 => {
224
-      //   this.setState({
225
-      //     recordId: res1.recordId
226
-      //   })
227
-      // })
216
+      savePoint({
217
+        event: 'detail',
218
+        eventType: 'help',
219
+        propertyName: '助力详情',
220
+        buildingId: res.helpActivity.buildingId,
221
+        targetId: id,
222
+        data: '{"initiateId":"'+initiateId+'"}'
223
+      }).then(() => {})
228 224
     })
229 225
   }
230 226
 

+ 2
- 2
src/pages/activity/detail/index.js Ver fichero

@@ -71,9 +71,9 @@ export default class Detail extends Component {
71 71
         loaded: true,
72 72
         selector: times(res.maxEnlistByPerson || 1).map((_, i) => `${i+1}`),
73 73
       }, () => {
74
-        console.log('-----state-->', this.state)
74
+
75 75
         const { detail } = this.state
76
-        if (detail.posters[0].posterImg) {
76
+        if (detail.posters && detail.posters.length && detail.posters[0].posterImg) {
77 77
           this.setState({
78 78
             posterShow: true
79 79
           })

+ 14
- 10
src/pages/activity/index.js Ver fichero

@@ -6,8 +6,6 @@ import ActivityItem from './item'
6 6
 import { savePoint, updatePoint } from '@services/common'
7 7
 import { connect } from '@tarojs/redux'
8 8
 
9
-let pageIndex = 1
10
-
11 9
 @connect(state => state.city)
12 10
 export default class Index extends Component {
13 11
 
@@ -23,6 +21,8 @@ export default class Index extends Component {
23 21
     pageIndex: 1
24 22
   }
25 23
 
24
+  refreshing = false
25
+
26 26
   componentWillMount() {
27 27
     // App.zhuge.track('查看活动列表页面')
28 28
     savePoint({
@@ -37,15 +37,14 @@ export default class Index extends Component {
37 37
       console.log('活动列表')
38 38
     })
39 39
   }
40
-  componentDidMount() {
41
-    console.log(this.$router, "9999999999999999")
40
+ 
41
+  componentDidShow () {
42
+    this.onPullDownRefresh()
42 43
   }
44
+  
43 45
   componentWillUnmount() {
44 46
     const { recordId } = this.state
45 47
     updatePoint(recordId)
46
-
47
-    this.loadList(1)
48
-
49 48
   }
50 49
 
51 50
   loadList(pageNumber) {
@@ -90,6 +89,9 @@ export default class Index extends Component {
90 89
   }
91 90
 
92 91
   onPullDownRefresh = async (rest) => {
92
+    if (this.refreshing) return
93
+    this.refreshing = true
94
+
93 95
     const { records, list, total } = await this.loadList(1);
94 96
     const _list = records || list || []
95 97
     this.setState({
@@ -99,18 +101,20 @@ export default class Index extends Component {
99 101
       pageIndex: 1
100 102
     })
101 103
     rest && rest()
104
+    
105
+    this.refreshing = false
102 106
   }
103 107
 
104 108
   onScrollToLower = async (fn) => {
105 109
     const { list } = this.state;
106
-    pageIndex++
107
-    const { records, list: list1, total } = await this.loadList(this.state.pageIndex + 1);
110
+
111
+    const { records, list: list1, total, current } = await this.loadList(this.state.pageIndex + 1);
108 112
     const _list = records || list1 || []
109 113
     const newList = list.concat(_list)
110 114
     this.setState({
111 115
       list: newList,
112 116
       hasMore: newList.length >= total ? false : true,
113
-      pageIndex: this.state.pageIndex + 1
117
+      pageIndex: current,
114 118
     });
115 119
     fn && fn();
116 120
   }

+ 2
- 1
src/pages/news/detail/index.js Ver fichero

@@ -123,7 +123,7 @@ export default class NewsDetail extends Component {
123 123
         isSaved: res.isSave
124 124
       }, () => {
125 125
         const { detail } = this.state
126
-        if (detail.posters[0].posterImg) {
126
+        if (detail.posters && detail.posters.length && detail.posters[0].posterImg) {
127 127
           this.setState({
128 128
             posterShow: 'flex'
129 129
           })
@@ -162,6 +162,7 @@ export default class NewsDetail extends Component {
162 162
         "page": 'pages/news/detail/index',
163 163
       }
164 164
       const _avatarurl = getDownloadURL(avatarurl, 'avatar');
165
+
165 166
       getMiniQrcode(payload).then(qrcode => {
166 167
         let data = {
167 168
           qrcode,//小程序二维码

+ 1
- 1
src/pages/person/index.js Ver fichero

@@ -214,7 +214,7 @@ export default class Person extends Component {
214 214
     return (
215 215
       <View className='wrap'>
216 216
         {phone && this.renderDetail()}
217
-        {/* {!phone && this.renderLogin()} */}
217
+        {!phone && this.renderLogin()}
218 218
       </View>
219 219
     )
220 220
   }

+ 10
- 1
src/pages/project/detail/index.js Ver fichero

@@ -152,7 +152,7 @@ export default class Index extends Component {
152 152
         circumOpts,
153 153
         isSaved: res.isSave
154 154
       }, () => {
155
-        if (res.poster) {
155
+        if (res.posters && res.posters.length) {
156 156
           this.setState({
157 157
             posterShow: 'flex'
158 158
           })
@@ -327,6 +327,15 @@ export default class Index extends Component {
327 327
       // App.zhuge.track('生成海报')
328 328
 
329 329
       this.getPosterData().then(posterData => {
330
+        const { poster, qrcode } = posterData || {}
331
+        if (!poster || !qrcode) {
332
+          Taro.showToast({
333
+            title: '没有海报背景或二维码',
334
+            icon: 'none'
335
+          })
336
+          return
337
+        }
338
+
330 339
         this.setState({
331 340
           posterStatus: !!flag,
332 341
           posterData

+ 48
- 7
src/pages/project/index.js Ver fichero

@@ -252,10 +252,54 @@ export default class Index extends Component {
252 252
   }
253 253
 
254 254
   handleBannerClick(item) {
255
-    Taro.navigateTo({
256
-      url: `/pages/project/detail/index?id=${item.buildingId}`
257
-    })
255
+    this.redirectTo(item)
258 256
   }
257
+
258
+  redirectTo({contentId, contentType, buildingId} = {}) {
259
+    switch (contentType) {
260
+      // 项目
261
+      case 'project':
262
+        Taro.navigateTo({
263
+          url: '/pages/project/detail/index?id=' + buildingId
264
+        })
265
+        return;
266
+
267
+      // 活动
268
+      case 'activity':
269
+        Taro.navigateTo({
270
+          url: '/pages/activity/detail/index?id=' + contentId
271
+        })
272
+        return;
273
+
274
+      // 助力
275
+      case 'help':
276
+        Taro.navigateTo({
277
+          url: '/pages/activity/detail/assistance?id=' + contentId
278
+        })
279
+        return;
280
+      
281
+      // 拼团
282
+      case 'group':
283
+        Taro.navigateTo({
284
+          url: '/pages/activity/detail/assemble?id=' + contentId
285
+        })
286
+        return;
287
+      
288
+      // 资讯
289
+      case 'news':
290
+        Taro.navigateTo({
291
+          url: 'pages/news/detail/index?id=' + contentId
292
+        })
293
+        return;
294
+      
295
+      // 其他
296
+      case 'others':
297
+      default:
298
+        this.handleMaskClose()
299
+        return;
300
+    }
301
+  }
302
+
259 303
   handleHelpGroupClick(item) {
260 304
     if (item.type == 1) {
261 305
       Taro.navigateTo({
@@ -294,12 +338,9 @@ export default class Index extends Component {
294 338
   }
295 339
 
296 340
   handleMaskBannerClick(data) {
297
-    Taro.navigateTo({
298
-      url: '/pages/project/detail/index?id=' + data.buildingId
299
-    })
341
+    this.redirectTo(data)
300 342
   }
301 343
 
302
-
303 344
   handleLocationClick() {
304 345
     Taro.navigateTo({
305 346
       url: `/pages/city/index`

+ 2
- 7
src/pages/shop/index.js Ver fichero

@@ -212,9 +212,6 @@ export default class Shop extends Component {
212 212
     const { goodsList, goodsBuilding, current } = this.state
213 213
 
214 214
     return (
215
-
216
-
217
-
218 215
       <View className="list__wrap">
219 216
         {
220 217
 
@@ -331,13 +328,11 @@ export default class Shop extends Component {
331 328
   }
332 329
 
333 330
   render() {
334
-    const { person: { personType } } = this.props.userInfo
335
-    //const { person: { phone } } = this.props.userInfo
336
-    const isDrift = personType === ROLE_CODE['DRIFT']
331
+    const { person: { phone } } = this.props.userInfo
337 332
 
338 333
     return (
339 334
       <View className='wrap'>
340
-        {isDrift ? this.renderLogin() : this.renderDetail()}
335
+        {!phone ? this.renderLogin() : this.renderDetail()}
341 336
       </View>
342 337
     )
343 338
   }

+ 4
- 2
src/utils/login.js Ver fichero

@@ -24,11 +24,13 @@ export default function (params, callback) {
24 24
         const { dispatch } = getStore()
25 25
         Taro.setStorageSync('token', token)
26 26
         Taro.setStorageSync('sessionKey', sessionKey)
27
-        
27
+
28
+        dispatch({ type: USER_INFO, payload: { extraInfo, person } })
29
+
28 30
         // 用户信息已授权获取成功
29 31
         if (miniAuthorized) {
30 32
           // 保存用户信息
31
-          dispatch({ type: USER_INFO, payload: { extraInfo, person } })
33
+          // dispatch({ type: USER_INFO, payload: { extraInfo, person } })
32 34
           callback && callback(data)
33 35
 
34 36
         } else {