张延森 hace 5 años
padre
commit
6d3d821bc1

+ 4
- 4
config/dev.js Ver fichero

@@ -5,12 +5,12 @@ module.exports = {
5 5
   defineConstants: {
6 6
 		// HOST: '"http://47.101.36.130:8085"',//测试
7 7
     // WSS_HOST: '"wss://47.101.36.130:8085"',
8
-    // HOST: '"https://dev.jinchengjiaye.com"',//测试
9
-    // WSS_HOST: '"wss://dev.jinchengjiaye.com"',
8
+    HOST: '"https://dev.jinchengjiaye.com"',//测试
9
+    WSS_HOST: '"wss://dev.jinchengjiaye.com"',
10 10
     // HOST: '"https://lt.pawoma.cn"',
11 11
     // WSS_HOST: '"wss://lt.pawoma.cn"',
12
-    HOST: '"http://127.0.0.1:8080"',
13
-    WSS_HOST: '"ws://127.0.0.1:8080"',
12
+    // HOST: '"http://127.0.0.1:8080"',
13
+    // WSS_HOST: '"ws://127.0.0.1:8080"',
14 14
   },
15 15
   weapp: {},
16 16
   h5: {}

+ 40
- 1
project.config.json Ver fichero

@@ -23,5 +23,44 @@
23 23
 	"compileType": "miniprogram",
24 24
 	"simulatorType": "wechat",
25 25
 	"simulatorPluginLibVersion": {},
26
-	"condition": {}
26
+	"condition": {
27
+		"search": {
28
+			"current": -1,
29
+			"list": []
30
+		},
31
+		"conversation": {
32
+			"current": -1,
33
+			"list": []
34
+		},
35
+		"plugin": {
36
+			"current": -1,
37
+			"list": []
38
+		},
39
+		"game": {
40
+			"list": []
41
+		},
42
+		"gamePlugin": {
43
+			"current": -1,
44
+			"list": []
45
+		},
46
+		"miniprogram": {
47
+			"current": -1,
48
+			"list": [
49
+				{
50
+					"id": -1,
51
+					"name": "pages/im/list/index",
52
+					"pathName": "pages/im/list/index",
53
+					"query": "",
54
+					"scene": null
55
+				},
56
+				{
57
+					"id": -1,
58
+					"name": "pages/activity/detail/assistance",
59
+					"pathName": "pages/activity/detail/assistance",
60
+					"query": "id=85",
61
+					"scene": null
62
+				}
63
+			]
64
+		}
65
+	}
27 66
 }

+ 47
- 39
src/components/Poster/index.js Ver fichero

@@ -5,29 +5,34 @@ import { getCanvasConfig } from './util';
5 5
 import './style.scss';
6 6
 
