Commit 17ad1d24 authored by mqf_0707's avatar mqf_0707

会员插件优化

parent 8132299c
......@@ -41,10 +41,10 @@ export default {
cemMember: {
version: '*',
provider: '3000000026642582'
},
memberBenefit: {
version: '*',
provider: '3000000043103783'
}
},
memberBenefit: {
version: '*',
provider: '3000000043103783'
}
}
\ No newline at end of file
......@@ -10,13 +10,7 @@ Component({
data: {}
},
didMount(query) {},
didUpdate(preProps,preData) {
// 实时监听数据更新
const { updateFlag, data } = this.props
if(updateFlag !== 1 && updateFlag !== preProps.updateFlag) {
this.postMessage(data.type, data)
}
},
didUpdate() {},
didUnmount() {
// 页面被关闭
this.main && this.main.destroy();
......@@ -63,7 +57,8 @@ Component({
},
data: {
netName,
parameter
parameter,
postMessage: (netName, data) => this.postMessage(netName, data)
}
})
}else {
......
import React, { useEffect, useState } from 'react'
import React, { useEffect, useRef, useState } from 'react'
import { View } from '@tarojs/components'
import { useDidShow, useRouter, useDidHide, getApp, showToast } from '@tarojs/taro'
import API from '@/api'
......@@ -19,11 +19,10 @@ function GamePage(props) {
const app = getApp()
const { activityInfo, setActivityInfoAndStatus } = useActivityInfoModel()
const { loginInfo } = useLoginInfoModel()
const [canvasData,setCanvasData] = useState({})
const [ taskModalVisible, setTaskModalVisible] = useState(false)
const [ canvasVisible, setCanvasVisible] = useState(false)
const [ memberVisible,setMemberVisible] = useState(false)
const [updateFlag, setUpdateFlag] = useState(1)
const onHandlePost = useRef(null)
useEffect(() =>{
// getImgShareUrl('cloud://2D60DC04FC1888AF6F865B88F0B2EBCC//share.png').then(res => {
......@@ -46,8 +45,9 @@ function GamePage(props) {
//和main通信的方法,接收main的信息
const onMessage = (e)=> {
// 接口名字 参数
const { netName, parameter } = e.mpEvent.data
const { netName, parameter, postMessage } = e.mpEvent.data
console.warn('netName:'+netName,parameter)
if(!onHandlePost.current) onHandlePost.current = postMessage
//定制的授权
if (netName == "mine.authorize") {
this.getAuth()
......@@ -60,10 +60,6 @@ function GamePage(props) {
else if (netName == "mine.favorShop") {
this.doFavorShop()
}
//领养名字,有弹框的
else if (netName == "mine.getAdoptName") {
this.setData({ "adoptModalVisible": true, type: parameter.type })
}
//打开详情页,还有成功失败
else if (netName == "mine.openDetail") {
openDetail(parameter.itemId)
......@@ -122,24 +118,7 @@ function GamePage(props) {
setMemberVisible(true)
break;
}
setUpdateFlag(Math.floor(Math.random() * 1000))
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 })
})
onHandlePost.current && onHandlePost.current(netName, data)
}
}
// 入会插件
......@@ -157,7 +136,7 @@ function GamePage(props) {
}
return(
<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>
{<member-modal expend={memberVisible} onClose={onClose} onAuthFail={onAuthFail} onAuthSuccess={onAuthSuccess} />}
</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