UNPKG

react-app-shell

Version:

react打包脚本和example, 这里的版本请忽略

37 lines (34 loc) 1.19 kB
import {observable, action} from 'mobx'; import {lotteryService} from '../service'; /** * 大转盘状态管理 */ class LotteryStore { @observable lotteryId = null; @observable shareOptions = {}; @action initShareOption = (lotteryId) => { if (Object.keys(this.shareOptions).length === 0) { try { const {shareTitle, shareDesc, shareImgUrl} = lotteryService.getLotteryInfoById(lotteryId); this.lotteryId = lotteryId; this.shareOptions = { title: shareTitle, // 分享标题 desc: shareDesc, // 分享描述 imgUrl: shareImgUrl, // 分享图标 }; } catch (error) { this.shareOptions = {}; console.error(error.mag || '获取数据失败'); } } } @action configShareOptions = ({shareTitle = '', shareDesc = '', shareImgUrl = ''} = {}, lotteryId) => { this.shareOptions = { title: shareTitle, // 分享标题 desc: shareDesc, // 分享描述 imgUrl: shareImgUrl, // 分享图标 }; this.lotteryId = lotteryId; } } export default new LotteryStore();