星期二 shoppage api

This commit is contained in:
郑茂强 2018-12-18 17:37:23 +08:00
parent 6bacc5be25
commit 1383fe403d
14 changed files with 683 additions and 440 deletions

View File

@ -36,23 +36,23 @@
"taro-ui": "^1.5.0" "taro-ui": "^1.5.0"
}, },
"devDependencies": { "devDependencies": {
"@types/react": "^16.4.8",
"@types/webpack-env": "^1.13.6",
"@tarojs/plugin-babel": "^1.2.0-beta.3", "@tarojs/plugin-babel": "^1.2.0-beta.3",
"@tarojs/plugin-csso": "^1.2.0-beta.3", "@tarojs/plugin-csso": "^1.2.0-beta.3",
"@tarojs/plugin-sass": "^1.2.0-beta.3", "@tarojs/plugin-sass": "^1.2.0",
"@tarojs/plugin-uglifyjs": "^1.2.0-beta.3", "@tarojs/plugin-uglifyjs": "^1.2.0-beta.3",
"@tarojs/webpack-runner": "^1.2.0-beta.3", "@tarojs/webpack-runner": "^1.2.0-beta.3",
"@types/react": "^16.4.8",
"@types/webpack-env": "^1.13.6",
"babel-eslint": "^8.2.3",
"babel-plugin-transform-class-properties": "^6.24.1", "babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-jsx-stylesheet": "^0.6.5", "babel-plugin-transform-jsx-stylesheet": "^0.6.5",
"babel-plugin-transform-object-rest-spread": "^6.26.0", "babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1", "babel-preset-env": "^1.6.1",
"babel-eslint": "^8.2.3",
"eslint": "^4.19.1", "eslint": "^4.19.1",
"eslint-config-taro": "^1.2.0-beta.3", "eslint-config-taro": "^1.2.0-beta.3",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-import": "^2.12.0", "eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-taro": "^1.2.0-beta.3" "eslint-plugin-taro": "^1.2.0-beta.3"
} }
} }

View File

