Compare commits

...

12 Commits

76 changed files with 4420 additions and 2987 deletions

View File

@ -5,5 +5,12 @@ module.exports = {
defineConstants: { defineConstants: {
}, },
weapp: {}, weapp: {},
h5: {}
h5: {
esnextModules: ['taro-ui'],
devServer:{
host: "192.168.1.120",
port:80
}
}
} }

View File

@ -8,7 +8,7 @@ const config = {
'828': 1.81 / 2 '828': 1.81 / 2
}, },
sourceRoot: 'src', sourceRoot: 'src',
outputRoot: 'dist', outputRoot: 'dist',
plugins: { plugins: {
babel: { babel: {
sourceMap: true, sourceMap: true,
@ -61,6 +61,7 @@ const config = {
h5: { h5: {
publicPath: '/', publicPath: '/',
staticDirectory: 'static', staticDirectory: 'static',
esnextModules: ['@tarojs/components'],
module: { module: {
postcss: { postcss: {
autoprefixer: { autoprefixer: {
@ -69,6 +70,7 @@ const config = {
} }
} }
} }
} }
module.exports = function (merge) { module.exports = function (merge) {

View File

@ -5,5 +5,7 @@ module.exports = {
defineConstants: { defineConstants: {
}, },
weapp: {}, weapp: {},
h5: {} h5: {
esnextModules: ['taro-ui']
}
} }

View File

@ -1,59 +1,59 @@
{ {
"name": "cf-wx-app", "name": "cf-wx-app",
"version": "1.0.0", "version": "1.0.0",
"private": true, "private": true,
"description": "cf-wx-app", "description": "cf-wx-app",
"scripts": { "scripts": {
"build:weapp": "taro build --type weapp", "build:weapp": "taro build --type weapp",
"build:swan": "taro build --type swan", "build:swan": "taro build --type swan",
"build:alipay": "taro build --type alipay", "build:alipay": "taro build --type alipay",
"build:h5": "taro build --type h5", "build:h5": "taro build --type h5",
"build:rn": "taro build --type rn", "build:rn": "taro build --type rn",
"dev:weapp": "npm run build:weapp -- --watch", "dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch", "dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch", "dev:alipay": "npm run build:alipay -- --watch",
"dev:h5": "npm run build:h5 -- --watch", "dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch" "dev:rn": "npm run build:rn -- --watch"
}, },
"author": "", "author": "",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@tarojs/async-await": "^1.2.0-beta.3", "@tarojs/async-await": "1.2.17",
"@tarojs/components": "^1.2.0-beta.3", "@tarojs/components": "1.2.17",
"@tarojs/redux": "^1.2.0-beta.3", "@tarojs/redux": "1.2.17",
"@tarojs/redux-h5": "^1.2.0-beta.3", "@tarojs/redux-h5": "1.2.17",
"@tarojs/router": "^1.2.0-beta.3", "@tarojs/router": "1.2.17",
"@tarojs/taro": "^1.2.0-beta.3", "@tarojs/taro": "1.2.17",
"@tarojs/taro-alipay": "^1.2.0-beta.3", "@tarojs/taro-alipay": "1.2.17",
"@tarojs/taro-h5": "^1.2.0-beta.3", "@tarojs/taro-h5": "1.2.17",
"@tarojs/taro-swan": "^1.2.0-beta.3", "@tarojs/taro-swan": "1.2.17",
"@tarojs/taro-weapp": "^1.2.0-beta.3", "@tarojs/taro-weapp": "1.2.17",
"@tarojs/webpack-runner": "^1.2.8", "@tarojs/webpack-runner": "1.2.17",
"nerv-devtools": "^1.3.9", "nerv-devtools": "^1.3.9",
"nervjs": "^1.3.9", "nervjs": "^1.3.9",
"redux": "^4.0.0", "redux": "^4.0.0",
"redux-logger": "^3.0.6", "redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0", "redux-thunk": "^2.3.0",
"taro-ui": "^1.5.0" "taro-ui": "^1.5.0"
}, },
"devDependencies": { "devDependencies": {
"@tarojs/plugin-babel": "^1.2.0-beta.3", "@tarojs/plugin-babel": "1.2.17",
"@tarojs/plugin-csso": "^1.2.0-beta.3", "@tarojs/plugin-csso": "1.2.17",
"@tarojs/plugin-sass": "^1.2.0", "@tarojs/plugin-sass": "1.2.17",
"@tarojs/plugin-uglifyjs": "^1.2.0-beta.3", "@tarojs/plugin-uglifyjs": "1.2.17",
"@tarojs/webpack-runner": "^1.2.0-beta.3", "@tarojs/webpack-runner": "1.2.17",
"@types/react": "^16.4.8", "@types/react": "^16.4.8",
"@types/webpack-env": "^1.13.6", "@types/webpack-env": "^1.13.6",
"babel-eslint": "^8.2.3", "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",
"eslint": "^4.19.1", "eslint": "^4.19.1",
"eslint-config-taro": "^1.2.0-beta.3", "eslint-config-taro": "1.2.17",
"eslint-plugin-import": "^2.12.0", "eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2", "eslint-plugin-react": "^7.8.2",
"eslint-plugin-taro": "^1.2.0-beta.3" "eslint-plugin-taro": "1.2.17"
} }
} }

View File

@ -7,6 +7,7 @@ $linearGreen:linear-gradient(to right, #5cb85c, #5cb85c);;
$linearBlue:linear-gradient(to right, #337ab7, #337ab7); $linearBlue:linear-gradient(to right, #337ab7, #337ab7);
page{ page{
height: 100%; height: 100%;
background-color: white;
} }
.input-index--at-input__title{ .input-index--at-input__title{
@ -66,3 +67,6 @@ page{
font-size: 25rpx; font-size: 25rpx;
} }
.ali-blue-color{
color: #108ee9;
}

View File

@ -0,0 +1,255 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Text, Picker } from '@tarojs/components'
import { AtList, AtListItem, } from 'taro-ui'
import './AliShopTypeInteraction.scss'
import loginExpired from '../../util/loginExpired';
import { getGlobalStorage, setGlobalStorage } from '../../util/getSetStoage';
class ShopTypeInteractionComp extends Component {
config = {
navigationBarTitleText: 'shopTypeInteractionComp'
}
constructor() {
super(...arguments);
this.state = {
initailMultiArray: [[{}], [{ name: '选择店铺分类', id: '' }]],
multiIndex: [0, 0],
interactionMultiArray: [],// 联动数据
AliIsShowPicker: false,
}
}
// 店铺分类筛选列表GetShopTypeList
getShopTypeList(url) {
Taro.request({
url: url,
method: 'POST',
dataType: 'json',
data: {
id: this.props.shopId,
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
// console.log('店铺分类目录', res)
// this.formatIndustryType(res.data.data)
// this.formatIndustTypeInit(res.data.data)
if (res.data.err_code === 0) {
if (res.data.data === null) {
return
}
console.log('店铺分类目录ali', res)
if (!getGlobalStorage('shopTypeObject')) {
setGlobalStorage('shopTypeObject', res.data.data)
}
this.setState({
interactionMultiArray: this.interactionData(res.data.data),
initailMultiArray: this.initializedData(res.data.data),
}, () => {
// console.log('state', this.state.initailMultiArray, this.state.interactionMultiArray)
// this.passDataToParent(this.state.initailMultiArray)
//返回初始选项在 在商品编辑页面
// console.log('联动数据', this.state.interactionMultiArray)
// console.log('初始化数据', this.state.initailMultiArray)
// console.log('index初始化', this.state.multiIndex)
}) // 用递归来整理无限层次的数据
} else if (res.data.err_code === 88888) {
loginExpired(res)
} else {
console.log('店铺分类目录获取失败', res)
}
}
)
.catch(error => {
console.log('店铺分类请求错误', error)
})
}
// 递归整理无限层联动数据
interactionData(data) {
let parentArrayHolder = []
const keys = Object.keys(data)
for (let key of keys) {
let childrenArrayHolder = []
let parent = { name: data[key].n, id: key }
parentArrayHolder.push(parent)
for (let childItem of data[key].c) {
let child = { name: childItem.n, id: childItem.id }
childrenArrayHolder.push(child)
}
parent.children = childrenArrayHolder
}
return parentArrayHolder
}
// 递归整理无限层初始数据
initializedData(data) {
let outter = []
let inner = []
const keys = Object.keys(data)
for (let key of keys) {
outter.push({ name: data[key].n, id: key })
for (let child of data[key].c) {
inner.push({ name: child.n, id: child.id })
}
}
return [outter, inner]
}
// 触动联动筛选
bindMultiPickerCol(e) {
console.log('e', e)
console.log('修改的列为', e.detail.column, ',值为', e.detail.value)
const data = {
multiArray: this.state.initailMultiArray,
multiIndex: this.state.multiIndex
}
data.multiIndex[e.detail.column] = e.detail.value
if (e.detail.column == 0) {
for (let index in data.multiArray[0]) {
const indexNumber = Number(index)
if (indexNumber === data.multiIndex[0]) {
data.multiArray[1] = this.state.interactionMultiArray[indexNumber].children
}
}
}
this.setState({ multiIndex: data.multiIndex })
}
bindMultiPickerChange(e) {
// console.log('picker发送选择改变携带值为', e.detail.value)
if (getGlobalStorage('shopInfo').shop_id) {
this.setState({
multiIndex: e.detail.value,
}, () => {
//判断如果interactionMultiArray 的子类为空 那就取父类, 反之取子类
let industryTypeSelected
industryTypeSelected = this.state.interactionMultiArray[this.state.multiIndex[0]].children[this.state.multiIndex[1]]
this.passDataToParent(industryTypeSelected)
})
}
}
//--------------------结束-行业分类picker
passDataToParent(industryTypeSelected) {
this.props.onPassDataToChild(industryTypeSelected)
}
aliBindMultiPickerCol(e) {
console.log('e', e)
console.log(',值为', e.detail.value)
this.setState({ multiIndex: e.detail.value })
}
aliCancelButton() {
// 只有店铺页面才有onAliValueFromChild
if (this.props.hasOwnProperty('onAliValueFromChild')) {
this.props.onAliValueFromChild(false)
} else {
this.setState({
AliIsShowPicker: false
})
}
}
aliConfirmButton() {
// 只有店铺页面才有onAliValueFromChild
if (this.props.hasOwnProperty('onAliValueFromChild')) {
this.props.onAliValueFromChild(false)
} else {
this.setState({
AliIsShowPicker: false
})
}
let result = this.state.interactionMultiArray[this.state.multiIndex[0]].children[this.state.multiIndex[1]]
this.passDataToParent(result)
}
invokeAliPicker() {
this.setState({
AliIsShowPicker: true
})
}
componentDidMount() {
this.getShopTypeList(this.props.url)
}
// 当然父组件有新的props的 会从新渲染组件
componentWillReceiveProps(nextProps) {
// 只有店铺页面才有isShowCurtain
if (nextProps.hasOwnProperty('isShowCurtain')) {
this.setState({
AliIsShowPicker: nextProps.isShowCurtain
})
}
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
render() {
return (
<View className='shop-interaction' >
<View className='picker-wrapper' onClick={this.invokeAliPicker.bind(this)} >
<AtList>
<AtListItem hasBorder={false} title='店铺分类' extraText={this.props.selectedValue.name} arrow='right' />
</AtList>
</View>
{this.state.AliIsShowPicker ? <View>
<View className='curtain' onClick={this.aliCancelButton.bind(this)} > </View>
<View class='ali-picker-container'>
<View className='button'>
<View className='cancel-button' onClick={this.aliCancelButton.bind(this)}>取消</View>
<View className='confirm-button ali-blue-color' onClick={this.aliConfirmButton.bind(this)}>确定</View>
</View>
<picker-view value={this.state.multiIndex} onChange={this.aliBindMultiPickerCol.bind(this)}>
<picker-view-column>
{this.state.interactionMultiArray.map((item, index) => {
return <View key={index}>{item.name}</View>
})}
</picker-view-column>
<picker-view-column>
{this.state.interactionMultiArray[this.state.multiIndex[0]].children.map((item, index) => {
return <View key={index}>{item.name}</View>
})}
</picker-view-column>
</picker-view>
</View ></View> : null}
</View>
)
}
}
export default ShopTypeInteractionComp

View File

@ -0,0 +1,91 @@
.shop-interaction{
opacity: 1;
}
.page-section{
border-bottom: 1Px solid #d6e4ef;
font-size:32rpx;
.picker{
// padding: 24rpx 0;
.selected{
font-weight: normal;
display: inline-block;
margin-left: 20%;
font-size: 32rpx
}
.date{
margin-left: 0%
}
.title-box{
line-height:100rpx;
font-weight: bold;
.require{
color:red
}
.title{
//color: #333;
line-height:100rpx;
margin-right:16rpx;
width:172rpx;
font-size:32rpx;
vertical-align:middle;
text-align:left;
font-weight: bold;
}
.first-col{
font-weight: normal;
margin-left: 10%
}
.second-col{
font-weight: normal;
display: inline-block;
margin-left: 10%
}
}
}
}
.curtain{
height: 100%;
background-color: black;
width: 100%;
position: fixed;
z-index: 99;
opacity: 0.5;
position: fixed;
top: 0;
left: 0;
}
.ali-picker-container{
position: fixed;
width: 100%;
bottom: 0px;
left: 0;
background-color: #fff;
z-index: 100;
opacity: 1;
.button{
display: flex;
flex-direction: row;
padding:20px 30px;
border-bottom: 1px solid #d6e4ef;
}
.cancel-button{
flex:1;
text-align: left;
}
.confirm-button{
flex:1;
text-align: right;
}
}
// .picker-wrapper{
// .at-list__item{
// background: rgba(0,0,0,1)
// }
// }

View File

@ -0,0 +1,303 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Text, Picker } from '@tarojs/components'
import { AtList, AtListItem, } from 'taro-ui'
import './aliGoodsTypeInteraction.scss'
import loginExpired from '../../util/loginExpired'
import { getGlobalStorage } from '../../util/getSetStoage';
let maxDepth = 0
let initialDataArray = []
class AliGoodsTypeInteraction extends Component {
config = {
navigationBarTitleText: 'aliGoodsTypeInteraction'
}
constructor() {
super(...arguments);
this.state = {
///---行业分类 开始
initailMultiArray: [[{ class_name: '选择商品分类', class_id: '' }], [], []], // 初始化底部数据
multiIndex: [0, 0, 0, 0],// 默认联动列数为4个并且每一列都是第一行
interactionMultiArray: [],// 联动
///---行业分类 结束
}
}
//商品目录请求api GetShopCategoryList
getProductCateList(url) {
Taro.request({
url: url,
method: 'POST',
dataType: 'json',
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
if (res.data.err_code === 0) {
console.log('商品分类目录', res)
const recursionInteractionData = this.recursionInteraction(res.data.data)
maxDepth = 0
initialDataArray = []
this.recursionInitialized(res.data.data) //
const depthInArray = this.recursionDepth(res.data.data)
console.log('depthInArray', depthInArray)
console.log('initialDataArray', initialDataArray)
for (let i = initialDataArray.length; i < depthInArray.length; i++) {
initialDataArray.unshift([{ name: '--', id: '' }])
}
this.setState({
interactionMultiArray: recursionInteractionData,
multiIndex: depthInArray,
initailMultiArray: initialDataArray.reverse()
}, () => {
console.log('interactionMultiArray',this.state.interactionMultiArray)
// 把全局变变量赋值给state之后初始化商品分类为空 不然第二次进去的时候会自动添加进去
// console.log('联动数据', this.state.interactionMultiArray)
// console.log('初始化数据', this.state.initailMultiArray)
}) // 用递归来整理无限层次的数据
// console.log('联动数据', this.recursionInteraction(res.data.data))
// console.log('初始数据', this.recursionInitialized(res.data.data).reverse())
} else if (res.data.err_code === 88888) {
loginExpired(res)
} else {
Taro.showToast({
title: res.data.err_msg,
icon: 'none'
})
}
}
)
.catch(error => {
console.log('商品分类请求错误', error)
})
}
//联动确认
bindMultiPickerChange(e) {
// 如果没有上商品 那就不执行
if (getGlobalStorage('shopInfo').shop_id) {
this.setState({
multiIndex: e.detail.value.map(item => { if (item === null) { item = 0 } return item })
}, () => {
// console.log('picker发送选择改变携带值为', this.state.multiIndex)
this.returnResultToParent()
})
}
}
returnResultToParent() {
let selected = this.state.interactionMultiArray
for (let index of this.state.multiIndex) {
if (selected[index].children[0].id) {
selected = selected[index].children
} else {
this.props.onPassDataToChild(selected[index])
break
}
}
}
// 递归整理无限层初始数据,将整理好的数据赋值给initialDataArray
recursionInitialized(data) {
const arrayTem = []
if (data.length) {
for (let item of data) {
arrayTem.push({ name: item.class_name, id: item.class_id })
}
}
if (data[0].children.length) {
this.recursionInitialized(data[0].children)
}
initialDataArray.push(arrayTem)
return arrayTem
}
// 递归整理无限层联动数据
recursionInteraction(data) {
let arrayTem = []
for (let items of data) {
arrayTem.push({ name: items.class_name, id: items.class_id })
if (items.children) {
arrayTem[arrayTem.length - 1].children = this.recursionInteraction(items.children)
} else {
arrayTem[arrayTem.length - 1].children = [{ name: '--', id: '' }]
}
}
return arrayTem // 返回联动数据
// return arrayTem
}
// 递归整理无限层初始数据
// recursionInitialized(data) {
// const arrayTem = []
// const childrenHolderArray = []
// if (data.length) {
// for (let item of data) {
// arrayTem.push({ name: item.class_name, id: item.class_id })
// item.children ? childrenHolderArray.push(...item.children) : null
// }
// this.recursionInitialized(childrenHolderArray)
// }
// arrayTem.length ? initialDataArray.push(arrayTem) : null // 数组为空则不添加
// return initialDataArray
// }
// 递归整理无限层初始数据
recursionDepth(data) {
const arrayTem = []
const childrenHolderArray = []
if (data.length) {
for (let item of data) {
arrayTem.push({ name: item.class_name, id: item.class_id })
item.children ? childrenHolderArray.push(...item.children) : null
}
this.recursionDepth(childrenHolderArray)
maxDepth += 1
}
return new Array(maxDepth).fill(0)
}
// 触动联动筛选
bindMultiPickerCol(e) {
console.log('修改的列为', e.detail.column, ',值为', e.detail.value)
console.log(this.state.initailMultiArray)
const data = {
multiArray: this.state.initailMultiArray,
multiIndex: this.state.multiIndex
}
data.multiIndex[e.detail.column] = e.detail.value
if (e.detail.column == 0) {
for (let index in data.multiArray[0]) {
const indexNumber = Number(index)
if (indexNumber === data.multiIndex[0]) {
data.multiArray[1] = this.state.interactionMultiArray[indexNumber].children
data.multiArray[2] = this.state.interactionMultiArray[indexNumber].children[data.multiIndex[1]].children
data.multiArray[3] = this.state.interactionMultiArray[indexNumber].children[data.multiIndex[1]].children[data.multiIndex[2]].children
}
}
} else if (e.detail.column == 1) {
for (let index in data.multiArray[1]) {
const indexNumber = Number(index)
if (indexNumber === data.multiIndex[1]) {
data.multiArray[2] = this.state.interactionMultiArray[data.multiIndex[0]].children[indexNumber].children
}
}
}
else if (e.detail.column == 2) {
for (let index in data.multiArray[2]) {
const indexNumber = Number(index)
if (indexNumber === data.multiIndex[2]) {
data.multiArray[3] = this.state.interactionMultiArray[data.multiIndex[0]].children[data.multiIndex[1]].children[indexNumber].children
}
}
}
this.setState({ multiIndex: data.multiIndex })
}
aliBindMultiPickerCol(e) {
console.log(',值为', e.detail.value)
this.setState({ multiIndex: e.detail.value })
}
aliCancelButton() {
this.setState({
AliIsShowPicker: false
})
}
aliConfirmButton() {
this.setState({
AliIsShowPicker: false
})
this.returnResultToParent()
}
invokeAliPicker() {
this.setState({
AliIsShowPicker: true
})
}
componentDidMount() {
if (getGlobalStorage('shopInfo').shop_id) {
this.getProductCateList(this.props.url)
} else {
}
}
// 当然父组件有新的props的 会从新渲染组件
componentWillReceiveProps(nextProps) {
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
render() {
return (
<View className='goods-interaction' >
<View className='picker-wrapper' onClick={this.invokeAliPicker.bind(this)} >
<AtList >
<AtListItem hasBorder={false} title='商品分类' className='title' extraText={this.props.selectedValue.name} arrow='right' />
</AtList>
</View>
{this.state.AliIsShowPicker ? <View>
<View className='curtain' onClick={this.aliCancelButton.bind(this)} > </View>
<View class='ali-picker-container'>
<View className='button'>
<View className='cancel-button' onClick={this.aliCancelButton.bind(this)}>取消</View>
<View className='confirm-button ali-blue-color' onClick={this.aliConfirmButton.bind(this)}>确定</View>
</View>
<picker-view value={this.state.multiIndex} onChange={this.aliBindMultiPickerCol.bind(this)}>
<picker-view-column>
{this.state.interactionMultiArray.map((item, index) => {
return <View key={index}>{item.name}</View>
})}
</picker-view-column>
<picker-view-column>
{this.state.interactionMultiArray[this.state.multiIndex[0]].children.map((item, index) => {
return <View key={index}>{item.name}</View>
})}
</picker-view-column>
<picker-view-column>
{this.state.interactionMultiArray[this.state.multiIndex[0]].children[this.state.multiIndex[1]].children.map((item, index) => {
return <View key={index}>{item.name}</View>
})}
</picker-view-column>
<picker-view-column>
{this.state.interactionMultiArray[this.state.multiIndex[0]].children[this.state.multiIndex[1]].children[this.state.multiIndex[2]].children.map((item, index) => {
return <View key={index}>{item.name}</View>
})}
</picker-view-column>
</picker-view>
</View ></View> : null}
</View>
)
}
}
export default AliGoodsTypeInteraction

View File

@ -0,0 +1,47 @@
.picker-wrapper{
.item-content__info-title{
font-weight: bold
}
.item-extra__info{
color: black
}
.at-list__item{
padding-left: 0px;
}
}
.curtain{
height: 100%;
background-color: black;
width: 100%;
position: fixed;
z-index: 99;
opacity: 0.5;
position: fixed;
top: 0;
left:0
}
.ali-picker-container{
position: fixed;
width: 100%;
bottom: 0px;
left:0;
background-color: #fff;
z-index: 100;
opacity: 1;
.button{
display: flex;
flex-direction: row;
padding:20px 30px;
border-bottom: 1px solid #d6e4ef;
}
.cancel-button{
flex:1;
text-align: left;
}
.confirm-button{
flex:1;
text-align: right;
}
}

View File

@ -0,0 +1,235 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Text, Picker } from '@tarojs/components'
import { AtList, AtListItem, } from 'taro-ui'
import './aliIndustryTypeInteraction.scss'
import loginExpired from '../../util/loginExpired';
import { getGlobalStorage } from '../../util/getSetStoage';
let maxDepth = 0
let initialDataArray = []
class AliIndustryTypeInteraction extends Component {
config = {
navigationBarTitleText: 'aliIndustryTypeInteraction'
}
constructor() {
super(...arguments);
this.state = {
///---行业分类 开始
initailMultiArray: '',// 初始化底部数据
multiIndex: [0, 0],
interactionMultiArray: [],// 联动
AliIsShowPicker: false,
///---行业分类 结束
}
}
// 行业分类筛选列表GetIndustryTypeList
getIndustryTypeList(url) {
Taro.request({
url: url,
method: 'GET',
dataType: 'json',
header: {
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
'content-type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
}).then(res => {
console.log('res',res)
if (res.data.err_code === 0) {
let initailMultiArray = this.recursionInitialized(res.data.data)
initailMultiArray[1].unshift({ name: '全部', id: '-1' })
initailMultiArray[0] = [{ name: '--', id: '' }]
// console.log('initailMultiArray', initailMultiArray)
this.setState({
initailMultiArray: initailMultiArray.reverse(), //initailMultiArray.reverse(),
interactionMultiArray: [{ name: '全部', id: '-1', children: [{ name: '--', id: '' }] }, ...this.recursionInteraction(res.data.data)],
multiIndex: this.recursionDepth(res.data.data),
}, () => {
initialDataArray = []
console.log('state',this.state.interactionMultiArray)
})
} else if (res.data.err_code === 88888) {
// loginExpired(res)
} else {
console.log('行业分类请求没有成功', res)
}
}
)
.catch(error => {
console.log('行业分类请求错误', error)
})
}
// 递归整理无限层联动数据
recursionInteraction(data) {
let arrayTem = []
for (let items of data) {
arrayTem.push({ name: items.class_name, id: items.class_id })
if (items.child.length) {
arrayTem[arrayTem.length - 1].children = [{ name: '--', id: '' }, ...this.recursionInteraction(items.child)]
} else {
arrayTem[arrayTem.length - 1].children = [{ name: '--', id: '' }]
}
}
return arrayTem // 返回联动数据
// return arrayTem
}
// 递归整理无限层初始数据
recursionInitialized(data) {
const arrayTem = []
const childrenHolderArray = []
if (data.length) {
for (let item of data) {
arrayTem.push({ name: item.class_name, id: item.class_id })
if (data.indexOf(item) === 0) {
item.child.length ? childrenHolderArray.push(...item.child) : null
}
}
this.recursionInitialized(childrenHolderArray)
}
arrayTem.length ? initialDataArray.push(arrayTem) : null // 数组为空则不添加
return initialDataArray
}
// 递归整理无限层层次
recursionDepth(data) {
const arrayTem = []
const childrenHolderArray = []
if (data.length) {
for (let item of data) {
arrayTem.push({ name: item.class_name, id: item.class_id })
item.child.length ? childrenHolderArray.push(...item.child) : null
}
this.recursionDepth(childrenHolderArray)
maxDepth += 1
}
return new Array(maxDepth).fill(0)
}
bindMultiPickerCol(e) {
// console.log('修改的列为', e.detail.column, ',值为', e.detail.value)
const data = {
multiArray: this.state.initailMultiArray,
multiIndex: this.state.multiIndex
}
data.multiIndex[e.detail.column] = e.detail.value
if (e.detail.column == 0) {
for (let index in data.multiArray[0]) {
const indexNumber = Number(index)
if (indexNumber === data.multiIndex[0]) {
data.multiArray[1] = this.state.interactionMultiArray[indexNumber].children
}
}
}
this.setState({ multiIndex: data.multiIndex })
}
//--------------------开始-行业分类picker
bindMultiPickerChange(e) {
this.setState({
multiIndex: e.detail.value,
}, () => {
this.passDataToParent()
})
}
//--------------------结束-行业分类picker
passDataToParent() {
const parent = this.state.interactionMultiArray[this.state.multiIndex[0]]
const child = this.state.interactionMultiArray[this.state.multiIndex[0]].children[this.state.multiIndex[1]]
child.id ? this.props.onPassDataToChild(child) : this.props.onPassDataToChild(parent)
}
aliBindMultiPickerCol(e) {
console.log('e', e)
console.log(',值为', e.detail.value)
this.setState({ multiIndex: e.detail.value })
}
aliCancelButton() {
this.setState({
AliIsShowPicker: false
})
}
aliConfirmButton() {
this.setState({
AliIsShowPicker: false
})
let result = this.state.interactionMultiArray[this.state.multiIndex[0]].children[this.state.multiIndex[1]]
this.passDataToParent(result)
}
invokeAliPicker() {
this.setState({
AliIsShowPicker: true
})
}
componentDidMount() {
this.getIndustryTypeList(this.props.url)
}
// 当然父组件有新的props的 会从新渲染组件
componentWillReceiveProps(nextProps) {
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
render() {
return (
<View className='industry-interaction' >
<View className='picker-wrapper' onClick={this.invokeAliPicker.bind(this)} >
<AtList >
<AtListItem hasBorder={false} title='行业分类' className='title' extraText={this.props.selectedValue.name} arrow='right' />
</AtList>
</View>
{this.state.AliIsShowPicker ? <View>
<View className='curtain' onClick={this.aliCancelButton.bind(this)} > </View>
<View class='ali-picker-container'>
<View className='button'>
<View className='cancel-button' onClick={this.aliCancelButton.bind(this)}>取消</View>
<View className='confirm-button ali-blue-color' onClick={this.aliConfirmButton.bind(this)}>确定</View>
</View>
<picker-view value={this.state.multiIndex} onChange={this.aliBindMultiPickerCol.bind(this)}>
<picker-view-column>
{this.state.interactionMultiArray.map((item, index) => {
return <View key={index}>{item.name}</View>
})}
</picker-view-column>
<picker-view-column>
{this.state.interactionMultiArray[this.state.multiIndex[0]].children.map((item, index) => {
return <View key={index}>{item.name}</View>
})}
</picker-view-column>
</picker-view>
</View ></View> : null}
</View>
)
}
}
export default AliIndustryTypeInteraction

View File

@ -0,0 +1,47 @@
.picker-wrapper{
.item-content__info-title{
font-weight: bold
}
.item-extra__info{
color: black
}
.at-list__item{
padding-left: 0px;
}
}
.curtain{
height: 100%;
background-color: black;
width: 100%;
position: fixed;
z-index: 99;
opacity: 0.5;
position: fixed;
top: 0;
left:0
}
.ali-picker-container{
position: fixed;
width: 100%;
bottom: 0px;
left:0;
background-color: #fff;
z-index: 100;
opacity: 1;
.button{
display: flex;
flex-direction: row;
padding:20px 30px;
border-bottom: 1px solid #d6e4ef;
}
.cancel-button{
flex:1;
text-align: left;
}
.confirm-button{
flex:1;
text-align: right;
}
}

View File

@ -0,0 +1,172 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image, Button } from '@tarojs/components'
import { AtIcon } from 'taro-ui'
import URL from '../../serviceAPI.config'
import './aliPictureUploadComponent.scss'
import onClickValueService from '../../util/onClickValueService';
import { getGlobalStorage } from '../../util/getSetStoage';
class PictureUploadComponent extends Component {
// maxLength={4}
// isReceiveImageUrl={true}
// url={URL.UploadDSPorductImage}
// onGetImageDetails={this.getImageDetails.bind(this)}
// initialImageURL={this.state.initialImageURL}
// initialImagesInfo={this.state.initialImagesInfo}
static defaultProps = {
url: '',
maxLength: 100,
isReceiveImageUrl: true,
imageURLList: []
};
config = {
navigationBarTitleText: 'pictureUploadComponent'
}
constructor() {
super(...arguments);
this.state = {
imageURL: [],
imageDetails: [],
onlyOnce: true,// initial props 只setstate一次
}
}
uploadImage() {
const that = this
my.chooseImage({
count: this.props.maxLength,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
// console.log('res.apFilePaths',res.apFilePaths)
res.apFilePaths.forEach(item => {
that.onChangeImg(item)
});
},
fail(err) {
Taro.showToast({
title: err,
icon: 'none'
})
}
})
}
// 上传图片apo
onChangeImg(files) {
const that = this
my.uploadFile({
url: this.props.url,
filePath: files,
fileName: 'file',
fileType: 'image',
formData: {
'key': 'michael',
},
header: {
'content-type': 'multipart/form-data; boundary=----WebKitFormBoundaryAWxeadaAVmRVQCiz',
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
'X-Requested-With': 'XMLHttpRequest'
},
success(response) {
const data = JSON.parse(response.data)
if (data.err_code === 0) {
console.log('上传成功')
const imagePath = URL.Base + data.file_path
that.setState({ imageURL: [...that.state.imageURL, { url: imagePath }], imageDetails: [...that.state.imageDetails, data] }, () => {
that.props.onGetImageDetails(that.state.imageDetails)
})
Taro.showToast({
title: '上传成功',
icon: 'success',
duration: 1500
})
} else {
Taro.showToast({
title: data.err_msg,
icon: 'none',
duration: 1500
})
}
},
fail(err) {
Taro.showToast({
title: err,
icon: 'none'
})
}
})
}
deleteButton(e) {
const value = onClickValueService(e)
this.state.imageURL.splice(value, 1)
this.state.imageDetails.splice(value, 1)
this.setState({
imageURL: this.state.imageURL,
imageDetails: this.state.imageDetails,
}, () => {
this.props.onGetImageDetails(this.state.imageDetails)
})
Taro.showToast({
title: '删除成功',
icon: 'success',
duration: 1500
})
}
componentDidMount() {
}
// 当然父组件有新的props的 会从新渲染组件
componentWillReceiveProps(nextProps) {
if (nextProps.isReceiveImageUrl) {
if (this.state.onlyOnce) {
this.setState({
imageURL: nextProps.initialImageURL,
imageDetails: nextProps.initialImagesInfo,
onlyOnce: false
})
}
}
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
render() {
const { maxLength } = this.props
const imageElementArray = this.state.imageURL.map((item, index) => {
return <View key={index} className='image-wrapper'>
<View className='delete' onClick={this.deleteButton.bind(this, index)}><AtIcon value='close' size='15' color='#FFFFFF'></AtIcon>
</View>
<Image className='goods-img'
mode='aspectFit' style='max-height: 100%; max-width: 100%;'
src={item.url}
/>
</View>
})
return (
<View class='pictureUploadComponent' > {this.state.imageURL.length < maxLength ? <Button onClick={this.uploadImage.bind(this)}>上传图片</Button> : null} < View className='image-container' > {imageElementArray}</View></View>
)
}
}
export default PictureUploadComponent

View File

@ -0,0 +1,21 @@
.image-container{
display: flex;
flex-wrap: wrap;
flex-direction: row;
.image-wrapper{
box-sizing: border-box;
width: 25%;
height: 200px;
border-radius: 50%;
position: relative;
.delete{
position: absolute;
top:10px;
right: 10px;
background-color: rgb(153, 153, 153);
opacity: 0.8;
padding: 5px;
border-radius: 50%;
}
}
}

View File

@ -1,6 +1,6 @@
//scrollToTopComponent //scrollToTopComponent
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text,MovableArea, MovableView } from '@tarojs/components' import { View, Text, MovableArea, MovableView } from '@tarojs/components'
import './backToCenterComponent.scss' import './backToCenterComponent.scss'
@ -14,9 +14,9 @@ class BackToCenterComponent extends Component {
} }
goToCenterPage(){ goToCenterPage() {
Taro.switchTab({ Taro.switchTab({
url:'/pages/individualCenter/individualCenter' url: '/pages/individualCenter/individualCenter'
}) })
} }
@ -35,17 +35,11 @@ class BackToCenterComponent extends Component {
render() { render() {
return ( return (
// <View className='backToCenterComponent' onClick={this.goToCenterPage.bind(this)}>
// <View className='box'>
// <View>个人中心</View>
// </View>
// </View>
<MovableArea style='height: 100vh; width: 100%; position:fixed; top:0; '> <MovableArea style='height: 100vh; width: 100%; position:fixed; top:0; '>
<View>hello world</View> <View>hello world</View>
<MovableView style='height: 50px; width: 50px; background: blue;opacity:1' direction='all'></MovableView> <MovableView style='height: 50px; width: 50px; background: blue;opacity:1' direction='all'></MovableView>
</MovableArea> </MovableArea>
) )
} }
} }

View File

@ -1,47 +0,0 @@
import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'
import { AtTabBar } from 'taro-ui'
import './clientTabBarComponent.scss'
class ClientTabBarComponent extends Component {
config = {
navigationBarTitleText: '业主底栏导航'
}
//http://ihome6.com/Shop-supplyShops
componentDidMount() {
}
componentWillReceiveProps(nextProps) {
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
render() {
return (
<View className='clientTabBarComponent'>
<AtTabBar
fixed
tabList={[
{ title: '首页', iconType: 'bullet-list', text: 'new' },
{ title: '需求发布', iconType: 'camera' },
{ title: '我的需求', iconType: 'folder', text: '100', max: '99' },
{ title: '个人中心', iconType: 'folder', text: '100', max: '99' },
]}
onClick={this.handleClick.bind(this)}
current={this.state.current}
/>
</View>
)
}
}
export default ClientTabBarComponent

View File

@ -35,15 +35,14 @@ class recommondShop extends Component {
isOpenConsult: false, isOpenConsult: false,
consultTip: '', consultTip: '',
voucherResponseMsg: 'i am voucherResponseMsg', voucherResponseMsg: 'i am voucherResponseMsg',
userName: getGlobalStorage('user_identity').username || '', userName: '',
userPhone: getGlobalStorage('user_identity').userphone || '', userPhone: '',
isCanConsult: true, isCanConsult: true,
isCanVoucher: true isCanVoucher: true
} }
} }
goToShop(e) { goToShop(e) {
const value = onClickValueService(e) const value = onClickValueService(e)
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/shop/shop?id=' + value.shop_id url: '/pages/shop/shop?id=' + value.shop_id
@ -223,6 +222,10 @@ class recommondShop extends Component {
//console.log(this.props, nextProps) //console.log(this.props, nextProps)
} }
componentDidMount() { componentDidMount() {
this.setState({
userName: getGlobalStorage('user_identity') ? getGlobalStorage('user_identity').username : '',
userPhone: getGlobalStorage('user_identity') ? getGlobalStorage('user_identity').userphone : '',
})
} }
componentWillUnmount() { } componentWillUnmount() { }
@ -265,12 +268,12 @@ class recommondShop extends Component {
<Text>联系人</Text> <Text>联系人</Text>
</View> </View>
<View className='value'> <View className='value'>
<Input name='value' <Input name='value'
type='text' type='text'
value={this.state.userName} value={this.state.userName}
placeholder='请输入联系人' placeholder='请输入联系人'
onInput={this.handleInputCsultName.bind(this)} onInput={this.handleInputCsultName.bind(this)}
/> />
</View> </View>
@ -280,13 +283,13 @@ class recommondShop extends Component {
<Text>联系电话</Text> <Text>联系电话</Text>
</View> </View>
<View className='value'> <View className='value'>
<Input name='value' <Input name='value'
type='number' type='number'
maxLength='11' maxLength='11'
value={this.state.userPhone} value={this.state.userPhone}
placeholder='请输入联系电话' placeholder='请输入联系电话'
onInput={this.handleInputCsultPhone.bind(this)} onInput={this.handleInputCsultPhone.bind(this)}
/> />
</View> </View>
</View> </View>
</AtModalContent> </AtModalContent>

View File

@ -148,6 +148,7 @@ $linearBlue:linear-gradient(to right, #337ab7, #337ab7);
text-overflow: ellipsis; text-overflow: ellipsis;
.details-text{ .details-text{
font-weight: bold; font-weight: bold;
display: inline-block;
} }
} }

View File

@ -1,7 +1,6 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components' import { View, Text,Picker} from '@tarojs/components'
import { Picker } from 'taro-ui'
import './goodsTypeInteractionComp.scss' import './goodsTypeInteractionComp.scss'
import loginExpired from '../../util/loginExpired' import loginExpired from '../../util/loginExpired'

View File

@ -1,14 +1,12 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components' import { View, Text,Picker } from '@tarojs/components'
import { Picker } from 'taro-ui'
import './interactionComponent.scss' import './interactionComponent.scss'
import loginExpired from '../../util/loginExpired'; import loginExpired from '../../util/loginExpired';
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
// 这个是行业分类的联动
let maxDepth = 0 let maxDepth = 0
let initialDataArray = [] let initialDataArray = []
class Interaction extends Component { class Interaction extends Component {

View File

@ -1,78 +0,0 @@
import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'
import { AtTabBar } from 'taro-ui'
import './sellerTabBarComponent.scss'
class SellerTabBarComponent extends Component {
config = {
navigationBarTitleText: '店铺底栏导航'
}
constructor(){
this.state = {
current: 0,
options:[
{ title: '首页', url: '/pages/home/home', iconType: 'bullet-list', text: 'new' },
{ title: '商品发布', url: '/pages/goodsPublish/goodsPublish', iconType: 'camera' },
{ title: '供求发布', url: '/pages/supplyDemandPublish/supplyDemandPublish', iconType: 'folder', text: '100', max: '99' },
{ title: '我的供求', url: '/pages/mySupplyDemand/mySupplyDemand', iconType: 'folder', text: '100', max: '99' },
{ title: '我的需求', url: '/pages/myNeeds/myNeeds', iconType: 'folder', text: '100', max: '99' }
]
}
}
handleClick(value) {
this.setState({
current: value
})
let path = this.state.options[value].url
Taro.navigateTo({
url: path,
})
}
componentDidMount() {
}
componentWillReceiveProps(nextProps) {
}
componentWillUnmount() { }
componentDidShow() {
console.log('this.props.currentUrl',this.props.currentUrl)
if(this.props.currentUrl==='pages/home/home'){
this.setState({
current:0
})
}else if(this.props.currentUrl==='pages/supplyDemandPublish/supplyDemandPublish'){
this.setState({
current:2
})
}
}
componentDidHide() { }
render() {
return (
<View className='sellerTabBarComponent'>
<AtTabBar
fixed
tabList={this.state.options}
onClick={this.handleClick.bind(this)}
current={this.state.current}
/>
</View>
)
}
}
export default SellerTabBarComponent

View File

@ -20,7 +20,7 @@ class ShopItem extends Component {
shopOnClickHanlder(){ shopOnClickHanlder(){
let goodId=this.props.item.goods_id let goodId=this.props.item.goods_id
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/goods/goods?id='+goodId url: '/pages/goods/goods?id='+encodeURIComponent(goodId)
}) })
} }
componentDidMount(){ componentDidMount(){

View File

@ -40,6 +40,8 @@
margin:0 5%; margin:0 5%;
.name{ .name{
font-size: 30px; font-size: 30px;
overflow: hidden;
white-space: nowrap;
} }
} }

View File

@ -1,11 +1,10 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components' import { View, Text,Picker } from '@tarojs/components'
import { Picker } from 'taro-ui'
import './shopTypeInteractionComp.scss' import './shopTypeInteractionComp.scss'
import loginExpired from '../../util/loginExpired'; import loginExpired from '../../util/loginExpired';
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage,setGlobalStorage } from '../../util/getSetStoage';
class ShopTypeInteractionComp extends Component { class ShopTypeInteractionComp extends Component {
@ -48,13 +47,14 @@ class ShopTypeInteractionComp extends Component {
} }
console.log('店铺分类目录', res) console.log('店铺分类目录', res)
if(!getGlobalStorage('shopTypeObject')){ if(!getGlobalStorage('shopTypeObject')){
Taro.setStorageSync('shopTypeObject',res.data.data) setGlobalStorage('shopTypeObject',res.data.data)
} }
this.setState({ this.setState({
interactionMultiArray: this.interactionData(res.data.data), interactionMultiArray: this.interactionData(res.data.data),
initailMultiArray: this.initializedData(res.data.data), initailMultiArray: this.initializedData(res.data.data),
}, () => { }, () => {
console.log('state',this.state.initailMultiArray,this.state.interactionMultiArray)
// this.passDataToParent(this.state.initailMultiArray) // this.passDataToParent(this.state.initailMultiArray)
//返回初始选项在 在商品编辑页面 //返回初始选项在 在商品编辑页面

View File

@ -1,9 +1,10 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image, Button } from '@tarojs/components' import { View, Text, Image, Button, Picker } from '@tarojs/components'
import { AtInput, Picker, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import { AtInput, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent' import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
import AliIndustryTypeInteraction from '../../component/aliIndustryTypeInteraction/aliIndustryTypeInteraction'
import InteractionComponent from '../../component/interactionComponent/interactionComponent' import InteractionComponent from '../../component/interactionComponent/interactionComponent'
import loginExpired from '../../util/loginExpired' import loginExpired from '../../util/loginExpired'
import onClickValueService from '../../util/onClickValueService' import onClickValueService from '../../util/onClickValueService'
@ -12,372 +13,384 @@ import URL from '../../serviceAPI.config'
import './allDemanding.scss' import './allDemanding.scss'
import eyeIcon from '../../icons/eye.png' import eyeIcon from '../../icons/eye.png'
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading';
import platformChecker from '../../util/plaformChecker';
class AllDemanding extends Component { class AllDemanding extends Component {
config = { config = {
navigationBarTitleText: '全部业主需求' navigationBarTitleText: '全部业主需求'
}
constructor() {
super(...arguments)
this.state = {
supplys: [], // 需求列表
demandingState: [{ name: '全部', id: '' }, { name: '在用', id: '1' }, { name: '已抢单', id: '2' }, { name: '已抢光', id: '3' },], // 供求状态选择
demandingStateSelected: { name: '全部', id: '' }, // 当前供求状态
industryTypeSelected: { name: '全部', id: '' },// 当前行业分类
title: '',
startDateSel: '',
endDateSel: '',
isOpenedGrabModal: false,
grabOrderId: '',//抢到订单的id
isGrabOrderSuccess: false,// 是否显示轻提示
grabOrderSuccess: '无法显示绑定后的字段',// 抢单成功返回字段
isAddToList: false,// / 请求业主需求的时候是否添加到旧列表里
isShowTopNav: false,// 是否显示返回顶部按钮
loadMorePageIndex: 1
} }
constructor() { }
super(...arguments)
this.state = {
supplys: [], // 需求列表
demandingState: [{ name: '全部', id: '' }, { name: '在用', id: '1' }, { name: '已抢单', id: '2' }, { name: '已抢光', id: '3' },], // 供求状态选择
demandingStateSelected: { name: '全部', id: '' }, // 当前供求状态
industryTypeSelected: { name: '全部', id: '' },// 当前行业分类
title: '',
startDateSel: '',
endDateSel: '',
isOpenedGrabModal: false,
grabOrderId: '',//抢到订单的id
isGrabOrderSuccess: false,// 是否显示轻提示
grabOrderSuccess: '无法显示绑定后的字段',// 抢单成功返回字段
isAddToList: false,// / 请求业主需求的时候是否添加到旧列表里
isShowTopNav: false,// 是否显示返回顶部按钮
loadMorePageIndex: 1
} // 搜索业主需求函数
} searchDemanding({
curr_page = 1,
page_count = 10,
sd_title = this.state.title,
state = this.state.demandingStateSelected.id,
update_dateL = this.state.startDateSel,
update_dateU = this.state.endDateSel,
class_id = this.state.industryTypeSelected.id
}) {
Taro.request({
url: URL.GetAllDemanding,
method: 'POST',
dataType: 'json',
data: {
param: JSON.stringify({
curr_page: curr_page,
page_count: page_count,
sd_title: sd_title,
state: state,
update_dateL: update_dateL,
update_dateU: update_dateU,
class_id: class_id
// 搜索业主需求函数 }),
searchDemanding({ },
curr_page = 1, header: {
page_count = 10, 'content-type': 'application/x-www-form-urlencoded',
sd_title = this.state.title, 'X-Requested-With': 'XMLHttpRequest',
state = this.state.demandingStateSelected.id, 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
update_dateL = this.state.startDateSel, }
update_dateU = this.state.endDateSel, })
class_id = this.state.industryTypeSelected.id .then(res => {
}) { Taro.hideLoading()
Taro.request({ if (res.data.err_code === 0) {
url: URL.GetAllDemanding, if (res.data.supplys) {
method: 'POST', if (this.state.isAddToList) {
dataType: 'json', this.setState({ supplys: this.state.supplys.concat(res.data.supplys), isAddToList: false })
data: { } else {
param: JSON.stringify({ this.setState({ supplys: res.data.supplys })
curr_page: curr_page,
page_count: page_count,
sd_title: sd_title,
state: state,
update_dateL: update_dateL,
update_dateU: update_dateU,
class_id: class_id
}),
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest',
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
} }
}) } else {
.then(res => { if (this.state.isAddToList) {
Taro.hideLoading() Taro.showToast({
if (res.data.err_code === 0) { title: '没有更多了',
if (res.data.supplys) { icon: 'none'
if (this.state.isAddToList) { })
this.setState({ supplys: this.state.supplys.concat(res.data.supplys), isAddToList: false }) } else {
} else { this.setState({ supplys: [] })
this.setState({ supplys: res.data.supplys })
}
} else {
if (this.state.isAddToList) {
Taro.showToast({
title: '没有更多了',
icon: 'none'
})
} else {
this.setState({ supplys: [] })
}
}
} else if (res.data.err_code === 88888) {
loginExpired(res)
} else {
Taro.showToast({
title: res.data.err_msg,
icon: 'none',
duration: 1500
})
}
this.setState({ isAddToList: false })
})
}
// 改变需求选项
changeDemandingState = e => {
this.setState({
demandingStateSelected: this.state.demandingState[e.detail.value]
})
}
titleChange(event) {
this.setState({ title: event })
}
//改变开始日期
onStartDateChange = e => {
this.setState({
startDateSel: e.detail.value,
})
}
// 改变结束日期
onEndDateChange = e => {
this.setState({
endDateSel: e.detail.value
})
}
// 抢单接口
GrabDemand({ demandId = 218 }) {
Taro.request({
url: URL.GrabDemand,
method: 'POST',
dataType: 'json',
data: {
demandId: demandId
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
'X-Requested-With': 'XMLHttpRequest'
} }
})
.then(res => {
if (res.data.err_code === 0) {
Taro.showToast({
title: res.data.err_msg === 'success' ? '抢单成功' : res.data.err_msg,
icon: res.data.err_msg === 'success' ? 'success' : 'none'
})
this.searchDemanding({ curr_page: 1 })
} else if (res.data.err_code === 88888) {
loginExpired(res)
}
else {
Taro.showToast({ }
title: res.data.err_msg, } else if (res.data.err_code === 88888) {
icon: 'none' loginExpired(res)
}) } else {
} Taro.showToast({
title: res.data.err_msg,
console.log('抢单请求:', res) icon: 'none',
}) duration: 1500
})
}
grabOrder(e) {
const id = onClickValueService(e)
this.setState({ isOpenedGrabModal: true, grabOrderId: id })
}
handleGrabModalClose() {
this.setState({ isOpenedGrabModal: false })
}
handleGrabModalCancel() {
this.setState({ isOpenedGrabModal: false })
}
handleGrabConfirm() {
this.setState({ isOpenedGrabModal: false })
this.GrabDemand({ demandId: this.state.grabOrderId })
}
searchHanlder() {
Taro.showLoading({ title: '加载中' })
this.searchDemanding({})
}
//清空筛选项
emptyFilter() {
this.setState({
title: '',
endDateSel: '',
startDateSel: '',
demandingStateSelected: { name: '全部', id: '' },
industryTypeSelected: { name: '全部', id: '' },
})
Taro.showToast({
title: '已清空',
icon: 'success',
duration: 1000
})
}
getDataFromChild(value) {
console.log('从子组件传回来的值', value)
this.setState({ industryTypeSelected: value })
}
goToGrabOrderPage(e) {
const id = onClickValueService(e)
Taro.navigateTo({
url: '/pages/grabOrderPage/grabOrderPage?orderId=' + id
})
}
componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps)
}
componentDidMount() {
// 得到第一页需求数据
Taro.showLoading({ title: '加载中' }).then(() => {
this.searchDemanding({})
})
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
// 页面位置
onPageScroll(location) {
if (location.scrollTop <= 300 && this.state.isShowTopNav) {
this.setState({ isShowTopNav: false })
} else if (location.scrollTop > 300 && !this.state.isShowTopNav) {
this.setState({ isShowTopNav: true })
} }
this.setState({ isAddToList: false })
})
}
// 改变需求选项
changeDemandingState = e => {
this.setState({
demandingStateSelected: this.state.demandingState[e.detail.value]
})
}
titleChange(event) {
this.setState({ title: event })
}
//改变开始日期
onStartDateChange = e => {
this.setState({
startDateSel: e.detail.value,
})
}
// 改变结束日期
onEndDateChange = e => {
this.setState({
endDateSel: e.detail.value
})
}
// 抢单接口
GrabDemand({ demandId = 218 }) {
Taro.request({
url: URL.GrabDemand,
method: 'POST',
dataType: 'json',
data: {
demandId: demandId
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
if (res.data.err_code === 0) {
Taro.showToast({
title: res.data.err_msg === 'success' ? '抢单成功' : res.data.err_msg,
icon: res.data.err_msg === 'success' ? 'success' : 'none'
})
this.searchDemanding({ curr_page: 1 })
} else if (res.data.err_code === 88888) {
loginExpired(res)
}
else {
Taro.showToast({
title: res.data.err_msg,
icon: 'none'
})
}
console.log('抢单请求:', res)
})
}
grabOrder(e) {
const id = onClickValueService(e)
this.setState({ isOpenedGrabModal: true, grabOrderId: id })
}
handleGrabModalClose() {
this.setState({ isOpenedGrabModal: false })
}
handleGrabModalCancel() {
this.setState({ isOpenedGrabModal: false })
}
handleGrabConfirm() {
this.setState({ isOpenedGrabModal: false })
this.GrabDemand({ demandId: this.state.grabOrderId })
}
searchHanlder() {
showLoading({ title: '加载中' })
this.searchDemanding({})
}
//清空筛选项
emptyFilter() {
this.setState({
title: '',
endDateSel: '',
startDateSel: '',
demandingStateSelected: { name: '全部', id: '' },
industryTypeSelected: { name: '全部', id: '' },
})
Taro.showToast({
title: '已清空',
icon: 'success',
duration: 1000
})
}
getDataFromChild(value) {
console.log('从子组件传回来的值', value)
this.setState({ industryTypeSelected: value })
}
goToGrabOrderPage(e) {
const id = onClickValueService(e)
let orderId = encodeURIComponent(id)
Taro.navigateTo({
url: '/pages/grabOrderPage/grabOrderPage?orderId=' + orderId
})
}
componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps)
}
componentDidMount() {
// 得到第一页需求数据
showLoading({ title: '加载中' })
this.searchDemanding({})
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
// 页面位置
onPageScroll(location) {
if (location.scrollTop <= 300 && this.state.isShowTopNav) {
this.setState({ isShowTopNav: false })
} else if (location.scrollTop > 300 && !this.state.isShowTopNav) {
this.setState({ isShowTopNav: true })
} }
}
// 底部加载 // 底部加载
onReachBottom() { onReachBottom() {
Taro.showLoading({ showLoading({
title: '加载中' title: '加载中'
}) })
this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => { this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => {
this.searchDemanding({ curr_page: this.state.loadMorePageIndex }) this.searchDemanding({ curr_page: this.state.loadMorePageIndex })
}) })
} }
render() { render() {
// 提示模态弹窗element // 提示模态弹窗element
const modalMessageGrabElement = <AtModal isOpened={this.state.isOpenedGrabModal}> const modalMessageGrabElement = <AtModal isOpened={this.state.isOpenedGrabModal}>
<AtModalHeader>提示</AtModalHeader> <AtModalHeader>提示</AtModalHeader>
<AtModalContent> <AtModalContent>
确认抢单 确认抢单
</AtModalContent> </AtModalContent>
<AtModalAction> <Button onClick={this.handleGrabModalCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleGrabConfirm.bind(this)}></Button> </AtModalAction> <AtModalAction> <Button onClick={this.handleGrabModalCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleGrabConfirm.bind(this)}></Button> </AtModalAction>
</AtModal> </AtModal>
const allDemandingElementArray = this.state.supplys.length ? this.state.supplys.map((item, index) => { const allDemandingElementArray = this.state.supplys.length ? this.state.supplys.map((item, index) => {
return <View className='demanding-info' key={index}> return <View className='demanding-info' key={index}>
<View className='header'> <View className='header'>
<AtIcon value='user' size='12' color='#2196F3'></AtIcon> <AtIcon value='user' size='12' color='#2196F3'></AtIcon>
<View className='name'> 业主:{item.user_name}</View> <View className='name'> 业主:{item.user_name}</View>
<View className='others'> <View className='others'>
<Text className='cate'>{item.class_name + ' '} </Text> <Text className='cate'>{item.class_name + ' '} </Text>
| |
<Image src={eyeIcon} style='width:12px; height:12px; vertical-align:middle;' /> <Image src={eyeIcon} style='width:12px; height:12px; vertical-align:middle;' />
<Text className='watch'>{item.browse_times}</Text> <Text className='watch'>{item.browse_times}</Text>
</View> </View>
</View> </View>
<View className='body'> <View className='body'>
<View className='image-container' onClick={this.goToGrabOrderPage.bind(this, item.sd_id)}> <View className='image-container' onClick={this.goToGrabOrderPage.bind(this, item.sd_id)}>
<Image style='width:100%;height:100%' src={URL.Base + item.file_path[0].thumb_path} /> <Image style='width:100%;height:100%' src={URL.Base + item.file_path[0].thumb_path} />
</View> </View>
<View className='detail'> <View className='detail'>
<View className='title'>{item.sd_title}</View> <View className='title'>{item.sd_title}</View>
<View className='para'>{item.sd_desc}</View> <View className='para'>{item.sd_desc}</View>
{item.state === '1' ? <View className='button' onClick={this.grabOrder.bind(this, item.sd_id)}> {item.state === '1' ? <View className='button' onClick={this.grabOrder.bind(this, item.sd_id)}>
<Button size='mini' className='button-orange'>抢单</Button> <Button size='mini' className='button-orange'>抢单</Button>
</View> : null || item.state === '2' ? <View className='button'> </View> : null || item.state === '2' ? <View className='button'>
<Button size='mini' className='button-orange blur'>{item.state_name}</Button> <Button size='mini' className='button-orange blur'>{item.state_name}</Button>
</View> : null || item.state === '3' ? <View className='button'> </View> : null || item.state === '3' ? <View className='button'>
<Button size='mini' className='button-orange blur'>{item.state_name}</Button> <Button size='mini' className='button-orange blur'>{item.state_name}</Button>
</View> : null} </View> : null}
</View> </View>
</View> </View>
<View className='footer'> <View className='footer'>
<View className='location'><AtIcon value='map-pin' size='12' color='black'></AtIcon>{item.user_address}</View> <View className='location'><AtIcon value='map-pin' size='12' color='black'></AtIcon>{item.user_address}</View>
<View className='time'>更新日期:{item.update_date}</View> <View className='time'>更新日期:{item.update_date}</View>
</View>
</View>
}) : <View className='no-more-title'>没有更多了</View>
return (
<View className='allDemanding'>
{/* 模态框 */}
{modalMessageGrabElement}
<View className='page-section'>
{/* 供求状态选择 */}
<View>
<Picker mode='selector' rangeKey='name' range={this.state.demandingState} onChange={this.changeDemandingState}>
<View className='picker'>
<View className='title-box'>
<Text className='title'> 供求状态:</Text> <Text className='selected'>{this.state.demandingStateSelected.name}</Text>
</View> </View>
</View>
</Picker>
</View>
</View>
<View className='input-box'>
<AtInput
name='value'
title='需求标题:'
type='text'
placeholder='需求标题'
value={this.state.title}
onChange={this.titleChange.bind(this)}
border={false}
/>
</View>
{/* 开始和结束日期选择 */}
<View className='page-section-picker'>
<View className='picker-box'>
<View className='picker-wrapper'>
<Picker mode='date' className='picker-container' onChange={this.onStartDateChange}>
<View className='picker'>
<View className='title-box'>
<Text className='title'>开始日期:</Text> <Text className='date'>{this.state.startDateSel}</Text>
</View>
</View>
</Picker>
</View> </View>
}) : <View className='no-more-title'>没有更多了</View>
return (
<View className='allDemanding'>
{/* 模态框 */}
{modalMessageGrabElement}
<View className='page-section'> <View className='picker-wrapper'>
{/* 供求状态选择 */} <Picker className='picker-container' mode='date' start={this.state.startDateSel} onChange={this.onEndDateChange}>
<View> <View className='picker'>
<Picker mode='selector' rangeKey='name' range={this.state.demandingState} onChange={this.changeDemandingState}> <View className='title-box'>
<View className='picker'> <Text className='title'>结束日期:</Text> <Text className='date'>{this.state.endDateSel}</Text>
<View className='title-box'> </View>
<Text className='title'> 供求状态:</Text> <Text className='selected'>{this.state.demandingStateSelected.name}</Text>
</View>
</View>
</Picker>
</View>
</View> </View>
</Picker>
<View className='input-box'>
<AtInput
name='value'
title='需求标题:'
type='text'
placeholder='需求标题'
value={this.state.title}
onChange={this.titleChange.bind(this)}
/>
</View>
{/* 开始和结束日期选择 */}
<View className='page-section'>
<View className='picker-box'>
<View className='picker-wrapper'>
<Picker mode='date' className='picker-container' onChange={this.onStartDateChange}>
<View className='picker'>
<View className='title-box'>
<Text className='title'>开始日期:</Text> <Text className='date'>{this.state.startDateSel}</Text>
</View>
</View>
</Picker>
</View>
<View className='picker-wrapper'>
<Picker className='picker-container' mode='date' start={this.state.startDateSel} onChange={this.onEndDateChange}>
<View className='picker'>
<View className='title-box'>
<Text className='title'>结束日期:</Text> <Text className='date'>{this.state.endDateSel}</Text>
</View>
</View>
</Picker>
</View>
</View>
</View>
{/* 行业分类选择 */}
<InteractionComponent url={URL.GetIndustryTypeList} onPassDataToChild={this.getDataFromChild.bind(this)} selectedValue={this.state.industryTypeSelected}></InteractionComponent>
<View className='button-box'>
<View className='button' onClick={this.searchHanlder.bind(this)}>
<Button type='primary' size='mini' className='button-orange' >
<AtIcon value='search' size='12' color='white'></AtIcon>
搜索</Button>
</View>
<View className='button' onClick={this.emptyFilter.bind(this)}>
<Button type='primary' size='mini' className='button-dark-red' >
<AtIcon value='trash' size='12' color='white'></AtIcon>
清空</Button>
</View>
</View>
{/* 供求页面的数据加载 */}
<View className='demanding-box'>
{allDemandingElementArray}
</View>
{this.state.isShowTopNav ? <ScrollToTopComponent ></ScrollToTopComponent> : null}
<CopyrightComponent></CopyrightComponent>
</View> </View>
)
} </View>
</View>
{/* 行业分类选择 */}
{platformChecker() ?
<InteractionComponent url={URL.GetIndustryTypeList}
onPassDataToChild={this.getDataFromChild.bind(this)}
selectedValue={this.state.industryTypeSelected}></InteractionComponent> :
<AliIndustryTypeInteraction url={URL.GetIndustryTypeList}
onPassDataToChild={this.getDataFromChild.bind(this)}
selectedValue={this.state.industryTypeSelected} />
}
<View className='button-box'>
<View className='button' onClick={this.searchHanlder.bind(this)}>
<Button type='primary' size='mini' className='button-orange' >
<AtIcon value='search' size='12' color='white'></AtIcon>
搜索</Button>
</View>
<View className='button' onClick={this.emptyFilter.bind(this)}>
<Button type='primary' size='mini' className='button-dark-red' >
<AtIcon value='trash' size='12' color='white'></AtIcon>
清空</Button>
</View>
</View>
{/* 供求页面的数据加载 */}
<View className='demanding-box'>
{allDemandingElementArray}
</View>
{this.state.isShowTopNav ? <ScrollToTopComponent ></ScrollToTopComponent> : null}
<CopyrightComponent></CopyrightComponent>
</View>
)
}
} }
export default AllDemanding export default AllDemanding

View File

@ -17,31 +17,34 @@ $themeColor: #FF7142;
.page-section{ .page-section{
border-bottom: 1Px solid #d6e4ef; border-bottom: 1Px solid #d6e4ef;
.picker{
// padding: 24rpx 0;
.selected{
display: inline-block;
margin-left: 20%;
font-size: 32rpx
}
.date{
display: inline-block;
font-size: 32rpx
}
.title-box{
.title{
//color: #333;
margin-right:16rpx;
width:172rpx;
font-size:32rpx;
line-height:100px;
// vertical-align:middle;
text-align:left;
font-weight: bold;
}
} }
} .page-section-picker{
.picker{
// padding: 24rpx 0;
.selected{
display: inline-block;
margin-left: 20%;
font-size: 32rpx
}
.date{
display: inline-block;
font-size: 32rpx
}
.title-box{
.title{
//color: #333;
margin-right:16rpx;
width:172rpx;
font-size:32rpx;
line-height:100px;
// vertical-align:middle;
text-align:left;
font-weight: bold;
}
}
}
} }
.input-box{ .input-box{
display: flex; display: flex;

View File

@ -0,0 +1,108 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Image } from '@tarojs/components'
import URL from '../../../serviceAPI.config'
import './aliGoodCommentSection.scss'
//接收的参数
// mainActived,subActived,productImagesUrl
class AliGoodCommentSection extends Component {
config = {
navigationBarTitleText: '商品详情和评论'
}
passMainCurrentToParent(value) {
this.props.onAliMainOnClick(value)
}
passSubCurrentToParent(value) {
this.props.onAliSubOnClick(value)
}
componentDidMount() {
}
componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps)
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
render() {
const { mainActived, subActived, productImagesUrl } = this.props
const mainTabList = [{ title: '宝贝详情' }, { title: '全部评价' }, { title: '猜你喜欢' }]
const subTabList = [{ title: '全部' }, { title: '好评' }, { title: '中评' }, { title: '差评' }, { title: '公开' }, { title: '匿名' }]
const tabArrayElement = mainTabList.map((item, index) => {
return <View className={mainActived === index ? 'tab actived' : 'tab'} key={index} onClick={this.passMainCurrentToParent.bind(this, index)}>
{item.title}
</View>
})
const subTabArrayElement = subTabList.map((item, index) => {
return <View className={subActived === index ? 'sub-tab sub-actived' : 'sub-tab'} key={index} onClick={this.passSubCurrentToParent.bind(this, index)}>
{item.title}
</View>
})
const itemDescriptionPicsElementArray = 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 (
<View className='aliGoodCommentSection'>
<View className='tab-wrapper'>
<View className='tabs'>
{tabArrayElement}
</View>
<View className='tab-details'>
{mainActived === 0 && <View className='first-tab' style='background-color: #FAFBFC;' >
<View className='description-title'>商品细节</View>
<View className='description-img'>
{itemDescriptionPicsElementArray}
</View>
</View>
}
{mainActived === 1 && <View className='second-tab'>
<View className='tab-header'> {subTabArrayElement}</View>
{
subActived === 0 && <View className='sub-tab-details'>全部</View>
}
{
subActived === 1 && <View className='sub-tab-details'>好评</View>
}
{
subActived === 2 && <View className='sub-tab-details'>中评</View>
}
{
subActived === 3 && <View className='sub-tab-details'>差评</View>
}
{
subActived === 4 && <View className='sub-tab-details'>公开</View>
}
{
subActived === 5 && <View className='sub-tab-details'>匿名</View>
}
</View>}
{mainActived === 2 && <View className='third-tab' >标签页三的内容</View>}
</View>
</View>
</View>
)
}
}
export default AliGoodCommentSection

View File

@ -0,0 +1,72 @@
.tabs{
display: flex;
flex-wrap: nowrap;
flex-direction: row;
height: 80px;
border-bottom: 0.01px solid #d6e4ef;
.tab{
flex:1;
text-align: center;
padding: 24px;
}
.actived{
color:#FF7142;
border-bottom: 3px solid#FF7142
}
}
.tab-details{
border: 1px solid #d6e4ef;
.first-tab{
.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;
}
}
.second-tab{
.tab-header{
display: flex;
flex-wrap: nowrap;
flex-direction: row;
border-bottom: 0.1px solid #d6e4ef;
.sub-tab{
flex:1;
text-align: center;
padding: 12px;
}
}
.sub-tab-details{
padding: 100px 50px;
background-color: #FAFBFC;
text-align: center;
}
}
.third-tab{
padding: 100px 50px;
background-color: #FAFBFC;
text-align: center;
}
.actived{
color:#FF7142;
border-bottom: 3px solid#FF7142
}
.sub-actived{
color:#FF7142;
border: 2px solid#FF7142;
border-radius: 10%;
}
}

View File

@ -0,0 +1,117 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Image, Text } from '@tarojs/components'
import { AtTabs, AtTabsPane, AtSegmentedControl } from 'taro-ui'
import URL from '../../../serviceAPI.config'
import './goodCommentSection.scss'
// 需要的props
//productImagesUrlcurrentsubCurrent,onhandleClick,onClick
class GoodCommentSection extends Component {
config = {
navigationBarTitleText: '商品详情和评论'
}
passMainCurrentToParent(value){
this.props.onMainOnClick(value)
}
passSubCurrentToParent(value){
this.props.onSubOnClick(value)
}
componentDidMount() {
}
componentWillReceiveProps(nextProps) {
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
render() {
const mainTabList = [{ title: '宝贝详情' }, { title: '全部评价' }, { title: '猜你喜欢' }]
const { productImagesUrl, mainCurrent, subCurrent, } = this.props
const itemDescriptionPicsElementArray = 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 (
<View className='good-info-section'>
<View className='details-box'>
{/* 大类 */}
<AtTabs className='alltabs' animated={false} current={mainCurrent} tabList={mainTabList} onClick={this.passMainCurrentToParent.bind(this)}>
<AtTabsPane style='color:red' current={this.state.current} index={0} >
<View style='background-color: #FAFBFC;' >
<View className='description-title'>商品细节</View>
<View className='description-img'>
{itemDescriptionPicsElementArray}
</View>
</View>
</AtTabsPane>
<AtTabsPane current={subCurrent} index={1}>
<View style='padding: 1px 0px 100px;background-color: #FAFBFC;text-align: center;'>
{ /*子标签类*/}
<AtSegmentedControl selectedColor='#FF9500'
values={['全部', '好评', '中评', '差评', '公开', '匿名']}
onClick={this.passSubCurrentToParent.bind(this)}
current={subCurrent}
/>
{
this.state.subCurrent === 0
? <View className='tab-content'>
<Text className='title'>全部</Text>
</View>
: null
}
{
this.state.subCurrent === 1
? <View className='tab-content'>好评</View>
: null
}
{
this.state.subCurrent === 2
? <View className='tab-content'>中评</View>
: null
}
{
this.state.subCurrent === 3
? <View className='tab-content'>差评</View>
: null
}
{
this.state.subCurrent === 4
? <View className='tab-content'>公开</View>
: null
}
{
this.state.subCurrent === 5
? <View className='tab-content'>匿名</View>
: null
}
</View>
</AtTabsPane>
<AtTabsPane current={this.state.current} index={2}>
<View style='padding: 100px 50px;background-color: #FAFBFC;text-align: center;'>标签页三的内容</View>
</AtTabsPane>
</AtTabs>
</View>
</View>
)
}
}
export default GoodCommentSection

View File

@ -0,0 +1,22 @@
.details-box{
.at-tabs{
.at-tabs__item--active{
// color:$themeColor
}
}
.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;
}
}

View File

@ -1,13 +1,17 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image, Swiper, SwiperItem } from '@tarojs/components' import { View, Text, Image, Swiper, SwiperItem, Picker } from '@tarojs/components'
import { AtIcon } from 'taro-ui'
import { AtTabs, AtTabsPane, AtSegmentedControl, AtIcon, Picker } from 'taro-ui' import GoodCommentSection from './goodCommentSection/goodCommentSection'
import AliGoodCommentSection from './aliGoodCommentSection/aliGoodCommentSection'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import platformChecker from '../../util/plaformChecker'
import LoginService from '../../util/LoginService' import LoginService from '../../util/LoginService'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import './goods.scss' import './goods.scss'
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading';
import onClickValueService from '../../util/onClickValueService'
class Goods extends Component { class Goods extends Component {
@ -31,21 +35,26 @@ class Goods extends Component {
monthSold: '',//月销量 monthSold: '',//月销量
totalSold: '',//总销量 totalSold: '',//总销量
browsingCount: '',// 浏览数 browsingCount: '',// 浏览数
shopId: '' shopId: '',
actived: 0,// 默认tab
subActived: 0,//默认sub-tab
} }
} }
// 商品详情api // 商品详情api
getGoodDescription() { getGoodDescription() {
let goodId = decodeURIComponent(this.$router.params.id)
Taro.request({ Taro.request({
url: URL.GetShopItemDetail, url: URL.GetShopItemDetail,
method: 'POST', method: 'POST',
dataType: 'json', dataType: 'json',
data: { data: {
goodsID: this.$router.params.id, goodsID: goodId,
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'), 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
} }
@ -80,13 +89,13 @@ class Goods extends Component {
} }
// 大类评论区方法 // 大类评论区方法
handleClick(value) { mainTabClick(value) {
this.setState({ this.setState({
current: value current: value
}) })
} }
// 小磊评论区方法 // 小磊评论区方法
onClick(value) { subTabClick(value) {
this.setState({ this.setState({
subCurrent: value subCurrent: value
}) })
@ -122,6 +131,18 @@ class Goods extends Component {
}) })
} }
aliMainTabClick(e) {
let value = onClickValueService(e)
this.setState({
actived: value
})
}
aliSubTabClick(e) {
let value = onClickValueService(e)
this.setState({
subActived: value
})
}
// 数量或者规格方法 // 数量或者规格方法
onChange = e => { onChange = e => {
this.setState({ this.setState({
@ -130,9 +151,9 @@ class Goods extends Component {
} }
componentDidMount() { componentDidMount() {
Taro.showLoading({ showLoading({
title: '加载中' title: '加载中'
}) })
this.getGoodDescription() this.getGoodDescription()
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
@ -146,7 +167,9 @@ class Goods extends Component {
componentDidHide() { } componentDidHide() { }
render() { render() {
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) => { const itemPicsBannerElementArray = this.state.productImagesUrl.map((item, index) => {
return <SwiperItem key={index} > return <SwiperItem key={index} >
@ -156,25 +179,19 @@ class Goods extends Component {
</SwiperItem > </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'>
<View className='img-box'> <View className='img-box'>
{/* <Image className='img' src={URL.Base + this.state.productImagesUrl}></Image> */} {/* <Image className='img' src={URL.Base + this.state.productImagesUrl}></Image> */}
<Swiper <Swiper
className='swipper' className='swipper'
style='height:100%;' style='height:100%;'
indicatorColor='#999' indicatorColor='#999'
indicatorActiveColor='#333' indicatorActiveColor='#333'
hotizontal hotizontal
circular circular
indicatorDots indicatorDots
> >
{itemPicsBannerElementArray} {itemPicsBannerElementArray}
@ -240,70 +257,20 @@ class Goods extends Component {
</Picker> </Picker>
</View> </View>
{/* 详情和评论区 */} {/* 详情和评论区 */}
<View className='details-box'>
{/* 大类 */}
<AtTabs className='alltabs' animated={false} current={this.state.current} tabList={mainTabList} onClick={this.handleClick.bind(this)}>
<AtTabsPane style='color:red' current={this.state.current} index={0} >
<View style='background-color: #FAFBFC;' >
<View className='description-title'>商品细节</View>
<View className='description-img'>
{itemDescriptionPicsElementArray}
</View>
</View>
</AtTabsPane>
<AtTabsPane current={this.state.current} index={1}>
<View style='padding: 1px 0px 100px;background-color: #FAFBFC;text-align: center;'>
{ /*子标签类*/}
<AtSegmentedControl selectedColor='#FF9500'
values={['全部', '好评', '中评', '差评', '公开', '匿名']}
onClick={this.onClick.bind(this)}
current={this.state.subCurrent}
/>
{
this.state.subCurrent === 0
? <View className='tab-content'>
<Text className='title'>全部</Text>
</View>
: null
}
{
this.state.subCurrent === 1
? <View className='tab-content'>好评</View>
: null
}
{
this.state.subCurrent === 2
? <View className='tab-content'>中评</View>
: null
}
{
this.state.subCurrent === 3
? <View className='tab-content'>差评</View>
: null
}
{
this.state.subCurrent === 4
? <View className='tab-content'>公开</View>
: null
}
{
this.state.subCurrent === 5
? <View className='tab-content'>匿名</View>
: null
}
</View>
</AtTabsPane>
<AtTabsPane current={this.state.current} index={2}>
<View style='padding: 100px 50px;background-color: #FAFBFC;text-align: center;'>标签页三的内容</View>
</AtTabsPane>
</AtTabs>
</View>
{platformChecker() ? <GoodCommentSection
productImagesUrl={this.state.productImagesUrl}
mainCurrent={this.state.current}
subCurrent={this.state.subCurrent}
onMainOnClick={this.state.mainTabClick.bind(this)}
onSubOnClick={this.state.subTabClick.bind(this)}
/> : <AliGoodCommentSection
mainActived={this.state.actived}
subActived={this.state.subActived}
productImagesUrl={this.state.productImagesUrl}
onAliMainOnClick={this.state.aliMainTabClick.bind(this)}
onAliSubOnClick={this.state.aliSubTabClick.bind(this)}
/>}
<CopyrightComponent></CopyrightComponent> <CopyrightComponent></CopyrightComponent>
<View className='gap' style='height:150rpx'> <View className='gap' style='height:150rpx'>
</View> </View>
@ -330,7 +297,7 @@ class Goods extends Component {
</View> </View>
</View> </View>
</View> </View >
) )
} }
} }

View File

@ -119,30 +119,7 @@ $themeColor:#FF7142;
} }
//------------------------------
.details-box{
.at-tabs{
.at-tabs__item--active{
// color:$themeColor
}
}
.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{ .copyright-box{
padding:0 20px; padding:0 20px;
@ -213,4 +190,3 @@ $themeColor:#FF7142;
} }
} }

View File

@ -1,11 +1,13 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Button } from '@tarojs/components' import { View, Text, Button } from '@tarojs/components'
import { AtInput, AtImagePicker, AtTextarea, } from 'taro-ui' import { AtInput, AtTextarea, AtImagePicker } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import AliPictureUploadComponent from '../../component/aliPictureUploadComponent/aliPictureUploadComponent'
import ShopTypeInteractionComp from '../../component/shopTypeInteractionComp/shopTypeInteractionComp' import ShopTypeInteractionComp from '../../component/shopTypeInteractionComp/shopTypeInteractionComp'
import AliShopTypeInteraction from '../../component/AliShopTypeInteraction/AliShopTypeInteraction'
import GoodsTypeInteractionComp from '../../component/goodsTypeInteractionComp/goodsTypeInteractionComp' import GoodsTypeInteractionComp from '../../component/goodsTypeInteractionComp/goodsTypeInteractionComp'
import AliGoodsTypeInteraction from '../../component/aliGoodsTypeInteraction/aliGoodsTypeInteraction'
import LoginService from '../../util/LoginService' import LoginService from '../../util/LoginService'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
@ -14,6 +16,9 @@ import URL from '../../serviceAPI.config'
import './goodsPublish.scss' import './goodsPublish.scss'
import loginExpired from '../../util/loginExpired'; import loginExpired from '../../util/loginExpired';
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading';
import { isUserShopOwner } from '../../util/checkLogin';
import platformChecker from '../../util/plaformChecker';
class GoodsPublish extends Component { class GoodsPublish extends Component {
@ -23,7 +28,6 @@ class GoodsPublish extends Component {
constructor() { constructor() {
super(...arguments) super(...arguments)
this.state = { this.state = {
shopTypeSelected: { name: '选择店铺类型', id: '' },//已选的店铺分类 shopTypeSelected: { name: '选择店铺类型', id: '' },//已选的店铺分类
goodsTypeSelected: { name: '选择商品分类', id: '' },// 已选的商品分类 goodsTypeSelected: { name: '选择商品分类', id: '' },// 已选的商品分类
productName: '', productName: '',
@ -108,7 +112,7 @@ class GoodsPublish extends Component {
if (this.state.isPublish) { if (this.state.isPublish) {
// 导航到编辑页面 // 导航到编辑页面
Taro.redirectTo({ Taro.redirectTo({
url: '/pages/myGoodsList/myGoodsList' url: '/pages/myGoodList/myGoodList'
}) })
} else if (this.state.isPublishAndAdd) { } else if (this.state.isPublishAndAdd) {
// 导航到发布页面 // 导航到发布页面
@ -205,7 +209,12 @@ class GoodsPublish extends Component {
}) })
} }
} }
// 从图片子组件获取信息
getImageDetails(value) {
this.setState({
ImagesInfo: value
})
}
publishButtonHandler() { publishButtonHandler() {
if (this.state.productName && if (this.state.productName &&
@ -214,22 +223,22 @@ class GoodsPublish extends Component {
this.state.ImagesInfo.length && this.state.ImagesInfo.length &&
this.state.goodsTypeSelected.id && this.state.goodsTypeSelected.id &&
this.state.shopTypeSelected.id) { this.state.shopTypeSelected.id) {
Taro.showLoading({ title: '发布中' }).then(() => { showLoading({ title: '发布中' })
this.setState({ isPublish: true }, () => { this.setState({ isPublish: true }, () => {
this.uploadGoods({ this.uploadGoods({
goods_name: this.state.productName, goods_name: this.state.productName,
goods_price: this.state.productPrice, goods_price: this.state.productPrice,
goods_unit: this.state.productUnit, goods_unit: this.state.productUnit,
goods_profiles: this.state.productDescript, goods_profiles: this.state.productDescript,
class_id: this.state.goodsTypeSelected.id, class_id: this.state.goodsTypeSelected.id,
shop_class_id: this.state.shopTypeSelected.id, shop_class_id: this.state.shopTypeSelected.id,
})
}) })
}) })
} else { } else {
Taro.showToast({ title: '请填写完表格', icon: 'none' }) Taro.showToast({ title: '请填写完表格', icon: 'none' })
} }
@ -242,22 +251,22 @@ class GoodsPublish extends Component {
this.state.ImagesInfo.length && this.state.ImagesInfo.length &&
this.state.goodsTypeSelected.id && this.state.goodsTypeSelected.id &&
this.state.shopTypeSelected.id) { this.state.shopTypeSelected.id) {
Taro.showLoading({ title: '发布中' }).then(() => { showLoading({ title: '发布中' })
this.setState({ isPublishAndAdd: true }, () => { this.setState({ isPublishAndAdd: true }, () => {
this.uploadGoods({ this.uploadGoods({
goods_name: this.state.productName, goods_name: this.state.productName,
goods_price: this.state.productPrice, goods_price: this.state.productPrice,
goods_unit: this.state.productUnit, goods_unit: this.state.productUnit,
goods_profiles: this.state.productDescript, goods_profiles: this.state.productDescript,
class_id: this.state.goodsTypeSelected.id, class_id: this.state.goodsTypeSelected.id,
shop_class_id: this.state.shopTypeSelected.id, shop_class_id: this.state.shopTypeSelected.id,
})
}) })
}) })
} else { } else {
Taro.showToast({ title: '请填写完表格', icon: 'none' }) Taro.showToast({ title: '请填写完表格', icon: 'none' })
} }
@ -289,8 +298,8 @@ class GoodsPublish extends Component {
} }
} }
componentDidMount() { componentDidMount() {
}
}
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
// console.log(this.props, nextProps) // console.log(this.props, nextProps)
} }
@ -298,12 +307,7 @@ class GoodsPublish extends Component {
componentWillUnmount() { } componentWillUnmount() { }
componentDidShow() { componentDidShow() {
if (!getGlobalStorage('shopInfo').shop_id && getGlobalStorage('userInfo').user_id) { isUserShopOwner()
Taro.showToast({
title: '您还没有店铺,不能使用该功能,快去申请吧',
icon: 'none'
})
}
} }
componentDidHide() { } componentDidHide() { }
@ -317,11 +321,16 @@ class GoodsPublish extends Component {
<View className='goods-category'> <View className='goods-category'>
{/* 商品分类开始 */} {/* 商品分类开始 */}
<GoodsTypeInteractionComp {platformChecker() ? <GoodsTypeInteractionComp
url={URL.GetProductCategoryList} url={URL.GetProductCategoryList}
onPassDataToChild={this.getDataFromGoodsChild.bind(this)} onPassDataToChild={this.getDataFromGoodsChild.bind(this)}
selectedValue={this.state.goodsTypeSelected} selectedValue={this.state.goodsTypeSelected}
></GoodsTypeInteractionComp> ></GoodsTypeInteractionComp>
: <AliGoodsTypeInteraction url={URL.GetProductCategoryList}
onPassDataToChild={this.getDataFromGoodsChild.bind(this)}
selectedValue={this.state.goodsTypeSelected} />}
{/* 商品分类结束 */} {/* 商品分类结束 */}
<View className='input-box'> <View className='input-box'>
@ -364,7 +373,7 @@ class GoodsPublish extends Component {
<Text className='require'>*</Text> <Text className='require'>*</Text>
<Text className='title'>上传图片:</Text> <Text className='title'>上传图片:</Text>
</View> </View>
<View className='img-container'> {platformChecker() ? <View className='img-container'>
<AtImagePicker <AtImagePicker
multiple multiple
files={this.state.pickerImageUrl} files={this.state.pickerImageUrl}
@ -372,14 +381,24 @@ class GoodsPublish extends Component {
onFail={this.onFail.bind(this)} onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)} onImageClick={this.onImageClick.bind(this)}
/> />
</View> </View> : <AliPictureUploadComponent maxLength={20} isReceiveImageUrl={false} url={URL.UploadGoodsPorductImage} onGetImageDetails={this.getImageDetails.bind(this)} />
}
</View> </View>
{/* 店铺分类 */} {/* 店铺分类 */}
<ShopTypeInteractionComp url={URL.GetShopCategoryList} {platformChecker() ?
shopId={getGlobalStorage('shopInfo').shop_id} <ShopTypeInteractionComp url={URL.GetShopCategoryList}
selectedValue={this.state.shopTypeSelected} shopId={getGlobalStorage('shopInfo').shop_id}
onPassDataToChild={this.getDataFromShopChild.bind(this)} selectedValue={this.state.shopTypeSelected}
></ShopTypeInteractionComp> onPassDataToChild={this.getDataFromShopChild.bind(this)}
></ShopTypeInteractionComp>
: <AliShopTypeInteraction url={URL.GetShopCategoryList}
shopId={getGlobalStorage('shopInfo') ? getGlobalStorage('shopInfo').shop_id : ''}
selectedValue={this.state.shopTypeSelected}
onPassDataToChild={this.getDataFromShopChild.bind(this)}
></AliShopTypeInteraction>
}
{/* 店铺分类结束 */} {/* 店铺分类结束 */}
@ -388,12 +407,19 @@ class GoodsPublish extends Component {
<Text className='require'></Text> <Text className='require'></Text>
<Text className='title'>商品简介:</Text> <Text className='title'>商品简介:</Text>
</View> </View>
<AtTextarea {platformChecker() ? <AtTextarea
value={this.state.productDescript} value={this.state.productDescript}
onChange={this.productDescriptChange.bind(this)} onChange={this.productDescriptChange.bind(this)}
maxlength='140' maxlength='140'
placeholder='你的产品简介' placeholder='你的产品简介'
/> /> : <View className='textarea-wrapper'>
<textarea className='text-area'
onInput={this.productDescriptChange.bind(this)}
value={this.state.productDescript}
placeholder='你的产品简介'
maxlength='140' /></View>
}
</View> </View>
</View> </View>
<View className='button-box' > <View className='button-box' >

View File

@ -18,17 +18,20 @@ $themeColor:#FF7142;
} }
.img-box{ .img-box{
margin-top:10Px; margin-top:10Px;
.img-container{ .img-container{
border: 1Px solid #d6e4ef; border: 1Px solid #d6e4ef;
border-radius:8rpx; border-radius:8rpx;
} }
} }
.shoptype-box{ .shoptype-box{
margin-top:10Px; margin-top:10Px;
} }
.description-box{ .description-box{
margin-top:10Px; margin-top:10Px;
} }
} }
@ -88,6 +91,7 @@ $themeColor:#FF7142;
.page-section{ .page-section{
border-bottom: 1Px solid #d6e4ef; border-bottom: 1Px solid #d6e4ef;
} }
.selected{ .selected{
display: inline-block; display: inline-block;
@ -97,6 +101,7 @@ $themeColor:#FF7142;
.input-box{ .input-box{
border-bottom: 1Px solid #d6e4ef; border-bottom: 1Px solid #d6e4ef;
display: flex; display: flex;
} }
.require{ .require{
color:red; color:red;
@ -104,5 +109,23 @@ $themeColor:#FF7142;
} }
.picker-wrapper{
.item-content__info-title{
font-weight: bold
}
.item-extra__info{
color: black
}
}
.textarea-wrapper{
border-width: 1px;
border-style: solid;
border-color: rgb(214, 228, 239);
border-radius: 8px;
padding:5px;
.text-area{
height: 150px;
}
}

View File

@ -10,6 +10,7 @@ import CopyrightComponent from '../../component/copyrightComponent/copyrightComp
import './grabOrderPage.scss' import './grabOrderPage.scss'
import loginExpired from '../../util/loginExpired'; import loginExpired from '../../util/loginExpired';
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading';
class GrabOrderPage extends Component { class GrabOrderPage extends Component {
@ -29,7 +30,6 @@ class GrabOrderPage extends Component {
content: '', content: '',
images: [], images: [],
isOpen: false, // 抢单消息提示 isOpen: false, // 抢单消息提示
grabOrderId: this.$router.params.orderId,
stateId: '', stateId: '',
stateName: '', stateName: '',
userId: '', userId: '',
@ -40,12 +40,13 @@ class GrabOrderPage extends Component {
//获取抢单信息api supplyDemandDetails //获取抢单信息api supplyDemandDetails
getGrabOrderInfo() { getGrabOrderInfo() {
let orderId=decodeURIComponent(this.$router.params.orderId)
Taro.request({ Taro.request({
url: URL.supplyDemandDetails, url: URL.supplyDemandDetails,
method: 'GET', method: 'GET',
dataType: 'json', dataType: 'json',
data: { data: {
demandId: this.$router.params.orderId, demandId: orderId,
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -73,10 +74,10 @@ class GrabOrderPage extends Component {
}) })
} else if (res.data.err_code === 88888) { } else if (res.data.err_code === 88888) {
loginExpired(res) loginExpired(res)
}else{ } else {
Taro.showToast({ Taro.showToast({
title:res.data.err_msg, title: res.data.err_msg,
icon:'none' icon: 'none'
}) })
} }
@ -88,12 +89,13 @@ class GrabOrderPage extends Component {
} }
//抢单请求 //抢单请求
GrabDemand({ demandId = 218 }) { GrabDemand({ demandId = 218 }) {
let id=encodeURIComponent(demandId)
Taro.request({ Taro.request({
url: URL.GrabDemand, url: URL.GrabDemand,
method: 'POST', method: 'POST',
dataType: 'json', dataType: 'json',
data: { data: {
demandId: demandId demandId: id
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -111,7 +113,7 @@ class GrabOrderPage extends Component {
}) })
setTimeout(() => { setTimeout(() => {
Taro.navigateBack({ Taro.navigateBack({
delta:1 delta: 1
}) })
}, 1500); }, 1500);
@ -153,15 +155,16 @@ class GrabOrderPage extends Component {
handleGrabConfirm() { handleGrabConfirm() {
this.setState({ isOpen: false }) this.setState({ isOpen: false })
// 确认抢单之后 // 确认抢单之后
Taro.showLoading({ showLoading({
title: '加载中' title: '加载中'
}) })
this.GrabDemand({ demandId: this.state.grabOrderId })
this.GrabDemand({ demandId: this.$router.params.orderId })
} }
componentDidMount() { componentDidMount() {
Taro.showLoading({ showLoading({
title:'加载中' title: '加载中'
}) })
this.getGrabOrderInfo() this.getGrabOrderInfo()
} }
@ -185,7 +188,7 @@ class GrabOrderPage extends Component {
}) })
} }
goMyNeedEditPage() { goMyNeedEditPage() {
let id = this.$router.params.orderId let id = encodeURIComponent(this.$router.params.orderId)
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/myNeedsEdit/myNeedsEdit?id=' + id url: '/pages/myNeedsEdit/myNeedsEdit?id=' + id
}) })
@ -197,16 +200,18 @@ class GrabOrderPage extends Component {
this.setState({ isDeleteModal: false }) this.setState({ isDeleteModal: false })
} }
handleWindowConfirm() { handleWindowConfirm() {
this.setState({ isDeleteModal: false }) this.setState({ isDeleteModal: false })
this.deleteMyNeeds({ demandId: this.$router.params.orderId }) this.deleteMyNeeds({ demandId: this.$router.params.orderId })
} }
deleteMyNeeds({ demandId }) { deleteMyNeeds({ demandId }) {
let id=encodeURIComponent(demandId)
Taro.request({ Taro.request({
url: URL.DeleteMyNeeds, url: URL.DeleteMyNeeds,
method: 'POST', method: 'POST',
dataType: 'json', dataType: 'json',
data: { data: {
demandId: demandId demandId: id
}, },
header: { header: {
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'), 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
@ -223,7 +228,7 @@ class GrabOrderPage extends Component {
}) })
setTimeout(() => { setTimeout(() => {
Taro.navigateBack({ Taro.navigateBack({
delta:-1 delta: -1
}) })
}, 1500); }, 1500);
} else if (res.data.err_code === 88888) { } else if (res.data.err_code === 88888) {
@ -239,7 +244,7 @@ class GrabOrderPage extends Component {
} }
render() { render() {
const localStoageUserId = getGlobalStorage('userInfo').user_id const localStoageUserId = getGlobalStorage('userInfo') ? getGlobalStorage('userInfo').user_id : ''
// 提示框 // 提示框
const deleteModalWindowElement = <AtModal isOpened={this.state.isDeleteModal}> const deleteModalWindowElement = <AtModal isOpened={this.state.isDeleteModal}>
@ -249,58 +254,82 @@ class GrabOrderPage extends Component {
</AtModalContent> </AtModalContent>
<AtModalAction> <Button onClick={this.handleWindowModCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleWindowConfirm.bind(this)}></Button> </AtModalAction> <AtModalAction> <Button onClick={this.handleWindowModCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleWindowConfirm.bind(this)}></Button> </AtModalAction>
</AtModal> </AtModal>
let ButtonElement
if (localStoageUserId === this.state.userId && this.state.stateId === '1') {
ButtonElement = <View className='button-box'>
<View className='button' onClick={this.goMyNeedsPublishPage.bind(this)}>
<Button size='mini' className='button-green'>
<AtIcon value='add' size='12' color='white'></AtIcon>
新增</Button>
</View>
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
<Button size='mini' className='button-orange'>
<AtIcon value='' size='12' color='white'></AtIcon>
我的需求</Button>
</View>
{/* <View className='button' onClick={this.goMyNeedEditPage.bind(this)}>
<Button size='mini' className='button-blue'>
<AtIcon value='settings' size='12' color='white'></AtIcon>
修改</Button>
</View>
<View className='button' onClick={this.deleteButton.bind(this)}>
<Button size='mini' className='button-dark-red'> let ButtonElement = localStoageUserId === this.state.userId ? <View className='button-box'>
<AtIcon value='trash' size='12' color='white'></AtIcon> <View className='button' onClick={this.goMyNeedsPublishPage.bind(this)}>
删除</Button> <Button size='mini' className='button-green'>
</View> */} <AtIcon value='add' size='12' color='white'></AtIcon>
新增</Button>
</View> </View>
} else if (localStoageUserId === this.state.userId && this.state.stateId != '1') { <View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
ButtonElement = <View className='button-box'> <Button size='mini' className='button-orange'>
<View className='button' onClick={this.goMyNeedsPublishPage.bind(this)}> <AtIcon value='' size='12' color='white'></AtIcon>
<Button size='mini' className='button-green'> 我的需求</Button>
<AtIcon value='add' size='12' color='white'></AtIcon>
新增</Button>
</View>
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
<Button size='mini' className='button-orange'>
<AtIcon value='' size='12' color='white'></AtIcon>
我的需求</Button>
</View>
</View> </View>
} else if (this.state.stateId === '1') { </View> :
ButtonElement = <View className='button-box'><View className='button' onClick={this.grabButtonHandler.bind(this)}> this.state.stateId === '1' ? <View className='button-box'><View className='button' onClick={this.grabButtonHandler.bind(this)}>
<Button size='mini' className='button-orange'>抢单</Button> <Button size='mini' className='button-orange'>抢单</Button>
</View></View> </View></View> :
this.state.stateId === '2' ? <View className='button-box'><View className='button'>
<Button size='mini' className='button-orange blur'>已抢单</Button>
</View></View> :
<View className='button-box'><View className='button'>
<Button size='mini' className='button-orange blur'>已抢光</Button>
</View></View>
} else if (this.state.stateId === '2') {
ButtonElement = <View className='button-box'><View className='button'> // if (localStoageUserId === this.state.userId && this.state.stateId === '1') {
<Button size='mini' className='button-orange blur'>{this.state.stateName}</Button> // ButtonElement = <View className='button-box'>
</View></View> // <View className='button' onClick={this.goMyNeedsPublishPage.bind(this)}>
} else if (this.state.stateId === '3') { // <Button size='mini' className='button-green'>
ButtonElement = <View className='button-box'><View className='button'> // <AtIcon value='add' size='12' color='white'></AtIcon>
<Button size='mini' className='button-orange blur'>{this.state.stateName}</Button> // 新增</Button>
</View></View> // </View>
} // <View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
// <Button size='mini' className='button-orange'>
// <AtIcon value='' size='12' color='white'></AtIcon>
// 我的需求</Button>
// </View>
// {/* <View className='button' onClick={this.goMyNeedEditPage.bind(this)}>
// <Button size='mini' className='button-blue'>
// <AtIcon value='settings' size='12' color='white'></AtIcon>
// 修改</Button>
// </View>
// <View className='button' onClick={this.deleteButton.bind(this)}>
// <Button size='mini' className='button-dark-red'>
// <AtIcon value='trash' size='12' color='white'></AtIcon>
// 删除</Button>
// </View> */}
// </View>
// } else if (localStoageUserId === this.state.userId && this.state.stateId != '1') {
// ButtonElement = <View className='button-box'>
// <View className='button' onClick={this.goMyNeedsPublishPage.bind(this)}>
// <Button size='mini' className='button-green'>
// <AtIcon value='add' size='12' color='white'></AtIcon>
// 新增</Button>
// </View>
// <View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
// <Button size='mini' className='button-orange'>
// <AtIcon value='' size='12' color='white'></AtIcon>
// 我的需求</Button>
// </View>
// </View>
// } else if (this.state.stateId === '1') {
// ButtonElement = <View className='button-box'><View className='button' onClick={this.grabButtonHandler.bind(this)}>
// <Button size='mini' className='button-orange'>抢单</Button>
// </View></View>
// } else if (this.state.stateId === '2') {
// ButtonElement = <View className='button-box'><View className='button'>
// <Button size='mini' className='button-orange blur'>{this.state.stateName}</Button>
// </View></View>
// } else if (this.state.stateId === '3') {
// ButtonElement = <View className='button-box'><View className='button'>
// <Button size='mini' className='button-orange blur'>{this.state.stateName}</Button>
// </View></View>
// }
@ -324,7 +353,7 @@ class GrabOrderPage extends Component {
{modalMessageGrabElement} {modalMessageGrabElement}
{deleteModalWindowElement} {deleteModalWindowElement}
{this.state.isShowRendering ? <RenderingView rendering={this.state.renderingImage}></RenderingView> : null} {this.state.isShowRendering ? <RenderingView rendering={this.state.renderingImage}></RenderingView> : null}
{this.state.stateId === '3' && !this.state.isShowRendering&&this.state.renderingImage.length ? <View className='button-box show-image-button'><View className='button' onClick={this.showImageButton.bind(this)}> {this.state.stateId === '3' && !this.state.isShowRendering && this.state.renderingImage.length ? <View className='button-box show-image-button'><View className='button' onClick={this.showImageButton.bind(this)}>
<Button className='button-orange'>查看效果图</Button> <Button className='button-orange'>查看效果图</Button>
</View></View> : null} </View></View> : null}
<View className='type box'> <View className='type box'>

View File

@ -12,7 +12,8 @@ class ClientDemanding extends Component {
} }
// 导航去抢单页面 // 导航去抢单页面
goToGrabOrderPage(e) { goToGrabOrderPage(e) {
const orderId = onClickValueService(e) const id = onClickValueService(e)
let orderId=encodeURIComponent(id)
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/grabOrderPage/grabOrderPage?orderId=' + orderId url: '/pages/grabOrderPage/grabOrderPage?orderId=' + orderId
}) })

View File

@ -17,6 +17,8 @@ $themeColor: #FF7142;
} }
} }
.item-title{ .item-title{
padding-left: 10px;
padding-right: 10px;
font-size: 40px; font-size: 40px;
min-height: 21px; min-height: 21px;
clear: both; clear: both;

View File

@ -13,6 +13,8 @@ import LoginService from '../../util/LoginService'
import weChatLogin from '../../util/weChatLogin' import weChatLogin from '../../util/weChatLogin'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import './home.scss' import './home.scss'
import { showLoading } from '../../util/hideShowLoading';
import { getGlobalStorage } from '../../util/getSetStoage';
@ -35,8 +37,8 @@ class Home extends Component {
otherData: [], // 底部导航栏 otherData: [], // 底部导航栏
isOpen: false, // 抢单消息提示 isOpen: false, // 抢单消息提示
grabOrderId: '',//抢到订单的id grabOrderId: '',//抢到订单的id
userName: Taro.getStorageSync('user_identity').userName || '',//用户名字 userName: '',//用户名字
userPhone: Taro.getStorageSync('user_identity').userPhone || '',// 用户电话 userPhone: '',// 用户电话
isShowTopNav: false,// 是否显示返回顶部按钮 isShowTopNav: false,// 是否显示返回顶部按钮
loadMorePageIndex: 1,//下拉加载页面数 loadMorePageIndex: 1,//下拉加载页面数
isAddToList: false, isAddToList: false,
@ -50,7 +52,7 @@ class Home extends Component {
} }
// onPullDownRefresh() { // onPullDownRefresh() {
// Taro.showLoading({ title: '加载中' }) // showLoading({ title: '加载中' })
// this.login().then(() => { // this.login().then(() => {
// this.getShops({}) // this.getShops({})
@ -112,6 +114,7 @@ class Home extends Component {
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
} }
}) })
.then(res => { .then(res => {
@ -144,13 +147,11 @@ class Home extends Component {
) )
} }
getUserLocation() { getUserLocation() {
if (process.env.TARO_ENV === 'alipay') { if (process.env.TARO_ENV === 'alipay') {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
my.getLocation({ my.getLocation({
success(res) { success(res) {
my.hideLoading(); my.hideLoading();
resolve(res) resolve(res)
}, },
fail(res) { fail(res) {
@ -161,30 +162,23 @@ class Home extends Component {
}) })
}) })
} else if (process.env.TARO_ENV === 'weapp') {
return new Promise((resolve, reject) => {
Taro.getLocation({
} else if (process.env.TARO_ENV === 'weapp') { type: 'wgs84', // 返回可以用于wx.openLocation的经纬度
return new Promise((resolve, reject) => { success(res) {
Taro.getLocation({ resolve(res)
type: 'wgs84', // 返回可以用于wx.openLocation的经纬度 },
success(res) { fail(res) {
resolve(res) Taro.showToast({
}, title: '获取定位失败',
fail(res) { icon: 'none'
Taro.showToast({ })
title: '获取定位失败', reject(res)
icon: 'none' }
}) })
reject(res)
}
}) })
}
})
}
} }
@ -241,7 +235,7 @@ class Home extends Component {
onClickParentCate(e) { onClickParentCate(e) {
const item = onClickValueService(e) const item = onClickValueService(e)
Taro.showLoading({ showLoading({
title: '加载中' title: '加载中'
}) })
this.setState({ parentClass: item.class_id, childClass: item.class_id, supplyLevel: 1, subCate: item.children || [] }, () => { this.setState({ parentClass: item.class_id, childClass: item.class_id, supplyLevel: 1, subCate: item.children || [] }, () => {
@ -251,7 +245,7 @@ class Home extends Component {
// 点击子类 // 点击子类
clickChildCateHanlder(e) { clickChildCateHanlder(e) {
const item = onClickValueService(e) const item = onClickValueService(e)
Taro.showLoading({ showLoading({
title: '加载中' title: '加载中'
}) })
this.setState({ childClass: item.class_id, supplyLevel: 2 }, () => { this.setState({ childClass: item.class_id, supplyLevel: 2 }, () => {
@ -299,8 +293,6 @@ class Home extends Component {
this.GrabDemand({ demandId: this.state.grabOrderId }) this.GrabDemand({ demandId: this.state.grabOrderId })
} }
goToMyNeedsPublish() { goToMyNeedsPublish() {
// 传参数给myNeedsPublish页面- 显示效果图选项 // 传参数给myNeedsPublish页面- 显示效果图选项
Taro.navigateTo({ Taro.navigateTo({
@ -312,27 +304,23 @@ class Home extends Component {
componentDidMount() { componentDidMount() {
// 页面加载后 得到首页的基本信息和推荐店铺的信息 // 页面加载后 得到首页的基本信息和推荐店铺的信息
showLoading({ title: '加载中' })
Taro.showLoading({ title: '加载中' })
// promise 返回经纬度给state 然后调用函数 // promise 返回经纬度给state 然后调用函数
this.getShops({})
this.getHomeCategoriesInfo()
Taro.getStorageSync('userInfo').user_id ? true : weChatLogin()
this.getUserLocation().then(res => { this.getUserLocation().then(res => {
this.setState({ this.setState({
latitude: res.latitude, latitude: res.latitude,
longitude: res.longitude longitude: res.longitude
}, () => {
this.getShops({})
this.getHomeCategoriesInfo()
}) })
}).catch(err => { }).catch(err => {
this.getShops({}) Taro.showToast({
this.getHomeCategoriesInfo() title: '定位获取失败',
icon: 'none'
})
}) })
// 本地缓存没有userid时 从新登入
Taro.getStorageSync('userInfo').user_id ? true : weChatLogin()
} }
componentWillMount() { componentWillMount() {
@ -363,7 +351,7 @@ class Home extends Component {
} }
// 底部加载 // 底部加载
onReachBottom() { onReachBottom() {
Taro.showLoading({ showLoading({
title: '加载中' title: '加载中'
}) })
this.setState({ loadMorePageIndex: this.state.loadMorePageIndex + 1, isAddToList: true }, () => { this.setState({ loadMorePageIndex: this.state.loadMorePageIndex + 1, isAddToList: true }, () => {

View File

@ -9,7 +9,14 @@ $themeColor: #FF7142;
width: 100%; width: 100%;
} }
} }
.first-banner ,.third-banner{ .first-banner {
height:250px;
.banner-img{
height: 100%;
width: 100%;
}
}
.third-banner{
height:200px; height:200px;
.banner-img{ .banner-img{
height: 100%; height: 100%;

View File

@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components' import { View , Swiper, SwiperItem } from '@tarojs/components'
import { AtGrid, Swiper, SwiperItem } from 'taro-ui' import { AtGrid} from 'taro-ui'
import URL from '../../../serviceAPI.config' import URL from '../../../serviceAPI.config'
import './mainCateSlider.scss' import './mainCateSlider.scss'
@ -28,7 +28,6 @@ class MainCateSlider extends Component {
item.value = item.class_name item.value = item.class_name
return item return item
}) })
console.log('formatedData', formatedData)
return formatedData return formatedData
} }
render() { render() {

View File

@ -1,45 +1,40 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components' import { View, ScrollView } from '@tarojs/components'
import { AtGrid, Swiper, SwiperItem } from 'taro-ui'
import URL from '../../../serviceAPI.config'
import './subCateSlider.scss' import './subCateSlider.scss'
class SubCateSlider extends Component { class SubCateSlider extends Component {
passDataToParent(e) {
this.props.onClickChildCate(e)
}
passDataToParent(e) { render() {
const { subCateList } = this.props
const subCateElementsArray = subCateList.map((item, index) => {
return <View key={index} onClick={this.passDataToParent.bind(this, item)} className='view-item'>
<View className='text'>{item.class_name}</View>
</View>
})
this.props.onClickChildCate(e) return (
}
render() { <ScrollView
const { subCateList } = this.props className='scroll-view'
const subCateElementsArray = subCateList.map((item, index) => { scrollX
return <View key={index} onClick={this.passDataToParent.bind(this, item)} className='view-item'> scrollWithAnimation
<View className='text'>{item.class_name}</View> scrollTop='0'
</View> lowerThreshold='20'
}) upperThreshold='20'
style='white-space: nowrap;'
>
return ( {subCateElementsArray}
<ScrollView </ScrollView>
className='scroll-view' )
scrollX }
scrollWithAnimation
scrollTop='0'
lowerThreshold='20'
upperThreshold='20'
style='white-space: nowrap;'
>
{subCateElementsArray}
</ScrollView>
)
}
} }
export default SubCateSlider export default SubCateSlider

View File

@ -2,10 +2,12 @@
height:100%; height:100%;
padding:0px 0px; padding:0px 0px;
.view-item{ .view-item{
font-size: 25px;
width:150px; width:150px;
display:inline-block; display:inline-block;
text-align:center; text-align:center;
padding-bottom: 10px; padding-bottom: 10px;
border-bottom:2px solid #F2F2F2; border-bottom:2px solid #F2F2F2;
} }
} }

View File

@ -9,6 +9,7 @@ import './individualCenter.scss'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import onClickValueService from '../../util/onClickValueService'; import onClickValueService from '../../util/onClickValueService';
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
import { isUserLogin } from '../../util/checkLogin';
@ -18,6 +19,7 @@ class IndividualCenter extends Component {
navigationBarTitleText: '个人中心' navigationBarTitleText: '个人中心'
} }
constructor() { constructor() {
super(...arguments);
this.state = { this.state = {
client: [ client: [
{ {
@ -52,7 +54,7 @@ class IndividualCenter extends Component {
username: '', username: '',
avatar: '', avatar: '',
isShop: false, isShop: false,
vip_level:'' vip_level: ''
} }
} }
handlerGridClick(e) { handlerGridClick(e) {
@ -101,19 +103,25 @@ class IndividualCenter extends Component {
// }) // })
} }
getInfoFromStorage() { getInfoFromStorage() {
const username = getGlobalStorage('userInfo').login_name||'' const username = getGlobalStorage('userInfo').login_name || ''
const avatar = getGlobalStorage('userInfo').avatar||'' const avatar = getGlobalStorage('userInfo').avatar || ''
const vip_level=getGlobalStorage('userInfo').vip_name||'' const vip_level = getGlobalStorage('userInfo').vip_name || ''
const isShop = getGlobalStorage('shopInfo').shop_id ? true : false const isShop = getGlobalStorage('shopInfo').shop_id ? true : false
this.setState({ this.setState({
username, avatar, isShop,vip_level username, avatar, isShop, vip_level
}) })
} }
handleLogoutClick() { handleLogoutClick() {
Logout() Logout()
} }
componentDidMount() { componentDidMount() {
this.getInfoFromStorage() isUserLogin().then(res=>{
return res
}).then(res=>{
this.getInfoFromStorage()
})
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps) console.log(this.props, nextProps)
@ -122,17 +130,13 @@ class IndividualCenter extends Component {
componentWillUnmount() { } componentWillUnmount() { }
componentDidShow() { componentDidShow() {
if (!getGlobalStorage('userInfo').user_id) { isUserLogin()
console.log('login service')
LoginService()
return
}
} }
componentDidHide() { } componentDidHide() { }
render() { render() {
const { client, seller, username, avatar,vip_level, isShop } = this.state const { client, seller, username, avatar, vip_level, isShop } = this.state
return ( return (
<View className='individualCenter'> <View className='individualCenter'>
<View className='avatar'> <View className='avatar'>
@ -156,14 +160,14 @@ class IndividualCenter extends Component {
<View className='title'>我的足迹</View> */} <View className='title'>我的足迹</View> */}
</View> </View>
<AtList> <AtList>
<AtListItem hasBorder={false} title='业主中心' onClick={this.handlerTitleBarClick.bind(this)} extraText=''/> <AtListItem hasBorder={false} title='业主中心' onClick={this.handlerTitleBarClick.bind(this)} extraText='' />
</AtList> </AtList>
<AtGrid hasBorder={false} data={client} columnNum={4} onClick={this.handlerGridClick.bind(this)} /> <AtGrid hasBorder={false} data={client} columnNum={4} onClick={this.handlerGridClick.bind(this)} />
</View> </View>
{isShop ? <View className='seller-container'> {isShop ? <View className='seller-container'>
<AtList> <AtList>
<AtListItem hasBorder={false} title='店铺中心' onClick={this.handlerTitleBarClick.bind(this)} extraText=''/> <AtListItem hasBorder={false} title='店铺中心' onClick={this.handlerTitleBarClick.bind(this)} extraText='' />
</AtList> </AtList>
<AtGrid hasBorder={false} data={seller} columnNum={4} onClick={this.handlerGridClick.bind(this)} /> <AtGrid hasBorder={false} data={seller} columnNum={4} onClick={this.handlerGridClick.bind(this)} />
</View> : <View />} </View> : <View />}

View File

@ -11,6 +11,7 @@ class Login extends Component {
navigationBarTitleText: '登入' navigationBarTitleText: '登入'
} }
constructor() { constructor() {
super(...arguments);
this.state = { this.state = {
username: '', username: '',
password: '', password: '',
@ -31,9 +32,11 @@ class Login extends Component {
loginHandler() { loginHandler() {
if (this.state.username && this.state.password) { if (this.state.username && this.state.password) {
standardLogin(this.state.username, this.state.password).then(res => { standardLogin(this.state.username, this.state.password).then(res => {
Taro.reLaunch({ setTimeout(() => {
url: '/pages/home/home' Taro.reLaunch({
}) url: '/pages/home/home'
})
}, 1000);
}).catch(res => { }).catch(res => {
Taro.showToast({ Taro.showToast({
title: res.data.msg, title: res.data.msg,
@ -64,7 +67,7 @@ class Login extends Component {
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps) // console.log(this.props, nextProps)
} }
componentWillUnmount() { } componentWillUnmount() { }

View File

@ -1,8 +1,8 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Button, Input } from '@tarojs/components' import { View, Text, Button, Input, Picker } from '@tarojs/components'
import { AtInput, AtImagePicker, AtTextarea, Picker, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import { AtInput, AtImagePicker, AtTextarea, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import AliPictureUploadComponent from '../../component/aliPictureUploadComponent/aliPictureUploadComponent'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
@ -10,6 +10,8 @@ import URL from '../../serviceAPI.config'
import './myDemandSupplyEdit.scss' import './myDemandSupplyEdit.scss'
import loginExpired from '../../util/loginExpired'; import loginExpired from '../../util/loginExpired';
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading';
import platformChecker from '../../util/plaformChecker';
@ -32,6 +34,8 @@ class MyDemandSupplyEdit extends Component {
content: '', content: '',
pickerImageUrl: [], // 上传的图片 pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息 ImagesInfo: [],// 后台传回来的图片信息
initialImagesInfo: [],//初始化图片信息
initialImageURL: [],//初始化图片url
isFormCompleted: false, isFormCompleted: false,
isConfirmWindow: false,// 删除提示框 isConfirmWindow: false,// 删除提示框
demandSupplyId: '',// 供求id demandSupplyId: '',// 供求id
@ -42,12 +46,13 @@ class MyDemandSupplyEdit extends Component {
} }
//获取商品信息api GetProductInfo //获取商品信息api GetProductInfo
getSupplyDemandInfo() { getSupplyDemandInfo() {
let sdId = decodeURIComponent(this.$router.params.sdId)
Taro.request({ Taro.request({
url: URL.GetSupplyDemandInfo, url: URL.GetSupplyDemandInfo,
method: 'GET', method: 'GET',
dataType: 'json', dataType: 'json',
data: { data: {
sdID: this.$router.params.sdId, sdID: sdId,
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -73,14 +78,16 @@ class MyDemandSupplyEdit extends Component {
demandingSupplyStateSelected: selectedState, demandingSupplyStateSelected: selectedState,
pickerImageUrl: imageFile, pickerImageUrl: imageFile,
ImagesInfo: res.data.sdInfo.file_path, ImagesInfo: res.data.sdInfo.file_path,
initialImageURL: imageFile,
initialImagesInfo: res.data.sdInfo.file_path,
}) })
} else if (res.data.err_code === 88888) { } else if (res.data.err_code === 88888) {
loginExpired(res) loginExpired(res)
}else{ } else {
Taro.showToast({ Taro.showToast({
title:res.data.err_msg, title: res.data.err_msg,
icon:'none' icon: 'none'
}) })
} }
}) })
@ -97,7 +104,7 @@ class MyDemandSupplyEdit extends Component {
user_address = this.state.contactAddress, user_address = this.state.contactAddress,
sd_desc = this.state.content, sd_desc = this.state.content,
state = this.state.demandingSupplyStateSelected.id }) { state = this.state.demandingSupplyStateSelected.id }) {
let sd_id = decodeURIComponent(this.$router.params.sdId)
const file_path = []; const file_path = [];
this.state.ImagesInfo.forEach((item) => { this.state.ImagesInfo.forEach((item) => {
file_path.push({ file_path.push({
@ -114,7 +121,7 @@ class MyDemandSupplyEdit extends Component {
data: { data: {
action: 2, action: 2,
sdInfo: JSON.stringify({ sdInfo: JSON.stringify({
sd_id: this.$router.params.sdId, sd_id: sd_id,
sd_type: sd_type, sd_type: sd_type,
sd_title: sd_title, sd_title: sd_title,
user_name: user_name, user_name: user_name,
@ -149,7 +156,7 @@ class MyDemandSupplyEdit extends Component {
} else { } else {
Taro.redirectTo({ Taro.redirectTo({
url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面 url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面
}) })
} }
}, 1000); }, 1000);
}) })
@ -212,6 +219,13 @@ class MyDemandSupplyEdit extends Component {
}) })
} }
} }
// 从图片子组件获取信息
getImageDetails(value) {
this.setState({
ImagesInfo: value
})
}
// 删除我的供求api // 删除我的供求api
onDelete({ sdID = 0 }) { onDelete({ sdID = 0 }) {
Taro.request({ Taro.request({
@ -283,10 +297,9 @@ class MyDemandSupplyEdit extends Component {
saveButtonHandler() { saveButtonHandler() {
if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) { if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) {
Taro.showLoading({ title: '保存中' }).then(() => { showLoading({ title: '保存中' })
this.setState({ isSaveAndNew: false }, () => { this.setState({ isSaveAndNew: false }, () => {
this.uploadDemSup({}) this.uploadDemSup({})
})
}) })
} else { } else {
@ -301,11 +314,11 @@ class MyDemandSupplyEdit extends Component {
// 上传供求api // 上传供求api
saveAndNewButton() { saveAndNewButton() {
if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) { if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) {
Taro.showLoading({ title: '保存中' }).then(() => { showLoading({ title: '保存中' })
this.setState({ isSaveAndNew: true }, () => { this.setState({ isSaveAndNew: true }, () => {
this.uploadDemSup({}) this.uploadDemSup({})
})
}) })
} else { } else {
Taro.showToast({ Taro.showToast({
title: '请填写完表格', title: '请填写完表格',
@ -317,7 +330,7 @@ class MyDemandSupplyEdit extends Component {
goToMyDemSupPage() { goToMyDemSupPage() {
Taro.redirectTo({ Taro.redirectTo({
url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面 url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面
}) })
} }
deleteButtonHandler() { deleteButtonHandler() {
this.setState({ isConfirmWindow: true }) this.setState({ isConfirmWindow: true })
@ -336,7 +349,7 @@ class MyDemandSupplyEdit extends Component {
componentDidMount() { componentDidMount() {
// console.log('this.$router.params.sdId',this.$router.params.sdId) // console.log('this.$router.params.sdId',this.$router.params.sdId)
Taro.showLoading({ title: '加载中' }) showLoading({ title: '加载中' })
this.getSupplyDemandInfo() this.getSupplyDemandInfo()
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
@ -414,32 +427,44 @@ class MyDemandSupplyEdit extends Component {
<View className='title-box'> <View className='title-box'>
<Text className='title'><Text className='require'></Text>:</Text> <Text className='title'><Text className='require'></Text>:</Text>
</View> </View>
{platformChecker() ? <AtTextarea
<AtTextarea
value={this.state.contactAddress} value={this.state.contactAddress}
onChange={this.contactAddressChange.bind(this)} onChange={this.contactAddressChange.bind(this)}
maxlength='140' maxlength='140'
placeholder='联系地址' placeholder='联系地址'
/> /> : <View className='textarea-wrapper'>
<textarea className='text-area'
onInput={this.contactAddressChange.bind(this)}
value={this.state.contactAddress}
placeholder="联系地址"
maxlength='140' /></View>
}
</View> </View>
<View className='demanding-box'> <View className='demanding-box'>
<View className='title-box'> <View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='title'><Text className='require'>*</Text>:</Text>
</View> </View>
<AtTextarea {platformChecker() ? <AtTextarea
value={this.state.content} value={this.state.content}
onChange={this.contentChange.bind(this)} onChange={this.contentChange.bind(this)}
maxlength='140' maxlength='140'
placeholder='' placeholder=''
/> />: <View className='textarea-wrapper'>
<textarea className='text-area'
onInput={this.contentChange.bind(this)}
value={this.state.content}
placeholder=""
maxlength='140' /></View>
}
</View> </View>
<View className='img-box'> <View className='img-box'>
<View className='title-box'> <View className='title-box'>
<Text className='title'>需求图片:</Text> <Text className='title'>需求图片:</Text>
<View className='warn'>(最多4张)</View> <View className='warn'>(最多4张)</View>
</View> </View>
{platformChecker() ? <View className='img-container'>
<View className='img-container'>
<AtImagePicker <AtImagePicker
multiple multiple
showAddBtn={this.state.pickerImageUrl.length < 4} showAddBtn={this.state.pickerImageUrl.length < 4}
@ -448,8 +473,14 @@ class MyDemandSupplyEdit extends Component {
onFail={this.onFail.bind(this)} onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)} onImageClick={this.onImageClick.bind(this)}
/> />
</View> </View> : <AliPictureUploadComponent
maxLength={4}
isReceiveImageUrl={true}
initialImageURL={this.state.initialImageURL}
initialImagesInfo={this.state.initialImagesInfo}
url={URL.UploadDSPorductImage}
onGetImageDetails={this.getImageDetails.bind(this)}
/>}
</View> </View>
<View className='page-section'> <View className='page-section'>

View File

@ -77,3 +77,13 @@ $themeColor:#FF7142;
line-height:100rpx; line-height:100rpx;
} }
} }
.textarea-wrapper{
border-width: 1px;
border-style: solid;
border-color: rgb(214, 228, 239);
border-radius: 8px;
padding:5px;
.text-area{
height: 150px;
}
}

View File

@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Radio, Button, MovableArea, MovableView } from '@tarojs/components' import { View, Button, MovableArea, MovableView, CheckboxGroup, Checkbox ,Picker, Image , Text} from '@tarojs/components'
import { AtInput, Text, AtIcon, Picker, Image, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import { AtInput, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent' import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
@ -9,6 +9,7 @@ import './myGoodList.scss'
import loginExpired from '../../util/loginExpired'; import loginExpired from '../../util/loginExpired';
import onClickValueService from '../../util/onClickValueService'; import onClickValueService from '../../util/onClickValueService';
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
import platformChecker from '../../util/plaformChecker'
class MyGoodList extends Component { class MyGoodList extends Component {
@ -143,13 +144,14 @@ class MyGoodList extends Component {
'X-Requested-With': 'XMLHttpRequest' 'X-Requested-With': 'XMLHttpRequest'
} }
}).then(res => { }).then(res => {
const data = JSON.parse(res.data) Taro.hideLoading()
console.log('res',res)
const data = platformChecker()? JSON.parse(res.data):res.data
if (data.err_code === 88888) { if (data.err_code === 88888) {
loginExpired(data) loginExpired(data)
} else if (data.err_code != 10) { } else if (data.err_code != 10) {
console.log('我的商品列表', JSON.parse(res.data))
Taro.hideLoading()
if (data.goodsCount != '0' && data.goods.length) { if (data.goodsCount != '0' && data.goods.length) {
data.goods.forEach(item => { data.goods.forEach(item => {
item.checked = false item.checked = false
@ -309,7 +311,8 @@ class MyGoodList extends Component {
'X-Requested-With': 'XMLHttpRequest' 'X-Requested-With': 'XMLHttpRequest'
} }
}).then(res => { }).then(res => {
let responseData = JSON.parse(res.data) console.log('res',res)
let responseData = platformChecker()? JSON.parse(res.data):res.data
Taro.hideLoading() Taro.hideLoading()
if (responseData.err_code === 0) { if (responseData.err_code === 0) {
Taro.showToast({ Taro.showToast({
@ -338,10 +341,6 @@ class MyGoodList extends Component {
}) })
} }
// 搜索 // 搜索
searchButtonHandler() { searchButtonHandler() {
Taro.showLoading({ Taro.showLoading({
@ -494,11 +493,14 @@ class MyGoodList extends Component {
// 单个商品选择 // 单个商品选择
handleCheckChange(e) { handleCheckChange(e) {
//如果goodid 一样的那么checked 就取反 //如果goodid 一样的那么checked 就取反
console.log('clicke') // const id = onClickValueService(e)
const id = onClickValueService(e) const id = e.detail.value
const newMyGoodList = this.state.myGoodList.map((item) => { const newMyGoodList = this.state.myGoodList.map((item) => {
if (item.goods_id === id) { if (id.includes(item.goods_id)) {
item['checked'] = !item.checked item['checked'] = true
} else {
item['checked'] = false
} }
return item return item
}) })
@ -518,9 +520,6 @@ class MyGoodList extends Component {
duration: 1500 duration: 1500
}) })
// // this.deleteGood({ goodsID: checkedGoodsId }) // // this.deleteGood({ goodsID: checkedGoodsId })
} }
// 改变商品状态 // 改变商品状态
offStockGoodHandler() { offStockGoodHandler() {
@ -539,11 +538,11 @@ class MyGoodList extends Component {
} }
// 导航到商品编辑页面myGoodsEdit // 导航到商品编辑页面myGoodsEdit
goToGoodEditPage(e) { goToGoodEditPage(e) {
console.log('e',e)
const goodId = onClickValueService(e) const goodId = onClickValueService(e)
console.log('goodId',goodId) const id=encodeURIComponent(goodId)
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/myGoodsEdit/myGoodsEdit?id=' + goodId url: '/pages/myGoodsEdit/myGoodsEdit?id=' + id
}) })
} }
// 导航到商品发布页面 // 导航到商品发布页面
@ -555,8 +554,9 @@ class MyGoodList extends Component {
} }
goToGoodspage(e) { goToGoodspage(e) {
const goodId = onClickValueService(e) const goodId = onClickValueService(e)
const id=encodeURIComponent(goodId)
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/goods/goods?id=' + goodId url: '/pages/goods/goods?id=' + id
}) })
} }
@ -662,7 +662,7 @@ class MyGoodList extends Component {
const goodListElementArray = this.state.myGoodList.map((item, index) => { const goodListElementArray = this.state.myGoodList.map((item, index) => {
return <View key={index} className='good-container'> return <View key={index} className='good-container'>
<View className='good-container-a'> <View className='good-container-a'>
<Radio className='radio' value={item.goods_id} checked={item.checked} onClick={this.handleCheckChange.bind(this, item.goods_id)} ></Radio> <Checkbox className='radio' value={item.goods_id} checked={item.checked} ></Checkbox >
<View className='img-box' onClick={this.goToGoodspage.bind(this, item.goods_id)}> <View className='img-box' onClick={this.goToGoodspage.bind(this, item.goods_id)}>
{/* <Image mode='aspectFit' className='img' style='height:50px;width:50px' src={URL.Base + item.goods_url} /> */} {/* <Image mode='aspectFit' className='img' style='height:50px;width:50px' src={URL.Base + item.goods_url} /> */}
<Image className='img' style='height:100%;width:100%' src={URL.Base + item.goods_url} /> <Image className='img' style='height:100%;width:100%' src={URL.Base + item.goods_url} />
@ -818,19 +818,23 @@ class MyGoodList extends Component {
</View> </View>
<View className='sub-filter'> <View className='sub-filter'>
<Radio className='radio' checked={this.state.isCheckAll} onClick={this.checkAllHandler.bind(this)}>全选</Radio> <CheckboxGroup className='align-item' onChange={this.checkAllHandler.bind(this)}>
<View className='button' onClick={this.deleteGoodsHandler.bind(this)}> <Checkbox className='radio' checked={this.state.isCheckAll} >全选</Checkbox>
</CheckboxGroup>
<View className='button align-item' onClick={this.deleteGoodsHandler.bind(this)}>
<Button size='mini' className='button-dark-red'> <Button size='mini' className='button-dark-red'>
删除</Button> 删除</Button>
</View> </View>
<View className='button' onClick={this.offStockGoodHandler.bind(this)}> <View className='button align-item' onClick={this.offStockGoodHandler.bind(this)}>
<Button size='mini' className='button-blue'> <Button size='mini' className='button-blue'>
下架</Button> 下架</Button>
</View> </View>
</View> </View>
</View> </View>
{this.state.myGoodList.length ? <View className='mygoodlist-container'> {this.state.myGoodList.length ? <View className='mygoodlist-container'>
{goodListElementArray} <CheckboxGroup onChange={this.handleCheckChange.bind(this)}>
{goodListElementArray}
</CheckboxGroup>
</View > : <View className='no-more-title'> </View>} </View > : <View className='no-more-title'> </View>}
{this.state.isShowTopNav ? <ScrollToTopComponent ></ScrollToTopComponent> : null} {this.state.isShowTopNav ? <ScrollToTopComponent ></ScrollToTopComponent> : null}
@ -839,9 +843,9 @@ class MyGoodList extends Component {
<CopyrightComponent></CopyrightComponent> <CopyrightComponent></CopyrightComponent>
</View> </View>
<MovableView className='movable-point' x={this.state.screenWidth} y={this.state.screenHeight} style='opacity:0.3' direction='all' onClick={this.goToCenterPage.bind(this)} > <MovableView className='movable-point' x={this.state.screenWidth} y={this.state.screenHeight} style='opacity:0.3' direction='all'>
个人中心 <View onClick={this.goToCenterPage.bind(this)}> 个人中心</View>
</MovableView> </MovableView>
</MovableArea> </MovableArea>
) )

View File

@ -17,6 +17,10 @@ $themeColor:#FF7142;
opacity:1 ; opacity:1 ;
position:fixed; position:fixed;
} }
.align-item{
display: flex;
align-items: center;
}
.MyGoodList{ .MyGoodList{
padding: 10px 20px; padding: 10px 20px;
.filterbar-container{ .filterbar-container{

View File

@ -1,14 +1,18 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components' import { View, Text, Button } from '@tarojs/components'
import { AtInput, AtImagePicker, AtTextarea, Button, } from 'taro-ui' import { AtInput, AtTextarea, AtImagePicker } from 'taro-ui'
import ShopTypeInteractionComp from '../../component/shopTypeInteractionComp/shopTypeInteractionComp' import ShopTypeInteractionComp from '../../component/shopTypeInteractionComp/shopTypeInteractionComp'
import AliShopTypeInteraction from '../../component/AliShopTypeInteraction/AliShopTypeInteraction'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import AliPictureUploadComponent from '../../component/aliPictureUploadComponent/aliPictureUploadComponent'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import './myGoodsEdit.scss' import './myGoodsEdit.scss'
import loginExpired from '../../util/loginExpired'; import loginExpired from '../../util/loginExpired';
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading';
import platformChecker from '../../util/plaformChecker';
class MyGoodsEdit extends Component { class MyGoodsEdit extends Component {
config = { config = {
@ -24,6 +28,8 @@ class MyGoodsEdit extends Component {
productDescript: '', productDescript: '',
pickerImageUrl: [], // 上传的图片 pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息 ImagesInfo: [],// 后台传回来的图片信息
initialImagesInfo: [],//初始化图片信息
initialImageURL: [],//初始化图片url
goodsTypeParam: '',//商品分类参数 goodsTypeParam: '',//商品分类参数
goodId: '',//商品id goodId: '',//商品id
isSaveButton: false,//是否点击了保存按钮 isSaveButton: false,//是否点击了保存按钮
@ -33,12 +39,13 @@ class MyGoodsEdit extends Component {
//获取商品信息api GetProductInfo //获取商品信息api GetProductInfo
getGoodsInfo() { getGoodsInfo() {
let goodsID = decodeURIComponent(this.$router.params.id)
Taro.request({ Taro.request({
url: URL.GetProductInfo, url: URL.GetProductInfo,
method: 'GET', method: 'GET',
dataType: 'json', dataType: 'json',
data: { data: {
goodsID: this.$router.params.id, goodsID: goodsID,
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -48,25 +55,27 @@ class MyGoodsEdit extends Component {
}) })
.then(res => { .then(res => {
Taro.hideLoading() Taro.hideLoading()
if (res.data.err_code === 0) { if (res.data.err_code === 0) {
console.log('商品详情获取成功', res) console.log('商品详情获取成功', res)
const imageFile = res.data.goodsFiles.map((item) => { const imageFile = res.data.goodsFiles.map((item) => {
return { url: URL.Base + item.files.file_path } return { url: URL.Base + item.files.file_path }
}) })
// let shopTypeSelected let shopTypeSelected
// const shopTypeId = res.data.goods.shop_class_id const shopTypeId = res.data.goods.shop_class_id
// for (let key in this.state.shopTypeList) { for (let key in this.state.shopTypeList) {
// for (let item of this.state.shopTypeList[key].c) { for (let item of this.state.shopTypeList[key].c) {
// if (item.id === shopTypeId) { if (item.id === shopTypeId) {
// shopTypeSelected = { name: item.n, id: item.id } shopTypeSelected = { name: item.n, id: item.id }
// } }
// } }
// } }
if (getGlobalStorage('shopTypeObject')) { if (getGlobalStorage('shopTypeObject')) {
let selectedValue = '' let selectedValue = ''
const shopTypeObject = getGlobalStorage('shopTypeObject') const shopTypeObject = getGlobalStorage('shopTypeObject')
console.log('shopTypeObject', shopTypeObject)
for (let key in shopTypeObject) { for (let key in shopTypeObject) {
for (let item of shopTypeObject[key].c) { for (let item of shopTypeObject[key].c) {
if (item.id === res.data.goods.shop_class_id) { if (item.id === res.data.goods.shop_class_id) {
@ -81,6 +90,8 @@ class MyGoodsEdit extends Component {
productDescript: res.data.goods.goods_profiles, productDescript: res.data.goods.goods_profiles,
pickerImageUrl: imageFile, pickerImageUrl: imageFile,
ImagesInfo: res.data.goodsFiles, ImagesInfo: res.data.goodsFiles,
initialImageURL: imageFile,
initialImagesInfo: res.data.goodsFiles,
shopTypeSelected: selectedValue, shopTypeSelected: selectedValue,
goodsTypeParam: res.data.goods.class_id, goodsTypeParam: res.data.goods.class_id,
goodId: res.data.goods.goods_id, goodId: res.data.goods.goods_id,
@ -173,14 +184,14 @@ class MyGoodsEdit extends Component {
}).then(() => { }).then(() => {
setTimeout(() => { setTimeout(() => {
if (this.state.isSaveButton) { if (this.state.isSaveButton) {
// Taro.navigateBack({ // Taro.navigateBack({
// delta:1 // delta:1
// url: '/pages/myGoodsList/myGoodsEdit?id=' + this.$router.params.id // url: '/pages/myGoodsList/myGoodsEdit?id=' + this.$router.params.id
// }) // })
Taro.redirectTo({ Taro.redirectTo({
url: '/pages/myGoodList/myGoodList' url: '/pages/myGoodList/myGoodList'
}) })
} else if (this.state.isSaveAndNewBUtton) { } else if (this.state.isSaveAndNewBUtton) {
Taro.switchTab({ Taro.switchTab({
url: '/pages/goodsPublish/goodsPublish' url: '/pages/goodsPublish/goodsPublish'
@ -286,6 +297,12 @@ class MyGoodsEdit extends Component {
} }
} }
// 从图片子组件获取信息
getImageDetails(value) {
this.setState({
ImagesInfo: value
})
}
shopCategoryChanged(e) { shopCategoryChanged(e) {
this.setState({ this.setState({
shopCategoryCheckedPicker: this.state.shopCategoryList[e.detail.value] shopCategoryCheckedPicker: this.state.shopCategoryList[e.detail.value]
@ -296,20 +313,20 @@ class MyGoodsEdit extends Component {
// 保存按钮 // 保存按钮
saveButtonHandler() { saveButtonHandler() {
if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopTypeSelected.id) { if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopTypeSelected.id) {
Taro.showLoading({ title: '保存中' }).then(() => { showLoading({ title: '保存中' })
this.setState({ isSaveButton: true }, () => { this.setState({ isSaveButton: true }, () => {
this.uploadGoods({ this.uploadGoods({
goods_name: this.state.productName, goods_name: this.state.productName,
goods_price: this.state.productPrice, goods_price: this.state.productPrice,
goods_unit: this.state.productUnit, goods_unit: this.state.productUnit,
goods_profiles: this.state.productDescript, goods_profiles: this.state.productDescript,
shop_class_id: this.state.shopTypeSelected.id, shop_class_id: this.state.shopTypeSelected.id,
class_id: this.state.goodsTypeParam, class_id: this.state.goodsTypeParam,
goods_id: this.state.goodId, goods_id: this.state.goodId,
})
}) })
}) })
} else { } else {
Taro.showToast({ Taro.showToast({
title: '请填写完表格', title: '请填写完表格',
@ -322,21 +339,21 @@ class MyGoodsEdit extends Component {
// 保存并新增按钮 // 保存并新增按钮
saveAndNewButton() { saveAndNewButton() {
if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopTypeSelected.id) { if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopTypeSelected.id) {
Taro.showLoading({ title: '保存中' }).then(() => { showLoading({ title: '保存中' })
this.setState({ isSaveAndNewBUtton: true }, () => { this.setState({ isSaveAndNewBUtton: true }, () => {
this.uploadGoods({ this.uploadGoods({
goods_name: this.state.productName, goods_name: this.state.productName,
goods_price: this.state.productPrice, goods_price: this.state.productPrice,
goods_unit: this.state.productUnit, goods_unit: this.state.productUnit,
goods_profiles: this.state.productDescript, goods_profiles: this.state.productDescript,
shop_class_id: this.state.shopTypeSelected.id, shop_class_id: this.state.shopTypeSelected.id,
class_id: this.state.goodsTypeParam, class_id: this.state.goodsTypeParam,
goods_id: this.state.goodId, goods_id: this.state.goodId,
})
}) })
}) })
} else { } else {
Taro.showToast({ Taro.showToast({
title: '请填写完表格', title: '请填写完表格',
@ -348,8 +365,9 @@ class MyGoodsEdit extends Component {
} }
goToGoodsDetailPage() { goToGoodsDetailPage() {
let goodsID = encodeURIComponent(this.$router.params.id)
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/goods/goods?id=' + this.$router.params.id url: '/pages/goods/goods?id=' + goodsID
}) })
} }
goToMyGoodListPage() { goToMyGoodListPage() {
@ -362,18 +380,16 @@ class MyGoodsEdit extends Component {
console.log('从子组件店铺分类传回来的值', value) console.log('从子组件店铺分类传回来的值', value)
this.setState({ shopTypeSelected: value }) this.setState({ shopTypeSelected: value })
} }
componentDidMount() { componentDidMount() {
Taro.showLoading({ showLoading({
title:'加载中' title: '加载中'
}) })
this.getGoodsInfo() this.getGoodsInfo()
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
// console.log(this.props, nextProps)
} }
componentWillUnmount() { } componentWillUnmount() { }
@ -384,8 +400,10 @@ class MyGoodsEdit extends Component {
render() { render() {
return ( return (
<View className='goods-publish'> <View className='goods-publish'>
<View className='goods-category'> <View className='goods-category'>
<View className='input-box'> <View className='input-box'>
<Text className='require'>*</Text> <Text className='require'>*</Text>
@ -429,7 +447,7 @@ class MyGoodsEdit extends Component {
<Text className='require'>*</Text> <Text className='require'>*</Text>
<Text className='title'>上传图片:</Text> <Text className='title'>上传图片:</Text>
</View> </View>
<View className='img-container'> {platformChecker() ? <View className='img-container'>
<AtImagePicker <AtImagePicker
multiple multiple
files={this.state.pickerImageUrl} files={this.state.pickerImageUrl}
@ -437,15 +455,31 @@ class MyGoodsEdit extends Component {
onFail={this.onFail.bind(this)} onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)} onImageClick={this.onImageClick.bind(this)}
/> />
</View> </View> : <AliPictureUploadComponent
maxLength={20}
isReceiveImageUrl={true}
initialImageURL={this.state.initialImageURL}
initialImagesInfo={this.state.initialImagesInfo}
url={URL.UploadGoodsPorductImage}
onGetImageDetails={this.getImageDetails.bind(this)}
/>}
</View> </View>
{/* 店铺分类 */} {/* 店铺分类 */}
<ShopTypeInteractionComp url={URL.GetShopCategoryList} {platformChecker() ?
shopId={getGlobalStorage('shopInfo').shop_id} <ShopTypeInteractionComp url={URL.GetShopCategoryList}
shopId={getGlobalStorage('shopInfo') ? getGlobalStorage('shopInfo').shop_id : ''}
selectedValue={this.state.shopTypeSelected}
onPassDataToChild={this.getDataFromShopChild.bind(this)
}></ShopTypeInteractionComp>
: <AliShopTypeInteraction url={URL.GetShopCategoryList}
shopId={getGlobalStorage('shopInfo') ? getGlobalStorage('shopInfo').shop_id : ''}
selectedValue={this.state.shopTypeSelected} selectedValue={this.state.shopTypeSelected}
onPassDataToChild={this.getDataFromShopChild.bind(this)} onPassDataToChild={this.getDataFromShopChild.bind(this)}
></ShopTypeInteractionComp> ></AliShopTypeInteraction>}
{/* 店铺分类结束 */} {/* 店铺分类结束 */}
<View className='description-box'> <View className='description-box'>
@ -453,13 +487,19 @@ class MyGoodsEdit extends Component {
<Text className='require'></Text> <Text className='require'></Text>
<Text className='title'>商品简介:</Text> <Text className='title'>商品简介:</Text>
</View> </View>
{platformChecker() ? <AtTextarea
<AtTextarea
value={this.state.productDescript} value={this.state.productDescript}
onChange={this.productDescriptChange.bind(this)} onChange={this.productDescriptChange.bind(this)}
maxlength='140' maxlength='140'
placeholder='你的产品简介' placeholder='你的产品简介'
/> /> : <View className='textarea-wrapper'>
<textarea className='text-area'
onInput={this.productDescriptChange.bind(this)}
value={this.state.contactAddress}
placeholder="你的产品简介"
maxlength='140' /></View>
}
</View> </View>
<View className='button-box' > <View className='button-box' >

View File

@ -7,21 +7,23 @@ $themeColor:#FF7142;
.border-box{ .border-box{
border-bottom: 1Px solid #d6e4ef; border-bottom: 1Px solid #d6e4ef;
} }
.at-input__container{ .at-input__container{
color:black; color:black;
font-weight: bold; font-weight: bold;
.at-input__input{ .at-input__input{
font-weight: normal font-weight: normal
} }
} }
.img-box{ .img-box{
margin-top:10Px; margin-top:10Px;
.img-container{ .img-container{
border: 1Px solid #d6e4ef; border: 1Px solid #d6e4ef;
border-radius:8rpx; border-radius:8rpx;
} }
} }
.shoptype-box{ .shoptype-box{
@ -29,6 +31,7 @@ $themeColor:#FF7142;
} }
.description-box{ .description-box{
margin-top:10Px; margin-top:10Px;
} }
} }
@ -97,9 +100,21 @@ $themeColor:#FF7142;
.input-box{ .input-box{
border-bottom: 1Px solid #d6e4ef; border-bottom: 1Px solid #d6e4ef;
display: flex; display: flex;
} }
.require{ .require{
color:red; color:red;
line-height:100rpx; line-height:100rpx;
} }
.textarea-wrapper{
border-width: 1px;
border-style: solid;
border-color: rgb(214, 228, 239);
border-radius: 8px;
padding:5px;
.text-area{
height: 150px;
}
}

View File

@ -1,10 +1,12 @@
//myNeeds //myNeeds
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Button } from '@tarojs/components' import { View, Text, Button, Picker, Input } from '@tarojs/components'
import { AtInput, Picker, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import { AtInput, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent' import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
import InteractionComponent from '../../component/interactionComponent/interactionComponent' import InteractionComponent from '../../component/interactionComponent/interactionComponent'
import AliIndustryTypeInteraction from '../../component/aliIndustryTypeInteraction/aliIndustryTypeInteraction'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import LoginService from '../../util/LoginService' import LoginService from '../../util/LoginService'
@ -12,6 +14,9 @@ import './myNeeds.scss'
import loginExpired from '../../util/loginExpired'; import loginExpired from '../../util/loginExpired';
import onClickValueService from '../../util/onClickValueService'; import onClickValueService from '../../util/onClickValueService';
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading';
import { isUserLogin } from '../../util/checkLogin';
import platformChecker from '../../util/plaformChecker';
class MyNeeds extends Component { class MyNeeds extends Component {
@ -185,21 +190,21 @@ class MyNeeds extends Component {
// 搜索按钮 // 搜索按钮
onSearchButtonHandler() { onSearchButtonHandler() {
Taro.showLoading({ title: '加载中' }).then(() => { showLoading({ title: '加载中' })
this.setState({ currentPage: 1, loadMorePageIndex: 1 }, () => { this.setState({ currentPage: 1, loadMorePageIndex: 1 }, () => {
this.getMyNeedsList({ this.getMyNeedsList({
curr_page: this.state.currentPage, curr_page: this.state.currentPage,
page_count: this.state.pageCount, page_count: this.state.pageCount,
sd_type: this.state.needsTypeSelected.id, sd_type: this.state.needsTypeSelected.id,
sd_title: this.state.title, sd_title: this.state.title,
update_dateL: this.state.startDateSel, update_dateL: this.state.startDateSel,
update_dateU: this.state.endDateSel, update_dateU: this.state.endDateSel,
class_id: this.state.industryTypeSelected.id === '-1' ? '' : this.state.industryTypeSelected.id, class_id: this.state.industryTypeSelected.id === '-1' ? '' : this.state.industryTypeSelected.id,
state: this.state.needsStateSelected.id state: this.state.needsStateSelected.id
})
}) })
}) })
} }
// 新增我的需求 // 新增我的需求
addNeeds() { addNeeds() {
@ -283,10 +288,15 @@ class MyNeeds extends Component {
componentDidMount() { componentDidMount() {
Taro.showLoading({ isUserLogin().then(res => {
title: '加载中' return res
}).then(res => {
showLoading({
title: '加载中'
})
this.getMyNeedsList({})
}) })
this.getMyNeedsList({})
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
@ -296,10 +306,7 @@ class MyNeeds extends Component {
componentWillUnmount() { } componentWillUnmount() { }
componentDidShow() { componentDidShow() {
if (!getGlobalStorage('userInfo').user_id) { isUserLogin()
LoginService()
return
}
} }
componentDidHide() { } componentDidHide() { }
@ -314,7 +321,7 @@ class MyNeeds extends Component {
} }
// 底部加载 // 底部加载
onReachBottom() { onReachBottom() {
Taro.showLoading({ showLoading({
title: '加载中' title: '加载中'
}) })
this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => { this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => {
@ -382,12 +389,13 @@ class MyNeeds extends Component {
title='需求标题:' title='需求标题:'
placeholder='需求标题·' placeholder='需求标题·'
type='text' type='text'
border={false}
value={this.state.title} value={this.state.title}
onChange={this.titleChange.bind(this)} onChange={this.titleChange.bind(this)}
/> />
</View> </View>
{/* 开始和结束日期 */} {/* 开始和结束日期 */}
<View className='page-section'> <View className='page-section-picker'>
<View className='picker-box'> <View className='picker-box'>
<View className='picker-wrapper'> <View className='picker-wrapper'>
<Picker mode='date' className='picker-container' onChange={this.onStartDateChange}> <Picker mode='date' className='picker-container' onChange={this.onStartDateChange}>
@ -411,7 +419,14 @@ class MyNeeds extends Component {
</View> </View>
</View> </View>
{/* 行业分类开始 */} {/* 行业分类开始 */}
<InteractionComponent url={URL.GetIndustryTypeList} onPassDataToChild={this.getDataFromChild.bind(this)} selectedValue={this.state.industryTypeSelected}></InteractionComponent> {/* 行业分类 */}
{platformChecker() ? <View className='InteractionComponent-wrapper'>
<InteractionComponent url={URL.GetIndustryTypeList} onPassDataToChild={this.getDataFromChild.bind(this)} selectedValue={this.state.industryTypeSelected}></InteractionComponent>
</View> : <AliIndustryTypeInteraction url={URL.GetIndustryTypeList}
onPassDataToChild={this.getDataFromChild.bind(this)}
selectedValue={this.state.industryTypeSelected} />}
{/* 行业分类结束 */} {/* 行业分类结束 */}
{/* 需求类型 */} {/* 需求类型 */}
<View className='page-section'> <View className='page-section'>

View File

@ -64,6 +64,47 @@ $themeColor:#FF7142;
margin-left: 10% margin-left: 10%
} }
}
}
}
.page-section-picker{
.picker{
// padding: 24rpx 0;
.selected{
font-weight: normal;
display: inline-block;
margin-left: 20%;
font-size: 32rpx
}
.date{
margin-left: 0%
}
.title-box{
line-height:100rpx;
font-weight: bold;
.title{
//color: #333;
line-height:100rpx;
margin-right:16rpx;
width:172rpx;
font-size:32rpx;
vertical-align:middle;
text-align:left;
font-weight: bold;
}
.first-col{
font-weight: normal;
margin-left: 10%
}
.second-col{
font-weight: normal;
display: inline-block;
margin-left: 10%
}
} }
} }
} }
@ -102,7 +143,6 @@ $themeColor:#FF7142;
} }
.info-box{ .info-box{
.needs-box{ .needs-box{
margin-top: 10px; margin-top: 10px;
border: 3rpx solid #ddd; border: 3rpx solid #ddd;

View File

@ -1,14 +1,18 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Button, Input } from '@tarojs/components' import { View, Text, Button, Input, Picker } from '@tarojs/components'
import { AtInput, AtImagePicker, AtTextarea, Picker, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import { AtInput, AtTextarea, AtModal, AtModalHeader, AtModalContent, AtModalAction, AtImagePicker } from 'taro-ui'
import InteractionComponent from '../../component/interactionComponent/interactionComponent' import InteractionComponent from '../../component/interactionComponent/interactionComponent'
import AliIndustryTypeInteraction from '../../component/aliIndustryTypeInteraction/aliIndustryTypeInteraction'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import AliPictureUploadComponent from '../../component/aliPictureUploadComponent/aliPictureUploadComponent'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import './myNeedsEdit.scss' import './myNeedsEdit.scss'
import loginExpired from '../../util/loginExpired'; import loginExpired from '../../util/loginExpired';
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading';
import platformChecker from '../../util/plaformChecker';
class MyNeedsEdit extends Component { class MyNeedsEdit extends Component {
@ -34,9 +38,10 @@ class MyNeedsEdit extends Component {
contactAddress: '', contactAddress: '',
content: '',//描述 content: '',//描述
pickerImageUrl: [], pickerImageUrl: [],
ImagesInfo: '', ImagesInfo: [],// 图片详细信息
initialImagesInfo: [],//初始化图片信息
initialImageURL: [],//初始化图片url
isDeleteModal: false,// 删除提示框 isDeleteModal: false,// 删除提示框
isSaveAndNew: false,//是否点击保存新增按钮 isSaveAndNew: false,//是否点击保存新增按钮
@ -44,12 +49,13 @@ class MyNeedsEdit extends Component {
} }
//获取需求信息api //获取需求信息api
getMyNeedEditInfo() { getMyNeedEditInfo() {
let id = decodeURIComponent(this.$router.params.id)
Taro.request({ Taro.request({
url: URL.EditMyNeeds, url: URL.EditMyNeeds,
method: 'GET', method: 'GET',
dataType: 'json', dataType: 'json',
data: { data: {
demandId: this.$router.params.id, demandId: id,
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -102,13 +108,15 @@ class MyNeedsEdit extends Component {
contactAddress: res.data.sdInfo.user_address, contactAddress: res.data.sdInfo.user_address,
content: res.data.sdInfo.sd_desc, content: res.data.sdInfo.sd_desc,
needsStateSelected: needsState, needsStateSelected: needsState,
initialImageURL: imageFile,
initialImagesInfo: res.data.sdInfo.file_path,
pickerImageUrl: imageFile, pickerImageUrl: imageFile,
ImagesInfo: res.data.sdInfo.file_path, ImagesInfo: res.data.sdInfo.file_path,
}) })
}else if (JSON.parse(res.data).err_code === 88888) { } else if (JSON.parse(res.data).err_code === 88888) {
loginExpired(res) loginExpired(res)
} else { } else {
Taro.showToast({ Taro.showToast({
title: JSON.parse(res.data).err_msg, title: JSON.parse(res.data).err_msg,
icon: 'none' icon: 'none'
@ -119,8 +127,6 @@ class MyNeedsEdit extends Component {
) )
} }
// uploadMyNeedsApi 上传需求 的api // uploadMyNeedsApi 上传需求 的api
uploadMyNeedsApi() { uploadMyNeedsApi() {
@ -185,9 +191,9 @@ class MyNeedsEdit extends Component {
} }
}, 1500); }, 1500);
}) })
}else if (res.data.err_code === 88888) { } else if (res.data.err_code === 88888) {
loginExpired(res) loginExpired(res)
} else { } else {
Taro.showToast({ Taro.showToast({
title: '保存失败', title: '保存失败',
icon: 'none', icon: 'none',
@ -199,51 +205,6 @@ class MyNeedsEdit extends Component {
} }
// 上传图片
onChangeImg(files, operationType, index) {
const that = this
if (operationType === 'add') {
Taro.uploadFile({
url: URL.UploadDSPorductImage,
filePath: files[files.length - 1].url,
name: 'file',
header: {
'content-type': 'multipart/form-data',
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
'X-Requested-With': 'XMLHttpRequest'
},
success(response) {
const data = JSON.parse(response.data)
const imagePath = URL.Base + data.file_path
const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath })
const newImageInfo = that.state.ImagesInfo.concat(data)
that.setState({
pickerImageUrl: newPickerImageUrl,
ImagesInfo: newImageInfo
})
Taro.showToast({
title: '上传成功',
icon: 'success',
duration: 1500
})
}
})
}
if (operationType === 'remove') {
this.state.ImagesInfo.splice(index, 1) // 删除显示的图片
this.state.pickerImageUrl.splice(index, 1)// 删除图片param
that.setState({
pockerImageUrl: this.state.pickerImageUrl,
ImagesInfo: this.state.ImagesInfo,
})
Taro.showToast({
title: '删除成功',
icon: 'success',
duration: 1500
})
}
}
//删除我的需求 api DeleteMyNeeds //删除我的需求 api DeleteMyNeeds
deleteMyNeeds({ demandId = 10 }) { deleteMyNeeds({ demandId = 10 }) {
Taro.request({ Taro.request({
@ -274,9 +235,9 @@ class MyNeedsEdit extends Component {
}) })
}, 1000); }, 1000);
}else if (res.data.err_code === 88888) { } else if (res.data.err_code === 88888) {
loginExpired(res) loginExpired(res)
} else { } else {
Taro.showToast({ Taro.showToast({
title: res.data.err_msg, title: res.data.err_msg,
icon: 'none', icon: 'none',
@ -326,7 +287,7 @@ class MyNeedsEdit extends Component {
this.state.contactName this.state.contactName
&& this.state.contactNumber && this.state.contactNumber
&& this.state.content && this.state.needsStateSelected) { && this.state.content && this.state.needsStateSelected) {
Taro.showLoading({ showLoading({
title: '保存中' title: '保存中'
}) })
this.setState({ isSaveAndNew: false }, () => { this.setState({ isSaveAndNew: false }, () => {
@ -340,13 +301,64 @@ class MyNeedsEdit extends Component {
}) })
} }
} }
// 上传图片
onChangeImg(files, operationType, index) {
const that = this
if (operationType === 'add') {
Taro.uploadFile({
url: URL.UploadDSPorductImage,
filePath: files[files.length - 1].url,
name: 'file',
header: {
'content-type': 'multipart/form-data',
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
'X-Requested-With': 'XMLHttpRequest'
},
success(response) {
const data = JSON.parse(response.data)
const imagePath = URL.Base + data.file_path
const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath })
const newImageInfo = that.state.ImagesInfo.concat(data)
that.setState({
pickerImageUrl: newPickerImageUrl,
ImagesInfo: newImageInfo
})
Taro.showToast({
title: '上传成功',
icon: 'success',
duration: 1500
})
}
})
}
if (operationType === 'remove') {
this.state.ImagesInfo.splice(index, 1) // 删除显示的图片
this.state.pickerImageUrl.splice(index, 1)// 删除图片param
that.setState({
pockerImageUrl: this.state.pickerImageUrl,
ImagesInfo: this.state.ImagesInfo,
})
Taro.showToast({
title: '删除成功',
icon: 'success',
duration: 1500
})
}
}
// 从图片子组件获取信息
getImageDetails(value) {
this.setState({
ImagesInfo: value
})
}
// 保存新增按钮 // 保存新增按钮
saveAndNewButton() { saveAndNewButton() {
if (this.state.title && if (this.state.title &&
this.state.contactName this.state.contactName
&& this.state.contactNumber && this.state.contactNumber
&& this.state.content && this.state.needsStateSelected) { && this.state.content && this.state.needsStateSelected) {
Taro.showLoading({ showLoading({
title: '保存中' title: '保存中'
}) })
this.setState({ isSaveAndNew: true }, () => { this.setState({ isSaveAndNew: true }, () => {
@ -406,131 +418,156 @@ class MyNeedsEdit extends Component {
<View className='supply-demand'> <View className='supply-demand'>
{deleteModalWindowElement} {deleteModalWindowElement}
{/* 行业分类 */} {/* 行业分类 */}
<InteractionComponent url={URL.GetIndustryTypeList} onPassDataToChild={this.getDataFromChild.bind(this)} selectedValue={this.state.industryTypeSelected} ></InteractionComponent> {platformChecker() ?
<InteractionComponent url={URL.GetIndustryTypeList} onPassDataToChild={this.getDataFromChild.bind(this)} selectedValue={this.state.industryTypeSelected} ></InteractionComponent>
: <AliIndustryTypeInteraction url={URL.GetIndustryTypeList} onPassDataToChild={this.getDataFromChild.bind(this)} selectedValue={this.state.industryTypeSelected} />}
{/* 需求类型 */} {/* 需求类型 */}
<View className='page-section'>
<View> <View className='page-section'>
<Picker mode='selector' rangeKey='name' range={this.state.needsType} onChange={this.needsTypeChange.bind(this)}> <View>
<View className='picker'> <Picker mode='selector' rangeKey='name' range={this.state.needsType} onChange={this.needsTypeChange.bind(this)}>
<View className='title-box'> <View className='picker'>
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.needsTypeSelected.name}</Text> <View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.needsTypeSelected.name}</Text>
</View>
</View> </View>
</Picker>
</View> </View>
</Picker>
</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} border={false}
border={false} onChange={this.titleChange.bind(this)}
onChange={this.titleChange.bind(this)}
/> />
</View>
<View className='input-box'>
<Text className='require'>*</Text>
<AtInput
name='value'
title='联系人:'
type='text'
value={this.state.contactName}
border={false}
onChange={this.contactNameChange.bind(this)}
/>
</View>
<View className='input-box' style='padding:24rpx 0;font-size:32rpx'>
<View className='title' style='font-weight:bold;'>
<Text style='color:red'>*</Text>
<Text>联系电话</Text>
</View> </View>
<View style='margin-left:5%;'> <View className='input-box'>
<Input name='value' <Text className='require'>*</Text>
maxLength='11' <AtInput
type='number' name='value'
value={this.state.contactNumber} title='联系人:'
onInput={this.contactNumberChange.bind(this)} type='text'
/></View> value={this.state.contactName}
</View> border={false}
onChange={this.contactNameChange.bind(this)}
<View className='demanding-box'>
<View className='title-box'>
<Text className='title'>联系地址:</Text>
</View>
<AtTextarea
value={this.state.contactAddress}
onChange={this.contactAddressChange.bind(this)}
maxlength='140'
placeholder='联系地址'
/>
</View>
<View className='demanding-box'>
<View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text>
</View>
<AtTextarea
value={this.state.content}
onChange={this.contentChange.bind(this)}
maxlength='140'
placeholder=''
/>
</View>
<View className='img-box'>
<View className='title-box'>
<Text className='title'>需求图片:</Text>
<View className='warn'>(最多4张)</View>
</View>
<View className='img-container'>
<AtImagePicker
multiple
showAddBtn={this.state.pickerImageUrl.length < 4}
files={this.state.pickerImageUrl}
onChange={this.onChangeImg.bind(this)}
onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)}
/> />
</View> </View>
<View className='input-box' style='padding:24rpx 0;font-size:32rpx'>
<View className='title' style='font-weight:bold;'>
<Text style='color:red'>*</Text>
<Text>联系电话</Text>
</View>
<View style='margin-left:5%;'>
<Input name='value'
maxLength='11'
type='number'
value={this.state.contactNumber}
onInput={this.contactNumberChange.bind(this)}
/></View>
</View>
</View> <View className='demanding-box'>
<View className='page-section'> <View className='title-box'>
<Text className='title'>联系地址:</Text>
</View>
{platformChecker() ? <AtTextarea
value={this.state.contactAddress}
onChange={this.contactAddressChange.bind(this)}
maxlength='140'
placeholder='联系地址'
/> : <View className='textarea-wrapper'>
<textarea className='text-area'
onInput={this.contactAddressChange.bind(this)}
value={this.state.contactAddress}
placeholder="联系地址"
maxlength='140' /></View>
}
</View>
<View className='demanding-box'>
<View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text>
</View>
{platformChecker() ?<AtTextarea
value={this.state.content}
onChange={this.contentChange.bind(this)}
maxlength='140'
placeholder=''
/> : <View className='textarea-wrapper'>
<textarea className='text-area'
onInput={this.contentChange.bind(this)}
value={this.state.content}
placeholder=""
maxlength='140' /></View>
}
</View>
<View className='img-box'>
<View className='title-box'>
<Text className='title'>需求图片:</Text>
<View className='warn'>(最多4张)</View>
</View>
{platformChecker() ? <View className='img-container'>
<AtImagePicker
multiple
showAddBtn={this.state.pickerImageUrl.length < 4}
files={this.state.pickerImageUrl}
onChange={this.onChangeImg.bind(this)}
onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)}
/>
</View> : <AliPictureUploadComponent
maxLength={4}
isReceiveImageUrl={true}
initialImageURL={this.state.initialImageURL}
initialImagesInfo={this.state.initialImagesInfo}
url={URL.UploadDSPorductImage}
onGetImageDetails={this.getImageDetails.bind(this)}
/>}
</View>
<View className='page-section'>
<View>
<Picker mode='selector' rangeKey='name' range={this.state.needsState} onChange={this.needsStateChange.bind(this)}>
<View className='picker'>
<View className='title-box'>
<Text className='title'> <Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.needsStateSelected.name}</Text>
</View>
<View>
<Picker mode='selector' rangeKey='name' range={this.state.needsState} onChange={this.needsStateChange.bind(this)}>
<View className='picker'>
<View className='title-box'>
<Text className='title'> <Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.needsStateSelected.name}</Text>
</View> </View>
</Picker>
</View> </View>
</Picker>
</View> </View>
</View>
<View className='button-box'> <View className='button-box'>
<View className='button' onClick={this.saveButtonHandler.bind(this)}> <View className='button' onClick={this.saveButtonHandler.bind(this)}>
<Button size='mini' className='button-orange'>保存</Button> <Button size='mini' className='button-orange'>保存</Button>
</View> </View>
{/* <View className='button' onClick={this.saveAndNewButton.bind(this)}> {/* <View className='button' onClick={this.saveAndNewButton.bind(this)}>
<Button size='mini' className='button-green'>保存并新增</Button> <Button size='mini' className='button-green'>保存并新增</Button>
</View> */} </View> */}
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}> <View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
<Button className='button-green' size='mini'>我的需求</Button> <Button className='button-green' size='mini'>我的需求</Button>
</View> </View>
{/* <View className='button' onClick={this.deleteButtonHandler.bind(this)}> {/* <View className='button' onClick={this.deleteButtonHandler.bind(this)}>
<Button className='button-dark-red' size='mini'>删除</Button> <Button className='button-dark-red' size='mini'>删除</Button>
</View> */} </View> */}
</View>
<CopyrightComponent></CopyrightComponent>
</View> </View>
<CopyrightComponent></CopyrightComponent>
</View>
) )
} }
} }

View File

@ -2,7 +2,6 @@ $themeColor:#FF7142;
.supply-demand{ .supply-demand{
padding: 10px 20px; padding: 10px 20px;
.border-box{ .border-box{
border-bottom: 1Px solid #d6e4ef; border-bottom: 1Px solid #d6e4ef;
display: flex display: flex
@ -77,3 +76,13 @@ $themeColor:#FF7142;
line-height:100rpx; line-height:100rpx;
} }
} }
.textarea-wrapper{
border-width: 1px;
border-style: solid;
border-color: rgb(214, 228, 239);
border-radius: 8px;
padding:5px;
.text-area{
height: 150px;
}
}

View File

@ -1,17 +1,22 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Button, Input } from '@tarojs/components' import { View, Text, Button, Input, Picker } from '@tarojs/components'
import { AtInput, AtImagePicker, AtTextarea, Picker } from 'taro-ui' import { AtInput, AtTextarea, AtImagePicker } from 'taro-ui'
import AliPictureUploadComponent from '../../component/aliPictureUploadComponent/aliPictureUploadComponent'
import AliIndustryTypeInteraction from '../../component/aliIndustryTypeInteraction/aliIndustryTypeInteraction'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import InteractionComponent from '../../component/interactionComponent/interactionComponent' import InteractionComponent from '../../component/interactionComponent/interactionComponent'
import LoginService from '../../util/LoginService'
import './myNeedsPublish.scss' import './myNeedsPublish.scss'
import loginExpired from '../../util/loginExpired'; import loginExpired from '../../util/loginExpired';
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading';
import { isUserLogin } from '../../util/checkLogin';
import platformChecker from '../../util/plaformChecker';
@ -29,14 +34,14 @@ class MyNeedsPublish extends Component {
needsType: [{ name: '业主需求', id: '4' }, { name: '效果图', id: '5' }], needsType: [{ name: '业主需求', id: '4' }, { name: '效果图', id: '5' }],
needsTypeSelected: { name: '业主需求', id: '4' }, needsTypeSelected: { name: '业主需求', id: '4' },
title: '', title: '',
contactName: getGlobalStorage('user_identity').username || '', contactName: '',
contactNumber: getGlobalStorage('user_identity').userphone || '', contactNumber: '',
contactAddress: '', contactAddress: '',
content: '', content: '',
pickerImageUrl: [], // 上传的图片 pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息 ImagesInfo: [],// 后台传回来的图片信息
isPublishAndNew: false,//是否点击发布新增按钮 isPublishAndNew: false,//是否点击发布新增按钮
} }
} }
@ -72,7 +77,6 @@ class MyNeedsPublish extends Component {
sd_desc: this.state.content, sd_desc: this.state.content,
state: this.state.needsStateSelected.id, state: this.state.needsStateSelected.id,
file_path: file_path, file_path: file_path,
}) })
}, },
header: { header: {
@ -82,36 +86,34 @@ class MyNeedsPublish extends Component {
} }
}) })
.then(response => { .then(response => {
console.log('上传需求', response) console.log('上传需求成功', response)
const res = response.data
const res = JSON.parse(response.data)
console.log('jonson parse', res)
Taro.hideLoading() Taro.hideLoading()
if (res.err_code === 0) { if (res.err_code === 0) {
console.log('error code 0')
Taro.showToast({ Taro.showToast({
title: '发布成功', title: '发布成功',
icon: 'success', icon: 'success',
duration: 1500 duration: 1500
}).then(() => {
setTimeout(() => {
if (this.state.isPublishAndNew) {
Taro.navigateTo({
url: '/pages/myNeedsPublish/myNeedsPublish'
})
} else {
Taro.navigateTo({
url: '/pages/myNeedsEdit/myNeedsEdit?id=' + res.sd_id
})
}
}, 1500);
}) })
setTimeout(() => {
console.log('settimeout')
if (this.state.isPublishAndNew) {
Taro.navigateTo({
url: '/pages/myNeedsPublish/myNeedsPublish'
})
} else {
Taro.navigateTo({
url: '/pages/myNeedsEdit/myNeedsEdit?id=' + res.sd_id
})
}
}, 1500);
} else if (res.err_code === 88888) { } else if (res.err_code === 88888) {
console.log('返回错误88888')
const resp = { data: { err_msg: res.err_msg } } const resp = { data: { err_msg: res.err_msg } }
console.log('resp',resp)
loginExpired(resp) loginExpired(resp)
} else { } else {
Taro.showToast({ Taro.showToast({
title: res.err_msg, title: res.err_msg,
icon: 'none', icon: 'none',
@ -121,12 +123,12 @@ class MyNeedsPublish extends Component {
} }
) )
} }
// 上传图片 // 上传图片
onChangeImg(files, operationType, index) { onChangeImg(files, operationType, index) {
const that = this const that = this
if (operationType === 'add') { if (operationType === 'add') {
Taro.uploadFile({ Taro.uploadFile({
url: URL.MyNeedUploadImage, url: URL.MyNeedUploadImage,
@ -200,6 +202,13 @@ class MyNeedsPublish extends Component {
contentChange(event) { contentChange(event) {
this.setState({ content: event.target.value }) this.setState({ content: event.target.value })
} }
// 从图片子组件获取信息
getImageDetails(value) {
this.setState({
ImagesInfo: value
})
}
// 发布按钮 // 发布按钮
publishButtonHandler() { publishButtonHandler() {
if (this.state.title && if (this.state.title &&
@ -207,7 +216,7 @@ class MyNeedsPublish extends Component {
&& this.state.contactNumber && this.state.contactNumber
&& this.state.content && this.state.needsStateSelected) { && this.state.content && this.state.needsStateSelected) {
Taro.showLoading({ showLoading({
title: '发布中' title: '发布中'
}) })
this.setState({ isPublishAndNew: false }, () => { this.setState({ isPublishAndNew: false }, () => {
@ -231,7 +240,7 @@ class MyNeedsPublish extends Component {
&& this.state.contactNumber && this.state.contactNumber
&& this.state.content && this.state.needsStateSelected) { && this.state.content && this.state.needsStateSelected) {
Taro.showLoading({ showLoading({
title: '发布中' title: '发布中'
}) })
this.setState({ isPublishAndNew: true }, () => { this.setState({ isPublishAndNew: true }, () => {
@ -259,11 +268,15 @@ class MyNeedsPublish extends Component {
componentDidMount() { componentDidMount() {
this.setState({
contactName: getGlobalStorage('user_identity') ? getGlobalStorage('user_identity').username : '',
contactNumber: getGlobalStorage('user_identity') ? getGlobalStorage('user_identity').userphone : '',
})
// console.log('this.$router.params.sdId',this.$router.params.sdId) // console.log('this.$router.params.sdId',this.$router.params.sdId)
// Taro.showLoading({title:'加载中'}) // Taro.showLoading({title:'加载中'})
// this.getSupplyDemandInfo() // this.getSupplyDemandInfo()
// 如果路由参数为1 就默认显示 效果图,反之 显示业主需求 // 如果路由参数为1 就默认显示 效果图,反之 显示业主需求
const isRenderingPic = this.$router.params.id const isRenderingPic = decodeURIComponent(this.$router.params.id)
if (parseInt(isRenderingPic)) { if (parseInt(isRenderingPic)) {
this.setState({ needsTypeSelected: { name: '效果图', id: '5' } }) this.setState({ needsTypeSelected: { name: '效果图', id: '5' } })
} }
@ -275,10 +288,7 @@ class MyNeedsPublish extends Component {
componentWillUnmount() { } componentWillUnmount() { }
componentDidShow() { componentDidShow() {
if (!getGlobalStorage('userInfo').user_id) { isUserLogin()
LoginService()
return
}
} }
componentDidHide() { } componentDidHide() { }
@ -288,131 +298,156 @@ class MyNeedsPublish extends Component {
<View className='supply-demand'> <View className='supply-demand'>
{/* 行业分类 */} {/* 行业分类 */}
<InteractionComponent url={URL.GetIndustryTypeList}
{platformChecker() ? <View className='InteractionComponent-wrapper'><InteractionComponent url={URL.GetIndustryTypeList}
onPassDataToChild={this.getDataFromChild.bind(this)} onPassDataToChild={this.getDataFromChild.bind(this)}
selectedValue={this.state.industryTypeSelected} selectedValue={this.state.industryTypeSelected}
></InteractionComponent> ></InteractionComponent></View> : <AliIndustryTypeInteraction url={URL.GetIndustryTypeList}
{/* 需求类型 */} onPassDataToChild={this.getDataFromChild.bind(this)}
<View className='page-section'> selectedValue={this.state.industryTypeSelected} />}
<View className='page-section'>
<View> <View>
<Picker mode='selector' rangeKey='name' range={this.state.needsType} onChange={this.needsTypeHandler.bind(this)}> <Picker mode='selector' rangeKey='name' range={this.state.needsType} onChange={this.needsTypeHandler.bind(this)}>
<View className='picker'> <View className='picker'>
<View className='title-box'> <View className='title-box'>
<Text className='title'>需求类型:</Text> <Text className='selected'>{this.state.needsTypeSelected.name}</Text> <Text className='title'>需求类型:</Text> <Text className='selected'>{this.state.needsTypeSelected.name}</Text>
</View> </View>
</View> </View>
</Picker> </Picker>
</View> </View>
</View> </View>
<View className='border-box'> <View className='border-box'>
<Text className='require'>*</Text> <Text className='require'>*</Text>
<AtInput <AtInput
name='value' name='value'
title='需求标题:' title='需求标题:'
type='text' type='text'
value={this.state.title} value={this.state.title}
border={false} border={false}
onChange={this.titleChange.bind(this)} onChange={this.titleChange.bind(this)}
/>
</View>
<View className='input-box'>
<Text className='require'>*</Text>
<AtInput
name='value'
title='联系人:'
type='text'
value={this.state.contactName}
border={false}
onChange={this.contactNameChange.bind(this)}
/>
</View>
<View className='input-box' style='padding:24rpx 0;font-size:32rpx'>
<View className='title' style='font-weight:bold;'>
<Text style='color:red'>*</Text>
<Text>联系电话</Text>
</View>
<View style='margin-left:5%;'>
<Input name='value'
maxLength='11'
type='number'
value={this.state.contactNumber}
onInput={this.contactNumberChange.bind(this)}
/></View>
</View>
<View className='demanding-box'>
<View className='title-box'>
<Text className='title'>联系地址:</Text>
</View>
<AtTextarea
value={this.state.contactAddress}
onChange={this.contactAddressChange.bind(this)}
maxlength='140'
placeholder='联系地址'
/>
</View>
<View className='demanding-box'>
<View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text>
</View>
<AtTextarea
value={this.state.content}
onChange={this.contentChange.bind(this)}
maxlength='140'
placeholder=''
/>
</View>
<View className='img-box'>
<View className='title-box'>
<Text className='title'>需求图片:</Text>
<View className='warn'>(最多4张)</View>
</View>
<View className='img-container'>
<AtImagePicker
multiple
showAddBtn={this.state.pickerImageUrl.length < 4}
files={this.state.pickerImageUrl}
onChange={this.onChangeImg.bind(this)}
onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)}
/> />
</View> </View>
<View className='input-box'>
<Text className='require'>*</Text>
<AtInput
name='value'
title='联系人:'
type='text'
value={this.state.contactName}
border={false}
onChange={this.contactNameChange.bind(this)}
/>
</View>
<View className='input-box'>
<Text className='require'>*</Text>
<AtInput
name='value'
title='联系电话:'
type='number'
value={this.state.contactNumber}
border={false}
onChange={this.contactNumberChange.bind(this)}
/>
</View>
{/* <View className='input-box' style='padding:24rpx 0;font-size:32rpx'>
<View className='title' style='font-weight:bold;'>
<Text style='color:red'>*</Text>
<Text>联系电话</Text>
</View>
<View style='margin-left:5%;'>
<Input name='value'
maxLength='11'
type='number'
value={this.state.contactNumber}
onInput={this.contactNumberChange.bind(this)}
/></View>
</View> */}
</View> <View className='demanding-box'>
<View className='page-section'> <View className='title-box'>
<Text className='title'>联系地址:</Text>
</View>
{platformChecker() ? <AtTextarea
value={this.state.contactAddress}
onChange={this.contactAddressChange.bind(this)}
maxlength='140'
placeholder='联系地址'
/> : <View className='textarea-wrapper'>
<textarea className='text-area' onInput={this.contactAddressChange.bind(this)} value={this.state.contactAddress} placeholder="联系地址" maxlength='140' /></View>
}
</View>
<View className='demanding-box'>
<View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text>
</View>
{platformChecker() ? <AtTextarea
value={this.state.content}
onChange={this.contentChange.bind(this)}
maxlength='140'
placeholder=''
/> : <View className='textarea-wrapper'>
<textarea className='text-area' onInput={this.contentChange.bind(this)} value={this.state.content} maxlength='140' /></View>
}
</View>
<View className='img-box'>
<View className='title-box'>
<Text className='title'>需求图片:</Text>
<View className='warn'>(最多4张)</View>
</View>
{platformChecker() ? <View className='img-container'>
<AtImagePicker
multiple
showAddBtn={this.state.pickerImageUrl.length < 4}
files={this.state.pickerImageUrl}
onChange={this.onChangeImg.bind(this)}
onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)}
/>
</View> : <AliPictureUploadComponent maxLength={4} isReceiveImageUrl={false} url={URL.UploadDSPorductImage} onGetImageDetails={this.getImageDetails.bind(this)} />
}
</View>
<View className='page-section'>
<View>
<Picker mode='selector' rangeKey='name' range={this.state.needsState} onChange={this.needsStateHandler}>
<View className='picker'>
<View className='title-box'>
<Text className='title'> <Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.needsStateSelected.name}</Text>
</View>
<View>
<Picker mode='selector' rangeKey='name' range={this.state.needsState} onChange={this.needsStateHandler}>
<View className='picker'>
<View className='title-box'>
<Text className='title'> <Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.needsStateSelected.name}</Text>
</View> </View>
</Picker>
</View> </View>
</Picker>
</View> </View>
<View className='button-box'>
<View className='button' onClick={this.publishButtonHandler.bind(this)}>
<Button size='mini' className='button-orange' >发布</Button>
</View>
<View className='button' onClick={this.publishAndNewButton.bind(this)}>
<Button className='button-green' size='mini' >发布并新增</Button>
</View>
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
<Button className='button-green' size='mini' >我的需求</Button>
</View>
</View>
<CopyrightComponent></CopyrightComponent>
</View> </View>
<View className='button-box'>
<View className='button' onClick={this.publishButtonHandler.bind(this)}>
<Button size='mini' className='button-orange' >发布</Button>
</View>
<View className='button' onClick={this.publishAndNewButton.bind(this)}>
<Button className='button-green' size='mini' >发布并新增</Button>
</View>
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
<Button className='button-green' size='mini' >我的需求</Button>
</View>
</View>
<CopyrightComponent></CopyrightComponent>
</View>
) )
} }
} }

View File

@ -1,7 +1,8 @@
$themeColor:#FF7142; $themeColor:#FF7142;
.supply-demand{ .supply-demand{
padding: 10px 20px; padding: 10px 20px ;
.border-box{ .border-box{
border-bottom: 1Px solid #d6e4ef; border-bottom: 1Px solid #d6e4ef;
@ -77,3 +78,13 @@ $themeColor:#FF7142;
line-height:100rpx; line-height:100rpx;
} }
} }
.textarea-wrapper{
border-width: 1px;
border-style: solid;
border-color: rgb(214, 228, 239);
border-radius: 8px;
padding:5px;
.text-area{
height: 150px;
}
}

View File

@ -10,6 +10,7 @@ import CopyrightComponent from '../../component/copyrightComponent/copyrightComp
import './myNeedsView.scss' import './myNeedsView.scss'
import loginExpired from '../../util/loginExpired'; import loginExpired from '../../util/loginExpired';
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading';
@ -42,13 +43,14 @@ class SupplyDemandView extends Component {
} }
//获取需求信息api //获取需求信息api
getSingleMyNeedInfo() { getSingleMyNeedInfo() {
let id=decodeURIComponent(this.$router.params.id)
Taro.request({ Taro.request({
// url: URL.EditMyNeeds, // url: URL.EditMyNeeds,
url: URL.supplyDemandDetails, url: URL.supplyDemandDetails,
method: 'GET', method: 'GET',
dataType: 'json', dataType: 'json',
data: { data: {
demandId: this.$router.params.id, demandId:id ,
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -194,7 +196,7 @@ class SupplyDemandView extends Component {
} }
componentDidMount() { componentDidMount() {
Taro.showLoading({ title: '加载中' }) showLoading({ title: '加载中' })
this.getSingleMyNeedInfo() this.getSingleMyNeedInfo()
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {

View File

@ -1,17 +1,18 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Button, MovableArea, MovableView } from '@tarojs/components' import { View, Text, Button, MovableArea, MovableView ,Picker } from '@tarojs/components'
import { AtInput, Picker, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import { AtInput, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent' import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import LoginService from '../../util/LoginService'
import loginExpired from '../../util/loginExpired' import loginExpired from '../../util/loginExpired'
import './mySupplyDemand.scss' import './mySupplyDemand.scss'
import onClickValueService from '../../util/onClickValueService'; import onClickValueService from '../../util/onClickValueService';
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading';
import { isUserShopOwner } from '../../util/checkLogin';
class MySupplyDemand extends Component { class MySupplyDemand extends Component {
@ -116,7 +117,7 @@ class MySupplyDemand extends Component {
onSearchButtonHandler() { onSearchButtonHandler() {
Taro.showLoading({ title: '加载中' }) showLoading({ title: '加载中' })
this.setState({ loadMorePageIndex: 1 }, () => { this.setState({ loadMorePageIndex: 1 }, () => {
this.getMySupplyDemand({ curr_page: this.state.loadMorePageIndex }) this.getMySupplyDemand({ curr_page: this.state.loadMorePageIndex })
@ -146,6 +147,7 @@ class MySupplyDemand extends Component {
Taro.showToast({ Taro.showToast({
title: '删除成功' title: '删除成功'
}).then(() => { }).then(() => {
Taro.showLoading()
this.getMySupplyDemand({}) this.getMySupplyDemand({})
}) })
@ -227,7 +229,7 @@ class MySupplyDemand extends Component {
} }
handleWindowConfirm() { handleWindowConfirm() {
this.setState({ isConfirmWindow: false }) this.setState({ isConfirmWindow: false })
Taro.showLoading({ showLoading({
title: '加载中' title: '加载中'
}) })
this.onDelete({ sdID: this.state.demandSupplyId }) this.onDelete({ sdID: this.state.demandSupplyId })
@ -246,7 +248,8 @@ class MySupplyDemand extends Component {
// 跳转到我的供求编辑页面 // 跳转到我的供求编辑页面
goToMyDSEditPage(e) { goToMyDSEditPage(e) {
const sdId = onClickValueService(e) let id = onClickValueService(e)
let sdId=encodeURIComponent(id)
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + sdId url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + sdId
}) })
@ -254,7 +257,8 @@ class MySupplyDemand extends Component {
} }
// 转到供求查看页面 // 转到供求查看页面
goSupplyDemandView(e) { goSupplyDemandView(e) {
const sdId = onClickValueService(e) let id = onClickValueService(e)
let sdId=encodeURIComponent(id)
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/supplyDemandView/supplyDemandView?sdId=' + sdId url: '/pages/supplyDemandView/supplyDemandView?sdId=' + sdId
}) })
@ -286,23 +290,14 @@ class MySupplyDemand extends Component {
componentDidMount() { componentDidMount() {
this.getUserSystemInfo() this.getUserSystemInfo()
Taro.showLoading({ title: '加载中' }).then(() => { showLoading({ title: '加载中' })
this.getMySupplyDemand({}) this.getMySupplyDemand({})
})
} }
componentWillUnmount() { } componentWillUnmount() { }
componentDidShow() { componentDidShow() {
if (!getGlobalStorage('userInfo').user_id) { isUserShopOwner()
LoginService()
return
}
if (!getGlobalStorage('shopInfo').shop_id && getGlobalStorage('userInfo').user_id) {
Taro.showToast({
title: '您还没有店铺,不能使用该功能,快去申请吧',
icon: 'none'
})
}
} }
componentDidHide() { } componentDidHide() { }
@ -316,7 +311,7 @@ class MySupplyDemand extends Component {
} }
// 底部加载 // 底部加载
onReachBottom() { onReachBottom() {
Taro.showLoading({ showLoading({
title: '加载中' title: '加载中'
}) })
@ -484,10 +479,10 @@ class MySupplyDemand extends Component {
<CopyrightComponent></CopyrightComponent> <CopyrightComponent></CopyrightComponent>
</View> </View>
<MovableView className='movable-point' x={this.state.screenWidth} y={this.state.screenHeight} style='opacity:0.3' direction='all' onClick={this.goToCenterPage.bind(this)} > <MovableView className='movable-point' x={this.state.screenWidth} y={this.state.screenHeight} style='opacity:0.3' direction='all' >
<View className='movable-point' onClick={this.goToCenterPage.bind(this)}> 个人中心</View>
个人中心 </MovableView>
</MovableView>
</MovableArea> </MovableArea>
) )
} }

File diff suppressed because it is too large Load Diff

View File

@ -59,7 +59,9 @@ $themeColor:#FF7142;
position: relative; position: relative;
.interaction{ .interaction{
position: absolute; position: absolute;
opacity: 0; // opacity: 0;
top:-100px;
} }
} }
.homepage-link{ .homepage-link{

View File

@ -1,15 +1,19 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Button, Input } from '@tarojs/components' import { View, Text, Button, Input, Picker } from '@tarojs/components'
import { AtInput, AtImagePicker, AtTextarea, Picker } from 'taro-ui' import { AtInput, AtImagePicker, AtTextarea } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import LoginService from '../../util/LoginService'
import AliPictureUploadComponent from '../../component/aliPictureUploadComponent/aliPictureUploadComponent'
import LoginService from '../../util/LoginService'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import './supplyDemandPublish.scss' import './supplyDemandPublish.scss'
import loginExpired from '../../util/loginExpired'; import loginExpired from '../../util/loginExpired';
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading';
import { isUserShopOwner } from '../../util/checkLogin';
import platformChecker from '../../util/plaformChecker';
class SupplyDemand extends Component { class SupplyDemand extends Component {
config = { config = {
@ -23,8 +27,8 @@ class SupplyDemand extends Component {
demandingSupplyState: [{ name: '上架', id: '1' }, { name: '下架', id: '0' }], // 状态选择 demandingSupplyState: [{ name: '上架', id: '1' }, { name: '下架', id: '0' }], // 状态选择
demandingSupplyStateSelected: { name: '上架', id: '1' },// 当前状态 demandingSupplyStateSelected: { name: '上架', id: '1' },// 当前状态
title: '', title: '',
contactName: getGlobalStorage('user_identity').username||'', contactName: '',
contactNumber: getGlobalStorage('user_identity').userphone||'', contactNumber: '',
contactAddress: '', contactAddress: '',
content: '', content: '',
pickerImageUrl: [], // 上传的图片 pickerImageUrl: [], // 上传的图片
@ -82,7 +86,6 @@ class SupplyDemand extends Component {
icon: res.data.err_msg == 'success' ? 'success' : 'none', icon: res.data.err_msg == 'success' ? 'success' : 'none',
duration: 1000 duration: 1000
}).then(() => { }).then(() => {
console.log('this.state.isPublishAndNew', this.state.isPublishAndNew)
setTimeout(() => { setTimeout(() => {
if (this.state.isPublishAndNew) { if (this.state.isPublishAndNew) {
Taro.navigateTo({ Taro.navigateTo({
@ -166,6 +169,12 @@ class SupplyDemand extends Component {
}) })
} }
} }
// 从图片子组件获取信息
getImageDetails(value) {
this.setState({
ImagesInfo: value
})
}
// 修改供求类型 // 修改供求类型
demandingSupplyCate = e => { demandingSupplyCate = e => {
this.setState({ this.setState({
@ -203,11 +212,11 @@ class SupplyDemand extends Component {
} }
if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) { if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) {
Taro.showLoading({ title: '发布中' }).then(() => { showLoading({ title: '发布中' })
this.setState({ isPublishAndNew: false }, () => { this.setState({ isPublishAndNew: false }, () => {
this.uploadDemSup({}) this.uploadDemSup({})
})
}) })
} else { } else {
Taro.showToast({ Taro.showToast({
title: '请填写完表格', title: '请填写完表格',
@ -223,11 +232,11 @@ class SupplyDemand extends Component {
} }
if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) { if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) {
Taro.showLoading({ title: '发布中' }).then(() => { showLoading({ title: '发布中' })
this.setState({ isPublishAndNew: true }, () => { this.setState({ isPublishAndNew: true }, () => {
this.uploadDemSup({}) this.uploadDemSup({})
})
}) })
} else { } else {
Taro.showToast({ Taro.showToast({
title: '请填写完表格', title: '请填写完表格',
@ -250,7 +259,10 @@ class SupplyDemand extends Component {
} }
componentDidMount() { componentDidMount() {
this.setState({
contactName: getGlobalStorage('user_identity').username || '',
contactNumber: getGlobalStorage('user_identity').userphone || '',
})
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
// console.log(this.props, nextProps) // console.log(this.props, nextProps)
@ -259,16 +271,7 @@ class SupplyDemand extends Component {
componentWillUnmount() { } componentWillUnmount() { }
componentDidShow() { componentDidShow() {
if (!getGlobalStorage('userInfo').user_id) { isUserShopOwner()
LoginService()
return
}
if (!getGlobalStorage('shopInfo').shop_id && getGlobalStorage('userInfo').user_id) {
Taro.showToast({
title: '您还没有店铺,不能使用该功能,快去申请吧',
icon: 'none'
})
}
} }
componentDidHide() { } componentDidHide() { }
@ -311,7 +314,18 @@ class SupplyDemand extends Component {
border={false} border={false}
/> />
</View> </View>
<View className='input-box' style='padding:24rpx 0;font-size:32rpx'> <View className='input-box'>
<Text className='require'>*</Text>
<AtInput
name='value'
title='联系电话:'
type='number'
value={this.state.contactNumber}
onChange={this.contactNumberChange.bind(this)}
border={false}
/>
</View>
{/* <View className='input-box' style='padding:24rpx 0;font-size:32rpx'>
<View className='title' style='font-weight:bold;'> <View className='title' style='font-weight:bold;'>
<Text style='color:red'>*</Text> <Text style='color:red'>*</Text>
<Text>联系电话</Text> <Text>联系电话</Text>
@ -323,38 +337,51 @@ class SupplyDemand extends Component {
value={this.state.contactNumber} value={this.state.contactNumber}
onInput={this.contactNumberChange.bind(this)} onInput={this.contactNumberChange.bind(this)}
/></View> /></View>
</View> </View> */}
<View className='demanding-box'> <View className='demanding-box'>
<View className='title-box'> <View className='title-box'>
<Text className='title'>联系地址:</Text> <Text className='title'>联系地址:</Text>
</View> </View>
{platformChecker() ? <AtTextarea
<AtTextarea
value={this.state.contactAddress} value={this.state.contactAddress}
onChange={this.contactAddressChange.bind(this)} onChange={this.contactAddressChange.bind(this)}
maxlength='140' maxlength='140'
placeholder='联系地址' placeholder='联系地址'
/> /> : <View className='textarea-wrapper'>
<textarea className='text-area'
onInput={this.contactAddressChange.bind(this)}
value={this.state.contactAddress}
placeholder="联系地址"
maxlength='140' /></View>
}
</View> </View>
<View className='demanding-box'> <View className='demanding-box'>
<View className='title-box'> <View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='title'><Text className='require'>*</Text>:</Text>
</View> </View>
<AtTextarea {platformChecker() ? <AtTextarea
value={this.state.content} value={this.state.content}
onChange={this.contentChange.bind(this)} onChange={this.contentChange.bind(this)}
maxlength='140' maxlength='140'
placeholder='' placeholder=''
/> /> : <View className='textarea-wrapper'>
<textarea className='text-area'
onInput={this.contentChange.bind(this)}
value={this.state.content}
placeholder=""
maxlength='140' /></View>
}
</View> </View>
<View className='img-box'> <View className='img-box'>
<View className='title-box'> <View className='title-box'>
<Text className='title'>需求图片:</Text> <Text className='title'>需求图片:</Text>
<View className='warn'>(最多4张)</View> <View className='warn'>(最多4张)</View>
</View> </View>
{platformChecker() ? <View className='img-container'>
<View className='img-container'>
<AtImagePicker <AtImagePicker
multiple multiple
showAddBtn={this.state.pickerImageUrl.length < 4} showAddBtn={this.state.pickerImageUrl.length < 4}
@ -363,7 +390,9 @@ class SupplyDemand extends Component {
onFail={this.onFail.bind(this)} onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)} onImageClick={this.onImageClick.bind(this)}
/> />
</View> </View> : <AliPictureUploadComponent maxLength={4} isReceiveImageUrl={false} url={URL.UploadDSPorductImage} onGetImageDetails={this.getImageDetails.bind(this)} />
}
</View> </View>
<View className='page-section'> <View className='page-section'>

View File

@ -72,3 +72,13 @@ $themeColor:#FF7142;
line-height:100rpx; line-height:100rpx;
} }
.textarea-wrapper{
border-width: 1px;
border-style: solid;
border-color: rgb(214, 228, 239);
border-radius: 8px;
padding:5px;
.text-area{
height: 150px;
}
}

View File

@ -10,6 +10,7 @@ import CopyrightComponent from '../../component/copyrightComponent/copyrightComp
import './supplyDemandView.scss' import './supplyDemandView.scss'
import loginExpired from '../../util/loginExpired'; import loginExpired from '../../util/loginExpired';
import { getGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
import { showLoading } from '../../util/hideShowLoading';
@ -35,12 +36,14 @@ class SupplyDemandView extends Component {
} }
//获取商品信息api GetProductInfo //获取商品信息api GetProductInfo
getSupplyDemandInfo() { getSupplyDemandInfo() {
let sdId=decodeURIComponent(this.$router.params.sdId)
Taro.request({ Taro.request({
url: URL.GetSupplyDemandInfo, url: URL.GetSupplyDemandInfo,
method: 'GET', method: 'GET',
dataType: 'json', dataType: 'json',
data: { data: {
sdID: this.$router.params.sdId, sdID: sdId,
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -67,12 +70,12 @@ class SupplyDemandView extends Component {
} else if (res.data.err_code === 88888) { } else if (res.data.err_code === 88888) {
loginExpired(res) loginExpired(res)
}else{ } else {
Taro.showToast({ Taro.showToast({
title:res.data.err_msg, title: res.data.err_msg,
icon:'none' icon: 'none'
}) })
} }
} }
) )
@ -129,8 +132,9 @@ class SupplyDemandView extends Component {
} }
// 跳转到我的供求编辑页面 // 跳转到我的供求编辑页面
goToMyDSEditPage() { goToMyDSEditPage() {
let sdId=encodeURIComponent(this.state.itemId)
Taro.redirectTo({ Taro.redirectTo({
url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + this.state.itemId url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + sdId
}) })
} }
@ -153,15 +157,15 @@ class SupplyDemandView extends Component {
} }
handleWindowConfirm() { handleWindowConfirm() {
this.setState({ isDeleteModal: false }) this.setState({ isDeleteModal: false })
Taro.showLoading({ showLoading({
title: '加载中' title: '加载中'
}) })
this.onDelete({ sdID: this.state.itemId }) this.onDelete({ sdID: this.state.itemId })
} }
componentDidMount() { componentDidMount() {
Taro.showLoading({ title: '加载中' }) showLoading({ title: '加载中' })
this.getSupplyDemandInfo() this.getSupplyDemandInfo()
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {

View File

@ -1,6 +1,6 @@
const LOCALURL = "http://192.168.1.230/" const LOCALURL = "http://192.168.1.230/"
// const LOCALURL = "https://www.ihome6.com/" //const LOCALURL = "https://www.ihome6.com/"
const URL = { const URL = {
Base: LOCALURL, Base: LOCALURL,

View File

@ -1,588 +0,0 @@
todo list
首页:
商品发布页面:
供求发布页面
全部业主需求页面:
我的供求页面:
我的商品列表页面
商品编辑页面
我的需求列表页面:
接口问题:
优惠卷和询价
bug 商品编辑 增加图片后 图片顺序乱了
等待后台--- 单个我的商品页面的图片顺序,单个我的需求页面的接口, 当个我哦的需求编辑页面的接口
import Taro, { Component } from '@tarojs/taro'
import { View, Button, Text, Swiper, SwiperItem, Image, } from '@tarojs/components'
import { AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import MainCateSlider from './mainCateSlider/mainCateSlider'
import FilteredShopComponent from '../../component/filteredShopComponent/filteredShopComponent'
import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import LoginService from '../../util/LoginService'
import weChatLogin from '../../util/weChatLogin'
import URL from '../../serviceAPI.config'
import './home.scss'
class Home extends Component {
config = {
navigationBarTitleText: '首页',
}
constructor() {
super(...arguments);
this.state = {
shops: [], // 推荐店铺的信息
ads: [], //广告图片数组
categories: [],// 大类
subCate: [], //小类
demanding: [],// 业主需求
otherData: [], // 底部导航栏
isOpen: false, // 抢单消息提示
grabOrderId: '',//抢到订单的id
userName: getGlobalStorage('user_identity').userName || '',//用户名字
userPhone: getGlobalStorage('user_identity').userPhone || '',// 用户电话
isShowTopNav: false,// 是否显示返回顶部按钮
loadMorePageIndex: 1,//下拉加载页面数
isAddToList: false,
parentClass: '',// 大类的id
childClass: '-1',//小类的id
supplyLevel: 1,// 筛选1是小类或者2是大类,
latitude: '',
longitude: '',
}
}
// onPullDownRefresh() {
// Taro.showLoading({ title: '加载中' })
// this.login().then(() => {
// this.getShops({})
// this.getHomeCategoriesInfo()
// }).catch(err => console.log('微信登入失败:', err))
// Taro.stopPullDownRefresh()
// }
//api得到首页的信息
getHomeCategoriesInfo() {
Taro.request({
url: URL.ShopWxStore,
header: {
// 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
}
})
.then(res => {
console.log('首页基本信息', res)
if (res.data.err_msg === 'success') {
this.setState({
ads: res.data.data.adsLb,
categories: [res.data.data.supplyClass[0], Object.values(res.data.data.supplyClass[1])],
demanding: res.data.data.demand.supplys,
otherData: res.data.otherData,
userName: res.data.otherData.userName,
userPhone: res.data.otherData.userPhone,
})
} else {
Taro.showToast({
title: res.data.err_msg,
icon: 'none',
duration: 1500
})
}
})
}
// api 得到推荐商店的信息
getShops({ parent_supply_class = this.state.parentClass, supply_class = this.state.childClass, supply_level = this.state.supplyLevel, curr_page = 1,
page_count = 5, action = "2" }) {
Taro.request({
url: URL.ShopSupplyShops,
method: 'POST',
dataType: 'json',
data: {
param: JSON.stringify({
curr_page: curr_page,
page_count: page_count,
parent_supply_class: parent_supply_class, //父级class id
supply_class: supply_class,// 子级class id
supply_level: supply_level,// 层级
action: action,
latitude: this.state.latitude,
longitude: this.state.longitude,
})
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
}
})
.then(res => {
console.log('所有店铺的信息', res)
Taro.hideLoading()
if (res.data.err_code === 0) {
if (this.state.isAddToList) {
if (res.data.shops) {
this.setState({ shops: this.state.shops.concat(res.data.shops), isAddToList: false })
} else {
Taro.showToast({
title: '没有更多了',
icon: 'none',
duration: 1500
})
}
} else {
res.data.shops ? this.setState({ shops: res.data.shops }) : this.setState({ shops: [] })
}
} else {
Taro.showToast({
title: res.data.err_msg,
icon: 'none',
duration: 1500
})
}
this.setState({ isAddToList: false })
}
)
}
getUserLocation() {
return new Promise((resolve, reject) => {
Taro.getLocation({
type: 'wgs84', // 返回可以用于wx.openLocation的经纬度
success(res) {
resolve(res)
},
fail(res) {
Taro.showToast({
title: '获取定位失败',
icon: 'none'
})
reject(res)
}
})
})
}
// 微信用户设置
// wxUserSetting() {
// Taro.getSetting({
// success(res) {
// if (res.authSetting['scope.userInfo']) {
// console.log('personal info', res)
// Taro.authorize({
// scope: 'scope.userInfo',
// success() {
// // 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问
// // Taro.getUserInfo({
// // success(res1) {
// // console.log('res1',res1)
// // }
// // })
// console.log('权限允许')
// }
// })
// }
// }
// })
// }
// api 抢单请求
GrabDemand({ demandId = 218 }) {
Taro.request({
url: URL.GrabDemand,
method: 'POST',
dataType: 'json',
data: {
demandId: demandId
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
Taro.showToast({
title: res.data.err_msg === 'success' ? '抢单成功' : res.data.err_msg,
icon: 'none',
duration: 1500
})
console.log('抢单请求:', res)
})
}
// 点击大类icon
onClickParentCate(e) {
const item = e.currentTarget.dataset.eTapAA
Taro.showLoading({
title: '加载中'
})
this.setState({ parentClass: item.class_id, childClass: item.class_id, supplyLevel: 1, subCate: item.children || [] }, () => {
this.getShops({})
})
}
// 点击子类
onClickChildCate(e) {
const item = e.currentTarget.dataset.eTapAA
Taro.showLoading({
title: '加载中'
})
this.setState({ childClass: item.class_id, supplyLevel: 2 }, () => {
this.getShops({})
})
// this.getShops(item.parent_class_id, item.class_id, 2)
}
scrollToSubCate(item) {
Taro.pageScrollTo({
scrollTop: 410,
duration: 300
})
this.onClickParentCate(item)
}
// 转到其他页面
goToAllDemandingPage() {
if (!getGlobalStorage('userInfo').user_id) {
LoginService()
return
}
Taro.navigateTo({
url: '/pages/allDemanding/allDemanding'
})
}
grabOrderId(e) {
const id = e.currentTarget.dataset.eTapAA
this.setState({ isOpen: true, grabOrderId: id })
}
handleGrabModalClose() {
this.setState({ isOpen: false })
}
handleGrabModalCancel() {
this.setState({ isOpen: false })
}
handleGrabConfirm() {
if (!getGlobalStorage('userInfo').user_id) {
LoginService()
}
this.setState({ isOpen: false })
// 确认抢单之后
this.GrabDemand({ demandId: this.state.grabOrderId })
}
// 导航去抢单页面
goToGrabOrderPage(e) {
const orderId = e.currentTarget.dataset.eTapAA
Taro.navigateTo({
url: '/pages/grabOrderPage/grabOrderPage?orderId=' + orderId
})
}
goToMyNeedsPublish() {
// 传参数给myNeedsPublish页面- 显示效果图选项
Taro.navigateTo({
url: '/pages/myNeedsPublish/myNeedsPublish?id=1'
})
}
componentDidMount() {
// 页面加载后 得到首页的基本信息和推荐店铺的信息
Taro.showLoading({ title: '加载中' })
// promise 返回经纬度给state 然后调用函数
this.getUserLocation().then(res => {
this.setState({
latitude: res.latitude,
longitude: res.longitude
}, () => {
this.getShops({})
this.getHomeCategoriesInfo()
})
}).catch(err => {
this.getShops({})
this.getHomeCategoriesInfo()
})
// 本地缓存没有userid时 从新登入
getGlobalStorage('userInfo').user_id ? true : weChatLogin()
}
componentWillMount() {
}
componentWillUnmount() { }
componentDidShow() {
}
componentDidHide() { }
// 微信用户信息
onGotUserInfo(e) {
console.log(e.detail.errMsg)
console.log(e.detail.userInfo)
console.log(e.detail.rawData)
}
// 页面位置
onPageScroll(location) {
if (location.scrollTop <= 300 && this.state.isShowTopNav) {
this.setState({ isShowTopNav: false })
} else if (location.scrollTop > 300 && !this.state.isShowTopNav) {
this.setState({ isShowTopNav: true })
}
}
// 底部加载
onReachBottom() {
Taro.showLoading({
title: '加载中'
})
this.setState({ loadMorePageIndex: this.state.loadMorePageIndex + 1, isAddToList: true }, () => {
this.getShops({ curr_page: this.state.loadMorePageIndex, })
})
}
render() {
// 提示模态弹窗element
const modalMessageGrabElement = <AtModal isOpened={this.state.isOpen}>
<AtModalHeader>提示</AtModalHeader>
<AtModalContent>
确认抢单?
</AtModalContent>
<AtModalAction> <Button onClick={this.handleGrabModalCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleGrabConfirm.bind(this)}>确定</Button> </AtModalAction>
</AtModal>
const demandingElemensArray = this.state.demanding.length ? this.state.demanding.map((item, index) => {
return <SwiperItem key={index} >
<View className={this.state.demanding.length - 1 === index ? 'demanding-item last' : 'demanding-item'}>
<View onClick={this.goToGrabOrderPage.bind(this, item.sd_id)}>
<View className='item-tag'>
<Text className='item-tag-text'> {item.class_name}</Text>
</View>
<View className='item-title'>
{item.sd_title}
</View>
<View className='item-address'>
{item.user_address || '--'}
</View>
<View className='item-name'>
业主:{item.user_name}
</View>
</View>
{item.state === '1' ? <View className='button' onClick={this.grabOrderId.bind(this, item.sd_id)}>
<Button size='mini' className='button-orange'>抢单</Button>
</View> : null || item.state === '2' ? <View className='button'>
<Button size='mini' className='button-orange blur'>{item.state_name}</Button>
</View> : null || item.state === '3' ? <View className='button'>
<Button size='mini' className='button-orange blur'>{item.state_name}</Button>
</View> : null}
{/* <View className='item-button-box' onClick={this.grabOrderId.bind(this, item.sd_id)}>
<Button className='item-button' > {item.state_name === '在用' ? '抢单' : '已抢光'}</Button>
</View> */}
</View>
</SwiperItem >
}) : null
const adsImgElementsArray = this.state.ads.length ? this.state.ads.map((item, index) => {
return <SwiperItem key={index}>
<Image className='banner-img' src={URL.Base + item.ads_pic} />
</SwiperItem>
}) : null
// 这里应该代码可以优化-----
const categoriesElementsArray1 = this.state.categories.length ? this.state.categories[0].map((item, index) => {
return <View className='category-item' key={index} onClick={this.scrollToSubCate.bind(this, item)}>
{/* onClick={this.onClickParentCate.bind(this, item)}> */}
<Image className='cate-img' src={URL.Base + item.icon} />
<View>{item.class_name}</View>
</View>
}) : null
const categoriesElementsArray2 = this.state.categories.length ? this.state.categories[1].map((item, index) => {
return <View className='category-item' key={index} onClick={this.scrollToSubCate.bind(this, item)}>
{/* onClick={this.onClickParentCate.bind(this, item)}> */}
<Image className='cate-img' src={URL.Base + item.icon} />
<View>{item.class_name}</View>
</View>
}) : null
const shopCollectionElementsArray = this.state.shops.length ? this.state.shops.map((item, index) => {
return <FilteredShopComponent
shop={item}
key={index}
categoryLevel={this.state.supplyLevel}
classId={this.state.parentClass === this.state.childClass ? this.state.parentClass : this.state.childClass}
></FilteredShopComponent>
}) : <View className='no-more-title top'> 没有更多了</View>
const subCateElementsArray = this.state.subCate.length ? this.state.subCate.map((item, index) => {
return <SwiperItem key={index} onClick={this.onClickChildCate.bind(this, item)}>
<View className='text'>{item.class_name}</View>
</SwiperItem>
}) : null
return (
<View className='home'>
{/* 获取微信用户的信息 */}
{/* <AtButton open-type='getUserInfo' lang='zh_CN' type='primary' size='normal' onGetUserInfo={this.onGotUserInfo.bind(this)}>获取微信用户的信息</AtButton> */}
{modalMessageGrabElement}
<View className='first-banner'>
<Swiper
className='swipper'
style='height:120px;'
indicatorColor='#999'
indicatorActiveColor='#333'
hotizontal
circular
indicatorDots
autoplay
>
{adsImgElementsArray}
</Swiper>
</View>
{/* 第二行图片滚动条 */}
{/* <View className='second-banner'>
<Swiper
style='height:100%;'
className='swipper'
indicatorColor='#999'
indicatorActiveColor='#333'
hotizontal
circular
indicatorDots
// autoplay
>
<SwiperItem>
<View className='categories'>
{categoriesElementsArray1}
</View>
</SwiperItem>
<SwiperItem>
<View className='categories'>
{categoriesElementsArray2}
</View>
</SwiperItem>
</Swiper>
</View> */}
<MainCateSlider/>
{/* 第三行图片滚动条 */}
<View className='third-banner'>
<Swiper
style='height:100px;'
className='swipper'
indicatorColor='#999'
indicatorActiveColor='#333'
horizontal
circular
indicatorDots
autoplay
>
<SwiperItem onClick={this.goToMyNeedsPublish.bind(this)}>
<Image className='banner-img' src={URL.Base + 'Public/images/xgt.png'} />
</SwiperItem>
</Swiper>
</View>
{/* 业主需求和行业推荐 */}
<View className='container'>
<View className='title'>
<Text className='title-block'></Text>
<Text className='title-text'>业主需求</Text>
<Text className='more-link' onClick={this.goToAllDemandingPage.bind(this)}>
更多>>
</Text>
</View>
<View className='customer-demanding'>
<Swiper
style='height:180px;'
className='swipper swiper-sub'
indicatorColor='#999'
indicatorActiveColor='#333'
horizontal
displayMultipleItems='2.5'
>
{demandingElemensArray}
</Swiper>
</View>
<View className='second-banner-level2'>
{this.state.subCate.length ? <Swiper
style='height:35px;'
className='swipper swiper-sub'
indicatorColor='#999'
indicatorActiveColor='#333'
horizontal
displayMultipleItems={this.state.subCate.length > 4.5 ? 4.5 : this.state.subCate.length}
>
{subCateElementsArray}
</Swiper> : null}
</View>
<View className='title'>
<Text className='title-block'></Text>
<Text className='title-text'>行业推荐</Text>
</View>
<View className='shop-box'>
{shopCollectionElementsArray}
</View>
{this.state.isShowTopNav ? <ScrollToTopComponent ></ScrollToTopComponent> : null}
<CopyrightComponent></CopyrightComponent>
<View className='gap'>
</View>
</View>
<View className='bottom-nav-box'>
{/* <BottomNav otherData={this.state.otherData} /> */}
</View>
{/* {this.state.isShopOwner ? <SellerTabBarComponent currentUrl={currentUrl} /> : <ClientTabBarComponent currentUrl={currentUrl} />} */}
</View>
)
}
}
export default Home

31
src/util/checkLogin.js Normal file
View File

@ -0,0 +1,31 @@
import { getGlobalStorage } from "./getSetStoage";
import Taro from '@tarojs/taro'
// check if user login
const isUserLogin = () => {
return new Promise((resolve,reject)=>{
let isLogin = getGlobalStorage('userInfo') ? true : false
if (!isLogin) {
Taro.switchTab({
url: '/pages/home/home'
})
Taro.navigateTo({
url: '/pages/login/login'
})
}else{
resolve('继续')
}
})
}
const isUserShopOwner = () => {
let isShopOwner = getGlobalStorage('shopInfo') ? true : false
if (!isShopOwner) {
Taro.showToast({
title: '您还没有店铺,不能使用该功能,快去申请吧',
icon: 'none'
})
}
}
export { isUserLogin, isUserShopOwner }

View File

@ -3,10 +3,7 @@ import Taro from '@tarojs/taro'
const setGlobalStorage = (key, value) => { const setGlobalStorage = (key, value) => {
if (process.env.TARO_ENV === 'weapp') { if (process.env.TARO_ENV === 'weapp') {
Taro.setStorageSync({ Taro.setStorageSync(key, value)
key: key,
data: value
})
} else if (process.env.TARO_ENV === 'alipay') { } else if (process.env.TARO_ENV === 'alipay') {
my.setStorageSync({ my.setStorageSync({
@ -18,15 +15,20 @@ const setGlobalStorage = (key, value) => {
const getGlobalStorage = (key) => { const getGlobalStorage = (key) => {
if (process.env.TARO_ENV === 'weapp') { if (process.env.TARO_ENV === 'weapp') {
getGlobalStorage(key) return Taro.getStorageSync(key)
} else if (process.env.TARO_ENV === 'alipay') { } else if (process.env.TARO_ENV === 'alipay') {
let res = my.getStorageSync({ let res = my.getStorageSync({
key: key, key: key,
}) })
res.data=res.data?res.data:{username:'',userphone:'',user_id:''} if (res.data || res.APDataStorage) {
return res.data ||res.APDataStorage return res.data || res.APDataStorage
} else {
return
}
} }
} }
export { setGlobalStorage, getGlobalStorage } export { setGlobalStorage, getGlobalStorage }

View File

@ -0,0 +1,24 @@
import Taro from '@tarojs/taro'
const showLoading = ({ title='加载中'}) => {
if (process.env.TARO_ENV === 'weapp') {
Taro.showLoading({
title: title
})
} else if (process.env.TARO_ENV === 'alipay') {
my.showLoading({
content: title
})
}
}
const hideLoading = () => {
if (process.env.TARO_ENV === 'weapp') {
Taro.hideLoading()
} else if (process.env.TARO_ENV === 'alipay') {
my.hideLoading()
}
}
export { showLoading, hideLoading }

View File

@ -1,13 +1,13 @@
export default function onClickValueService(e) { export default function onClickValueService(value) {
let value
if (process.env.TARO_ENV === 'alipay') { if (process.env.TARO_ENV === 'alipay') {
value = e.currentTarget.dataset.eOnTapAA return value
} else if (process.env.TARO_ENV === 'weapp') { } else if (process.env.TARO_ENV === 'weapp') {
value = e.currentTarget.dataset.eTapAA return value
} }
value=typeof(value)==='string'?encodeURIComponent(value):value
return value
} }

View File

@ -0,0 +1,8 @@
const platformChecker=()=>{
if(process.env.TARO_ENV==='weapp'||process.env.TARO_ENV==='h5'||process.env.TARO_ENV==='rn'){
return true
}else if(process.env.TARO_ENV==='alipay'){
return false
}
}
export default platformChecker

View File

@ -4,60 +4,59 @@ import { setGlobalStorage, getGlobalStorage } from './getSetStoage';
const setUserInfoToStorage = () => { const setUserInfoToStorage = () => {
Taro.request({ Taro.request({
url: URL.ShopWxStore, url: URL.ShopWxStore,
header: { header: {
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'), 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
} }
}) })
.then(res => { .then(res => {
if (res.data.err_msg === 'success') {
setGlobalStorage('user_identity', { username: res.data.otherData.userName, userphone: res.data.otherData.userPhone })
} else { if (res.data.err_msg === 'success') {
Taro.showToast({ setGlobalStorage('user_identity', { username: res.data.otherData.userName, userphone: res.data.otherData.userPhone })
title: res.data.err_msg,
icon: 'none', } else {
duration: 1500 Taro.showToast({
}) title: res.data.err_msg,
} icon: 'none',
duration: 1500
}) })
}
})
} }
export default function standardLogin(username, password) { export default function standardLogin(username, password) {
return new Promise((resolve,reject)=>{ return new Promise((resolve, reject) => {
Taro.request({ Taro.request({
url: URL.StandardLogin, url: URL.StandardLogin,
method: 'POST', method: 'POST',
dataType: 'json', dataType: 'json',
data: { data: {
username: username, username: username,
password: password, password: password,
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest' 'X-Requested-With': 'XMLHttpRequest'
} }
}) })
.then(res => { .then(res => {
console.log('普通登录',res) console.log('普通登录', res)
if (res.data.err_code === 0) { if (res.data.err_code === 0) {
Taro.showToast({ Taro.showToast({
title: '登入成功', title: '登入成功',
icon: 'success', icon: 'success',
duration: 1000 duration: 1000
}) })
setGlobalStorage('session_id', res.data.session_id)
setGlobalStorage('session_id', res.data.session_id) setGlobalStorage('shopInfo', res.data.shop_info)
setGlobalStorage('shopInfo', res.data.shop_info) setGlobalStorage('userInfo', res.data.user_info)
setGlobalStorage('userInfo', res.data.user_info) setGlobalStorage('accountInfo', { username: username, password: password })
setGlobalStorage('accountInfo', { username: username, password: password }) setUserInfoToStorage()
setUserInfoToStorage() resolve('success')
resolve('success') } else {
} else { reject(res)
}
reject(res) })
}
})
}) })
} }

View File

@ -1,6 +1,7 @@
import Taro from '@tarojs/taro' import Taro from '@tarojs/taro'
import URL from '../serviceAPI.config' import URL from '../serviceAPI.config'
import { getGlobalStorage } from './getSetStoage'; import { getGlobalStorage } from './getSetStoage';
import platformChecker from './plaformChecker'
//用户信息姓名和电话号码接口 //用户信息姓名和电话号码接口
const setUserInfoToStorage = () => { const setUserInfoToStorage = () => {
@ -28,54 +29,61 @@ const setUserInfoToStorage = () => {
// 异步函数登入api // 异步函数登入api
export default function wechatLogin() { export default function wechatLogin() {
return new Promise((resolve,reject)=>{ //微信登录的时候查看小程序端是什么平台
Taro.login({ if (platformChecker()) {
success(res) { return new Promise((resolve, reject) => {
if (res.code) { Taro.login({
// 发起网络请求 success(res) {
console.log('手机端微信code', res.code) if (res.code) {
Taro.request({ // 发起网络请求
url: URL.Login, Taro.request({
method: 'POST', url: URL.Login,
dataType: 'json', method: 'POST',
data: { dataType: 'json',
code: res.code data: {
}, code: res.code
header: { },
'content-type': 'application/x-www-form-urlencoded', header: {
} 'content-type': 'application/x-www-form-urlencoded',
}) }
.then(response => { })
if (response.data.err_code === 0) { .then(response => {
console.log('微信登入成功', response) if (response.data.err_code === 0) {
Taro.showToast({ console.log('微信登入成功', response)
title: '微信登入成功', Taro.showToast({
icon: 'success', title: '微信登入成功',
duration: 2000 icon: 'success',
}) duration: 2000
Taro.setStorageSync('session_id', response.data.session_id) })
Taro.setStorageSync('shopInfo', response.data.shop_info) Taro.setStorageSync('session_id', response.data.session_id)
Taro.setStorageSync('userInfo', response.data.user_info) Taro.setStorageSync('shopInfo', response.data.shop_info)
setUserInfoToStorage() Taro.setStorageSync('userInfo', response.data.user_info)
resolve('微信登入成功') setUserInfoToStorage()
} else { resolve('微信登入成功')
Taro.showToast({ } else {
title: '微信登入失败', Taro.showToast({
icon: 'none', title: '微信登入失败',
duration: 2000 icon: 'none',
}) duration: 2000
reject('微信登入失败') })
// Taro.clearStorageSync() reject('微信登入失败')
} }
}
)
} }
) else {
} console.log('微信登录失败!' + res.errMsg)
else { }
console.log('登录失败!' + res.errMsg) }
} })
} })
})
}) }else{
return new Promise((resolve, reject)=>{
resolve()
})
}
} }

220
todo list.json Normal file
View File

@ -0,0 +1,220 @@
todo list
:
bug
--- ,
<View className='details-box'>
// shop interaction
import Taro, { Component } from '@tarojs/taro'
import { View, Text,Picker } from '@tarojs/components'
import './shopTypeInteractionComp.scss'
import loginExpired from '../../util/loginExpired';
import { getGlobalStorage,setGlobalStorage } from '../../util/getSetStoage';
class ShopTypeInteractionComp extends Component {
config = {
navigationBarTitleText: 'shopTypeInteractionComp'
}
constructor() {
super(...arguments);
this.state = {
initailMultiArray: [[{}], [{ name: '', id: '' }]],
multiIndex: [0, 0],
interactionMultiArray: [],//
}
}
// GetShopTypeList
getShopTypeList(url) {
Taro.request({
url: url,
method: 'POST',
dataType: 'json',
data: {
id: this.props.shopId,
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
// console.log('', res)
// this.formatIndustryType(res.data.data)
// this.formatIndustTypeInit(res.data.data)
if (res.data.err_code === 0) {
if (res.data.data === null) {
return
}
console.log('', res)
if(!getGlobalStorage('shopTypeObject')){
setGlobalStorage('shopTypeObject',res.data.data)
}
this.setState({
interactionMultiArray: this.interactionData(res.data.data),
initailMultiArray: this.initializedData(res.data.data)[0],
}, () => {
console.log('state',this.state.initailMultiArray,this.state.interactionMultiArray)
// this.passDataToParent(this.state.initailMultiArray)
//
// console.log('', this.state.interactionMultiArray)
// console.log('', this.state.initailMultiArray)
// console.log('index', this.state.multiIndex)
}) //
}else if (res.data.err_code === 88888) {
loginExpired(res)
} else {
console.log('', res)
}
}
)
.catch(error => {
console.log('', error)
})
}
//
interactionData(data) {
let parentArrayHolder = []
const keys = Object.keys(data)
for (let key of keys) {
let childrenArrayHolder = []
let parent = { name: data[key].n, id: key }
parentArrayHolder.push(parent)
for (let childItem of data[key].c) {
let child = { name: childItem.n, id: childItem.id }
childrenArrayHolder.push(child)
}
parent.children = childrenArrayHolder
}
return parentArrayHolder
}
//
initializedData(data) {
let outter = []
let inner = []
const keys = Object.keys(data)
for (let key of keys) {
outter.push({ name: data[key].n, id: key })
for (let child of data[key].c) {
inner.push({ name: child.n, id: child.id })
}
}
return [outter, inner]
}
//
bindMultiPickerCol(e) {
console.log('', e.detail.column, '', e.detail.value)
const data = {
multiArray: this.state.initailMultiArray,
multiIndex: this.state.multiIndex
}
data.multiIndex[e.detail.column] = e.detail.value
if (e.detail.column == 0) {
for (let index in data.multiArray[0]) {
const indexNumber = Number(index)
if (indexNumber === data.multiIndex[0]) {
data.multiArray[1] = this.state.interactionMultiArray[indexNumber].children
}
}
}
this.setState({ multiIndex: data.multiIndex })
}
bindMultiPickerChange(e) {
// console.log('picker', e.detail.value)
if (getGlobalStorage('shopInfo').shop_id) {
this.setState({
multiIndex: e.detail.value,
}, () => {
//interactionMultiArray
let industryTypeSelected
industryTypeSelected = this.state.interactionMultiArray[this.state.multiIndex[0]].children[this.state.multiIndex[1]]
this.passDataToParent(industryTypeSelected)
})
}
}
//---------------------picker
passDataToParent(industryTypeSelected) {
this.props.onPassDataToChild(industryTypeSelected)
}
componentDidMount() {
this.getShopTypeList(this.props.url)
}
// props
componentWillReceiveProps(nextProps) {
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
render() {
return (
<View class='page-section'>
<Picker
rangeKey='name'
mode='multiSelector'
onChange={this.bindMultiPickerChange.bind(this)}
onColumnchange={this.bindMultiPickerCol.bind(this)}
value={this.state.multiIndex}
range={this.state.initailMultiArray}
>
<View class='picker type'>
<View className='title-box'>
<Text className='require'>*</Text>
<Text className='title'>:</Text>
<Text className='first-col'>
{this.props.selectedValue.name}
</Text>
</View>
</View>
</Picker>
</View>
)
}
}
export default ShopTypeInteractionComp