Commit fde05524 by Bal Feng

add ext.json

parent 6237190d
......@@ -5,6 +5,11 @@ const config = {
designWidth: 750,
sourceRoot: 'src',
outputRoot: 'dist',
copy: {
patterns: [
{ from: 'ext.json', to: 'dist/ext.json' } // 指定需要 copy 的文件
]
},
// 通用插件配置
plugins: {
babel: {
......
{
"extEnable": true,
"extAppid": "wx337a3a660c6da1c6",
"ext": {
"attr": {
"siteId": "11536422",
"logoUrl": "https://user-assets.sxlcdn.com/images/24978/FuN1XSaebo4UJHhfumbZHfySq3S9.png?imageMogr2/strip/thumbnail/1200x9000%3E/format/png",
"siteUrl": "www.sxl.cn",
"description": "自主选位,自主点菜,源味渔社针对大食堂的弊端,致力于为消费者提供本味,健康,绿色,快捷的餐饮食品。"
},
"style": {
"mainBackground": "#AB8F83"
}
},
"pages": [
"pages/home/index",
"pages/cart/index",
"pages/user/index"
],
"window": {
"backgroundTextStyle": "dark",
"navigationBarBackgroundColor": "#346b30",
"navigationBarTitleText": "点餐小程序",
"navigationBarTextStyle": "white"
},
"tabBar": {
"list": [
{
"pagePath": "pages/home/index",
"text": "首页",
"iconPath": "./images/tab/icon-home.png",
"selectedIconPath": "./images/tab/icon-home-selected.png"
},
{
"pagePath": "pages/cart/index",
"text": "订单",
"iconPath": "./images/tab/icon-order.png",
"selectedIconPath": "./images/tab/icon-order-selected.png"
},
{
"pagePath": "pages/user/index",
"text": "更多",
"iconPath": "./images/tab/icon-mine.png",
"selectedIconPath": "./images/tab/icon-mine-selected.png"
}
],
"color": "#fff",
"selectedColor": "#fff",
"backgroundColor": "#346b30",
"borderStyle": "#ccc"
},
"networkTimeout": {
"request": 10000,
"downloadFile": 10000
},
"debug": true
}
{
"miniprogramRoot": "./dist",
"projectname": "taro-msparis",
"projectname": "taro-ordering-production",
"description": "",
"appid": "wxd2a161b3c8752b6f",
"appid": "wx2a21c16c91b7e1bf",
"setting": {
"urlCheck": true,
"es6": false,
......
......@@ -7,15 +7,13 @@ import { Provider } from '@tarojs/redux'
import './styles/base.scss'
const dvaApp = dva.createApp({
initialState: {},
models: models,
});
const store = dvaApp.getStore();
models,
})
const store = dvaApp.getStore()
class App extends Component {
config = {
pages: [
'pages/home/index',
......@@ -52,10 +50,6 @@ class App extends Component {
}
}
componentDidMount() {
}
render() {
return (<Provider store={store}>
<Home/>
......
import Taro from '@tarojs/taro'
export default {
namespace: 'global',
state: {},
effects: {},
reducers: {
save(state, {
payload,
}) {
return {
...state,
...payload,
}
}
},
}
......@@ -2,10 +2,12 @@ import cart from '../pages/cart/model'
import home from '../pages/home/model'
import user from '../pages/user/model'
import products from '../pages/productTabs/model'
import global from './global'
export default [
cart,
home,
user,
products,
global,
]
......@@ -4,14 +4,22 @@ export default {
namespace: 'home',
state: {
settings: {},
currentStoreFrontId: null,
},
effects: {
* load(_, {
call,
put
put,
select,
}) {
const { attr, style } = yield call(homeApi.getExtConfig)
yield put({
type: 'global/save',
payload: attr,
})
const { siteId } = yield select(state => state.global)
const { data } = yield call(homeApi.settings, {
siteId: '11536422',
siteId,
})
yield put({
type: 'saveSettings',
......@@ -19,6 +27,15 @@ export default {
settings: data,
}
})
yield put({
type: 'products/categories',
})
yield put({
type: 'saveSettings',
payload: {
currentStoreFrontId: data.storefronts && data.storefronts[0].id
}
})
},
},
reducers: {
......
import Request from '../../utils/request';
import Taro from '@tarojs/taro'
import Request from '../../utils/request'
import extJson from '../../../ext.json'
const isWeApp = process.env.TARO_ENV === 'weapp'
export const settings = data => Request({
url: `/r/v1/sites/${data.siteId}/restaurant/settings`,
method: 'GET',
});
})
export const getExtConfig = () => {
return new Promise((resolve, reject) => {
if (isWeApp) {
Taro.getExtConfig({
success: (res) => {
resolve(res.extConfig)
},
fail: (error) => {
reject(error)
},
})
} else {
resolve(extJson.ext)
}
})
}
......@@ -11,9 +11,11 @@ export default {
* categories(_, {
call,
put,
select,
}) {
const { siteId } = yield select(state => state.global)
const { data } = yield call(api.categories, {
siteId: '11536422',
siteId,
})
yield put({
type: 'save',
......@@ -37,8 +39,9 @@ export default {
select,
}) {
const { categoryId } = yield select(state => state.products)
const { currentStoreFrontId } = yield select(state => state.home)
const { data } = yield call(api.products, {
storefrontsId: '14171',
storefrontsId: currentStoreFrontId,
categoryId,
from: 0,
per: 999,
......
......@@ -10,6 +10,7 @@ import Loading from '../../components/Loading/Loading'
...loading,
}))
export default class ProductTabs extends Component {
handleClick (value) {
const { categories } = this.props
this.props.dispatch({
......@@ -25,12 +26,6 @@ export default class ProductTabs extends Component {
current: value,
})
}
componentDidMount() {
const { dispatch } = this.props
dispatch({
type: 'products/categories'
})
}
getTitle() {
const { categories } = this.props
......
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