Merge branch 'pinjinjin' of git.ishopex.cn:onex/espier-taro-fenxiao into pinjinjin

This commit is contained in:
chenhui0212
2019-03-04 18:49:53 +08:00
13 changed files with 1027 additions and 1000 deletions

1780
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,71 +1,71 @@
{
"name": "espier-taro-fenxiao",
"app_name": "源源客h5",
"version": "1.0.0",
"private": true,
"description": "taro app for bbc",
"scripts": {
"build:weapp": "taro build --type weapp",
"build:swan": "taro build --type swan",
"build:alipay": "taro build --type alipay",
"build:tt": "taro build --type tt",
"build:h5": "taro build --type h5",
"build:rn": "taro build --type rn",
"dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch",
"dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch"
},
"author": "",
"license": "MIT",
"dependencies": {
"@tarojs/async-await": "^1.2.15",
"@tarojs/components": "1.2.13",
"@tarojs/redux": "^1.2.15",
"@tarojs/redux-h5": "^1.2.15",
"@tarojs/router": "1.2.13",
"@tarojs/taro": "1.2.13",
"@tarojs/taro-alipay": "1.2.13",
"@tarojs/taro-h5": "1.2.13",
"@tarojs/taro-swan": "1.2.13",
"@tarojs/taro-tt": "1.2.13",
"@tarojs/taro-weapp": "1.2.13",
"axios": "^0.18.0",
"classnames": "^2.2.6",
"copy-to-clipboard": "^3.0.8",
"lodash": "^4.17.11",
"memoize-one": "^5.0.0",
"moment": "^2.24.0",
"nerv-devtools": "^1.3.9",
"nervjs": "^1.3.9",
"qs": "^6.6.0",
"redux": "^4.0.1",
"redux-create-reducer": "^1.2.0",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"stylenames": "^1.1.6",
"taro-ui": "^2.0.1"
},
"devDependencies": {
"@tarojs/plugin-babel": "1.2.13",
"@tarojs/plugin-csso": "1.2.13",
"@tarojs/plugin-sass": "1.2.13",
"@tarojs/plugin-uglifyjs": "1.2.13",
"@tarojs/webpack-runner": "1.2.13",
"@types/react": "^16.8.5",
"@types/webpack-env": "^1.13.6",
"babel-eslint": "^8.2.3",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-jsx-stylesheet": "^0.6.5",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"eslint": "^4.19.1",
"eslint-config-taro": "1.2.13",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-taro": "1.2.13"
}
"name": "espier-taro-fenxiao",
"app_name": "源源客h5",
"version": "1.0.0",
"private": true,
"description": "taro app for bbc",
"scripts": {
"build:weapp": "taro build --type weapp",
"build:swan": "taro build --type swan",
"build:alipay": "taro build --type alipay",
"build:tt": "taro build --type tt",
"build:h5": "taro build --type h5",
"build:rn": "taro build --type rn",
"dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch",
"dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch"
},
"author": "",
"license": "MIT",
"dependencies": {
"@tarojs/async-await": "1.2.15",
"@tarojs/components": "1.2.15",
"@tarojs/redux": "1.2.15",
"@tarojs/redux-h5": "1.2.15",
"@tarojs/router": "1.2.15",
"@tarojs/taro": "1.2.15",
"@tarojs/taro-alipay": "1.2.15",
"@tarojs/taro-h5": "1.2.15",
"@tarojs/taro-swan": "1.2.15",
"@tarojs/taro-tt": "1.2.15",
"@tarojs/taro-weapp": "1.2.15",
"axios": "^0.18.0",
"classnames": "^2.2.6",
"copy-to-clipboard": "^3.0.8",
"lodash": "^4.17.11",
"memoize-one": "^5.0.0",
"moment": "^2.24.0",
"nerv-devtools": "^1.3.9",
"nervjs": "^1.3.9",
"qs": "^6.6.0",
"redux": "^4.0.1",
"redux-create-reducer": "^1.2.0",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"stylenames": "^1.1.6",
"taro-ui": "^2.0.1"
},
"devDependencies": {
"@tarojs/plugin-babel": "1.2.15",
"@tarojs/plugin-csso": "1.2.15",
"@tarojs/plugin-sass": "1.2.15",
"@tarojs/plugin-uglifyjs": "1.2.15",
"@tarojs/webpack-runner": "1.2.15",
"@types/react": "^16.8.5",
"@types/webpack-env": "^1.13.6",
"babel-eslint": "^8.2.3",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-jsx-stylesheet": "^0.6.5",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"eslint": "^4.19.1",
"eslint-config-taro": "1.2.15",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-taro": "1.2.15"
}
}

View File

@@ -2,9 +2,9 @@ import Taro from '@tarojs/taro'
import S from '@/spx'
import qs from 'qs'
function addQuery (url, query) {
return url + (url.indexOf('?') >= 0 ? '&' : '?') + query
}
// function addQuery (url, query) {
// return url + (url.indexOf('?') >= 0 ? '&' : '?') + query
// }
class API {
constructor (options = {}) {
@@ -12,6 +12,8 @@ class API {
if (!/\/$/.test(baseURL)) {
baseURL = baseURL + '/'
}
this.options = options
this.baseURL = baseURL
this.genMethods(['get', 'post', 'delete', 'put'])
}
@@ -33,34 +35,37 @@ class API {
let reqUrl = /^http/.test(url) ? url : `${this.baseURL}${url.replace(/^\//, '')}`
const query = (!data || typeof data === 'string')
? data
: qs.stringify(data)
? qs.parse(data)
: data
if (methodIsGet) {
if (query)
reqUrl = addQuery(reqUrl, query)
} else {
if (!methodIsGet) {
header['content-type'] = header['content-type'] || 'application/x-www-form-urlencoded'
}
header['Authorization'] = `Bearer ${S.getAuthToken()}`
const options = {
...config,
url: reqUrl,
data: query,
method: method.toUpperCase(),
header: header
}
if (methodIsGet) {
delete options.data
}
if (showLoading) {
Taro.showLoading({
mask: true
})
}
// TODO: update taro version
// if (this.options.interceptor && Taro.addInterceptor) {
// Taro.addInterceptor(this.options.interceptor)
// }
options.data = {
...(options.data || {}),
company_id: 1
}
return Taro.request(options)
.then(res => {
// eslint-disable-next-line
@@ -108,7 +113,14 @@ class API {
}
export default new API({
baseURL: TARO_APP.BASE_URL
baseURL: TARO_APP.BASE_URL,
// interceptor (chain) {
// const { requestParams } = chain
// requestParams.company_id = '1'
// return chain.proceed(requestParams)
// }
})
export { API }

View File

@@ -21,10 +21,10 @@ export default class TabBar extends Component {
this.state = {
current: 0,
tabList: [
{ title: '首页', iconType: 'shop', iconPrefixClass: 'sp-icon' },
{ title: '分类', iconType: 'menu', iconPrefixClass: 'sp-icon' },
{ title: '购物车', iconType: 'cart', text: this.props.cartTotalCount || '', max: '99', iconPrefixClass: 'sp-icon' },
{ title: '会员', iconType: 'user', iconPrefixClass: 'sp-icon' }
{ title: '首页', iconType: 'shop', iconPrefixClass: 'sp-icon', url: '/pages/home/index' },
{ title: '分类', iconType: 'menu', iconPrefixClass: 'sp-icon', url: '/pages/category/index' },
{ title: '购物车', iconType: 'cart', text: this.props.cartTotalCount || '', max: '99', iconPrefixClass: 'sp-icon', url: '/pages/cart/index' },
{ title: '会员', iconType: 'user', iconPrefixClass: 'sp-icon', url: '/pages/member/index', urlRedirect: true }
]
}
}
@@ -58,14 +58,17 @@ export default class TabBar extends Component {
}
handleClick = (current) => {
const cur = this.state.current
this.setState({
current
})
if (current === 2) {
Taro.navigateTo({
url: '/pages/cart/index'
})
if (cur !== current) {
const curTab = this.state.tabList[current]
const { url } = curTab
if (url) {
Taro[curTab.urlRedirect ? 'redirectTo' : 'navigateTo']({ url })
}
}
}

View File

@@ -2,7 +2,7 @@ import Taro, { Component } from '@tarojs/taro'
import { View, Text, ScrollView } from '@tarojs/components'
import { AtInputNumber, AtButton } from 'taro-ui'
import { GoodsItem, SpCheckbox, SpNote, Address, Loading, Price } from '@/components'
import { log } from '@/utils'
import { log, navigateTo } from '@/utils'
import api from '@/api'
import './index.scss'
@@ -126,6 +126,8 @@ export default class CartIndex extends Component {
})
}
navigateTo = navigateTo
// TODO: 对接api
render () {
const { list, selection, totalPrice, cartMode } = this.state
@@ -201,11 +203,11 @@ export default class CartIndex extends Component {
{
!list.length && (
<View>
<SpNote customStyle={'margin-bottom: 20px'} img='cart_empty.png'>快去给我挑点宝贝吧~</SpNote>
<SpNote customStyle='margin-bottom: 20px' img='cart_empty.png'>快去给我挑点宝贝吧~</SpNote>
<AtButton
circle
type='primary'
onClick={() => Taro.navigateTo({ url: '/pages/items/list' })}
onClick={this.navigateTo.bind(this, '/pages/home/index', true)}
>随便逛逛</AtButton>
</View>
)

View File

@@ -37,6 +37,15 @@ export default class CartIndex extends Component {
})
}
handleClickItem (item) {
const { cat_id } = item
const url = `/pages/item/list?cat_id=16`
Taro.navigateTo({
url
})
}
render () {
const { list, pluralType, imgType, currentIndex } = this.state
let items
@@ -79,7 +88,11 @@ export default class CartIndex extends Component {
<View className={classNames(pluralType ? 'category-content' : 'category-content-no')}>
{
items.map(item =>
<View className='category-content__img' key={item.cat_id}>
<View
className='category-content__img'
key={item.cat_id}
onClick={this.handleClickItem.bind(this, item)}
>
<Image
className={classNames(imgType ? 'cat-img' : 'cat-img-no')}
mode='aspectFill'

View File

@@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'
import { SearchBar } from '@/components'
import { SearchBar, TabBar } from '@/components'
import req from '@/api/req'
import { WgtSlider, WgtNavigation, WgtCoupon, WgtGoodsScroll, WgtGoodsGrid, WgtShowcase } from './wgts'
@@ -55,6 +55,7 @@ export default class HomeIndex extends Component {
})
}
</View>
<TabBar></TabBar>
</View>
)
}

View File

@@ -4,6 +4,10 @@ body, page {
background: #fff;
}
.page-index {
padding-bottom: $tabbar-height;
}
.wgts-wrap {
&__fixed {
padding-top: $searchbar-height + $edge-margin;

View File

@@ -17,6 +17,11 @@ export default class WgtNavigation extends Component {
render () {
const { info } = this.props
if (!info) {
return null
}
const { base, data } = info
return (

View File

@@ -35,13 +35,14 @@ export default class WgtSlider extends Component {
render () {
const { info } = this.props
const { curIdx } = this.state
const { config, base, data } = info
const curContent = (data[curIdx] || {}).content
if (!info) {
return null
}
const { config, base, data } = info
const curContent = (data[curIdx] || {}).content
return (
<View className={`wgt ${base.padded ? 'wgt__padded' : null}`}>
{base.title && (

View File

@@ -10,7 +10,7 @@ export default class Index extends Component {
componentWillMount () {
if (process.env.NODE_ENV === 'development') {
Taro.redirectTo({
url: '/pages/member/recharge'
url: '/pages/home/index'
})
}
}

View File

@@ -34,7 +34,7 @@ export default class List extends Component {
distributor_id: 16,
item_type: 'normal',
approve_status: 'onsale,only_show',
category: this.$router.params.cateId
category: this.$router.params.cat_id
}
}, () => {
this.nextPage()

View File

@@ -79,6 +79,12 @@ export function pickBy (arr, keyMaps = {}) {
return arr.map(picker)
}
export function navigateTo (url, isRedirect) {
return Taro[!isRedirect ? 'navigateTo' : 'redirectTo']({
url
})
}
export function resolvePath (baseUrl, params = {}) {
const queryStr = typeof params === 'string'
? params