Authored by 王水玲

ufo

... ... @@ -80,9 +80,15 @@
"query": ""
},
{
"id": -1,
"id": 8,
"name": "出售",
"pathName": "pages/sell/index",
"pathName": "page/subPackage/pages/sell/index",
"query": ""
},
{
"id": -1,
"name": "订单列表",
"pathName": "pages/orderList/index",
"query": ""
}
]
... ...
... ... @@ -3,7 +3,6 @@ import { Provider, connect } from '@tarojs/redux'
import { bindActionCreators } from 'redux';
import Index from './pages/index'
import createStore from './store'
import userUtil from './utils/user';
import * as globalData from './actions/globalData';
import udid from './utils/udid';
import './app.scss'
... ... @@ -25,13 +24,13 @@ class App extends Component {
'pages/search/index',
'pages/searchList/index',
'pages/filter/index',
// 'pages/brand/index',
'pages/productDetail/index',
'pages/sell/index',
'pages/classify/index',
'pages/message/index',
'pages/userCenter/index',
'pages/login/index'
'pages/login/index',
'pages/orderList/index'
],
window: {
backgroundTextStyle: 'light',
... ...
import Taro, {Component} from '@tarojs/taro';
import {View, ScrollView, Text, Navigator} from '@tarojs/components';
import './index.scss'
import {brand as brandModel} from '../../models';
import { SideIndex } from '../../components';
import { connect } from '@tarojs/redux';
import { modifyZoom } from '../../actions/brand'
@connect(({ brand }) => ({
brand
}), (dispatch) => ({
modifyZoom (curData) {
dispatch(modifyZoom(curData))
}
}))
export default class Brand extends Component {
constructor(props) {
super(props);
this.state = {
brandList: [],
indexList: []
};
}
config = {
navigationBarTitleText: 'BRANDS'
}
componentWillMount () { }
componentDidMount () {
this.getBrandList();
}
componentWillUnmount () { }
componentDidShow () { }
componentDidHide () { }
getBrandList () {
brandModel.getBrandList({
channel: this.$router.params.channel || ''
}).then(res => {
this.setState({
brandList: res.brandList,
indexList: res.indexList
});
});
}
onChangeBrandIndex (e) {
this.props.modifyZoom(e.target.id);
}
render () {
const {indexList, brandList} = this.state;
let toView = this.props.brand.curZoom;
return (
<View className='brand'>
<ScrollView className='brand-list-box'
scrollY
scrollWithAnimation
scrollTop='0'
lowerThreshold='20'
upperThreshold='20'
scrollIntoView={toView}>
{
brandList.map((item, brandKey) => {
return (
<View key={brandKey} className="per-brand-box">
<View className="index">
<Text id={item.index == '0~9' ? 'zero' : item.index} name={item.index} onClick={this.onChangeBrandIndex}>{item.index}</Text>
</View>
<View ClassName="brand-big-box clearfix">
{
item.brands.map(brand => {
return (
<View className="brand-box" key={brand.name}>
<Navigator>
<Text className="brand-name">{brand.name}</Text>
</Navigator>
</View>
)
})
}
</View>
</View>
)
})
}
</ScrollView>
<SideIndex indexList={indexList}></SideIndex>
</View>
)
}
}
.brand {
.brand-list-box {
width: 100%;
height: 100vh;
background: #f6f6f6;
.per-brand-box {
background: #fff;
.index {
height: 60px;
line-height: 60px;
background-color: #f6f7f6;
padding: 0 30px;
font-family: "PingFang-SC-Medium";
a {
font-size: 32px;
}
}
}
.brand-big-box {
width: 100%;
}
.brand-box {
width: 100%;
height: 80px;
line-height: 80px;
border-bottom: 1px solid #f6f6f6;
box-sizing: border-box;
overflow: hidden;
.brand-logo {
margin: 0 auto;
width: 136px;
height: 136px;
overflow: hidden;
img {
width: 100%;
}
}
.brand-name {
font-size: 28px;
color: #000;
overflow: hidden;
display: inline-block;
padding: 0 30px;
font-family: "PingFang-SC-Regular" !important;
font-weight: normal;
}
a {
height: 100%;
width: 100%;
display: inline-block;
font-weight: bold;
}
}
}
}
\ No newline at end of file
import Taro, {Component} from '@tarojs/taro';
import {View} from '@tarojs/components';
import './index.scss';
export default class OrderList extends Component {
constructor() {
super(...arguments);
this.state = {
tabs: ['出售', '代发货', '已发货', '交易成功', '交易失败'],
curTab: '代发货'
};
}
render() {
let {tabs, curTab} = this.state;
return (
<View className="order-list-page">
<View className="tabs">
{
tabs.map((item, index) => {
return (
<View className={curTab === item ? 'tabs-item actived' : 'tabs-item'} key={index}>{item}</View>
)
})
}
</View>
</View>
)
}
}
\ No newline at end of file
... ...
.tabs {
width: 100%;
height: 100px;
padding: 0 5px;
box-sizing: border-box;
background: #fff;
display: flex;
justify-content: space-between;
.tabs-item {
font-family: PingFang-SC-Medium;
font-size: 32px;
color: #999;
letter-spacing: 0;
text-align: center;
line-height: 96px;
display: inline-block;
padding: 0 20px;
&.actived {
font-size: 40px;
color: #000;
box-sizing: border-box;
border-bottom: 6px solid #000;
}
}
}
... ...
import jumpToMiniapp from './jump-to-miniapp';
import rules from './rules';
import Taro from '@tarojs/taro';
import {stringify} from 'query-string';
let pageNameMap = {};
for (let i in rules) {
if (rules.hasOwnProperty(i) && rules[i].path) {
pageNameMap[rules[i].path] = i;
}
}
export default {
// go(name, qs, type) {
// qs = qs || {};
// const rule = rules[name];
// if (!rule) {
// return Promise.reject(`router rules mismatch : ${name}`);
// }
// // 添加yas上报【fromPage】参数
// let pages = Taro.getCurrentPages();
// let currentPage = pages[pages.length - 1];
// let path = `/${currentPage.route}`;
// let options = currentPage.options;
// if (pageNameMap[path]) {
// qs.fromPage = pageNameMap[path];
// qs.fromParam = stringify(options);
// }
// // 跳转类型
// const jumpFn = jump[type] || rule.type || jump.navigateTo;
// return jumpFn(rule.path, qs);
// },
goUrl(url) {
if (!url) {
return Promise.reject('error url');
}
const [uri, search] = url.split('?');
const path = uri.split(MINI_APP_DOMAIN)[1];
const qs = parse(search);
if (qs.app && path) {
return jumpToMiniapp({
app: qs.app,
path: `${path}?${stringify(qs)}`
});
}
}
}
import Taro from '@tarojs/taro';
import {stringify} from 'query-string';
const appData = {
yohobuyLimitChannel: {
appId: 'wxed31f9e8705fb8d1',
page: {
limitProductList: 'pages/index/index'
}
},
anotherApp: {
appId: 'wx084ab813d88c594b',
page: {
home: '/pages/product/detail/detail'
}
},
};
export default function(params) {
let navigateToMiniParams = {
appId: appData[params.app].appId,
path: params.path || `${appData[params.app].page[params.page]}?${stringify(params.data)}`
};
return Taro.navigateToMiniProgram(navigateToMiniParams);
}
import Taro from '@tarojs/taro';
import {stringify} from 'query-string';
export default {
navigateTo(path, qs) {
return Taro.navigateTo({url: `${path}?${stringify(qs)}`});
},
redirectTo(path, qs) {
return Taro.redirectTo({url: `${path}?${stringify(qs)}`});
},
switchTab(path) {
return Taro.switchTab({url: path});
}
};
export default {
index: {path: '/pages/index/index'},
search: {path: '/pages/search/index'},
}
import {stringify} from 'query-string';
import router from '../router/index';
const GO_LIST = 'go.list';
const GO_PRODUCTPOOL = 'go.poollist';
const GO_SHOP = 'go.shop';
const GO_BRAND = 'go.brand';
const GO_CATEGORY = 'go.category';
const GO_DETAIL = 'go.productDetail';
const GO_COUPON = 'go.coupon';
const GO_MINE = 'go.mine';
const GO_NEW = 'go.new';
const GO_SHOPCART = 'go.shopcart';
const GO_H5 = 'go.h5';
const GO_ACTIVITY = 'go.activitytemplate';
const GO_MINIAPP = 'go.miniapp';
const GO_ZEROSELL = 'go.zerosell';
const GO_COLLAGEHOME = 'go.collagehome';//拼团购首页
const MINI_APP_DOMAIN = 'miniapp.yohobuy.com';
export default {
jumpByUrl(jumpUrl, pageName) {
if (!jumpUrl) {
return;
}
// 跳小程序
if (jumpUrl.indexOf(MINI_APP_DOMAIN)>=0) {
router.goUrl(jumpUrl);
return;
}
let url = "";
let startIndex = jumpUrl.indexOf('openby:yohobuy=');
if (startIndex < 0) {
return;
}
let jsonRule = jumpUrl.substring(startIndex + 'openby:yohobuy='.length);
let json = JSON.parse(jsonRule);
let action = json.action;
let path = '';
if (GO_LIST === action) {
let actionType = json.params.actiontype;
if (1 == actionType) {
path = "../goodsList/goodsList";
} else if (2 == actionType) {
path = "../goodsList/activtyDetail";
}
} else if (GO_BRAND === action) {
path = "../goodsList/brand";
} else if (GO_PRODUCTPOOL === action) {
path = "../goodsList/productPool";
} else if (GO_SHOP === action) {
path = "../goodsList/brandStore";
} else if (GO_DETAIL === action) {
let actionType = '';
if (json.params && json.params.activity_type){
actionType = json.params.activity_type;
}
if (actionType && actionType == 'groupPurchase'){
path = "/pages/groupPurchase/groupPurchaseDetail"
}else{
path = "../goodsDetail/goodsDetail";
}
} else if (GO_COUPON === action) {
path = "../page/subPackage/pages/couponList/couponList";
}else if (GO_NEW === action) {
path = "../goodsList/newArrival";
} else if (GO_ZEROSELL == action) {
path = "/page/subPackage/pages/zeroSell/index";
} else if (GO_SHOPCART === action) {
Taro.switchTab({
url: "/pages/shopCart/shopCart"
})
return;
}else if (GO_CATEGORY === action) {
Taro.switchTab({
url: "/pages/classify/category"
})
return;
}else if (GO_MINE === action) {
Taro.switchTab({
url: "/pages/userCenter/userCenter"
})
return;
} else if (GO_H5 === action) {
path = "/pages/webview/webview";
} else if (GO_ACTIVITY === action) {
let actionType;
if (json.params && json.params.type){
actionType = json.params.type;
}
if (actionType == 2) {
path = "../groupPurchase/groupPurchase";
} else if (actionType == 3) {
path = "../assist/assist";
}
}else if (GO_MINIAPP === action){
//跳转到小程序必须有appid和path
if(!json.params||!json.params.appId||!json.params.path ||json.params.appId.length===0 ||json.params.path.length===0){return}
let app_id = json.params.appId;
let target_path = json.params.path;
//如果appid的值为miniapp则表示要跳转到当前小程序中给定的path界面
if (app_id && 'miniapp' == app_id && target_path){
if (target_path.indexOf(0) != '/'){
target_path = '/' + target_path;
}
Taro.navigateTo({
url: target_path,
})
return;
}
let navigateToMiniParams = {
appId: json.params.appId,
path: json.params.path
};
Taro.navigateToMiniProgram(navigateToMiniParams);
return
} else if (GO_COLLAGEHOME == action){
path = "/pages/groupPurchase/groupPurchaseHome"
}
let params = stringify(json.params, false);
console.log(path)
url = path + "?page_name=" + pageName + "&" + params;
console.log(url)
if (!path) {
return;
}
if (url) {
Taro.navigateTo({
url: url,
})
}
}
}
\ No newline at end of file