Commit 147e884d authored by mqf_0707's avatar mqf_0707

增加游戏原生混编功能

parent a2fa4918
No preview for this file type
export default {
hasGameModule: true, // 是否开启游戏模块自动注入dist
defaultPlugins: [
[
'@pluve/taro-plugin-mars', // taro暂时未支持阿里小程序自定义插件 需要引用插件的页面需配置
{
usingComponents: {// 原生组件引入
enable: true,
include: [ 'pages/index/index', 'pages/myPrize/myPrize' ]
}
}
]
],
addPages: ['pages/games/games'],// 游戏页面(自动注入app.json)
gamePages: [// 拷贝相关页面和依赖到dist目录
{ from: 'src/pages/games', to: 'dist/pages/games' },
{ from: 'minigame/node_modules', to: 'dist/node_modules'}
]
}
\ No newline at end of file
// eslint-disable-next-line import/no-commonjs // eslint-disable-next-line import/no-commonjs
const path = require('path') const path = require('path')
const { hasGameModule, defaultPlugins, addPages, gamePages } = require('./default').default
const config = { const config = {
projectName: 'taro-test', projectName: 'taro-test',
...@@ -15,22 +16,16 @@ const config = { ...@@ -15,22 +16,16 @@ const config = {
alias: { alias: {
'@': path.resolve(__dirname, '..', 'src/') '@': path.resolve(__dirname, '..', 'src/')
}, },
plugins: [ plugins: hasGameModule ? [...defaultPlugins,[ // 是否开启原生页面自动注入
[ path.resolve(__dirname,'..')+'/plugin/changeAppJsonPlugin.js',
'@pluve/taro-plugin-mars', // taro暂时未支持阿里小程序自定义插件 需要引用插件的页面需配置
{ {
usingComponents: { addPages: addPages
enable: true,
include: [ 'pages/index/index', 'pages/myPrize/myPrize' ]
}
} }
] ]] : defaultPlugins,
],
defineConstants: { defineConstants: {
}, },
copy: { copy: {
patterns: [ patterns: hasGameModule ? gamePages : [],
],
options: { options: {
} }
}, },
......
{
"pages":
[
"pages/index/index",
"pages/myPrize/myPrize",
"pages/browseGoods/browseGoods",
"pages/collectGoods/collectGoods",
"pages/orderGoods/orderGoods",
"pages/gamePage/gamePage"
],
"window":{
"enableSkia":"true",
"allowsBounceVertical":"NO",
"defaultTitle":"活动名称"
},
"plugins":{"cemMember":{"version":"*","provider":"3000000026642582"}}}
\ No newline at end of file
{
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"fyge-tbmini": {
"version": "1.4.8",
"resolved": "https://registry.npmjs.org/fyge-tbmini/-/fyge-tbmini-1.4.8.tgz",
"integrity": "sha512-07+DySosT5rIR6nfkfqc1+hnfaeuiDrMGBe4dOVqi+IdWIbgjv/vY7Wm/zVQJ5gqjU607b2jfkzY/rA6r97s4A=="
}
}
}
{
"name": "",
"version": "1.0.0",
"main": "",
"license": "MIT",
"dependencies": {
"fyge-tbmini": "^1.3.1"
}
}
const fs = require('fs');
const path = require('path')
export default (ctx, options) => {
// plugin 主体
const { addPages = [] } = options
ctx.onBuildStart(() => {
// console.log('编译开始!')
})
ctx.onBuildFinish(() => {
const dirUrl = path.resolve(__dirname,'..')+'/dist/app.json'
const rawdata = fs.readFileSync(dirUrl);
const { pages, ...ext } = JSON.parse(rawdata);
let new_pages = [...pages,...addPages]
const new_info = {
pages: new_pages,
...ext
}
fs.writeFileSync(dirUrl, JSON.stringify(new_info));
console.log('文件写入成功!');
//ctx.writeFileToDist({ filePath: string, content: string })
})
}
\ No newline at end of file
...@@ -45,8 +45,7 @@ export default function RuleModal(props) { ...@@ -45,8 +45,7 @@ export default function RuleModal(props) {
} }
// 助力条件为新会员 // 助力条件为新会员
const res = await checkIsMember() const isVip = await checkIsMember()
const isVip = res?.businessSuccess && res?.data?.isMember
// 已经是会员 // 已经是会员
if (isVip) { if (isVip) {
...@@ -57,6 +56,10 @@ export default function RuleModal(props) { ...@@ -57,6 +56,10 @@ export default function RuleModal(props) {
} }
}, 2000) }, 2000)
const closeMemberModal = () => {
// setMemberModalVisible(false)
}
return ( return (
<View> <View>
<Modal onClose={onClose} closePostion={closePostion} top={top}> <Modal onClose={onClose} closePostion={closePostion} top={top}>
...@@ -71,7 +74,7 @@ export default function RuleModal(props) { ...@@ -71,7 +74,7 @@ export default function RuleModal(props) {
{ {
memberModalVisible && memberModalVisible &&
<member-modal <member-modal
onClose={() => setMemberModalVisible(false)} onClose={() => closeMemberModal()}
onAuthFail={onAuthFail} onAuthFail={onAuthFail}
onAuthSuccess={onAuthSuccess} onAuthSuccess={onAuthSuccess}
/> />
......
...@@ -73,7 +73,7 @@ export default function GoodsPage(props) { ...@@ -73,7 +73,7 @@ export default function GoodsPage(props) {
{ {
goodsList.map((item, i) => { goodsList.map((item, i) => {
return ( return (
<View className='goods-modal-container__content-item' key={item}> <View className='goods-modal-container__content-item' key={'goods_'+i}>
<View className='goods-modal-container__content-item__img' onClick={() => goToGoodsDetail(item)}> <View className='goods-modal-container__content-item__img' onClick={() => goToGoodsDetail(item)}>
<Image mode='scaleToFill' src={item.image} /> <Image mode='scaleToFill' src={item.image} />
</View> </View>
......
export default { export default {
env: 'test', // 云函数环境 test 测试环境 online 线上环境 env: 'test', // 云函数环境 test 测试环境 online 线上环境
requestType: 'yapi', // cloud: 云函数, yapi: yapi 接口, ams: ams接口,tornadoAPI: 风驰台接口 requestType: 'tornadoAPI', // cloud: 云函数, yapi: yapi 接口, ams: ams接口,tornadoAPI: 风驰台接口
cloudName: 'CommonToC', // 主云函数项目名 CommonToC cloudName: 'luolai', // 主云函数项目名 CommonToC
sellerId: '2207644377875', sellerId: '2207644377875',
tornadoAPI: 'https://tornado.duibadev.com.cn/tbServer/api?db=xxx&proxyIp=xxx', // 新增:当requestType: 'tornadoAPI'时,找服务端提供地址 tornadoAPI: 'https://tornado.duibadev.com.cn/tbServer/api?db=db3000000038851072&proxyIp=172.16.130.158', // 新增:当requestType: 'tornadoAPI'时,找服务端提供地址
defaultActivityId: '5ff7e0a3e5c0d7dafd30dce5' // 默认活动id defaultActivityId: '60642aafc752d118247c2a2d' // 默认活动id
} }
.canvas {
width:100%;
height:100%;
}
.page-game {
width:100%;
height:100vh;
flex: 1;
display: flex;
flex-direction: column;
background: #f5cccd;
}
<view class="page-game">
<canvas id="canvas" type="2d" class="canvas" disable-scroll="true"
onTouchStart="onMouseEvent"
onTouchMove="onMouseEvent"
onTouchEnd="onMouseEvent"
onReady="onCanvasReady"
></canvas>
</view>
This diff is collapsed.
{
"disableScroll": "true"
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
import React, { useState } from 'react' import React, { useState } from 'react'
import { View } from '@tarojs/components' import { View } from '@tarojs/components'
import Taro, { useShareAppMessage, useDidShow } from '@tarojs/taro' import Taro, { useShareAppMessage, useDidShow } from '@tarojs/taro'
import classnames from 'classnames'
import { SHARE_CONFIG } from '@/const.js' import { SHARE_CONFIG } from '@/const.js'
import { useLogin, useLoginFromShare } from '@/hooks/useLogin' import { useLogin, useLoginFromShare } from '@/hooks/useLogin'
import { useActivityInfoModel, useLoginInfoModel } from '@/store' import { useActivityInfoModel, useLoginInfoModel } from '@/store'
...@@ -9,6 +10,8 @@ import RuleModal from '@/components/RuleModal/RuleModal' ...@@ -9,6 +10,8 @@ import RuleModal from '@/components/RuleModal/RuleModal'
import DoHelpModal from '@/components/DoHelpModal/DoHelpModal' import DoHelpModal from '@/components/DoHelpModal/DoHelpModal'
import TasksModal from '@/components/TasksModal/TasksModal' import TasksModal from '@/components/TasksModal/TasksModal'
import styles from './index.module.less' import styles from './index.module.less'
import tbcc from 'tbcc-sdk-ts'
const { navigateTo } = tbcc.tb
const INDEX_CONFIG = { const INDEX_CONFIG = {
bg: '', // 背景 bg: '', // 背景
...@@ -61,14 +64,21 @@ function Index() { ...@@ -61,14 +64,21 @@ function Index() {
} }
const onShare = () => my.showSharePanel() const onShare = () => my.showSharePanel()
const onGoMyPrizePage = () => Taro.navigateTo({ url: '/pages/myPrize/myPrize' }) const onGoMyPrizePage = () => navigateTo('/pages/myPrize/myPrize')
const homeStyle = classnames(styles.container,{
[`${styles['content_fixed']}`]: ruleModalVisible
})
return ( return (
<View className={styles.container} style={{ backgroundImage: `url(${INDEX_CONFIG.bg})` }}> <View className={homeStyle} style={{ backgroundImage: `url(${INDEX_CONFIG.bg})`}}>
<View className={styles.rule} style={{ backgroundImage: `url(${INDEX_CONFIG.ruleButton})` }} onTap={() => setRuleModalVisible(true)}>活动规则</View> <View className={styles.rule} style={{ backgroundImage: `url(${INDEX_CONFIG.ruleButton})` }} onTap={() => setRuleModalVisible(true)}>活动规则</View>
<View className={styles.my_prize} style={{ backgroundImage: `url(${INDEX_CONFIG.myPrizeButton})` }} onTap={onGoMyPrizePage}>我的奖品</View> <View className={styles.my_prize} style={{ backgroundImage: `url(${INDEX_CONFIG.myPrizeButton})` }} onTap={onGoMyPrizePage}>我的奖品</View>
<View className={styles.share} style={{ backgroundImage: `url(${INDEX_CONFIG.shareButton})` }} onTap={onShare}>分享</View> <View className={styles.share} style={{ backgroundImage: `url(${INDEX_CONFIG.shareButton})` }} onTap={onShare}>分享</View>
<View className={styles.tasks} style={{ backgroundImage: `url(${INDEX_CONFIG.taskButton})` }} onTap={() => setTasksModalVisible(true)}>任务</View> <View className={styles.tasks} style={{ backgroundImage: `url(${INDEX_CONFIG.taskButton})` }} onTap={() => setTasksModalVisible(true)}>任务</View>
<View className={styles.games} style={{ backgroundImage: `url(${INDEX_CONFIG.taskButton})` }} onTap={() => navigateTo('/pages/games/games')}>游戏</View>
<View className={styles['blank_content']}><text>{`dldlddddl\n212222222`}</text></View>
<View className={styles.bemember} onTap={() => setMemberVisible(true)}>入会</View> <View className={styles.bemember} onTap={() => setMemberVisible(true)}>入会</View>
{ {
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
min-height: 100vh; min-height: 100vh;
.image-property(cover, top center); .image-property(cover, top center);
} }
.content_fixed {
position: fixed;
}
.index_button() { .index_button() {
.wh(150px, 46px); .wh(150px, 46px);
.border(#000); .border(#000);
...@@ -39,3 +41,13 @@ ...@@ -39,3 +41,13 @@
right: 20px; right: 20px;
top: 340px; top: 340px;
} }
.games {
.index_button();
right: 20px;
top: 420px;
}
.blank_content {
width: 100%;
height: 2500px;
background: #eee;
}
import React, { useState } from 'react' import React, { useState, useEffect } from 'react'
import { Image, ScrollView, View } from '@tarojs/components' import { Image, ScrollView, View } from '@tarojs/components'
import API from '@/api' import API from '@/api'
import { DRAW_STATUS, PRIZE_TYPE } from '@/const' import { DRAW_STATUS, PRIZE_TYPE } from '@/const'
...@@ -6,7 +6,6 @@ import DeliveryModal from '@/components/DeliveryModal/DeliveryModal' ...@@ -6,7 +6,6 @@ import DeliveryModal from '@/components/DeliveryModal/DeliveryModal'
import tbccTs from 'tbcc-sdk-ts' import tbccTs from 'tbcc-sdk-ts'
import { useThrottle } from '@/hooks/useThrottle' import { useThrottle } from '@/hooks/useThrottle'
import { checkIsMember } from 'tbcc-sdk-ts/lib/utils' import { checkIsMember } from 'tbcc-sdk-ts/lib/utils'
import { useDidShow } from '@tarojs/taro'
import { dateFormatter } from '@/utils/date' import { dateFormatter } from '@/utils/date'
import './myPrize.less' import './myPrize.less'
...@@ -56,13 +55,9 @@ function MyPrizeList() { ...@@ -56,13 +55,9 @@ function MyPrizeList() {
const [ memberVisible, setMemberVisible ] = useState(false) const [ memberVisible, setMemberVisible ] = useState(false)
const [ deliveryModalVisible, setDeliveryModalVisible ] = useState(false) const [ deliveryModalVisible, setDeliveryModalVisible ] = useState(false)
// useEffect(() => { useEffect(() => {
// fetchMyPriceList()
// }, [])
useDidShow(() => {
fetchMyPriceList() fetchMyPriceList()
}) }, [])
async function fetchMyPriceList() { async function fetchMyPriceList() {
const res = await getMyPrizeList() const res = await getMyPrizeList()
...@@ -198,7 +193,7 @@ function MyPrizeList() { ...@@ -198,7 +193,7 @@ function MyPrizeList() {
<View className='my-prize-list'> <View className='my-prize-list'>
{myPrizeList.map((item, i) => { {myPrizeList.map((item, i) => {
return ( return (
<View className='my-prize-item' key={item}> <View className='my-prize-item' key={'prize_'+i}>
<Image className='my-prize-item__avatar' src={item.image} /> <Image className='my-prize-item__avatar' src={item.image} />
<View className='my-prize-item__content'> <View className='my-prize-item__content'>
......
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