Commit fa8b779c authored by 王能飞's avatar 王能飞

Merge branch 'c_client_taro-pack' into 'c_client_taro'

会员插件优化

See merge request !55
parents 3b4a134a 17ad1d24
...@@ -41,10 +41,10 @@ export default { ...@@ -41,10 +41,10 @@ export default {
cemMember: { cemMember: {
version: '*', version: '*',
provider: '3000000026642582' provider: '3000000026642582'
},
memberBenefit: {
version: '*',
provider: '3000000043103783'
} }
},
memberBenefit: {
version: '*',
provider: '3000000043103783'
} }
} }
\ No newline at end of file
...@@ -10,13 +10,7 @@ Component({ ...@@ -10,13 +10,7 @@ Component({
data: {} data: {}
}, },
didMount(query) {}, didMount(query) {},
didUpdate(preProps,preData) { didUpdate() {},
// 实时监听数据更新
const { updateFlag, data } = this.props
if(updateFlag !== 1 && updateFlag !== preProps.updateFlag) {
this.postMessage(data.type, data)
}
},
didUnmount() { didUnmount() {
// 页面被关闭 // 页面被关闭
this.main && this.main.destroy(); this.main && this.main.destroy();
...@@ -63,7 +57,8 @@ Component({ ...@@ -63,7 +57,8 @@ Component({
}, },
data: { data: {
netName, netName,
parameter parameter,
postMessage: (netName, data) => this.postMessage(netName, data)
} }
}) })
}else { }else {
......
import React, { useEffect, useState } from 'react' import React, { useEffect, useRef, useState } from 'react'
import { View } from '@tarojs/components' import { View } from '@tarojs/components'
import { useDidShow, useRouter, useDidHide, getApp, showToast } from '@tarojs/taro' import { useDidShow, useRouter, useDidHide, getApp, showToast } from '@tarojs/taro'
import API from '@/api' import API from '@/api'
...@@ -19,11 +19,10 @@ function GamePage(props) { ...@@ -19,11 +19,10 @@ function GamePage(props) {
const app = getApp() const app = getApp()
const { activityInfo, setActivityInfoAndStatus } = useActivityInfoModel() const { activityInfo, setActivityInfoAndStatus } = useActivityInfoModel()
const { loginInfo } = useLoginInfoModel() const { loginInfo } = useLoginInfoModel()
const [canvasData,setCanvasData] = useState({})
const [ taskModalVisible, setTaskModalVisible] = useState(false) const [ taskModalVisible, setTaskModalVisible] = useState(false)
const [ canvasVisible, setCanvasVisible] = useState(false) const [ canvasVisible, setCanvasVisible] = useState(false)
const [ memberVisible,setMemberVisible] = useState(false) const [ memberVisible,setMemberVisible] = useState(false)
const [updateFlag, setUpdateFlag] = useState(1) const onHandlePost = useRef(null)
useEffect(() =>{ useEffect(() =>{
// getImgShareUrl('cloud://2D60DC04FC1888AF6F865B88F0B2EBCC//share.png').then(res => { // getImgShareUrl('cloud://2D60DC04FC1888AF6F865B88F0B2EBCC//share.png').then(res => {
...@@ -46,8 +45,9 @@ function GamePage(props) { ...@@ -46,8 +45,9 @@ function GamePage(props) {
//和main通信的方法,接收main的信息 //和main通信的方法,接收main的信息
const onMessage = (e)=> { const onMessage = (e)=> {
// 接口名字 参数 // 接口名字 参数
const { netName, parameter } = e.mpEvent.data const { netName, parameter, postMessage } = e.mpEvent.data
console.warn('netName:'+netName,parameter) console.warn('netName:'+netName,parameter)
if(!onHandlePost.current) onHandlePost.current = postMessage
//定制的授权 //定制的授权
if (netName == "mine.authorize") { if (netName == "mine.authorize") {
this.getAuth() this.getAuth()
...@@ -60,10 +60,6 @@ function GamePage(props) { ...@@ -60,10 +60,6 @@ function GamePage(props) {
else if (netName == "mine.favorShop") { else if (netName == "mine.favorShop") {
this.doFavorShop() this.doFavorShop()
} }
//领养名字,有弹框的
else if (netName == "mine.getAdoptName") {
this.setData({ "adoptModalVisible": true, type: parameter.type })
}
//打开详情页,还有成功失败 //打开详情页,还有成功失败
else if (netName == "mine.openDetail") { else if (netName == "mine.openDetail") {
openDetail(parameter.itemId) openDetail(parameter.itemId)
...@@ -122,24 +118,7 @@ function GamePage(props) { ...@@ -122,24 +118,7 @@ function GamePage(props) {
setMemberVisible(true) setMemberVisible(true)
break; break;
} }
setUpdateFlag(Math.floor(Math.random() * 1000)) onHandlePost.current && onHandlePost.current(netName, data)
setCanvasData(data)
} else {
//获取后端接口
const { function: fc } = app.cloud;
//处理下带上activityId
if (!parameter) parameter = {};
parameter.activityId = app.activityId;
//netName得分割下
fc.invoke(netName.split(".")[0], parameter, netName.split(".")[1])
.then(res => {
// console.log("返回数据" + JSON.stringify(res));
//发送消息
this.postMessage(netName, res || { success: false })
}, (err) => {
//网络异常,返回失败
this.postMessage(netName, { success: false })
})
} }
} }
// 入会插件 // 入会插件
...@@ -157,7 +136,7 @@ function GamePage(props) { ...@@ -157,7 +136,7 @@ function GamePage(props) {
} }
return( return(
<View> <View>
{ canvasVisible && <canvas-comp data={canvasData} onMessage={onMessage} updateFlag={updateFlag} />} { canvasVisible && <canvas-comp onMessage={onMessage} />}
<View className={styles['test-box']} onClick={(e) => onTestHandle(e)}>入会按钮</View> <View className={styles['test-box']} onClick={(e) => onTestHandle(e)}>入会按钮</View>
{<member-modal expend={memberVisible} onClose={onClose} onAuthFail={onAuthFail} onAuthSuccess={onAuthSuccess} />} {<member-modal expend={memberVisible} onClose={onClose} onAuthFail={onAuthFail} onAuthSuccess={onAuthSuccess} />}
</View> </View>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment