123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- import MESSAGE_ENUM from '@/uilts/messageCenter/iframe/messageEnum'
- import messageCenter from '@/uilts/messageCenter/iframe'
- import { getQueryString } from '@/uilts/help'
- const iframeId = getQueryString('iframeId')
- // 做任务
- const doTask = {
- createTweet({ tweetId }, overTime) {
- return new Promise((res, rej) => {
- messageCenter.send({
- info: {
- actionType: MESSAGE_ENUM.IFRAME_DO_TASK_CREATE_TWEET,
- iframeId //用于告诉父窗口会传消息给哪个iframe
- },
- data: {
- tweetId
- },
- overTime,
- callback: (data) => {
- res(data);
- },
- failback: (e) => {
- rej(e)
- }
- })
- })
- },
- like({ tweetId }, overTime) {
- return new Promise((res, rej) => {
- messageCenter.send({
- info: {
- actionType: MESSAGE_ENUM.IFRAME_DO_TASK_LIKE,
- iframeId //用于告诉父窗口会传消息给哪个iframe
- },
- data: {
- tweetId,
- },
- overTime,
- callback: (data) => {
- res(data);
- },
- failback: (e) => {
- rej(e)
- }
- })
- })
- },
- follows({ follows }, overTime) {
- return new Promise((res, rej) => {
- messageCenter.send({
- info: {
- actionType: MESSAGE_ENUM.IFRAME_DO_TASK_FOLLOWS,
- iframeId //用于告诉父窗口会传消息给哪个iframe
- },
- data: {
- follows
- },
- overTime,
- callback: (data) => {
- res(data);
- },
- failback: (e) => {
- rej(e)
- }
- })
- })
- },
- reTweet({ tweetId }, overTime) {
- return new Promise((res, rej) => {
- messageCenter.send({
- info: {
- actionType: MESSAGE_ENUM.IFRAME_DO_TASK_RETWEET,
- iframeId //用于告诉父窗口会传消息给哪个iframe
- },
- data: {
- tweetId
- },
- overTime,
- callback: (data) => {
- res(data);
- },
- failback: (e) => {
- rej(e)
- }
- })
- })
- }
- }
- export default doTask
- // iframe > dom id
- // iframe > createTweet dom id
|