7 7
 export default class Poster extends Component {
8
+  static options = {
9
+    addGlobalClass: true,
10
+  }
11
+  static defaultProps = {
12
+    configs: {}
13
+  }
14
+
8 15
   state = {
9 16
     images: [],
17
+    done: false,
10 18
     current: undefined,
11
-    configs: undefined,
19
+  }
20
+
21
+  static transTPLs2Configs(tpls, params) {
22
+    return tpls.map((tpl) => {
23
+      const conf = getCanvasConfig(tpl.configs, params)
24
+      return { ...conf }
25
+    })
12 26
   }
13 27
 
14 28
   componentWillMount() {
15
-    if (!Array.isArray(this.props.tpls)) {
16
-      throw new Error('当前内容未维护海报信息')
29
+    if (!Array.isArray(this.props.configs)) {
30
+      throw new Error('未设置海报配置信息')
17 31
     }
18
-
19
-    let configs = this.state.configs || []
20
-    this.props.tpls.forEach((tpl, inx) => {
21
-      const conf = getCanvasConfig(tpl.configs, this.props.params)
22
-      configs.push(conf)
23
-
24
-      if (inx === this.props.tpls.length - 1) {
25
-        this.setState({ configs })
26
-      }
27
-    })
28 32
   }
29 33
 
30
-  onScroll = inx => (e) => {
34
+  onScroll = (e) => {
35
+    const inx = e.detail.current
31 36
     this.setState({ current: this.state.images[inx] })
32 37
   }
33 38
 
@@ -77,38 +82,39 @@ export default class Poster extends Component {
77 82
     })
78 83
   }
79 84
 
80
-  onCreateSuccess = (inx) => (result) => {
81
-    if (inx + 1 === this.props.tpls.length) {
82
-      Taro.hideLoading();
83
-    }
85
+  tmpImgs = []
84 86
 
85
-    let images = this.state.images || []
86
-    const { tempFilePath, errMsg } = result;
87
-    if (errMsg === 'canvasToTempFilePath:ok') {
88
-      images[inx] = tempFilePath
89
-    } else {
90
-      images[inx] = undefined
91
-      console.log(errMsg);
87
+  onCreateSuccess = (inx) => {
88
+    return (result) => {
89
+      const { tempFilePath, errMsg } = result;
90
+      if (errMsg === 'canvasToTempFilePath:ok') {
91
+        this.tmpImgs[inx] = tempFilePath
92
+      } else {
93
+        this.tmpImgs[inx] = undefined
94
+        console.log(errMsg);
95
+      }
96
+
97
+      if (inx + 1 === this.props.configs.length) {
98
+        this.setState({ done: true, images: [...this.tmpImgs] });
99
+        this.tmpImgs = [];
100
+        Taro.hideLoading();
101
+      }
92 102
     }
93
-    this.setState({ images });
94 103
   }
95 104
 
96 105
   onCreateFail = (inx) => (err) => {
97
-    if (inx + 1 === this.props.tpls.length) {
106
+    this.tmpImgs[inx] = undefined
107
+    if (inx + 1 === this.props.configs.length) {
108
+      this.setState({ done: true, images: [...this.tmpImgs] });
109
+      this.tmpImgs = [];
98 110
       Taro.hideLoading();
99 111
     }
100
-
101
-    let images = this.state.images || []
102
-    images[inx] = undefined
103
-    this.setState({ images });
104 112
     console.err(err);
105 113
   }
106 114
 
107 115
   render() {
108
-    const {
109
-      images,
110
-      configs
111
-    } = this.state
116
+    const { images, done } = this.state
117
+    const { configs } = this.props
112 118
 
113 119
     return (
114 120
       <View className="poster">
@@ -118,20 +124,22 @@ export default class Poster extends Component {
118 124
             <Text className="iconfont icon-buoumaotubiao20" onClick={this.onCancel}></Text>
119 125
           </View>
120 126
           <View className="con-body">
127
+            <Swiper className="preview-box" onChange={this.onScroll} >
121 128
             {
122
-              images.map((img, inx) => {
129
+              done && images.map((img, inx) => {
123 130
                 return (
124
-                  <ScrollView scrollX scrollWithAnimation onScroll={this.onScroll(inx)} style="width: 100%" key={`img-${inx}`}>
131
+                  <SwiperItem key={`img-${inx}`}>
125 132
                     <Image className="result-img" mode="aspectFit" lazy-load src={img} onClick={this.onPreview}></Image>
126
-                  </ScrollView>
133
+                  </SwiperItem>
127 134
                 )
128 135
               })
129 136
             }
137
+            </Swiper>
130 138
           </View>
131 139
           <Button className="save-btn" onClick={this.saveToAlbum}>保存海报</Button>
132 140
         </View>
133 141
         {
134
-          configs &&
142
+          !done && configs && configs.length &&
135 143
           (
136 144
             configs.map((conf, inx) => {
137 145
               return (

+ 7
- 2
src/components/Poster/style.scss Ver fichero

@@ -43,10 +43,15 @@
43 43
       border-radius: 10px;
44 44
       padding: 40px 0;
45 45
 
46
-      .result-img {
46
+      .preview-box {
47
+        width: 100%;
47 48
         height: 60vh;
48
-        display: block;
49
+      }
50
+
51
+      .result-img {
52
+        height: 100%;
49 53
         margin: 0 auto;
54
+        display: inline-block;
50 55
       }
51 56
     }
52 57
   }

+ 16
- 9
src/components/Poster/util.js Ver fichero

@@ -9,23 +9,30 @@ export function getCanvasConfig(config, params) {
9 9
   const itemConf = items.reduce((conf, item) => {
10 10
     const { type, remark, value, variable, ...others } = item
11 11
     const settingOfType = conf[type] || []
12
-    
12
+    let val = variable ? params[variable] : value
13
+
13 14
     let mainVal = {}
14 15
     switch (type) {
15
-      case 'text':
16
-        mainVal = { text: variable ? params[variable] : value }
16
+      case 'texts':
17
+        mainVal = { text: val }
17 18
         break;
18
-      case 'image':
19
-        mainVal = { url: variable ? params[variable] : value }
19
+      case 'images':
20
+        mainVal = { url: val }
20 21
         break;
21 22
       default:
23
+        val = true
22 24
         break;
23 25
     }
24 26
 
25
-    settingOfType.push({
26
-      ...mainVal,
27
-      ...others,
28
-    })
27
+    if (val) {
28
+      settingOfType.push({
29
+        ...mainVal,
30
+        ...others,
31
+      })
32
+      conf[type] = settingOfType
33
+    }
34
+    
35
+    return conf
29 36
   }, {})
30 37
 
31 38
   return {

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

@@ -40,12 +40,14 @@ export default class CanvasDrawer extends Component {
40 40
   }
41 41
 
42 42
   componentDidMount() {
43
-    const sysInfo = Taro.getSystemInfoSync();
44
-    const screenWidth = sysInfo.screenWidth;
45
-    this.setState({
46
-      factor: screenWidth / 750
47
-    })
48
-    this.onCreate();
43
+    setTimeout(() => {
44
+      const sysInfo = Taro.getSystemInfoSync();
45
+      const screenWidth = sysInfo.screenWidth;
46
+      this.setState({
47
+        factor: screenWidth / 750
48
+      })
49
+      this.onCreate();
50
+    }, 0)
49 51
   }
50 52
 
51 53
   componentWillUnmount() { }
@@ -139,11 +141,15 @@ export default class CanvasDrawer extends Component {
139 141
    */
140 142
   initCanvas = (w, h, debug) => {
141 143
     return new Promise((resolve) => {
144
+      console.debug('-----------start to init canvas state------------')
142 145
       this.setState({
143 146
         pxWidth: this.toPx(w),
144 147
         pxHeight: this.toPx(h),
145 148
         debug,
146
-      }, resolve);
149
+      }, () => {
150
+        console.debug('-----------finish init canvas state------------')
151
+        resolve()
152
+      });
147 153
     });
148 154
   }
149 155
   /**
@@ -152,8 +158,10 @@ export default class CanvasDrawer extends Component {
152 158
   onCreate = () => {
153 159
     const { onCreateFail, config } = this.props;
154 160
     Taro.showLoading({ mask: true, title: '生成中...' });
161
+    console.debug('-----start to download images---')
155 162
       return this.downloadResourceTransit()
156 163
       .then(() => {
164
+        console.debug('-----finish download images---')
157 165
         this.create(config);
158 166
       })
159 167
       .catch((err) => {
@@ -171,10 +179,14 @@ export default class CanvasDrawer extends Component {
171 179
    * @param  { object } config
172 180
    */
173 181
   create = (config) => {
182
+    console.debug('-----create canvas---', this.canvasId, this.$scope)
174 183
     this.ctx = Taro.createCanvasContext(this.canvasId, this.$scope);
184
+    console.debug('-----finish create canvas---')
175 185
     const height = getHeight(config);
186
+    console.debug('-----ready to init canvas---')
176 187
     this.initCanvas(config.width, height, config.debug)
177 188
       .then(() => {
189
+        console.debug('-----finish init canvas---')
178 190
         // 设置画布底色
179 191
         if (config.backgroundColor) {
180 192
           this.ctx.save();
@@ -231,8 +243,11 @@ export default class CanvasDrawer extends Component {
231 243
           // 在安卓平台,经测试发现如果海报过于复杂在转换时需要做延时,要不然样式会错乱
232 244
           time = 300;
233 245
         }
246
+        console.debug('-----start to draw---')
234 247
         this.ctx.draw(false, () => {
248
+          console.debug('-----finish draw---')
235 249
           setTimeout(() => {
250
+            console.debug('-----ready to read file---')
236 251
             this.getTempFile();
237 252
           }, time);
238 253
         });
@@ -248,6 +263,7 @@ export default class CanvasDrawer extends Component {
248 263
     Taro.canvasToTempFilePath({
249 264
       canvasId: this.canvasId,
250 265
       success: (result) => {
266
+        console.debug('-----read file success---')
251 267
         if (!onCreateSuccess) {
252 268
           console.warn('您必须实现 taro-plugin-canvas 组件的 onCreateSuccess 方法,详见文档 https://github.com/chuyun/taro-plugin-canvas#success');
253 269
         }
@@ -272,6 +288,8 @@ export default class CanvasDrawer extends Component {
272 288
   }
273 289
 
274 290
   render() {
291
+    console.log('------render canvas----')
292
+
275 293
     const { pxWidth, pxHeight, debug } = this.state;
276 294
     if(pxWidth && pxHeight){
277 295
       return (

+ 86
- 26
src/pages/activity/detail/assemble.js Ver fichero

@@ -52,7 +52,8 @@ export default class Detail extends Component {
52 52
     recordDetail: {}, // 发团记录
53 53
     memberList: [], // 团员记录
54 54
     shares: [], // 分享设置
55
-    posters: [], // 海报模板
55
+    posters: [],  // 海报设置
56
+    posterTpls: [], // 海报模板
56 57
     leftTime: 0,  // 剩余时间
57 58
     ltTicker: undefined,  // 剩余时间计时器
58 59
     actState: ActBeforeStart,  // 活动本身状态
@@ -76,10 +77,18 @@ export default class Detail extends Component {
76 77
   }
77 78
 
78 79
   componentWillUnmount() {
79
-    this.clearTicker()
80
+    this.stopTicker()
80 81
     this.state.pointRecordId && updatePoint(pointRecordId)
81 82
   }
82 83
 
84
+  componentDidShow() {
85
+    this.startTicker()
86
+  }
87
+  
88
+  componentDidHide() {
89
+    this.stopTicker()
90
+  }
91
+
83 92
   // 初始化页面数据
84 93
   initPageData = () => {
85 94
     if (!this.state.detail.groupActivityId) {
@@ -98,11 +107,17 @@ export default class Detail extends Component {
98 107
     }
99 108
   }
100 109
 
110
+  // 启动 ticker
111
+  startTicker() {
112
+    if (this.state.ltTicker && !this.state.ltTicker.processing) {
113
+      this.state.ltTicker.start()
114
+    }
115
+  }
116
+
101 117
   // 清除 ticker
102
-  clearTicker() {
118
+  stopTicker() {
103 119
     if (this.state.ltTicker) {
104
-      clearInterval(this.state.ltTicker)
105
-      this.setState({ ltTicker: undefined })
120
+      this.state.ltTicker.stop()
106 121
     }
107 122
   }
108 123
 
@@ -130,15 +145,32 @@ export default class Detail extends Component {
130 145
 
131 146
   // 打开关闭 ActionSheet 面板
132 147
   toggleActionVisible = () => {
148
+    debugger
149
+    const { actionSheetVisible } = this.state
150
+
151
+    if (this.state.ltTicker) {
152
+      actionSheetVisible ? this.startTicker() : this.stopTicker()
153
+    }
154
+
133 155
     this.setState({
134
-      actionSheetVisible: !this.state.actionSheetVisible
156
+      actionSheetVisible: !actionSheetVisible
135 157
     })
136 158
   }
137 159
 
138 160
   // 打开关闭海报面板
139 161
   togglePosterVisible = () => {
162
+    const { posterVisible, posters } = this.state
163
+
164
+    if (!posters || !posters.length) {
165
+      Taro.showToast({
166
+        title: '未设置海报模板',
167
+        icon: 'none'
168
+      })
169
+      return
170
+    }
171
+
140 172
     this.setState({
141
-      posterVisible: !this.state.posterVisible,
173
+      posterVisible: !posterVisible,
142 174
       actionSheetVisible: false
143 175
     })
144 176
   }
@@ -161,21 +193,38 @@ export default class Detail extends Component {
161 193
   }
162 194
 
163 195
   // 计时器更新剩余时间
164
-  updateLeftTime(startDate, endDate) {
165
-    this.setState({
166
-      ltTicker: setInterval(() => {
167
-        const [actState, leftTime] = this.compActState(startDate, endDate)
168
-        this.setState({ actState, leftTime })
196
+  getLeftTimeTicker(startDate, endDate) {
197
+    let processing = false
198
+    let ticker = undefined
169 199
 
170
-        if (actState === ActFinished) {
171
-          this.clearTicker()
172
-        }
173
-      }, 1000)
174
-    })
200
+    const stop = () => {
201
+      ticker && clearInterval(ticker)
202
+      processing = false
203
+    }
204
+
205
+    const fn = () => {
206
+      const [actState, leftTime] = this.compActState(startDate, endDate)
207
+      this.setState({ actState, leftTime })
208
+
209
+      if (actState === ActFinished) {
210
+        stop()
211
+      }
212
+    }
213
+
214
+    const start = () => {
215
+      ticker = setInterval(fn, 1000)
216
+      processing = true
217
+    }
218
+
219
+    return {
220
+      start,
221
+      stop,
222
+      processing,
223
+    }
175 224
   }
176 225
 
177 226
   loadDetail() {
178
-    const { id, recordId } = this.state
227
+    let { id, recordId, ltTicker } = this.state
179 228
     const { userInfo } = this.props
180 229
 
181 230
     Taro.showLoading()
@@ -189,6 +238,10 @@ export default class Detail extends Component {
189 238
         actState = ActFinished
190 239
       }
191 240
 
241
+      if (actState != ActFinished) {
242
+        ltTicker = this.getLeftTimeTicker(res.taShareActivity.startTime, res.taShareActivity.endTime)
243
+      }
244
+
192 245
       Taro.hideLoading()
193 246
       this.setState({
194 247
         detail: res.taShareActivity,
@@ -203,11 +256,8 @@ export default class Detail extends Component {
203 256
         isStarter: !recordDetail.personId || userInfo.person.personId === recordDetail.personId,
204 257
         actState,
205 258
         leftTime,
206
-      })
207
-
208
-      if (actState != ActFinished) {
209
-        this.updateLeftTime(res.taShareActivity.startTime, res.taShareActivity.endTime)
210
-      }
259
+        ltTicker
260
+      }, () => this.startTicker())
211 261
 
212 262
       // Taro.setNavigationBarTitle({ title: res.taShareActivity.activityName })
213 263
 
@@ -378,8 +428,10 @@ export default class Detail extends Component {
378 428
     const [page, scene] = this.currentPageAndParams()
379 429
     const payload = { page, scene }
380 430
 
381
-    getMiniQrcode(payload).then(qrCode => {
382
-      this.setState({ qrCode, posterVisible: true })
431
+    return new Promise((resolve) => {
432
+      getMiniQrcode(payload).then(qrCode => {
433
+        this.setState({ qrCode, posterVisible: true }, resolve)
434
+      })
383 435
     })
384 436
   }
385 437
 
@@ -407,6 +459,7 @@ export default class Detail extends Component {
407 459
       posters,
408 460
       qrCode,
409 461
       leftTime,
462
+      ltTicker,
410 463
     } = this.state
411 464
 
412 465
     const { userInfo } = this.props
@@ -424,10 +477,17 @@ export default class Detail extends Component {
424 477
 
425 478
     const joinedNum = detail.groupBuyPeople - (recordDetail.recordId ? 1 : 0) - memberList.length
426 479
 
480
+    const posterConfigs = Poster.transTPLs2Configs(posterTpls, posterData)
481
+
482
+    console.log('------posterConfigs------', posterConfigs)
427 483
     return (
428 484
       <Block>
429 485
         {/* 生成海报 */}
430
-        {posterVisible && (<Poster tpls={posterTpls} params={posterData} onCancel={this.togglePosterVisible} onFinish={this.togglePosterVisible}></Poster>)}
486
+        { posterVisible && !ltTicker.processing &&
487
+          (
488
+            <Poster configs={posterConfigs} onCancel={this.togglePosterVisible} onFinish={this.togglePosterVisible}></Poster>
489
+          )
490
+        }
431 491
 
432 492
         {
433 493
           grantPhoneVisible &&

+ 90
- 32
src/pages/activity/detail/assistance.js Ver fichero

@@ -64,7 +64,7 @@ export default class Detail extends Component {
64 64
     handleHelpBtn: true, // 立即助力好友
65 65
     pointRecordId: undefined, // 埋点ID
66 66
   }
67
-
67
+  
68 68
   componentWillMount() {
69 69
     ready.queue(() => {
70 70
       // 必须先授权电话
@@ -75,10 +75,18 @@ export default class Detail extends Component {
75 75
   }
76 76
 
77 77
   componentWillUnmount() {
78
-    this.clearTicker()
78
+    this.stopTicker()
79 79
     this.state.pointRecordId && updatePoint(pointRecordId)
80 80
   }
81 81
 
82
+  componentDidShow() {
83
+    this.startTicker()
84
+  }
85
+  
86
+  componentDidHide() {
87
+    this.stopTicker()
88
+  }
89
+
82 90
   // 初始化页面数据
83 91
   initPageData = () => {
84 92
     if (!this.state.detail.helpActivityId) {
@@ -97,11 +105,17 @@ export default class Detail extends Component {
97 105
     }
98 106
   }
99 107
 
108
+  // 启动 ticker
109
+  startTicker() {
110
+    if (this.state.ltTicker && !this.state.ltTicker.processing) {
111
+      this.state.ltTicker.start()
112
+    }
113
+  }
114
+
100 115
   // 清除 ticker
101
-  clearTicker() {
116
+  stopTicker() {
102 117
     if (this.state.ltTicker) {
103
-      clearInterval(this.state.ltTicker)
104
-      this.setState({ ltTicker: undefined })
118
+      this.state.ltTicker.stop()
105 119
     }
106 120
   }
107 121
 
@@ -129,15 +143,32 @@ export default class Detail extends Component {
129 143
 
130 144
   // 打开关闭 ActionSheet 面板
131 145
   toggleActionVisible = () => {
146
+    debugger
147
+    const { actionSheetVisible } = this.state
148
+
149
+    if (this.state.ltTicker) {
150
+      actionSheetVisible ? this.startTicker() : this.stopTicker()
151
+    }
152
+
132 153
     this.setState({
133
-      actionSheetVisible: !this.state.actionSheetVisible
154
+      actionSheetVisible: !actionSheetVisible
134 155
     })
135 156
   }
136 157
 
137 158
   // 打开关闭海报面板
138 159
   togglePosterVisible = () => {
160
+    const { posterVisible, posters } = this.state
161
+    
162
+    if (!posters || !posters.length) {
163
+      Taro.showToast({
164
+        title: '未设置海报模板',
165
+        icon: 'none'
166
+      })
167
+      return
168
+    }
169
+
139 170
     this.setState({
140
-      posterVisible: !this.state.posterVisible,
171
+      posterVisible: !posterVisible,
141 172
       actionSheetVisible: false
142 173
     })
143 174
   }
@@ -160,28 +191,44 @@ export default class Detail extends Component {
160 191
   }
161 192
 
162 193
   // 计时器更新剩余时间
163
-  updateLeftTime(startDate, endDate) {
164
-    this.setState({
165
-      ltTicker: setInterval(() => {
166
-        const [actState, leftTime] = this.compActState(startDate, endDate)
167
-        this.setState({ actState, leftTime })
194
+  getLeftTimeTicker(startDate, endDate) {
195
+    let processing = false
196
+    let ticker = undefined
168 197
 
169
-        if (actState === ActFinished) {
170
-          this.clearTicker()
171
-        }
172
-      }, 1000)
173
-    })
198
+    const stop = () => {
199
+      ticker && clearInterval(ticker)
200
+      processing = false
201
+    }
202
+
203
+    const fn = () => {
204
+      const [actState, leftTime] = this.compActState(startDate, endDate)
205
+      this.setState({ actState, leftTime })
206
+
207
+      if (actState === ActFinished) {
208
+        stop()
209
+      }
210
+    }
211
+
212
+    const start = () => {
213
+      ticker = setInterval(fn, 1000)
214
+      processing = true
215
+    }
216
+
217
+    return {
218
+      start,
219
+      stop,
220
+      processing,
221
+    }
174 222
   }
175 223
 
176 224
   // 请求详情
177 225
   loadDetail() {
178
-    // debugger
179
-    const { id, initiateId } = this.state
226
+    let { id, initiateId, ltTicker } = this.state
180 227
     const { userInfo } = this.props
181 228
 
182 229
     Taro.showLoading()
183 230
     getHelpDetail(id, initiateId).then(res => {
184
-      this.clearTicker()
231
+      this.stopTicker()
185 232
 
186 233
       const initiateDetail = res.helpInitiateRecord || {}
187 234
       let [actState, leftTime] = this.compActState(res.helpActivity.startDate, res.helpActivity.endDate)
@@ -190,6 +237,10 @@ export default class Detail extends Component {
190 237
         actState = ActFinished
191 238
       }
192 239
 
240
+      if (actState != ActFinished) {
241
+        ltTicker = this.getLeftTimeTicker(res.helpActivity.startDate, res.helpActivity.endDate)
242
+      }
243
+
193 244
       Taro.hideLoading()
194 245
       this.setState({
195 246
         detail: res.helpActivity,
@@ -204,12 +255,9 @@ export default class Detail extends Component {
204 255
         isStarter: !initiateDetail.personId || userInfo.person.personId === initiateDetail.personId,
205 256
         actState,
206 257
         leftTime,
207
-        isJoin: res.isJoin
208
-      })
209
-
210
-      if (actState != ActFinished) {
211
-        this.updateLeftTime(res.helpActivity.startDate, res.helpActivity.endDate)
212
-      }
258
+        isJoin: res.isJoin,
259
+        ltTicker
260
+      }, () => this.startTicker())
213 261
 
214 262
       // Taro.setNavigationBarTitle({ title: res.helpActivity.title })
215 263
 
@@ -366,7 +414,6 @@ export default class Detail extends Component {
366 414
     // 必须授权头像
367 415
     if (this.toggleGrantAvatar()) {
368 416
       const initiateDetail = this.state.initiateDetail
369
-      // debugger
370 417
       if (!initiateDetail.helpRecordInitiateId) {
371 418
         // 如果是未发起的助力, 先以当前人身份发起
372 419
         this.startMine().then(() => {
@@ -382,8 +429,10 @@ export default class Detail extends Component {
382 429
     const [page, scene] = this.currentPageAndParams()
383 430
     const payload = { page, scene }
384 431
 
385
-    getMiniQrcode(payload).then(qrCode => {
386
-      this.setState({ qrCode, posterVisible: true })
432
+    return new Promise((resolve) => {
433
+      getMiniQrcode(payload).then(qrCode => {
434
+        this.setState({ qrCode }, resolve)
435
+      })
387 436
     })
388 437
   }
389 438
 
@@ -411,6 +460,7 @@ export default class Detail extends Component {
411 460
       posters,
412 461
       qrCode,
413 462
       leftTime,
463
+      ltTicker,
414 464
     } = this.state
415 465
 
416 466
     const { userInfo } = this.props
@@ -424,10 +474,18 @@ export default class Detail extends Component {
424 474
       avatarurl: getDownloadURL(userInfo.person.avatarurl, 'avatar') || '',
425 475
     }
426 476
 
477
+    const posterConfigs = Poster.transTPLs2Configs(posterTpls, posterData)
478
+
479
+    console.log('------posterConfigs------', posterConfigs)
480
+
427 481
     return (
428
-      <Block>
482
+      <View>
429 483
         {/* 生成海报 */}
430
-        {posterVisible && (<Poster tpls={posterTpls} params={posterData} onCancel={this.togglePosterVisible} onFinish={this.togglePosterVisible}></Poster>)}
484
+        { posterVisible && !ltTicker.processing &&
485
+          (
486
+            <Poster configs={posterConfigs} onCancel={this.togglePosterVisible} onFinish={this.togglePosterVisible}></Poster>
487
+          )
488
+        }
431 489
 
432 490
         {
433 491
           grantPhoneVisible &&
@@ -553,7 +611,7 @@ export default class Detail extends Component {
553 611
             </View>
554 612
           )
555 613
         }
556
-      </Block>
614
+      </View>
557 615
     )
558 616
   }
559 617
 }

+ 1
- 0
src/pages/project/detail/poster.js Ver fichero

@@ -27,6 +27,7 @@ export default class Index extends Component {
27 27
     }
28 28
   }
29 29
   componentWillMount() {
30
+    debugger
30 31
     this.initConfig()
31 32
     Taro.showLoading({
32 33
       title: '生成中...',