@ -26,7 +26,7 @@ class App extends Component {
'pages/supplyDemandPublish/supplyDemandPublish', 'pages/supplyDemandPublish/supplyDemandPublish',
'pages/mySupplyDemand/mySupplyDemand', 'pages/mySupplyDemand/mySupplyDemand',
'pages/allDemanding/allDemanding', 'pages/allDemanding/allDemanding',
'pages/shopDescription/shopDescription', // 'pages/shopDescription/shopDescription',
], ],
window: { window: {
backgroundTextStyle: 'light', backgroundTextStyle: 'light',

View File

@ -10,6 +10,9 @@ const hornIcon = require('../../icons/horn.png')
const houseIcon = require('../../icons/house.png') const houseIcon = require('../../icons/house.png')
class recommondShop extends Component { class recommondShop extends Component {
static options = {
addGlobalClass: true
}
config = { config = {
navigationBarTitleText: 'recommondShop' navigationBarTitleText: 'recommondShop'
@ -194,44 +197,44 @@ class recommondShop extends Component {
const voucherModalElement = <AtModal className='voucher-modal' isOpened={this.state.isOpenVouhcer}> const voucherModalElement = <AtModal className='voucher-modal' isOpened={this.state.isOpenVouhcer}>
<AtModalHeader>优惠卷须知</AtModalHeader> <AtModalHeader>优惠卷须知</AtModalHeader>
<AtModalContent> <AtModalContent>
<AtNoticebar className='warning' icon='volume-plus'> <AtNoticebar style='color:#a94442' icon='volume-plus'>
提示具体可以前往实体店进行领取优惠卷或通过电话进行咨询 提示具体可以前往实体店进行领取优惠卷或通过电话进行咨询
</AtNoticebar> </AtNoticebar>
<View className='voucher-left'>当前优惠卷{voucherLeft}</View> <View className='voucher-left'>当前优惠卷{voucherLeft}</View>
<AtInput <AtInput
disabled disabled
name='value' name='value'
title='联系人:' title='联系人:'
type='text' type='text'
placeholder='123' placeholder='123'
/> />
<AtInput <AtInput
disabled disabled
name='value' name='value'
title='联系电话:' title='联系电话:'
type='number' type='number'
placeholder='需求标题' placeholder='需求标题'
/> />
{!this.state.voucherCanConsult ? <View className='voucher-ResponseMsg'>{this.state.voucherResponseMsg}</View> : null} {!this.state.voucherCanConsult ? <View className='voucher-ResponseMsg'>{this.state.voucherResponseMsg}</View> : null}
</AtModalContent> </AtModalContent>
<AtModalAction> <Button onClick={this.voucherModalClose.bind(this)} >取消</Button> <Button onClick={this.voucherModalConfirm.bind(this)}></Button> </AtModalAction> <AtModalAction> <Button onClick={this.voucherModalClose.bind(this)} >取消</Button> <Button style='color:#FF7B00' onClick={this.voucherModalConfirm.bind(this)}></Button> </AtModalAction>
</AtModal> </AtModal>
const consultModalElement = <AtModal isOpened={this.state.isOpenConsult}> const consultModalElement = <AtModal isOpened={this.state.isOpenConsult}>
<AtModalHeader>咨询</AtModalHeader> <AtModalHeader>咨询</AtModalHeader>
<AtModalContent> <AtModalContent>
<View className='tip'> <Text>提示:</Text><Text className='tip-info'>{this.state.consultTip}</Text></View> <View className='tip'> <Text>提示:</Text><Text className='tip-info'>{this.state.consultTip}</Text></View>
<AtInput <AtInput
name='value' name='value'
title='联系人:' title='联系人:'
type='text' type='text'
placeholder='123' placeholder='123'
/> />
<AtInput <AtInput
name='value' name='value'
title='联系电话:' title='联系电话:'
type='number' type='number'
placeholder='需求标题' placeholder='需求标题'
/> />
</AtModalContent> </AtModalContent>
<AtModalAction> <Button onClick={this.consultModalClose.bind(this)} >取消</Button> <Button onClick={this.consultModalConfirm.bind(this)}></Button> </AtModalAction> <AtModalAction> <Button onClick={this.consultModalClose.bind(this)} >取消</Button> <Button onClick={this.consultModalConfirm.bind(this)}></Button> </AtModalAction>
@ -239,8 +242,8 @@ class recommondShop extends Component {
// 请提示元素 // 请提示元素
const toast = <AtToast const toast = <AtToast
isOpened={this.state.isToast} isOpened={this.state.isToast}
text={this.state.consultResponseMsg} text={this.state.consultResponseMsg}
// iconSize={iconSize} // iconSize={iconSize}
// iconType={iconType} // iconType={iconType}
// iconColor={iconColor} // iconColor={iconColor}

View File

@ -9,6 +9,7 @@
.at-modal-content{ .at-modal-content{
background-color: black background-color: black
} }
} }

View File

@ -19,10 +19,14 @@ class ShopItem extends Component {
}} }}
shopOnClickHanlder(){ shopOnClickHanlder(){
let goodId=this.props.item.goods_id
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/goods/goods?id=123&name=michael' url: '/pages/goods/goods?id='+goodId
}) })
} }
componentDidMount(){
}
// 当图片无效的时候 的方法 (为什么不起作用??) // 当图片无效的时候 的方法 (为什么不起作用??)
onError(e){ onError(e){
@ -30,6 +34,7 @@ class ShopItem extends Component {
e.target.onerror = null; e.target.onerror = null;
e.target.src = 'https://raw.githubusercontent.com/shenghy/SmileVue/master/src/assets/images/errorimg.png' e.target.src = 'https://raw.githubusercontent.com/shenghy/SmileVue/master/src/assets/images/errorimg.png'
} }
render() { render() {
const imgURL =this.props.item? URL.Base +this.props.item.goods_url:null const imgURL =this.props.item? URL.Base +this.props.item.goods_url:null
const newPrice = this.props.item ? this.props.item.goods_price : null const newPrice = this.props.item ? this.props.item.goods_price : null

View File

@ -1,6 +1,7 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components' import { View, Text, Image , Swiper, SwiperItem} from '@tarojs/components'
import {AtTabs, AtTabsPane, AtSegmentedControl, AtIcon, AtToast ,Picker } from 'taro-ui'
import { AtTabs, AtTabsPane, AtSegmentedControl, AtIcon, AtToast, Picker } from 'taro-ui'
import copyrightComponent from '../../component/copyrightComponent/copyrightComponent' import copyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import SearchBarComponent from '../../component/searchBarComponent/searchBarComponent' import SearchBarComponent from '../../component/searchBarComponent/searchBarComponent'
@ -8,7 +9,7 @@ import URL from '../../serviceAPI.config'
import './goods.scss' import './goods.scss'
//GetShopItemDetail
class Goods extends Component { class Goods extends Component {
config = { config = {
@ -18,13 +19,55 @@ class Goods extends Component {
super(...arguments) super(...arguments)
this.state = { this.state = {
current: 0, // 当前大类评论区 current: 0, // 当前大类评论区
subCurrent:0, // 当前小类评论区 subCurrent: 0, // 当前小类评论区
isOpened:false, // 是否显示轻提示 isOpened: false, // 是否显示轻提示
selector: ['0', '1', '2', '3'], // 数量或者规格选择 selector: ['0', '1', '2', '3'], // 数量或者规格选择
selectorChecked: '0', // 已选择的数量或规格 selectorChecked: '0', // 已选择的数量或规格
}} productImagesUrl: '', // 图片地址
productName: '',// 商品名字
productDes: '',// 商品简介
oldPirce: '',// 原价
specialPrice: '',//促销价
productType: '',//商品类型
serviceArea: '',//服务区域
monthSold: '',//月销量
totalSold: '',//总销量
browsingCount: '',// 浏览数
}
}
// 商品详情api
getShopDescription() {
Taro.request({
url: URL.GetShopItemDetail,
method: 'POST',
dataType: 'json',
data: {
goodsID: this.$router.params.id,
},
header: {
'content-type': 'application/x-www-form-urlencoded',
}
})
.then(res => {
console.log('商品详情:', res)
this.setState({
productImagesUrl: res.data.goods.goods_pic,
productName: res.data.goods.goods_name,
productDes: res.data.goods.goods_profiles,
oldPirce: res.data.goods.goods_org_price,
specialPrice: res.data.goods.goods_price,
productType: res.data.goods.goods_type_name,
serviceArea: res.data.goodsRegionName[0],
monthSold: res.data.goods.month_sales,
totalSold: res.data.goods.sales_volume,
browsingCount: res.data.goods.browse_times,
})
}
)
}
// 大类评论区方法 // 大类评论区方法
handleClick(value) { handleClick(value) {
this.setState({ this.setState({
@ -38,14 +81,14 @@ class Goods extends Component {
}) })
} }
// 去其他页面 // 去其他页面
goShopPage(){ goShopPage() {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/shop/shop' url: '/pages/shop/shop'
}) })
} }
// 收藏商品 // 收藏商品
saveItem(){ saveItem() {
this.setState({isOpened:true}) this.setState({ isOpened: true })
} }
// 数量或者规格方法 // 数量或者规格方法
onChange = e => { onChange = e => {
@ -54,7 +97,8 @@ class Goods extends Component {
}) })
} }
componentDidMount() { componentDidMount() {
//this.$router.params.id
this.getShopDescription()
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps) console.log(this.props, nextProps)
@ -69,92 +113,126 @@ class Goods extends Component {
render() { render() {
const mainTabList = [{ title: '宝贝详情' }, { title: '全部评价' }, { title: '猜你喜欢' }] const mainTabList = [{ title: '宝贝详情' }, { title: '全部评价' }, { title: '猜你喜欢' }]
// const subTabList = [{ title: '全部' }, { title: '好评' }, { title: '差评' }, { title: '公开' }, { title: '匿名' }] // const subTabList = [{ title: '全部' }, { title: '好评' }, { title: '差评' }, { title: '公开' }, { title: '匿名' }]
const itemPicsBannerElementArray=this.state.productImagesUrl.map((item,index)=>{
return < SwiperItem key={index} >
<Image mode='aspectFit' src={URL.Base + item.file_path} style='max-width: 100%; height:100%;' />
</SwiperItem >
})
const itemDescriptionPicsElementArray = this.state.productImagesUrl.map((item, index) => {
return <View className='description-img' key={index}>
<Image mode='widthFix' src={URL.Base + item.file_path} style='width: 100%; max-height:100%;' />
</View>
})
return ( return (
<View className='gooods=container'> <View className='gooods=container'>
<SearchBarComponent></SearchBarComponent> <SearchBarComponent></SearchBarComponent>
<View className='img-box'> <View className='img-box'>
<Image className='img' src={URL.Base + 'Uploads/zone/user_1041/201808/thumb/e10a0bfea09a3078a800af8054bc80ce_400X400.jpg'}></Image> {/* <Image className='img' src={URL.Base + this.state.productImagesUrl}></Image> */}
<Swiper
className='swipper'
style='height:100%;'
indicatorColor='#999'
indicatorActiveColor='#333'
hotizontal
circular
indicatorDots
>
{itemPicsBannerElementArray}
</Swiper>
</View> </View>
<View className='title-box'> <View className='title-box'>
<View className='main-title'> <View className='main-title'>
11 {this.state.productName}
</View> </View>
<View className='subtitle-box'> <View className='subtitle-box'>
11 {this.state.productDes}
</View> </View>
</View> </View>
<View className='price-box'> <View className='price-box'>
<View className='org-box'> <View className='org-box'>
<Text className='title'>原价</Text> <Text className='title'>原价</Text>
<Text className='price'>11</Text> <Text className='price'>{this.state.oldPirce}</Text>
</View> </View>
<View className='spe-price'> <View className='spe-price'>
<Text className='title'>促销价</Text> <Text className='title'>促销价</Text>
<Text className='price'>11</Text> <Text className='price'>{this.state.specialPrice}</Text>
</View> </View>
</View> </View>
<View className='info-box'> <View className='info-box'>
<View className='type'> <View className='type'>
<Text className='title'>商品类型</Text> <Text className='title'>商品类型</Text>
<Text className='desc'>设计师商品</Text> <Text className='desc'>{this.state.productType}</Text>
</View> </View>
<View className='district'> <View className='district'>
<Text className='title'>服务区域</Text> <Text className='title'>服务区域</Text>
<Text className='desc'>中国/福建省(全省)</Text> <Text className='desc'>{this.state.serviceArea}</Text>
</View> </View>
</View> </View>
<View className='counter-box'> <View className='counter-box'>
<View className='month-sold'> <View className='month-sold'>
<Text className='title'>月销量</Text> <Text className='title'>月销量</Text>
<Text className='amount'>0</Text> <Text className='amount'>{this.state.monthSold}</Text>
</View> </View>
<View className='total-sold'> <View className='total-sold'>
<Text className='title'>总销量</Text> <Text className='title'>总销量</Text>
<Text className='amount'>0</Text> <Text className='amount'>{this.state.totalSold}</Text>
</View> </View>
<View className='browsing-amount'> <View className='browsing-amount'>
<Text className='title'>浏览量</Text> <Text className='title'>浏览量</Text>
<Text className='amount'>13</Text> <Text className='amount'>{this.state.browsingCount}</Text>
</View> </View>
</View> </View>
<View className='standard-box'> <View className='standard-box'>
{/* 规格或者数量 */} {/* 规格或者数量 */}
<Picker mode='selector' range={this.state.selector} onChange={this.onChange}> <Picker mode='selector' range={this.state.selector} onChange={this.onChange}>
<View className='picker'> <View className='picker'>
<View className='title'> <View className='title'>
可选规格: 可选规格:
</View> </View>
<View className='more'> <View className='more'>
{this.state.selectorChecked} {this.state.selectorChecked}
</View> </View>
</View> </View>
</Picker> </Picker>
</View> </View>
{/* 详情和评论区 */} {/* 详情和评论区 */}
<View className='details-box'> <View className='details-box'>
{/* 大类 */} {/* 大类 */}
<AtTabs selectedColor='#FF7142' className='alltabs' animated={false} current={this.state.current} tabList={mainTabList} onClick={this.handleClick.bind(this)}> <AtTabs selectedColor='#FF7142' className='alltabs' animated={false} current={this.state.current} tabList={mainTabList} onClick={this.handleClick.bind(this)}>
<AtTabsPane current={this.state.current} index={0} > <AtTabsPane current={this.state.current} index={0} >
<View style='padding: 100px 50px;background-color: #FAFBFC;text-align: center;' >商品细节</View> <View style='background-color: #FAFBFC;' >
<View className='description-title'>商品细节</View>
<View className='description-img'>
{itemDescriptionPicsElementArray}
</View>
</View>
</AtTabsPane> </AtTabsPane>
<AtTabsPane current={this.state.current} index={1}> <AtTabsPane current={this.state.current} index={1}>
<View style='padding: 1px 0px 100px;background-color: #FAFBFC;text-align: center;'> <View style='padding: 1px 0px 100px;background-color: #FAFBFC;text-align: center;'>
{ /*子标签类*/} { /*子标签类*/}
<AtSegmentedControl selectedColor='#FF9500' <AtSegmentedControl selectedColor='#FF9500'
values={['全部', '好评', '中评', '差评', '公开','匿名']} values={['全部', '好评', '中评', '差评', '公开', '匿名']}
onClick={this.onClick.bind(this)} onClick={this.onClick.bind(this)}
current={this.state.subCurrent} current={this.state.subCurrent}
/> />
{ {
this.state.subCurrent === 0 this.state.subCurrent === 0
? <View className='tab-content'> ? <View className='tab-content'>
<Text className='title'>全部</Text> <Text className='title'>全部</Text>
</View> </View>
: null : null
} }
{ {
@ -182,15 +260,15 @@ class Goods extends Component {
? <View className='tab-content'>匿名</View> ? <View className='tab-content'>匿名</View>
: null : null
} }
</View> </View>
</AtTabsPane> </AtTabsPane>
<AtTabsPane current={this.state.current} index={2}> <AtTabsPane current={this.state.current} index={2}>
<View style='padding: 100px 50px;background-color: #FAFBFC;text-align: center;'>标签页三的内容</View> <View style='padding: 100px 50px;background-color: #FAFBFC;text-align: center;'>标签页三的内容</View>
</AtTabsPane> </AtTabsPane>
</AtTabs> </AtTabs>
</View> </View>
<copyrightComponent></copyrightComponent> <copyrightComponent></copyrightComponent>
@ -201,13 +279,13 @@ class Goods extends Component {
<Text className='title'>进店</Text> <Text className='title'>进店</Text>
</View> </View>
<View className='collection' onClick={this.saveItem.bind(this)}> <View className='collection' onClick={this.saveItem.bind(this)}>
<AtIcon className='icon' value='heart' size='12' color='white'></AtIcon> <AtIcon className='icon' value='heart' size='12' color='white'></AtIcon>
<AtToast <AtToast
isOpened={this.state.isOpened} isOpened={this.state.isOpened}
duration={1000} duration={1000}
text='收藏成功' text='收藏成功'
></AtToast> ></AtToast>
<Text className='title'>收藏商品</Text> <Text className='title'>收藏商品</Text>
</View> </View>
<View className='add-cart'> <View className='add-cart'>
加入购物车 加入购物车

View File

@ -1,188 +1,200 @@
// border: 1px solid #ddd; // border: 1px solid #ddd;
// padding: 5px 0; // padding: 5px 0;
.img-box{ .img-box{
border: 1px solid #ddd; // border: 1px solid #ddd;
padding: 20px 0; padding: 20px 0;
text-align: center; text-align: center;
.img{ height: 600px;
height: 700px;
width: 60%
}
}
.title-box{
border: 1px solid #ddd;
padding: 5px 0;
.main-title{
margin-left: 20px;
font-size: 30px;
font-weight: bold;
}
.subtitle-box{
margin-left: 20px;
font-size: 25px;
}
}
.price-box{
border: 1px solid #ddd;
padding: 5px 0;
color:#999;
font-size: 25px;
.org-box{
margin-left: 20px;
.title{
font-weight: bold
}
.price{
text-decoration-line: line-through
}
}
.spe-price{
font-weight: bold;
margin-left: 20px;
.price{
font-size: 40px;
color: #c00;
}
}
}
.info-box{
border: 1px solid #ddd;
padding: 5px 0;
color:#999;
font-size: 25px;
.type, .district{
margin-left: 20px;
padding: 5px 0;
.title{
font-weight: bold
}
.desc{
color: black;
display: inline-block;
margin-left: 20px
}
}
}
.counter-box{
width: 100%;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
.month-sold,.total-sold,.browsing-amount{
flex:1;
font-size: 25px;
text-align: center;
margin:20px 0;
border-right: 1px solid #ddd;
.amount{
display: inline-block;
margin-left: 20px;
color: #c00;
font-weight: bold
}
}
.browsing-amount{
border-right: 0px solid #ddd;
}
}
.standard-box{
.picker{
border: 1px solid #ddd;
padding: 10px 0;
color:#999;
font-size: 25px;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
.title{
flex:1;
font-weight: bold;
margin-left: 20px;
}
.more{
flex:1;
text-align: right;
margin-right: 20px;
}
}
}
//------------------------------
.details-box{
.at-tabs{
.at-tabs__item--active{
color:#FF7142
}
}
}
//------------------------------
.copyright-box{
padding:0 20px;
.title{
text-align: center;
line-height: 100px;
font-size: 25px;
}}
.gap{
height:150px;
} }
.shop-bottom-box{ .title-box{
position: fixed; border: 1px solid #ddd;
bottom: 0; padding: 5px 0;
width: 100%;
z-index: 600; .main-title{
.shop-bottom-nav{ margin-left: 20px;
display: flex; font-size: 30px;
flex-wrap: nowrap; font-weight: bold;
flex-direction: row; }
text-align: center; .subtitle-box{
height: 90px; margin:0 20px;
line-height: 90px; font-size: 25px;
font-size: 30px;
}
.to-shop{
flex:1;
color: #333;
background-color: white;
} }
.collection{ .price-box{
flex:1; border: 1px solid #ddd;
background-color: #FF9500; padding: 5px 0;
color: white; color:#999;
.icon{ font-size: 25px;
vertical-align: middle .org-box{
} margin-left: 20px;
.title{
font-weight: bold
}
.price{
text-decoration-line: line-through
}
}
.spe-price{
font-weight: bold;
margin-left: 20px;
.price{
font-size: 40px;
color: #c00;
}
}
}
.info-box{
border: 1px solid #ddd;
padding: 5px 0;
color:#999;
font-size: 25px;
.type, .district{
margin-left: 20px;
padding: 5px 0;
.title{
font-weight: bold
}
.desc{
color: black;
display: inline-block;
margin-left: 20px
}
}
}
.counter-box{
width: 100%;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
.month-sold,.total-sold,.browsing-amount{
flex:1;
font-size: 25px;
text-align: center;
margin:20px 0;
border-right: 1px solid #ddd;
.amount{
display: inline-block;
margin-left: 20px;
color: #c00;
font-weight: bold
}
}
.browsing-amount{
border-right: 0px solid #ddd;
}
}
.standard-box{
.picker{
border: 1px solid #ddd;
padding: 10px 0;
color:#999;
font-size: 25px;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
.title{ .title{
display: inline-block; flex:1;
margin-left: 10px; font-weight: bold;
} margin-left: 20px;
}
.more{
flex:1;
text-align: right;
margin-right: 20px;
}
}
} }
.add-cart{ //------------------------------
flex:1; .details-box{
background-color:#F03726; .at-tabs{
color: white;
.at-tabs__item--active{
color:#FF7142
}
}
.description-title{
font-size:35px;
color:#999;
margin-top:20px;
margin-left: 20px;
margin-bottom: 20px;
font-weight: bold;
}
.description-img{
padding:0 10px;
font-size: 0px;
}
} }
} //------------------------------
} .copyright-box{
padding:0 20px;
.title{
text-align: center;
line-height: 100px;
font-size: 25px;
}}
.gap{
height:150px;
}
.shop-bottom-box{
position: fixed;
bottom: 0;
width: 100%;
z-index: 600;
.shop-bottom-nav{
display: flex;
flex-wrap: nowrap;
flex-direction: row;
text-align: center;
height: 90px;
line-height: 90px;
font-size: 30px;
.to-shop{
flex:1;
color: #333;
background-color: white;
}
.collection{
flex:1;
background-color: #FF9500;
color: white;
.icon{
vertical-align: middle
}
.title{
display: inline-block;
margin-left: 10px;
}
}
.add-cart{
flex:1;
background-color:#F03726;
color: white;
}
}
}

View File

@ -1,9 +1,10 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Radio, RadioGroup, Label } from '@tarojs/components' import { View, Text, Radio, RadioGroup, Label } from '@tarojs/components'
import { AtInput, AtImagePicker, AtTextarea, AtButton, Picker } from 'taro-ui' import { AtInput, AtImagePicker, AtTextarea, AtButton, Picker } from 'taro-ui'
import SearchBarComponent from '../../component/searchBarComponent/searchBarComponent' import SearchBarComponent from '../../component/searchBarComponent/searchBarComponent'
import copyrightComponent from '../../component/copyrightComponent/copyrightComponent' import copyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import URL from '../../serviceAPI.config'
import './goodsPublish.scss' import './goodsPublish.scss'
@ -18,10 +19,10 @@ class GoodsPublish extends Component {
this.state = { this.state = {
selector: ['需求', '供应', '人才'], // 应该是树型结构,需要修改 selector: ['需求', '供应', '人才'], // 应该是树型结构,需要修改
selectorChecked: '需求', selectorChecked: '需求',
productName:'', productName: '',
productPrice:'', productPrice: '',
productUnit:'', productUnit: '',
productDescript:'', productDescript: '',
files: [{ files: [{
url: 'https://jimczj.gitee.io/lazyrepay/aragaki1.jpeg', url: 'https://jimczj.gitee.io/lazyrepay/aragaki1.jpeg',
}, },
@ -52,38 +53,78 @@ class GoodsPublish extends Component {
text: '日本', text: '日本',
checked: false checked: false
} }
] // 店铺分类选项 ] // 店铺分类选项
} }
} }
// 发布商品api
uploadGoods() {
Taro.request({
url: URL.UploadProduct,
method: 'POST',
dataType: 'json',
data: {
deployType: 1,
action: 1,
goods: JSON.stringify({ "goods_name": "test2", "goods_price": "1.00", "goods_unit": "1", "goods_profiles": "test2", "class_id": "10103", "shop_class_id": "1899" }),
goodsFiles: JSON.stringify([{ "file_id": "27959", "file_type": 1, "if_cover": 1, "file_sort": 1 }])
},
header: {
'content-type': 'application/x-www-form-urlencoded',
}
})
.then(res => {
console.log('上传商品', res) // 提示非法请求 ----- to be continue
}
)
}
// 上传商品图片api
uploadGoodsImage() {
Taro.request({
url: URL.UploadPorductImage,
method: 'POST',
dataType: 'json',
data: {
file: 1,
},
header: {
'content-type': 'application/x-www-form-urlencoded',
}
})
.then(res => {
console.log('上传商品图片', res)
}
)
}
// 改变商品分类状态 // 改变商品分类状态
onChange(e){ onChange(e) {
this.setState({ this.setState({
selectorChecked: this.state.selector[e.detail.value] selectorChecked: this.state.selector[e.detail.value]
}) })
} }
productNameChange(event){ productNameChange(event) {
this.setState({ this.setState({
productName: event productName: event
}) })
} }
productPriceChange(event){ productPriceChange(event) {
this.setState({ this.setState({
productPrice: event productPrice: event
}) })
} }
productUnitChange(event){ productUnitChange(event) {
this.setState({ this.setState({
productUnit: event productUnit: event
}) })
} }
productDescriptChange(event){ productDescriptChange(event) {
this.setState({ this.setState({
productDescript: event.target.value productDescript: event.target.value
}) })
} }
// 上传图片 // 上传图片
onChangeImg(files,operationType) { onChangeImg(files, operationType,index) {
if (operationType === 'add') { if (operationType === 'add') {
this.setState({ this.setState({
files files
@ -93,7 +134,7 @@ class GoodsPublish extends Component {
this.state.files.splice(index, 1); this.state.files.splice(index, 1);
this.setState({ files: this.state.files }); this.setState({ files: this.state.files });
} }
} }
// 图片上传失败 // 图片上传失败
onFail(mes) { onFail(mes) {
@ -101,9 +142,12 @@ class GoodsPublish extends Component {
} }
// 删除图片 // 删除图片
onImageClick(index) { onImageClick(index) {
} }
componentDidMount(){
}
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps) console.log(this.props, nextProps)
} }
@ -136,33 +180,33 @@ class GoodsPublish extends Component {
<View className='input-box'> <View className='input-box'>
<Text className='require'>*</Text> <Text className='require'>*</Text>
<AtInput <AtInput
name='value' name='value'
title='商品名称:' title='商品名称:'
type='text' type='text'
value={this.state.productName} value={this.state.productName}
onChange={this.productNameChange.bind(this)} onChange={this.productNameChange.bind(this)}
/> />
</View> </View>
<View className='input-box'> <View className='input-box'>
<Text className='require'>*</Text> <Text className='require'>*</Text>
<AtInput <AtInput
name='value' name='value'
title='商品价格:' title='商品价格:'
type='number' type='number'
placeholder='¥' placeholder='¥'
value={this.state.productPrice} value={this.state.productPrice}
onChange={this.productPriceChange.bind(this)} onChange={this.productPriceChange.bind(this)}
/> />
</View> </View>
<View className='input-box'> <View className='input-box'>
<Text className='require'>*</Text> <Text className='require'>*</Text>
<AtInput <AtInput
name='value' name='value'
title='商品单位:' title='商品单位:'
type='text' type='text'
value={this.state.productUnit} value={this.state.productUnit}
onChange={this.productUnitChange.bind(this)} onChange={this.productUnitChange.bind(this)}
/> />
</View> </View>
{/* 图片上传 */} {/* 图片上传 */}
<View className='img-box'> <View className='img-box'>
@ -172,16 +216,16 @@ class GoodsPublish extends Component {
</View> </View>
<View className='img-container'> <View className='img-container'>
<AtImagePicker <AtImagePicker
multiple multiple
files={this.state.files} files={this.state.files}
onChange={this.onChangeImg.bind(this)} onChange={this.onChangeImg.bind(this)}
onFail={this.onFail.bind(this)} onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)} onImageClick={this.onImageClick.bind(this)}
/> />
</View> </View>
</View> </View>
<View className='shoptype-box'> <View className='shoptype-box'>
{/* 店铺分类 */} {/* 店铺分类 */}
<View className='title-box'> <View className='title-box'>
<Text className='require'>*</Text> <Text className='require'>*</Text>
<Text className='title'>店铺分类:</Text> <Text className='title'>店铺分类:</Text>
@ -231,20 +275,20 @@ class GoodsPublish extends Component {
</View> </View>
</View> </View>
</View> </View>
<View className='description-box'> <View className='description-box'>
<View className='title-box'> <View className='title-box'>
<Text className='require'></Text> <Text className='require'></Text>
<Text className='title'>商品简介:</Text> <Text className='title'>商品简介:</Text>
</View> </View>
<AtTextarea <AtTextarea
value={this.state.productDescript} value={this.state.productDescript}
onChange={this.productDescriptChange.bind(this)} onChange={this.productDescriptChange.bind(this)}
maxlength='200' maxlength='200'
placeholder='你的产品简介' placeholder='你的产品简介'
/> />
</View> </View>
@ -254,13 +298,13 @@ class GoodsPublish extends Component {
<AtButton type='primary' size='small'>发布</AtButton> <AtButton type='primary' size='small'>发布</AtButton>
</View> </View>
<View className='button'> <View className='button'>
<AtButton type='primary' className='button-a' size='small'>发布并新增</AtButton> <AtButton type='primary' className='button-a' size='small'>发布并新增</AtButton>
</View> </View>
<View className='button'> <View className='button'>
<AtButton type='primary' className='button-a' size='small'>商品列表</AtButton> <AtButton type='primary' className='button-a' size='small'>商品列表</AtButton>
</View> </View>
</View> </View>

View File

@ -11,43 +11,44 @@ class Home extends Component {
config = { config = {
navigationBarTitleText: '首页' navigationBarTitleText: '首页'
} }
constructor() { constructor() {
super(...arguments); super(...arguments);
this.state = { this.state = {
shopsDetails: [], // 推荐店铺的信息 shopsDetails: [], // 推荐店铺的信息
ads: [], //广告图片数组 ads: [], //广告图片数组
categories: [],// 大类 categories: [],// 大类
subCate:[], //小类 subCate: [], //小类
demanding: [],// 业主需求 demanding: [],// 业主需求
otherData:[], // 底部导航栏 otherData: [], // 底部导航栏
isOpen:false, // 抢单消息提示 isOpen: false, // 抢单消息提示
} }
} }
componentWillMount(){ componentWillMount() {
} }
componentDidMount() { componentDidMount() {
// 页面加载后 得到首页的基本信息和推荐店铺的信息 // 页面加载后 得到首页的基本信息和推荐店铺的信息
Taro.showLoading({ title: '加载中' }) Taro.showLoading({ title: '加载中' })
this.getShops() this.getShops()
this.getHomeCategoriesInfo() this.getHomeCategoriesInfo()
this.login()
} }
//api 得到首页的信息
//api 得到首页的信息
getHomeCategoriesInfo() { getHomeCategoriesInfo() {
Taro.request({ Taro.request({
url: URL.ShopWxStore, url: URL.ShopWxStore,
}) })
.then(res => { .then(res => {
console.log('首页基本信息',res) console.log('首页基本信息', res)
this.setState({ this.setState({
ads: res.data.data.adsLb, ads: res.data.data.adsLb,
categories: res.data.data.supplyClass, categories: res.data.data.supplyClass,
demanding: res.data.data.demand.supplys, demanding: res.data.data.demand.supplys,
otherData:res.data.otherData otherData: res.data.otherData
}) })
}) })
} }
@ -79,25 +80,60 @@ class Home extends Component {
} }
) )
} }
// api 抢单请求
GrabDemand({demandId=218}){
Taro.request({
url: URL.GrabDemand,
method: 'POST',
dataType: 'json',
data: {
demandId: demandId
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
console.log('抢单请求:',res)
})
} // 登入api
login() {
Taro.login({
success(res) {
if (res.code) {
// 发起网络请求
console.log(res)
Taro.request({
url: URL.Login,
method: 'POST',
dataType: 'json',
data: {
code: res.code
},
header: {
'content-type': 'application/x-www-form-urlencoded',
}
})
.then(response => {
console.log('登入', response)
}
)}
else {
console.log('登录失败!' + res.errMsg)
}
}
})
}
// api 抢单请求
GrabDemand({ demandId = 218 }) {
Taro.request({
url: URL.GrabDemand,
method: 'POST',
dataType: 'json',
data: {
demandId: demandId
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
console.log('抢单请求:', res)
})
}
// 点击大类icon // 点击大类icon
onClickParentCate(item) { onClickParentCate(item) {
this.setState({ subCate: item.children }) this.setState({ subCate: item.children })
@ -108,23 +144,23 @@ class Home extends Component {
this.getShops(item.parent_class_id, item.class_id, 2) this.getShops(item.parent_class_id, item.class_id, 2)
} }
// 转到其他页面 // 转到其他页面
goToAllDemandingPage(){ goToAllDemandingPage() {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/allDemanding/allDemanding' url: '/pages/allDemanding/allDemanding'
}) })
} }
grabOrder(){ grabOrder() {
this.setState({isOpen:true}) this.setState({ isOpen: true })
} }
handleGrabModalClose(){ handleGrabModalClose() {
this.setState({isOpen:false}) this.setState({ isOpen: false })
} }
handleGrabModalCancel(){ handleGrabModalCancel() {
this.setState({isOpen:false}) this.setState({ isOpen: false })
} }
handleGrabConfirm(){ handleGrabConfirm() {
this.setState({isOpen:false}) this.setState({ isOpen: false })
// 确认抢单之后 // 确认抢单之后
this.GrabDemand({}) this.GrabDemand({})
} }
@ -133,10 +169,11 @@ class Home extends Component {
componentDidShow() { } componentDidShow() { }
componentDidHide() { } componentDidHide() { }
render() { render() {
// 提示弹窗element
// 提示弹窗element
const modalMessage = <AtModal className='modal' const modalMessage = <AtModal className='modal'
isOpened={this.state.isOpen} isOpened={this.state.isOpen}
title='提示' title='提示'
@ -147,7 +184,10 @@ class Home extends Component {
onConfirm={this.handleGrabConfirm.bind(this)} onConfirm={this.handleGrabConfirm.bind(this)}
content='确认抢单?\n' content='确认抢单?\n'
/> />
const demandingElemensArray = this.state.demanding.length?this.state.demanding.map((item, index) => {
const demandingElemensArray = this.state.demanding.length ? this.state.demanding.map((item, index) => {
return < SwiperItem key={index} > return < SwiperItem key={index} >
<View className='demanding-item'> <View className='demanding-item'>
<View className='item-tag'> <View className='item-tag'>
@ -157,7 +197,7 @@ class Home extends Component {
{item.sd_title} {item.sd_title}
</View> </View>
<View className='item-address'> <View className='item-address'>
{item.user_address||'无地址'} {item.user_address || '无地址'}
</View> </View>
<View className='item-name'> <View className='item-name'>
业主{item.user_name} 业主{item.user_name}
@ -167,37 +207,37 @@ class Home extends Component {
</View> </View>
</View> </View>
</SwiperItem > </SwiperItem >
}) :null }) : null
const adsImgElementsArray = this.state.ads.length?this.state.ads.map((item, index) => { const adsImgElementsArray = this.state.ads.length ? this.state.ads.map((item, index) => {
return <SwiperItem key={index}> return <SwiperItem key={index}>
<Image className='banner-img' src={URL.Base + item.ads_pic} /> <Image className='banner-img' src={URL.Base + item.ads_pic} />
</SwiperItem> </SwiperItem>
}):null }) : null
// 这里应该代码可以优化----- // 这里应该代码可以优化-----
const categoriesElementsArray1 = this.state.categories.length?this.state.categories[0].map((item, index) => { const categoriesElementsArray1 = this.state.categories.length ? this.state.categories[0].map((item, index) => {
return <View className='category-item' key={index} onClick={this.onClickParentCate.bind(this, item)}> return <View className='category-item' key={index} onClick={this.onClickParentCate.bind(this, item)}>
<Image className='cate-img' src={URL.Base + item.icon} /> <Image className='cate-img' src={URL.Base + item.icon} />
<View>{item.class_name}</View> <View>{item.class_name}</View>
</View> </View>
}):null }) : null
const categoriesElementsArray2 = this.state.categories.length?this.state.categories[1].map((item, index) => { const categoriesElementsArray2 = this.state.categories.length ? this.state.categories[1].map((item, index) => {
return <View className='category-item' key={index} onClick={this.onClickParentCate.bind(this, item)}> return <View className='category-item' key={index} onClick={this.onClickParentCate.bind(this, item)}>
<View> <Image className='cate-img' src={URL.Base + item.icon} /></View> <View> <Image className='cate-img' src={URL.Base + item.icon} /></View>
<View>{item.class_name}</View> <View>{item.class_name}</View>
</View> </View>
}):null }) : null
const shopCollectionElementsArray = this.state.shopsDetails.length?this.state.shopsDetails.map((item, index) => { const shopCollectionElementsArray = this.state.shopsDetails.length ? this.state.shopsDetails.map((item, index) => {
return <filteredShopComponent shop={item} key={index}></filteredShopComponent> return <filteredShopComponent shop={item} key={index}></filteredShopComponent>
}):null }) : null
const subCateElementsArray = this.state.subCate.length?this.state.subCate.map((item, index) => { const subCateElementsArray = this.state.subCate.length ? this.state.subCate.map((item, index) => {
return <SwiperItem key={index} onClick={this.onClickChildCate.bind(this, item)}> return <SwiperItem key={index} onClick={this.onClickChildCate.bind(this, item)}>
<View className='text'>{item.class_name}</View> <View className='text'>{item.class_name}</View>
</SwiperItem> </SwiperItem>
}):null }) : null
return ( return (
<View className='home'> <View className='home'>
@ -227,7 +267,7 @@ class Home extends Component {
hotizontal hotizontal
circular circular
indicatorDots indicatorDots
// autoplay // autoplay
> >
<SwiperItem> <SwiperItem>
<View className='categories'> <View className='categories'>
@ -253,15 +293,15 @@ class Home extends Component {
indicatorDots indicatorDots
autoplay> autoplay>
<SwiperItem> <SwiperItem>
<Image className='banner-img' src={URL.Base +'Public/images/xgt.png'} /> <Image className='banner-img' src={URL.Base + 'Public/images/xgt.png'} />
</SwiperItem> </SwiperItem>
<SwiperItem> <SwiperItem>
<Image className='banner-img' src={URL.Base +'Public/images/xgt.png'} /> <Image className='banner-img' src={URL.Base + 'Public/images/xgt.png'} />
</SwiperItem> </SwiperItem>
</Swiper> </Swiper>
</View> </View>
{/* 业主需求和行业推荐 */} {/* 业主需求和行业推荐 */}
<View className='container'> <View className='container'>
<View className='title'> <View className='title'>
@ -285,8 +325,8 @@ class Home extends Component {
{demandingElemensArray} {demandingElemensArray}
</Swiper> </Swiper>
</View> </View>
<View className='second-banner-level2'> <View className='second-banner-level2'>
{this.state.subCate.length ? <Swiper {this.state.subCate.length ? <Swiper
style='height:35px;' style='height:35px;'
className='swipper swiper-sub' className='swipper swiper-sub'
@ -296,32 +336,32 @@ class Home extends Component {
displayMultipleItems={this.state.subCate.length > 4.5 ? 4.5 : this.state.subCate.length} displayMultipleItems={this.state.subCate.length > 4.5 ? 4.5 : this.state.subCate.length}
> >
{subCateElementsArray} {subCateElementsArray}
</Swiper>:null} </Swiper> : null}
</View> </View>
<View className='title'> <View className='title'>
<Text className='title-block'></Text> <Text className='title-block'></Text>
<Text className='title-text'>行业推荐</Text> <Text className='title-text'>行业推荐</Text>
</View> </View>
<View className='shop-box'> <View className='shop-box'>
{shopCollectionElementsArray} {shopCollectionElementsArray}
{this.state.shopsDetails.length !== 0 ? <View className='title'> {this.state.shopsDetails.length !== 0 ? <View className='title'>
沒有更多了... 沒有更多了...
</View>: < View className='title' > </View> : < View className='title' >
没有找到... 没有找到...
</View > } </View >}
</View> </View>
<View className='gap'> <View className='gap'>
</View> </View>
</View> </View>
<View className='bottom-nav-box'> <View className='bottom-nav-box'>
<bottomNav otherData={this.state.otherData}/> <bottomNav otherData={this.state.otherData} />
</View> </View>
</View> </View>
) )

View File

@ -27,10 +27,15 @@ class Index extends Component {
//http://ihome6.com/Shop-supplyShops //http://ihome6.com/Shop-supplyShops
componentDidMount(){ componentDidMount(){
Taro.setStorageSync('PFWSSS','hq0erouhm4mea8b0mg34gdj0q7')
Taro.setStorageSync('X-Token','eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.IntcInVzZXJfaWRcIjpcIjI3XCIsXCJsb2dpbl9uYW1lXCI6XCJ5YW5neGJcIixcImF0XCI6XCIyMDE4LTEyLTE4IDEzOjM1OjUxXCJ9Ig.gXvZxXgU5asfwUJAG-z7k5g2p3dbts2e1X9L902KksE')
Taro.setStorageSync('PLU','%2Fm-more')
Taro.setStorageSync('localCity','think%3A%7B%2214%22%3A%22%25E7%25A6%258F%25E5%25BB%25BA%25E7%259C%2581%22%2C%2214001%22%3A%22%25E7%25A6%258F%25E5%25B7%259E%25E5%25B8%2582%22%7D')
Taro.navigateTo({ Taro.navigateTo({
// url: '/pages/home/home'
// url: '/pages/goodsPublish/goodsPublish'
url: '/pages/home/home' url: '/pages/home/home'
// url: '/pages/goodsPublish/goodsPublish'
// url:'/pages/supplyDemandPublish/supplyDemandPublish'
}) })
} }
componentWillReceiveProps (nextProps) { componentWillReceiveProps (nextProps) {

View File

@ -44,6 +44,7 @@ class MySupplyDemand extends Component {
'X-Requested-With': 'XMLHttpRequest' 'X-Requested-With': 'XMLHttpRequest'
} }
}).then(res => { }).then(res => {
console.log(res) // ------------------------------------------- to be continue----
console.log('个人供求=》暂时无数据, 后台需要权限验证') console.log('个人供求=》暂时无数据, 后台需要权限验证')
}) })

View File

@ -24,11 +24,11 @@ class Shop extends Component {
shopId: '', // 店铺的id shopId: '', // 店铺的id
shopName: '', // 店铺名 shopName: '', // 店铺名
FilterText: '', // 筛选的可选项 FilterText: '', // 筛选的可选项
filterBar: ['all', 'amount', 'newProduct', 'price', 'popularity'], filterBar: ['all', 'amount', 'newProduct', 'price', 'popularity'], //筛选选项
filterBarKeys: { all: '综合排序', amount: '销量', newProduct: '新品', price: '价格', popularity: '人气' }, filterBarKeys: { all: '综合排序', amount: '销量', newProduct: '新品', price: '价格', popularity: '人气' }, // 筛选选项对应值
selectedFilterValue: 0, //筛选项 selectedFilterValue: 0, //筛选项
isShowFilter: false, //是否显示侧边筛选 isShowFilter: false, //是否显示侧边筛选
showShopHomePage: false,// 是否显示首页页面 showShopHomePage: true,// 是否显示首页页面
shopDescriptionData: '',// 店铺详情信息 shopDescriptionData: '',// 店铺详情信息
shopName: '',//店铺名称 shopName: '',//店铺名称
shopAddress: '',//店铺地址 shopAddress: '',//店铺地址
@ -154,7 +154,7 @@ class Shop extends Component {
// api 得到店铺详情请求 // api 得到店铺详情请求
getShopDescription({ shopID = 808 }) { getShopDescription({ shopID = 808 }) {
Taro.request({ Taro.request({
url: URL.Base + 'shop-wxShopInfo', url: URL.ShopDescription,
method: 'POST', method: 'POST',
dataType: 'json', dataType: 'json',
data: { data: {
@ -173,7 +173,7 @@ class Shop extends Component {
contactNumber: res.data.userRes.phone, contactNumber: res.data.userRes.phone,
shopDescription: res.data.data.shop_desc shopDescription: res.data.data.shop_desc
}, () => { }, () => {
console.log(this.state.shopDescriptionData) // console.log(this.state.shopDescriptionData)
}) })
} }

View File

@ -1,10 +1,11 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Button, Text } from '@tarojs/components' import { View, Text } from '@tarojs/components'
import { AtInput, AtForm, AtImagePicker, AtTextarea, AtRadio, AtButton, Picker} from 'taro-ui' import { AtInput, AtImagePicker, AtTextarea, AtButton, Picker } from 'taro-ui'
import SearchBarComponent from '../../component/searchBarComponent/searchBarComponent' import SearchBarComponent from '../../component/searchBarComponent/searchBarComponent'
import copyrightComponent from '../../component/copyrightComponent/copyrightComponent' import copyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import URL from '../../serviceAPI.config'
import './supplyDemandPublish.scss' import './supplyDemandPublish.scss'
@ -23,12 +24,12 @@ class SupplyDemand extends Component {
demandingSupplyCateSelected: '需求',// 当前供求类型 demandingSupplyCateSelected: '需求',// 当前供求类型
demandingSupplyState: ['上架', '下架'], // 状态选择 demandingSupplyState: ['上架', '下架'], // 状态选择
demandingSupplyStateSelected: '上架',// 当前状态 demandingSupplyStateSelected: '上架',// 当前状态
title:'', title: '',
contactName:'', contactName: '',
contactNumber:'', contactNumber: '',
contactAddress:'', contactAddress: '',
content:'', content: '',
addImg:true, // 是否支持添加图片 addImg: true, // 是否支持添加图片
files: [{ files: [{
url: 'https://jimczj.gitee.io/lazyrepay/aragaki1.jpeg', url: 'https://jimczj.gitee.io/lazyrepay/aragaki1.jpeg',
}, },
@ -38,9 +39,48 @@ class SupplyDemand extends Component {
{ {
url: 'https://jimczj.gitee.io/lazyrepay/aragaki3.png', url: 'https://jimczj.gitee.io/lazyrepay/aragaki3.png',
}] }]
} }
} }
// 上传供求api
uploadSupplyDemand() {
Taro.request({
url: URL.UploadSupplyDemand,
method: 'POST',
dataType: 'json',
data: {
action: 1,
sdInfo: JSON.stringify({ "sd_type": "2", "sd_title": "534523", "user_name": "杨夕兵", "user_phone": "18950295811", "user_address": "2342", "sd_desc": "42342", "state": "1", "file_path": [{ "file_name": "bg3.jpg", "file_size": "212678", "file_path": "Uploads/supply/user_27/201812/38bf91f30d215bbefb2686f2401217a6.jpg", "thumb_path": "Uploads/supply/user_27/201812/thumb/38bf91f30d215bbefb2686f2401217a6_200X200.jpg" }] })
},
header: {
'content-type': 'application/x-www-form-urlencoded',
}
})
.then(res => {
console.log('上传供求', res)
}
)
}
// 上传商品图片api
uploadGoodsImage() {
Taro.request({
url: URL.UploadPorductImage,
method: 'POST',
dataType: 'json',
data: {
file: 1,
},
header: {
'content-type': 'application/x-www-form-urlencoded',
}
})
.then(res => {
console.log('上传商品图片', res)
}
)
}
// 修改供求类型 // 修改供求类型
demandingSupplyCate = e => { demandingSupplyCate = e => {
this.setState({ this.setState({
@ -54,24 +94,28 @@ class SupplyDemand extends Component {
}) })
} }
//改标题 //改标题
titleChange(event){ titleChange(event) {
this.setState({title:event}) this.setState({ title: event })
} }
contactNameChange(event){ contactNameChange(event) {
this.setState({contactName:event}) this.setState({ contactName: event })
} }
contactNumberChange(event){ contactNumberChange(event) {
this.setState({contactNumber:event}) this.setState({ contactNumber: event })
} }
contactAddressChange(event){ contactAddressChange(event) {
this.setState({contactAddress:event.target.value}) this.setState({ contactAddress: event.target.value })
} }
contentChange(event){ contentChange(event) {
this.setState({ content: event.target.value}) this.setState({ content: event.target.value })
} }
// 添加图片 // 添加图片
onChange(files, operationType,index) { onChange(files, operationType, index) {
if (operationType==='add'){ console.log(files[0].url)
Taro.uploadFile(files[0].url).then((res)=>{
console.log(res)
})
if (operationType === 'add') {
this.setState({ this.setState({
files files
}, () => { }, () => {
@ -80,7 +124,7 @@ class SupplyDemand extends Component {
} }
}) })
} }
if (operationType === 'remove'){ if (operationType === 'remove') {
this.state.files.splice(index, 1); this.state.files.splice(index, 1);
this.setState({ files: this.state.files }); this.setState({ files: this.state.files });
} }
@ -91,6 +135,9 @@ class SupplyDemand extends Component {
onImageClick(index, file) { onImageClick(index, file) {
console.log(index, file) console.log(index, file)
} }
componentDidMount(){
this.uploadSupplyDemand()
}
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps) console.log(this.props, nextProps)
} }
@ -106,45 +153,45 @@ class SupplyDemand extends Component {
<View className='supply-demand'> <View className='supply-demand'>
<SearchBarComponent></SearchBarComponent> <SearchBarComponent></SearchBarComponent>
<View className='page-section'> <View className='page-section'>
<View> <View>
<Picker mode='selector' range={this.state.demandingSupplyCate} onChange={this.demandingSupplyCate.bind(this)}> <Picker mode='selector' range={this.state.demandingSupplyCate} onChange={this.demandingSupplyCate.bind(this)}>
<View className='picker'> <View className='picker'>
<View className='title-box'> <View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.demandingSupplyCateSelected}</Text> <Text className='title'><Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.demandingSupplyCateSelected}</Text>
</View> </View>
</View> </View>
</Picker> </Picker>
</View> </View>
</View> </View>
<View className='border-box'> <View className='border-box'>
<Text className='require'>*</Text><AtInput <Text className='require'>*</Text><AtInput
name='value' name='value'
title='需求标题:' title='需求标题:'
type='text' type='text'
value={this.state.title} value={this.state.title}
onChange={this.titleChange.bind(this)} onChange={this.titleChange.bind(this)}
/> />
</View> </View>
<View className='input-box'> <View className='input-box'>
<Text className='require'>*</Text> <Text className='require'>*</Text>
<AtInput <AtInput
name='value' name='value'
title='联系人:' title='联系人:'
type='text' type='text'
value={this.state.contactName} value={this.state.contactName}
onChange={this.contactNameChange.bind(this)} onChange={this.contactNameChange.bind(this)}
/> />
</View> </View>
<View className='input-box'> <View className='input-box'>
<Text className='require'>*</Text> <Text className='require'>*</Text>
<AtInput <AtInput
name='value' name='value'
title='联系电话:' title='联系电话:'
type='number' type='number'
value={this.state.contactNumber} value={this.state.contactNumber}
onChange={this.contactNumberChange.bind(this)} onChange={this.contactNumberChange.bind(this)}
/> />
</View> </View>
<View className='demanding-box'> <View className='demanding-box'>
@ -153,10 +200,10 @@ class SupplyDemand extends Component {
</View> </View>
<AtTextarea <AtTextarea
value={this.state.contactAddress} value={this.state.contactAddress}
onChange={this.contactAddressChange.bind(this)} onChange={this.contactAddressChange.bind(this)}
maxlength='200' maxlength='200'
placeholder='联系地址' placeholder='联系地址'
/> />
</View> </View>
<View className='demanding-box'> <View className='demanding-box'>
@ -164,10 +211,10 @@ class SupplyDemand extends Component {
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='title'><Text className='require'>*</Text>:</Text>
</View> </View>
<AtTextarea <AtTextarea
value={this.state.content} value={this.state.content}
onChange={this.contentChange.bind(this)} onChange={this.contentChange.bind(this)}
maxlength='200' maxlength='200'
placeholder='' placeholder=''
/> />
</View> </View>
<View className='img-box'> <View className='img-box'>
@ -178,14 +225,14 @@ class SupplyDemand extends Component {
<View className='img-container'> <View className='img-container'>
<AtImagePicker <AtImagePicker
showAddBtn={this.state.addImg} showAddBtn={this.state.addImg}
files={this.state.files} files={this.state.files}
onChange={this.onChange.bind(this)} onChange={this.onChange.bind(this)}
onFail={this.onFail.bind(this)} onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)} onImageClick={this.onImageClick.bind(this)}
/> />
</View> </View>
</View> </View>
<View className='page-section'> <View className='page-section'>
@ -206,7 +253,7 @@ class SupplyDemand extends Component {
<AtButton type='primary' size='small'>发布</AtButton> <AtButton type='primary' size='small'>发布</AtButton>
</View> </View>
<View className='button'> <View className='button'>
<AtButton type='primary' className='button-a' size='small'>发布并新增</AtButton> <AtButton type='primary' className='button-a' size='small'>发布并新增</AtButton>
</View> </View>
<View className='button'> <View className='button'>
@ -218,7 +265,7 @@ class SupplyDemand extends Component {
</View> </View>
<copyrightComponent></copyrightComponent> <copyrightComponent></copyrightComponent>
</View> </View>
) )
} }

View File

@ -2,6 +2,7 @@
const LOCALURL = "http://192.168.1.230/" const LOCALURL = "http://192.168.1.230/"
const URL = { const URL = {
Base:LOCALURL, Base:LOCALURL,
Login: LOCALURL + 'Applet-login', //登入接口
ShopWxStore: LOCALURL + 'Shop-wxStore', //商城首页信息 ShopWxStore: LOCALURL + 'Shop-wxStore', //商城首页信息
ShopSupplyShops: LOCALURL + 'Shop-supplyShops',// 商城店铺信息 ShopSupplyShops: LOCALURL + 'Shop-supplyShops',// 商城店铺信息
GoodsSearch: LOCALURL + 'GoodsSearch-search',// 店铺页面的信息 GoodsSearch: LOCALURL + 'GoodsSearch-search',// 店铺页面的信息
@ -15,6 +16,12 @@ const URL = {
GetVoucherInfo: LOCALURL + 'Shop-couponsTips',// 优惠卷信息 GetVoucherInfo: LOCALURL + 'Shop-couponsTips',// 优惠卷信息
GetConsultInfo: LOCALURL + 'Shop-consultTips',// 咨询信息 GetConsultInfo: LOCALURL + 'Shop-consultTips',// 咨询信息
BuyConsult: LOCALURL + 'Shop-consult',// 购买咨询 BuyConsult: LOCALURL + 'Shop-consult',// 购买咨询
GetShopItemDetail: LOCALURL + 'GoodsQuery-wxGoodsDetail',// 商品详情
// 商品发布api接口
UploadPorductImage: LOCALURL + 'Goods-fileUp',// 上传商品图片
UploadProduct: LOCALURL + 'Goods-phonePost',// 上传商品
UploadSupplyDemand: LOCALURL + 'Supply-post',// 上传供求
} }