Compare commits

..

No commits in common. "master" and "weapp" have entirely different histories.

76 changed files with 2988 additions and 4421 deletions

View File

@ -5,12 +5,5 @@ 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,7 +61,6 @@ const config = {
h5: { h5: {
publicPath: '/', publicPath: '/',
staticDirectory: 'static', staticDirectory: 'static',
esnextModules: ['@tarojs/components'],
module: { module: {
postcss: { postcss: {
autoprefixer: { autoprefixer: {
@ -70,7 +69,6 @@ const config = {
} }
} }
} }
} }
module.exports = function (merge) { module.exports = function (merge) {

View File

@ -5,7 +5,5 @@ 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.17", "@tarojs/async-await": "^1.2.0-beta.3",
"@tarojs/components": "1.2.17", "@tarojs/components": "^1.2.0-beta.3",
"@tarojs/redux": "1.2.17", "@tarojs/redux": "^1.2.0-beta.3",
"@tarojs/redux-h5": "1.2.17", "@tarojs/redux-h5": "^1.2.0-beta.3",
"@tarojs/router": "1.2.17", "@tarojs/router": "^1.2.0-beta.3",
"@tarojs/taro": "1.2.17", "@tarojs/taro": "^1.2.0-beta.3",
"@tarojs/taro-alipay": "1.2.17", "@tarojs/taro-alipay": "^1.2.0-beta.3",
"@tarojs/taro-h5": "1.2.17", "@tarojs/taro-h5": "^1.2.0-beta.3",
"@tarojs/taro-swan": "1.2.17", "@tarojs/taro-swan": "^1.2.0-beta.3",
"@tarojs/taro-weapp": "1.2.17", "@tarojs/taro-weapp": "^1.2.0-beta.3",
"@tarojs/webpack-runner": "1.2.17", "@tarojs/webpack-runner": "^1.2.8",
"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.17", "@tarojs/plugin-babel": "^1.2.0-beta.3",
"@tarojs/plugin-csso": "1.2.17", "@tarojs/plugin-csso": "^1.2.0-beta.3",
"@tarojs/plugin-sass": "1.2.17", "@tarojs/plugin-sass": "^1.2.0",
"@tarojs/plugin-uglifyjs": "1.2.17", "@tarojs/plugin-uglifyjs": "^1.2.0-beta.3",
"@tarojs/webpack-runner": "1.2.17", "@tarojs/webpack-runner": "^1.2.0-beta.3",
"@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.17", "eslint-config-taro": "^1.2.0-beta.3",
"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.17" "eslint-plugin-taro": "^1.2.0-beta.3"
} }
} }

View File

@ -19,7 +19,7 @@ class App extends Component {
config = { config = {
pages: [ pages: [
//'pages/index/index', // index页面 //'pages/index/index', // index页面
'pages/home/home',//首页 --------------------- 'pages/home/home',//首页 ---------------------
'pages/login/login',//登入页面 --------------------- 'pages/login/login',//登入页面 ---------------------
@ -89,7 +89,7 @@ class App extends Component {
} }
componentDidMount() { componentDidMount() {
} }
componentDidShow() { } componentDidShow() { }

View File

@ -7,7 +7,6 @@ $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,7 +65,4 @@ page{
text-align: center; text-align: center;
font-size: 25rpx; font-size: 25rpx;
}
.ali-blue-color{
color: #108ee9;
} }

View File

@ -1,255 +0,0 @@
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

@ -1,91 +0,0 @@
.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

@ -1,303 +0,0 @@
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

@ -1,47 +0,0 @@
.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

@ -1,235 +0,0 @@
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

@ -1,47 +0,0 @@
.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

@ -1,172 +0,0 @@
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

@ -1,21 +0,0 @@
.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,11 +35,17 @@ 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

@ -0,0 +1,47 @@
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,14 +35,15 @@ class recommondShop extends Component {
isOpenConsult: false, isOpenConsult: false,
consultTip: '', consultTip: '',
voucherResponseMsg: 'i am voucherResponseMsg', voucherResponseMsg: 'i am voucherResponseMsg',
userName: '', userName: getGlobalStorage('user_identity').username || '',
userPhone: '', userPhone: getGlobalStorage('user_identity').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
@ -222,10 +223,6 @@ 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() { }
@ -268,14 +265,14 @@ 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>
</View> </View>
<View className='input-box'> <View className='input-box'>
@ -283,13 +280,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,7 +148,6 @@ $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,6 +1,7 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text,Picker} from '@tarojs/components' import { View, Text } 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,12 +1,14 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text,Picker } from '@tarojs/components' import { View, Text } 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

@ -0,0 +1,78 @@
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='+encodeURIComponent(goodId) url: '/pages/goods/goods?id='+goodId
}) })
} }
componentDidMount(){ componentDidMount(){

View File

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

View File

@ -1,10 +1,11 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text,Picker } from '@tarojs/components' import { View, Text } 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,setGlobalStorage } from '../../util/getSetStoage'; import { getGlobalStorage } from '../../util/getSetStoage';
class ShopTypeInteractionComp extends Component { class ShopTypeInteractionComp extends Component {
@ -47,14 +48,13 @@ class ShopTypeInteractionComp extends Component {
} }
console.log('店铺分类目录', res) console.log('店铺分类目录', res)
if(!getGlobalStorage('shopTypeObject')){ if(!getGlobalStorage('shopTypeObject')){
setGlobalStorage('shopTypeObject',res.data.data) Taro.setStorageSync('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

@ -42,4 +42,4 @@
} }
} }
} }

View File

@ -1,10 +1,9 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image, Button, Picker } from '@tarojs/components' import { View, Text, Image, Button } from '@tarojs/components'
import { AtInput, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import { AtInput, Picker, 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'
@ -13,384 +12,372 @@ 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() { constructor() {
super(...arguments) super(...arguments)
this.state = { this.state = {
supplys: [], // 需求列表 supplys: [], // 需求列表
demandingState: [{ name: '全部', id: '' }, { name: '在用', id: '1' }, { name: '已抢单', id: '2' }, { name: '已抢光', id: '3' },], // 供求状态选择 demandingState: [{ name: '全部', id: '' }, { name: '在用', id: '1' }, { name: '已抢单', id: '2' }, { name: '已抢光', id: '3' },], // 供求状态选择
demandingStateSelected: { name: '全部', id: '' }, // 当前供求状态 demandingStateSelected: { name: '全部', id: '' }, // 当前供求状态
industryTypeSelected: { name: '全部', id: '' },// 当前行业分类 industryTypeSelected: { name: '全部', id: '' },// 当前行业分类
title: '', title: '',
startDateSel: '', startDateSel: '',
endDateSel: '', endDateSel: '',
isOpenedGrabModal: false, isOpenedGrabModal: false,
grabOrderId: '',//抢到订单的id grabOrderId: '',//抢到订单的id
isGrabOrderSuccess: false,// 是否显示轻提示 isGrabOrderSuccess: false,// 是否显示轻提示
grabOrderSuccess: '无法显示绑定后的字段',// 抢单成功返回字段 grabOrderSuccess: '无法显示绑定后的字段',// 抢单成功返回字段
isAddToList: false,// / 请求业主需求的时候是否添加到旧列表里 isAddToList: false,// / 请求业主需求的时候是否添加到旧列表里
isShowTopNav: false,// 是否显示返回顶部按钮 isShowTopNav: false,// 是否显示返回顶部按钮
loadMorePageIndex: 1 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
}),
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest',
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
}
})
.then(res => {
Taro.hideLoading()
if (res.data.err_code === 0) {
if (res.data.supplys) {
if (this.state.isAddToList) {
this.setState({ supplys: this.state.supplys.concat(res.data.supplys), isAddToList: false })
} else {
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,
icon: 'none'
})
}
console.log('抢单请求:', res)
})
} }
} grabOrder(e) {
const id = onClickValueService(e)
// 搜索业主需求函数 this.setState({ isOpenedGrabModal: true, grabOrderId: id })
searchDemanding({ }
curr_page = 1, handleGrabModalClose() {
page_count = 10, this.setState({ isOpenedGrabModal: false })
sd_title = this.state.title, }
state = this.state.demandingStateSelected.id, handleGrabModalCancel() {
update_dateL = this.state.startDateSel, this.setState({ isOpenedGrabModal: false })
update_dateU = this.state.endDateSel, }
class_id = this.state.industryTypeSelected.id handleGrabConfirm() {
}) { this.setState({ isOpenedGrabModal: false })
Taro.request({ this.GrabDemand({ demandId: this.state.grabOrderId })
url: URL.GetAllDemanding, }
method: 'POST', searchHanlder() {
dataType: 'json', Taro.showLoading({ title: '加载中' })
data: { this.searchDemanding({})
param: JSON.stringify({ }
curr_page: curr_page, //清空筛选项
page_count: page_count, emptyFilter() {
sd_title: sd_title, this.setState({
state: state, title: '',
update_dateL: update_dateL, endDateSel: '',
update_dateU: update_dateU, startDateSel: '',
class_id: class_id demandingStateSelected: { name: '全部', id: '' },
industryTypeSelected: { name: '全部', id: '' },
}), })
}, Taro.showToast({
header: { title: '已清空',
'content-type': 'application/x-www-form-urlencoded', icon: 'success',
'X-Requested-With': 'XMLHttpRequest', duration: 1000
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'), })
}
})
.then(res => {
Taro.hideLoading()
if (res.data.err_code === 0) {
if (res.data.supplys) {
if (this.state.isAddToList) {
this.setState({ supplys: this.state.supplys.concat(res.data.supplys), isAddToList: false })
} else {
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,
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 })
} }
}
// 底部加载 getDataFromChild(value) {
onReachBottom() { console.log('从子组件传回来的值', value)
showLoading({ this.setState({ industryTypeSelected: value })
title: '加载中' }
})
this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => { goToGrabOrderPage(e) {
this.searchDemanding({ curr_page: this.state.loadMorePageIndex }) const id = onClickValueService(e)
}) Taro.navigateTo({
url: '/pages/grabOrderPage/grabOrderPage?orderId=' + id
})
}
} componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps)
render() { }
// 提示模态弹窗element componentDidMount() {
// 得到第一页需求数据
Taro.showLoading({ title: '加载中' }).then(() => {
this.searchDemanding({})
})
const modalMessageGrabElement = <AtModal isOpened={this.state.isOpenedGrabModal}> }
<AtModalHeader>提示</AtModalHeader>
<AtModalContent> 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() {
Taro.showLoading({
title: '加载中'
})
this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => {
this.searchDemanding({ curr_page: this.state.loadMorePageIndex })
})
}
render() {
// 提示模态弹窗element
const modalMessageGrabElement = <AtModal isOpened={this.state.isOpenedGrabModal}>
<AtModalHeader>提示</AtModalHeader>
<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='picker-wrapper'> <View className='page-section'>
<Picker className='picker-container' mode='date' start={this.state.startDateSel} onChange={this.onEndDateChange}> {/* 供求状态选择 */}
<View className='picker'> <View>
<View className='title-box'> <Picker mode='selector' rangeKey='name' range={this.state.demandingState} onChange={this.changeDemandingState}>
<Text className='title'>结束日期:</Text> <Text className='date'>{this.state.endDateSel}</Text> <View className='picker'>
</View> <View className='title-box'>
<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

@ -16,35 +16,32 @@ $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;
@ -66,11 +63,11 @@ $themeColor: #FF7142;
flex-direction: row; flex-direction: row;
margin: 40px 0 0; margin: 40px 0 0;
padding: 0 120px; padding: 0 120px;
.button{ .button{
flex:1; flex:1;
text-align: center; text-align: center;
// .button-s{ // .button-s{
// // color:white; // // color:white;
@ -81,7 +78,7 @@ $themeColor: #FF7142;
// // background-color:$themeColor; // // background-color:$themeColor;
// // border:1PX solid $themeColor; // // border:1PX solid $themeColor;
// } // }
// .button-b{ // .button-b{
// width: 150px; // width: 150px;
// background-color:#d9534f; // background-color:#d9534f;
@ -153,8 +150,8 @@ $themeColor: #FF7142;
right:20px; right:20px;
} }
} }
} }
.footer{ .footer{
display: flex; display: flex;
@ -163,7 +160,7 @@ $themeColor: #FF7142;
font-size: 25rpx; font-size: 25rpx;
.location{ .location{
flex:1 flex:1
} }
.time{ .time{
flex:1 flex:1
} }
@ -171,7 +168,7 @@ $themeColor: #FF7142;
} }
} }
} }
.button{ .button{
.at-button--primary{ .at-button--primary{

View File

@ -1,108 +0,0 @@
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

@ -1,72 +0,0 @@
.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

@ -1,117 +0,0 @@
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

@ -1,22 +0,0 @@
.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,17 +1,13 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image, Swiper, SwiperItem, Picker } from '@tarojs/components' import { View, Text, Image, Swiper, SwiperItem } from '@tarojs/components'
import { AtIcon } from 'taro-ui'
import GoodCommentSection from './goodCommentSection/goodCommentSection' import { AtTabs, AtTabsPane, AtSegmentedControl, AtIcon, Picker } from 'taro-ui'
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 {
@ -35,26 +31,21 @@ 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: goodId, goodsID: this.$router.params.id,
}, },
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'),
} }
@ -89,13 +80,13 @@ class Goods extends Component {
} }
// 大类评论区方法 // 大类评论区方法
mainTabClick(value) { handleClick(value) {
this.setState({ this.setState({
current: value current: value
}) })
} }
// 小磊评论区方法 // 小磊评论区方法
subTabClick(value) { onClick(value) {
this.setState({ this.setState({
subCurrent: value subCurrent: value
}) })
@ -131,18 +122,6 @@ 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({
@ -151,9 +130,9 @@ class Goods extends Component {
} }
componentDidMount() { componentDidMount() {
showLoading({ Taro.showLoading({
title: '加载中' title: '加载中'
}) })
this.getGoodDescription() this.getGoodDescription()
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
@ -167,9 +146,7 @@ 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} >
@ -179,19 +156,25 @@ 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}
@ -257,20 +240,70 @@ 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>
@ -297,7 +330,7 @@ class Goods extends Component {
</View> </View>
</View> </View>
</View > </View>
) )
} }
} }

View File

@ -119,7 +119,30 @@ $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;
@ -190,3 +213,4 @@ $themeColor:#FF7142;
} }
} }

View File

@ -1,13 +1,11 @@
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, AtTextarea, AtImagePicker } from 'taro-ui' import { AtInput, AtImagePicker, AtTextarea, } 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'
@ -16,9 +14,6 @@ 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 {
@ -28,6 +23,7 @@ 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: '',
@ -112,7 +108,7 @@ class GoodsPublish extends Component {
if (this.state.isPublish) { if (this.state.isPublish) {
// 导航到编辑页面 // 导航到编辑页面
Taro.redirectTo({ Taro.redirectTo({
url: '/pages/myGoodList/myGoodList' url: '/pages/myGoodsList/myGoodsList'
}) })
} else if (this.state.isPublishAndAdd) { } else if (this.state.isPublishAndAdd) {
// 导航到发布页面 // 导航到发布页面
@ -209,12 +205,7 @@ class GoodsPublish extends Component {
}) })
} }
} }
// 从图片子组件获取信息
getImageDetails(value) {
this.setState({
ImagesInfo: value
})
}
publishButtonHandler() { publishButtonHandler() {
if (this.state.productName && if (this.state.productName &&
@ -223,22 +214,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) {
showLoading({ title: '发布中' }) Taro.showLoading({ title: '发布中' }).then(() => {
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' })
} }
@ -251,22 +242,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) {
showLoading({ title: '发布中' }) Taro.showLoading({ title: '发布中' }).then(() => {
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' })
} }
@ -298,8 +289,8 @@ class GoodsPublish extends Component {
} }
} }
componentDidMount() { componentDidMount() {
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
// console.log(this.props, nextProps) // console.log(this.props, nextProps)
} }
@ -307,7 +298,12 @@ class GoodsPublish extends Component {
componentWillUnmount() { } componentWillUnmount() { }
componentDidShow() { componentDidShow() {
isUserShopOwner() if (!getGlobalStorage('shopInfo').shop_id && getGlobalStorage('userInfo').user_id) {
Taro.showToast({
title: '您还没有店铺,不能使用该功能,快去申请吧',
icon: 'none'
})
}
} }
componentDidHide() { } componentDidHide() { }
@ -321,16 +317,11 @@ class GoodsPublish extends Component {
<View className='goods-category'> <View className='goods-category'>
{/* 商品分类开始 */} {/* 商品分类开始 */}
{platformChecker() ? <GoodsTypeInteractionComp <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'>
@ -373,7 +364,7 @@ class GoodsPublish extends Component {
<Text className='require'>*</Text> <Text className='require'>*</Text>
<Text className='title'>上传图片:</Text> <Text className='title'>上传图片:</Text>
</View> </View>
{platformChecker() ? <View className='img-container'> <View className='img-container'>
<AtImagePicker <AtImagePicker
multiple multiple
files={this.state.pickerImageUrl} files={this.state.pickerImageUrl}
@ -381,24 +372,14 @@ 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> : <AliPictureUploadComponent maxLength={20} isReceiveImageUrl={false} url={URL.UploadGoodsPorductImage} onGetImageDetails={this.getImageDetails.bind(this)} /> </View>
}
</View> </View>
{/* 店铺分类 */} {/* 店铺分类 */}
{platformChecker() ? <ShopTypeInteractionComp url={URL.GetShopCategoryList}
<ShopTypeInteractionComp url={URL.GetShopCategoryList} shopId={getGlobalStorage('shopInfo').shop_id}
shopId={getGlobalStorage('shopInfo').shop_id} selectedValue={this.state.shopTypeSelected}
selectedValue={this.state.shopTypeSelected} onPassDataToChild={this.getDataFromShopChild.bind(this)}
onPassDataToChild={this.getDataFromShopChild.bind(this)} ></ShopTypeInteractionComp>
></ShopTypeInteractionComp>
: <AliShopTypeInteraction url={URL.GetShopCategoryList}
shopId={getGlobalStorage('shopInfo') ? getGlobalStorage('shopInfo').shop_id : ''}
selectedValue={this.state.shopTypeSelected}
onPassDataToChild={this.getDataFromShopChild.bind(this)}
></AliShopTypeInteraction>
}
{/* 店铺分类结束 */} {/* 店铺分类结束 */}
@ -407,19 +388,12 @@ class GoodsPublish 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.productDescript}
placeholder='你的产品简介'
maxlength='140' /></View>
}
</View> </View>
</View> </View>
<View className='button-box' > <View className='button-box' >

View File

@ -18,20 +18,17 @@ $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;
} }
} }
@ -91,7 +88,6 @@ $themeColor:#FF7142;
.page-section{ .page-section{
border-bottom: 1Px solid #d6e4ef; border-bottom: 1Px solid #d6e4ef;
} }
.selected{ .selected{
display: inline-block; display: inline-block;
@ -101,7 +97,6 @@ $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;
@ -109,23 +104,5 @@ $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,7 +10,6 @@ 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 {
@ -30,6 +29,7 @@ class GrabOrderPage extends Component {
content: '', content: '',
images: [], images: [],
isOpen: false, // 抢单消息提示 isOpen: false, // 抢单消息提示
grabOrderId: this.$router.params.orderId,
stateId: '', stateId: '',
stateName: '', stateName: '',
userId: '', userId: '',
@ -40,13 +40,12 @@ 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: orderId, demandId: this.$router.params.orderId,
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -74,10 +73,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'
}) })
} }
@ -89,13 +88,12 @@ 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: id demandId: demandId
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -113,7 +111,7 @@ class GrabOrderPage extends Component {
}) })
setTimeout(() => { setTimeout(() => {
Taro.navigateBack({ Taro.navigateBack({
delta: 1 delta:1
}) })
}, 1500); }, 1500);
@ -155,16 +153,15 @@ class GrabOrderPage extends Component {
handleGrabConfirm() { handleGrabConfirm() {
this.setState({ isOpen: false }) this.setState({ isOpen: false })
// 确认抢单之后 // 确认抢单之后
showLoading({ Taro.showLoading({
title: '加载中' title: '加载中'
}) })
this.GrabDemand({ demandId: this.state.grabOrderId })
this.GrabDemand({ demandId: this.$router.params.orderId })
} }
componentDidMount() { componentDidMount() {
showLoading({ Taro.showLoading({
title: '加载中' title:'加载中'
}) })
this.getGrabOrderInfo() this.getGrabOrderInfo()
} }
@ -188,7 +185,7 @@ class GrabOrderPage extends Component {
}) })
} }
goMyNeedEditPage() { goMyNeedEditPage() {
let id = encodeURIComponent(this.$router.params.orderId) let id = this.$router.params.orderId
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/myNeedsEdit/myNeedsEdit?id=' + id url: '/pages/myNeedsEdit/myNeedsEdit?id=' + id
}) })
@ -200,18 +197,16 @@ 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: id demandId: demandId
}, },
header: { header: {
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'), 'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
@ -228,7 +223,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) {
@ -244,7 +239,7 @@ class GrabOrderPage extends Component {
} }
render() { render() {
const localStoageUserId = getGlobalStorage('userInfo') ? getGlobalStorage('userInfo').user_id : '' const localStoageUserId = getGlobalStorage('userInfo').user_id
// 提示框 // 提示框
const deleteModalWindowElement = <AtModal isOpened={this.state.isDeleteModal}> const deleteModalWindowElement = <AtModal isOpened={this.state.isDeleteModal}>
@ -254,82 +249,58 @@ 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)}>
let ButtonElement = localStoageUserId === this.state.userId ? <View className='button-box'> <Button size='mini' className='button-dark-red'>
<View className='button' onClick={this.goMyNeedsPublishPage.bind(this)}> <AtIcon value='trash' size='12' color='white'></AtIcon>
<Button size='mini' className='button-green'> 删除</Button>
<AtIcon value='add' size='12' color='white'></AtIcon> </View> */}
新增</Button>
</View> </View>
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}> } else if (localStoageUserId === this.state.userId && this.state.stateId != '1') {
<Button size='mini' className='button-orange'> ButtonElement = <View className='button-box'>
<AtIcon value='' size='12' color='white'></AtIcon> <View className='button' onClick={this.goMyNeedsPublishPage.bind(this)}>
我的需求</Button> <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> </View>
</View> : } else if (this.state.stateId === '1') {
this.state.stateId === '1' ? <View className='button-box'><View className='button' onClick={this.grabButtonHandler.bind(this)}> ButtonElement = <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') {
// if (localStoageUserId === this.state.userId && this.state.stateId === '1') { ButtonElement = <View className='button-box'><View className='button'>
// ButtonElement = <View className='button-box'> <Button size='mini' className='button-orange blur'>{this.state.stateName}</Button>
// <View className='button' onClick={this.goMyNeedsPublishPage.bind(this)}> </View></View>
// <Button size='mini' className='button-green'> } else if (this.state.stateId === '3') {
// <AtIcon value='add' size='12' color='white'></AtIcon> ButtonElement = <View className='button-box'><View className='button'>
// 新增</Button> <Button size='mini' className='button-orange blur'>{this.state.stateName}</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>
// }
@ -353,7 +324,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,8 +12,7 @@ class ClientDemanding extends Component {
} }
// 导航去抢单页面 // 导航去抢单页面
goToGrabOrderPage(e) { goToGrabOrderPage(e) {
const id = onClickValueService(e) const orderId = 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,8 +17,6 @@ $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;
@ -41,7 +39,7 @@ $themeColor: #FF7142;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
.button-orange{ .button-orange{
color:white; color:white;
font-size: 28px; font-size: 28px;
@ -51,9 +49,9 @@ $themeColor: #FF7142;
.blur{ .blur{
opacity: 0.5; opacity: 0.5;
} }
} }
.last{ .last{
border-right: 2px solid #ddd; border-right: 2px solid #ddd;
} }

View File

@ -13,8 +13,6 @@ 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';
@ -37,8 +35,8 @@ class Home extends Component {
otherData: [], // 底部导航栏 otherData: [], // 底部导航栏
isOpen: false, // 抢单消息提示 isOpen: false, // 抢单消息提示
grabOrderId: '',//抢到订单的id grabOrderId: '',//抢到订单的id
userName: '',//用户名字 userName: Taro.getStorageSync('user_identity').userName || '',//用户名字
userPhone: '',// 用户电话 userPhone: Taro.getStorageSync('user_identity').userPhone || '',// 用户电话
isShowTopNav: false,// 是否显示返回顶部按钮 isShowTopNav: false,// 是否显示返回顶部按钮
loadMorePageIndex: 1,//下拉加载页面数 loadMorePageIndex: 1,//下拉加载页面数
isAddToList: false, isAddToList: false,
@ -52,7 +50,7 @@ class Home extends Component {
} }
// onPullDownRefresh() { // onPullDownRefresh() {
// showLoading({ title: '加载中' }) // Taro.showLoading({ title: '加载中' })
// this.login().then(() => { // this.login().then(() => {
// this.getShops({}) // this.getShops({})
@ -92,7 +90,7 @@ class Home extends Component {
} }
}) })
} }
// api 得到推荐商店的信息 // api 得到推荐商店的信息
getShops({ parent_supply_class = this.state.parentClass, supply_class = this.state.childClass, supply_level = this.state.supplyLevel, curr_page = 1, 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" }) { page_count = 5, action = "2" }) {
Taro.request({ Taro.request({
@ -114,7 +112,6 @@ 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 => {
@ -147,11 +144,13 @@ 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) {
@ -160,25 +159,32 @@ class Home extends Component {
reject(res) reject(res)
}, },
}) })
})
} else if (process.env.TARO_ENV === 'weapp') {
return new Promise((resolve, reject) => {
Taro.getLocation({
type: 'wgs84', // 返回可以用于wx.openLocation的经纬度
success(res) {
resolve(res)
},
fail(res) {
Taro.showToast({
title: '获取定位失败',
icon: 'none'
})
reject(res)
}
}) })
} else if (process.env.TARO_ENV === 'weapp') {
return new Promise((resolve, reject) => { })
Taro.getLocation({
type: 'wgs84', // 返回可以用于wx.openLocation的经纬度 }
success(res) {
resolve(res)
},
fail(res) {
Taro.showToast({
title: '获取定位失败',
icon: 'none'
})
reject(res)
}
})
})
}
} }
@ -234,8 +240,8 @@ class Home extends Component {
// 点击大类icon // 点击大类icon
onClickParentCate(e) { onClickParentCate(e) {
const item = onClickValueService(e) const item = onClickValueService(e)
showLoading({ Taro.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 || [] }, () => {
@ -245,7 +251,7 @@ class Home extends Component {
// 点击子类 // 点击子类
clickChildCateHanlder(e) { clickChildCateHanlder(e) {
const item = onClickValueService(e) const item = onClickValueService(e)
showLoading({ Taro.showLoading({
title: '加载中' title: '加载中'
}) })
this.setState({ childClass: item.class_id, supplyLevel: 2 }, () => { this.setState({ childClass: item.class_id, supplyLevel: 2 }, () => {
@ -293,6 +299,8 @@ class Home extends Component {
this.GrabDemand({ demandId: this.state.grabOrderId }) this.GrabDemand({ demandId: this.state.grabOrderId })
} }
goToMyNeedsPublish() { goToMyNeedsPublish() {
// 传参数给myNeedsPublish页面- 显示效果图选项 // 传参数给myNeedsPublish页面- 显示效果图选项
Taro.navigateTo({ Taro.navigateTo({
@ -304,23 +312,27 @@ class Home extends Component {
componentDidMount() { componentDidMount() {
// 页面加载后 得到首页的基本信息和推荐店铺的信息 // 页面加载后 得到首页的基本信息和推荐店铺的信息
showLoading({ title: '加载中' })
// promise 返回经纬度给state 然后调用函数
this.getShops({})
this.getHomeCategoriesInfo()
Taro.getStorageSync('userInfo').user_id ? true : weChatLogin()
Taro.showLoading({ title: '加载中' })
// promise 返回经纬度给state 然后调用函数
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 => {
Taro.showToast({ this.getShops({})
title: '定位获取失败', this.getHomeCategoriesInfo()
icon: 'none'
})
}) })
// 本地缓存没有userid时 从新登入
Taro.getStorageSync('userInfo').user_id ? true : weChatLogin()
} }
componentWillMount() { componentWillMount() {
@ -351,7 +363,7 @@ class Home extends Component {
} }
// 底部加载 // 底部加载
onReachBottom() { onReachBottom() {
showLoading({ Taro.showLoading({
title: '加载中' title: '加载中'
}) })
this.setState({ loadMorePageIndex: this.state.loadMorePageIndex + 1, isAddToList: true }, () => { this.setState({ loadMorePageIndex: this.state.loadMorePageIndex + 1, isAddToList: true }, () => {
@ -421,7 +433,7 @@ class Home extends Component {
</Swiper> </Swiper>
</View> </View>
{/* 第二行图片滚动条 */} {/* 第二行图片滚动条 */}
<View className='second-banner'> <View className='second-banner'>
<MainCateSlider onScrollFromChild={this.scrollToSubFromChild.bind(this)} firstSlideData={mainCate1} secondSlideData={mainCate2} /> <MainCateSlider onScrollFromChild={this.scrollToSubFromChild.bind(this)} firstSlideData={mainCate1} secondSlideData={mainCate2} />
</View> </View>

View File

@ -9,14 +9,7 @@ $themeColor: #FF7142;
width: 100%; width: 100%;
} }
} }
.first-banner { .first-banner ,.third-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 , Swiper, SwiperItem } from '@tarojs/components' import { View } from '@tarojs/components'
import { AtGrid} from 'taro-ui' import { AtGrid, Swiper, SwiperItem } from 'taro-ui'
import URL from '../../../serviceAPI.config' import URL from '../../../serviceAPI.config'
import './mainCateSlider.scss' import './mainCateSlider.scss'
@ -28,6 +28,7 @@ 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,40 +1,45 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, ScrollView } from '@tarojs/components' import { View } 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)
}
render() { passDataToParent(e) {
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>
})
return ( this.props.onClickChildCate(e)
}
<ScrollView render() {
className='scroll-view' const { subCateList } = this.props
scrollX const subCateElementsArray = subCateList.map((item, index) => {
scrollWithAnimation return <View key={index} onClick={this.passDataToParent.bind(this, item)} className='view-item'>
scrollTop='0' <View className='text'>{item.class_name}</View>
lowerThreshold='20' </View>
upperThreshold='20' })
style='white-space: nowrap;'
>
{subCateElementsArray} return (
</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,12 +2,10 @@
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,7 +9,6 @@ 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';
@ -19,7 +18,6 @@ class IndividualCenter extends Component {
navigationBarTitleText: '个人中心' navigationBarTitleText: '个人中心'
} }
constructor() { constructor() {
super(...arguments);
this.state = { this.state = {
client: [ client: [
{ {
@ -54,12 +52,12 @@ class IndividualCenter extends Component {
username: '', username: '',
avatar: '', avatar: '',
isShop: false, isShop: false,
vip_level: '' vip_level:''
} }
} }
handlerGridClick(e) { handlerGridClick(e) {
const value = onClickValueService(e).value const value = onClickValueService(e).value
switch (value) { switch (value) {
case '需求发布': case '需求发布':
Taro.switchTab({ Taro.switchTab({
@ -103,25 +101,19 @@ 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() {
isUserLogin().then(res=>{ this.getInfoFromStorage()
return res
}).then(res=>{
this.getInfoFromStorage()
})
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps) console.log(this.props, nextProps)
@ -130,13 +122,17 @@ class IndividualCenter extends Component {
componentWillUnmount() { } componentWillUnmount() { }
componentDidShow() { componentDidShow() {
isUserLogin() if (!getGlobalStorage('userInfo').user_id) {
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'>
@ -160,14 +156,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,7 +11,6 @@ class Login extends Component {
navigationBarTitleText: '登入' navigationBarTitleText: '登入'
} }
constructor() { constructor() {
super(...arguments);
this.state = { this.state = {
username: '', username: '',
password: '', password: '',
@ -32,11 +31,9 @@ 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 => {
setTimeout(() => { Taro.reLaunch({
Taro.reLaunch({ url: '/pages/home/home'
url: '/pages/home/home' })
})
}, 1000);
}).catch(res => { }).catch(res => {
Taro.showToast({ Taro.showToast({
title: res.data.msg, title: res.data.msg,
@ -67,7 +64,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, Picker } from '@tarojs/components' import { View, Text, Button, Input } from '@tarojs/components'
import { AtInput, AtImagePicker, AtTextarea, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import { AtInput, AtImagePicker, AtTextarea, Picker, 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,8 +10,6 @@ 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';
@ -34,8 +32,6 @@ 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
@ -46,13 +42,12 @@ 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: sdId, sdID: this.$router.params.sdId,
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -78,16 +73,14 @@ 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'
}) })
} }
}) })
@ -104,7 +97,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({
@ -121,7 +114,7 @@ class MyDemandSupplyEdit extends Component {
data: { data: {
action: 2, action: 2,
sdInfo: JSON.stringify({ sdInfo: JSON.stringify({
sd_id: sd_id, sd_id: this.$router.params.sdId,
sd_type: sd_type, sd_type: sd_type,
sd_title: sd_title, sd_title: sd_title,
user_name: user_name, user_name: user_name,
@ -156,7 +149,7 @@ class MyDemandSupplyEdit extends Component {
} else { } else {
Taro.redirectTo({ Taro.redirectTo({
url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面 url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面
}) })
} }
}, 1000); }, 1000);
}) })
@ -219,13 +212,6 @@ class MyDemandSupplyEdit extends Component {
}) })
} }
} }
// 从图片子组件获取信息
getImageDetails(value) {
this.setState({
ImagesInfo: value
})
}
// 删除我的供求api // 删除我的供求api
onDelete({ sdID = 0 }) { onDelete({ sdID = 0 }) {
Taro.request({ Taro.request({
@ -297,9 +283,10 @@ 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) {
showLoading({ title: '保存中' }) Taro.showLoading({ title: '保存中' }).then(() => {
this.setState({ isSaveAndNew: false }, () => { this.setState({ isSaveAndNew: false }, () => {
this.uploadDemSup({}) this.uploadDemSup({})
})
}) })
} else { } else {
@ -314,11 +301,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) {
showLoading({ title: '保存中' }) Taro.showLoading({ title: '保存中' }).then(() => {
this.setState({ isSaveAndNew: true }, () => { this.setState({ isSaveAndNew: true }, () => {
this.uploadDemSup({}) this.uploadDemSup({})
})
}) })
} else { } else {
Taro.showToast({ Taro.showToast({
title: '请填写完表格', title: '请填写完表格',
@ -330,7 +317,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 })
@ -349,7 +336,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)
showLoading({ title: '加载中' }) Taro.showLoading({ title: '加载中' })
this.getSupplyDemandInfo() this.getSupplyDemandInfo()
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
@ -427,44 +414,32 @@ 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>
{platformChecker() ? <AtTextarea <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}
@ -473,14 +448,8 @@ 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> : <AliPictureUploadComponent </View>
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

@ -76,14 +76,4 @@ $themeColor:#FF7142;
.title-box{ .title-box{
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, Button, MovableArea, MovableView, CheckboxGroup, Checkbox ,Picker, Image , Text} from '@tarojs/components' import { View, Radio, Button, MovableArea, MovableView } from '@tarojs/components'
import { AtInput, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import { AtInput, Text, AtIcon, Picker, Image, 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,7 +9,6 @@ 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 {
@ -38,7 +37,7 @@ class MyGoodList extends Component {
}, // 正反排序 }, // 正反排序
selectedFilterValue: 0, // selectedFilterValue: 0, //
myGoodList: [],// 保存后台返回的商品列表 myGoodList: [],// 保存后台返回的商品列表
myGoodListTotal: '0',// 后台的商品总数 myGoodListTotal: '0',// 后台的商品总数
goodsStateParam: 1,//商品状态参数 goodsStateParam: 1,//商品状态参数
pageCountParam: 20,// 商品数量参数 pageCountParam: 20,// 商品数量参数
currPageParam: 1,// 当前页面 参数 currPageParam: 1,// 当前页面 参数
@ -144,14 +143,13 @@ class MyGoodList extends Component {
'X-Requested-With': 'XMLHttpRequest' 'X-Requested-With': 'XMLHttpRequest'
} }
}).then(res => { }).then(res => {
Taro.hideLoading() const data = JSON.parse(res.data)
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
@ -247,7 +245,7 @@ class MyGoodList extends Component {
// } // }
// 商品列表下架API // 商品列表下架API
changeGoodState({ goodsState = 0, goodsID = this.state.goodsIdList }) { changeGoodState({ goodsState = 0, goodsID = this.state.goodsIdList }) {
Taro.request({ Taro.request({
url: URL.ChangeGoodState, url: URL.ChangeGoodState,
@ -311,8 +309,7 @@ class MyGoodList extends Component {
'X-Requested-With': 'XMLHttpRequest' 'X-Requested-With': 'XMLHttpRequest'
} }
}).then(res => { }).then(res => {
console.log('res',res) let responseData = JSON.parse(res.data)
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({
@ -341,6 +338,10 @@ class MyGoodList extends Component {
}) })
} }
// 搜索 // 搜索
searchButtonHandler() { searchButtonHandler() {
Taro.showLoading({ Taro.showLoading({
@ -493,14 +494,11 @@ class MyGoodList extends Component {
// 单个商品选择 // 单个商品选择
handleCheckChange(e) { handleCheckChange(e) {
//如果goodid 一样的那么checked 就取反 //如果goodid 一样的那么checked 就取反
// const id = onClickValueService(e) console.log('clicke')
const id = e.detail.value const id = onClickValueService(e)
const newMyGoodList = this.state.myGoodList.map((item) => { const newMyGoodList = this.state.myGoodList.map((item) => {
if (id.includes(item.goods_id)) { if (item.goods_id === id) {
item['checked'] = true item['checked'] = !item.checked
} else {
item['checked'] = false
} }
return item return item
}) })
@ -520,6 +518,9 @@ class MyGoodList extends Component {
duration: 1500 duration: 1500
}) })
// // this.deleteGood({ goodsID: checkedGoodsId }) // // this.deleteGood({ goodsID: checkedGoodsId })
} }
// 改变商品状态 // 改变商品状态
offStockGoodHandler() { offStockGoodHandler() {
@ -538,11 +539,11 @@ class MyGoodList extends Component {
} }
// 导航到商品编辑页面myGoodsEdit // 导航到商品编辑页面myGoodsEdit
goToGoodEditPage(e) { goToGoodEditPage(e) {
console.log('e',e)
const goodId = onClickValueService(e) const goodId = onClickValueService(e)
const id=encodeURIComponent(goodId) console.log('goodId',goodId)
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/myGoodsEdit/myGoodsEdit?id=' + id url: '/pages/myGoodsEdit/myGoodsEdit?id=' + goodId
}) })
} }
// 导航到商品发布页面 // 导航到商品发布页面
@ -554,9 +555,8 @@ 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=' + id url: '/pages/goods/goods?id=' + goodId
}) })
} }
@ -658,11 +658,11 @@ class MyGoodList extends Component {
} }
render() { render() {
//等待接口数据 //等待接口数据
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'>
<Checkbox className='radio' value={item.goods_id} checked={item.checked} ></Checkbox > <Radio className='radio' value={item.goods_id} checked={item.checked} onClick={this.handleCheckChange.bind(this, item.goods_id)} ></Radio>
<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,23 +818,19 @@ class MyGoodList extends Component {
</View> </View>
<View className='sub-filter'> <View className='sub-filter'>
<CheckboxGroup className='align-item' onChange={this.checkAllHandler.bind(this)}> <Radio className='radio' checked={this.state.isCheckAll} onClick={this.checkAllHandler.bind(this)}>全选</Radio>
<Checkbox className='radio' checked={this.state.isCheckAll} >全选</Checkbox> <View className='button' onClick={this.deleteGoodsHandler.bind(this)}>
</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 align-item' onClick={this.offStockGoodHandler.bind(this)}> <View className='button' 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'>
<CheckboxGroup onChange={this.handleCheckChange.bind(this)}> {goodListElementArray}
{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}
@ -843,9 +839,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'> <MovableView className='movable-point' x={this.state.screenWidth} y={this.state.screenHeight} style='opacity:0.3' direction='all' onClick={this.goToCenterPage.bind(this)} >
<View onClick={this.goToCenterPage.bind(this)}> 个人中心</View> 个人中心
</MovableView> </MovableView>
</MovableArea> </MovableArea>
) )

View File

@ -17,10 +17,6 @@ $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,18 +1,14 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Button } from '@tarojs/components' import { View, Text } from '@tarojs/components'
import { AtInput, AtTextarea, AtImagePicker } from 'taro-ui' import { AtInput, AtImagePicker, AtTextarea, Button, } 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 = {
@ -28,8 +24,6 @@ class MyGoodsEdit extends Component {
productDescript: '', productDescript: '',
pickerImageUrl: [], // 上传的图片 pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息 ImagesInfo: [],// 后台传回来的图片信息
initialImagesInfo: [],//初始化图片信息
initialImageURL: [],//初始化图片url
goodsTypeParam: '',//商品分类参数 goodsTypeParam: '',//商品分类参数
goodId: '',//商品id goodId: '',//商品id
isSaveButton: false,//是否点击了保存按钮 isSaveButton: false,//是否点击了保存按钮
@ -39,13 +33,12 @@ 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: goodsID, goodsID: this.$router.params.id,
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -55,27 +48,25 @@ 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) {
@ -90,8 +81,6 @@ 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,
@ -184,14 +173,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'
@ -297,12 +286,6 @@ 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]
@ -313,20 +296,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) {
showLoading({ title: '保存中' }) Taro.showLoading({ title: '保存中' }).then(() => {
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: '请填写完表格',
@ -339,21 +322,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) {
showLoading({ title: '保存中' }) Taro.showLoading({ title: '保存中' }).then(() => {
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: '请填写完表格',
@ -365,9 +348,8 @@ class MyGoodsEdit extends Component {
} }
goToGoodsDetailPage() { goToGoodsDetailPage() {
let goodsID = encodeURIComponent(this.$router.params.id)
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/goods/goods?id=' + goodsID url: '/pages/goods/goods?id=' + this.$router.params.id
}) })
} }
goToMyGoodListPage() { goToMyGoodListPage() {
@ -380,16 +362,18 @@ class MyGoodsEdit extends Component {
console.log('从子组件店铺分类传回来的值', value) console.log('从子组件店铺分类传回来的值', value)
this.setState({ shopTypeSelected: value }) this.setState({ shopTypeSelected: value })
} }
componentDidMount() { componentDidMount() {
showLoading({ Taro.showLoading({
title: '加载中' title:'加载中'
}) })
this.getGoodsInfo() this.getGoodsInfo()
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
// console.log(this.props, nextProps)
} }
componentWillUnmount() { } componentWillUnmount() { }
@ -400,10 +384,8 @@ 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>
@ -447,7 +429,7 @@ class MyGoodsEdit extends Component {
<Text className='require'>*</Text> <Text className='require'>*</Text>
<Text className='title'>上传图片:</Text> <Text className='title'>上传图片:</Text>
</View> </View>
{platformChecker() ? <View className='img-container'> <View className='img-container'>
<AtImagePicker <AtImagePicker
multiple multiple
files={this.state.pickerImageUrl} files={this.state.pickerImageUrl}
@ -455,31 +437,15 @@ 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> : <AliPictureUploadComponent </View>
maxLength={20}
isReceiveImageUrl={true}
initialImageURL={this.state.initialImageURL}
initialImagesInfo={this.state.initialImagesInfo}
url={URL.UploadGoodsPorductImage}
onGetImageDetails={this.getImageDetails.bind(this)}
/>}
</View> </View>
{/* 店铺分类 */} {/* 店铺分类 */}
{platformChecker() ? <ShopTypeInteractionComp url={URL.GetShopCategoryList}
<ShopTypeInteractionComp url={URL.GetShopCategoryList} shopId={getGlobalStorage('shopInfo').shop_id}
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)}
></AliShopTypeInteraction>} ></ShopTypeInteractionComp>
{/* 店铺分类结束 */} {/* 店铺分类结束 */}
<View className='description-box'> <View className='description-box'>
@ -487,19 +453,13 @@ 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,22 +7,20 @@ $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;
} }
} }
@ -31,7 +29,6 @@ $themeColor:#FF7142;
} }
.description-box{ .description-box{
margin-top:10Px; margin-top:10Px;
} }
} }
@ -100,21 +97,9 @@ $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,12 +1,10 @@
//myNeeds //myNeeds
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Button, Picker, Input } from '@tarojs/components' import { View, Text, Button } from '@tarojs/components'
import { AtInput, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import { AtInput, Picker, 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'
@ -14,9 +12,6 @@ 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 {
@ -190,21 +185,21 @@ class MyNeeds extends Component {
// 搜索按钮 // 搜索按钮
onSearchButtonHandler() { onSearchButtonHandler() {
showLoading({ title: '加载中' }) Taro.showLoading({ title: '加载中' }).then(() => {
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() {
@ -288,15 +283,10 @@ class MyNeeds extends Component {
componentDidMount() { componentDidMount() {
isUserLogin().then(res => { Taro.showLoading({
return res title: '加载中'
}).then(res => {
showLoading({
title: '加载中'
})
this.getMyNeedsList({})
}) })
this.getMyNeedsList({})
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
@ -306,7 +296,10 @@ class MyNeeds extends Component {
componentWillUnmount() { } componentWillUnmount() { }
componentDidShow() { componentDidShow() {
isUserLogin() if (!getGlobalStorage('userInfo').user_id) {
LoginService()
return
}
} }
componentDidHide() { } componentDidHide() { }
@ -321,7 +314,7 @@ class MyNeeds extends Component {
} }
// 底部加载 // 底部加载
onReachBottom() { onReachBottom() {
showLoading({ Taro.showLoading({
title: '加载中' title: '加载中'
}) })
this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => { this.setState({ isAddToList: true, loadMorePageIndex: this.state.loadMorePageIndex + 1 }, () => {
@ -389,13 +382,12 @@ 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-picker'> <View className='page-section'>
<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}>
@ -419,14 +411,7 @@ 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,47 +64,6 @@ $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%
}
} }
} }
} }
@ -143,6 +102,7 @@ $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,18 +1,14 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Button, Input, Picker } from '@tarojs/components' import { View, Text, Button, Input } from '@tarojs/components'
import { AtInput, AtTextarea, AtModal, AtModalHeader, AtModalContent, AtModalAction, AtImagePicker } from 'taro-ui' import { AtInput, AtImagePicker, AtTextarea, Picker, AtModal, AtModalHeader, AtModalContent, AtModalAction } 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 {
@ -38,24 +34,22 @@ class MyNeedsEdit extends Component {
contactAddress: '', contactAddress: '',
content: '',//描述 content: '',//描述
pickerImageUrl: [], pickerImageUrl: [],
ImagesInfo: [],// 图片详细信息 ImagesInfo: '',
initialImagesInfo: [],//初始化图片信息
initialImageURL: [],//初始化图片url
isDeleteModal: false,// 删除提示框 isDeleteModal: false,// 删除提示框
isSaveAndNew: false,//是否点击保存新增按钮 isSaveAndNew: false,//是否点击保存新增按钮
} }
} }
//获取需求信息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: id, demandId: this.$router.params.id,
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -68,7 +62,7 @@ class MyNeedsEdit extends Component {
// const selectedType = this.state.demandingSupplyCate.filter(item => item.id == res.data.sdInfo.sd_type)[0] // const selectedType = this.state.demandingSupplyCate.filter(item => item.id == res.data.sdInfo.sd_type)[0]
// const selectedState = this.state.needsState.filter(item => item.id == res.data.sdInfo.state)[0] // const selectedState = this.state.needsState.filter(item => item.id == res.data.sdInfo.state)[0]
if (res.data.err_code === 0) { if (res.data.err_code === 0) {
let industryType = {} let industryType = {}
const classId = res.data.sdInfo.class_id const classId = res.data.sdInfo.class_id
for (let outter of res.data.supplyTree) { for (let outter of res.data.supplyTree) {
@ -108,15 +102,13 @@ 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'
@ -127,6 +119,8 @@ class MyNeedsEdit extends Component {
) )
} }
// uploadMyNeedsApi 上传需求 的api // uploadMyNeedsApi 上传需求 的api
uploadMyNeedsApi() { uploadMyNeedsApi() {
@ -191,9 +185,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',
@ -205,102 +199,6 @@ class MyNeedsEdit extends Component {
} }
//删除我的需求 api DeleteMyNeeds
deleteMyNeeds({ demandId = 10 }) {
Taro.request({
url: URL.DeleteMyNeeds,
method: 'POST',
dataType: 'json',
data: {
demandId: demandId
},
header: {
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
'content-type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
}).then(res => {
console.log('删除我的列表', res)
if (res.data.err_code === 0) {
Taro.showToast({
title: '删除成功',
icon: 'success',
duration: 1000
})
setTimeout(() => {
Taro.switchTab({
url: '/pages/myNeeds/myNeeds'
})
}, 1000);
} else if (res.data.err_code === 88888) {
loginExpired(res)
} else {
Taro.showToast({
title: res.data.err_msg,
icon: 'none',
duration: 1500
})
}
})
}
// 修改需求类型
needsTypeChange = e => {
this.setState({
needsTypeSelected: this.state.needsType[e.detail.value]
})
}
// 修改供求状态
needsStateChange = e => {
this.setState({
needsStateSelected: this.state.needsState[e.detail.value]
})
}
//改标题
titleChange(event) {
this.setState({ title: event })
}
contactNameChange(event) {
this.setState({ contactName: event })
}
contactNumberChange(event) {
this.setState({ contactNumber: event })
}
contactAddressChange(event) {
this.setState({ contactAddress: event.target.value })
}
contentChange(event) {
this.setState({ content: event.target.value })
}
goToMyNeedsPage() {
Taro.switchTab({
url: '/pages/myNeeds/myNeeds'
})
}
// 保存需求按钮
saveButtonHandler() {
if (this.state.title &&
this.state.contactName
&& this.state.contactNumber
&& this.state.content && this.state.needsStateSelected) {
showLoading({
title: '保存中'
})
this.setState({ isSaveAndNew: false }, () => {
this.uploadMyNeedsApi({})
})
} else {
Taro.showToast({
title: '请填写完表格',
icon: 'none',
duration: 1500
})
}
}
// 上传图片 // 上传图片
onChangeImg(files, operationType, index) { onChangeImg(files, operationType, index) {
const that = this const that = this
@ -346,11 +244,101 @@ class MyNeedsEdit extends Component {
} }
} }
// 从图片子组件获取信息 //删除我的需求 api DeleteMyNeeds
getImageDetails(value) { deleteMyNeeds({ demandId = 10 }) {
this.setState({ Taro.request({
ImagesInfo: value url: URL.DeleteMyNeeds,
method: 'POST',
dataType: 'json',
data: {
demandId: demandId
},
header: {
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
'content-type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
}).then(res => {
console.log('删除我的列表', res)
if (res.data.err_code === 0) {
Taro.showToast({
title: '删除成功',
icon: 'success',
duration: 1000
})
setTimeout(() => {
Taro.switchTab({
url: '/pages/myNeeds/myNeeds'
})
}, 1000);
}else if (res.data.err_code === 88888) {
loginExpired(res)
} else {
Taro.showToast({
title: res.data.err_msg,
icon: 'none',
duration: 1500
})
}
}) })
}
// 修改需求类型
needsTypeChange = e => {
this.setState({
needsTypeSelected: this.state.needsType[e.detail.value]
})
}
// 修改供求状态
needsStateChange = e => {
this.setState({
needsStateSelected: this.state.needsState[e.detail.value]
})
}
//改标题
titleChange(event) {
this.setState({ title: event })
}
contactNameChange(event) {
this.setState({ contactName: event })
}
contactNumberChange(event) {
this.setState({ contactNumber: event })
}
contactAddressChange(event) {
this.setState({ contactAddress: event.target.value })
}
contentChange(event) {
this.setState({ content: event.target.value })
}
goToMyNeedsPage() {
Taro.switchTab({
url: '/pages/myNeeds/myNeeds'
})
}
// 保存需求按钮
saveButtonHandler() {
if (this.state.title &&
this.state.contactName
&& this.state.contactNumber
&& this.state.content && this.state.needsStateSelected) {
Taro.showLoading({
title: '保存中'
})
this.setState({ isSaveAndNew: false }, () => {
this.uploadMyNeedsApi({})
})
} else {
Taro.showToast({
title: '请填写完表格',
icon: 'none',
duration: 1500
})
}
} }
// 保存新增按钮 // 保存新增按钮
saveAndNewButton() { saveAndNewButton() {
@ -358,7 +346,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) {
showLoading({ Taro.showLoading({
title: '保存中' title: '保存中'
}) })
this.setState({ isSaveAndNew: true }, () => { this.setState({ isSaveAndNew: true }, () => {
@ -418,156 +406,131 @@ class MyNeedsEdit extends Component {
<View className='supply-demand'> <View className='supply-demand'>
{deleteModalWindowElement} {deleteModalWindowElement}
{/* 行业分类 */} {/* 行业分类 */}
{platformChecker() ? <InteractionComponent url={URL.GetIndustryTypeList} onPassDataToChild={this.getDataFromChild.bind(this)} selectedValue={this.state.industryTypeSelected} ></InteractionComponent>
<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 className='page-section'> <View>
<View> <Picker mode='selector' rangeKey='name' range={this.state.needsType} onChange={this.needsTypeChange.bind(this)}>
<Picker mode='selector' rangeKey='name' range={this.state.needsType} onChange={this.needsTypeChange.bind(this)}> <View className='picker'>
<View className='picker'> <View className='title-box'>
<View className='title-box'> <Text className='title'><Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.needsTypeSelected.name}</Text>
<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 className='border-box'> </View>
<Text className='require'>*</Text><AtInput <View className='border-box'>
name='value' <Text className='require'>*</Text><AtInput
title='需求标题:' name='value'
type='text' title='需求标题:'
value={this.state.title} type='text'
border={false} value={this.state.title}
onChange={this.titleChange.bind(this)} border={false}
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>
{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>
</View>
</View>
<View className='button-box'>
<View className='button' onClick={this.saveButtonHandler.bind(this)}>
<Button size='mini' className='button-orange'>保存</Button>
</View>
{/* <View className='button' onClick={this.saveAndNewButton.bind(this)}>
<Button size='mini' className='button-green'>保存并新增</Button>
</View> */}
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
<Button className='button-green' size='mini'>我的需求</Button>
</View>
{/* <View className='button' onClick={this.deleteButtonHandler.bind(this)}>
<Button className='button-dark-red' size='mini'>删除</Button>
</View> */}
</View>
<CopyrightComponent></CopyrightComponent>
</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' 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='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>
</View>
</View>
<View className='button-box'>
<View className='button' onClick={this.saveButtonHandler.bind(this)}>
<Button size='mini' className='button-orange'>保存</Button>
</View>
{/* <View className='button' onClick={this.saveAndNewButton.bind(this)}>
<Button size='mini' className='button-green'>保存并新增</Button>
</View> */}
<View className='button' onClick={this.goToMyNeedsPage.bind(this)}>
<Button className='button-green' size='mini'>我的需求</Button>
</View>
{/* <View className='button' onClick={this.deleteButtonHandler.bind(this)}>
<Button className='button-dark-red' size='mini'>删除</Button>
</View> */}
</View>
<CopyrightComponent></CopyrightComponent>
</View>
) )
} }
} }

View File

@ -2,6 +2,7 @@ $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
@ -75,14 +76,4 @@ $themeColor:#FF7142;
.title-box{ .title-box{
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,22 +1,17 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Button, Input, Picker } from '@tarojs/components' import { View, Text, Button, Input } from '@tarojs/components'
import { AtInput, AtTextarea, AtImagePicker } from 'taro-ui' import { AtInput, AtImagePicker, AtTextarea, Picker } 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';
@ -34,14 +29,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: '', contactName: getGlobalStorage('user_identity').username || '',
contactNumber: '', contactNumber: getGlobalStorage('user_identity').userphone || '',
contactAddress: '', contactAddress: '',
content: '', content: '',
pickerImageUrl: [], // 上传的图片 pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息 ImagesInfo: [],// 后台传回来的图片信息
isPublishAndNew: false,//是否点击发布新增按钮
isPublishAndNew: false,//是否点击发布新增按钮
} }
} }
@ -77,6 +72,7 @@ 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: {
@ -86,34 +82,36 @@ 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',
@ -123,12 +121,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,
@ -202,13 +200,6 @@ 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 &&
@ -216,7 +207,7 @@ class MyNeedsPublish extends Component {
&& this.state.contactNumber && this.state.contactNumber
&& this.state.content && this.state.needsStateSelected) { && this.state.content && this.state.needsStateSelected) {
showLoading({ Taro.showLoading({
title: '发布中' title: '发布中'
}) })
this.setState({ isPublishAndNew: false }, () => { this.setState({ isPublishAndNew: false }, () => {
@ -240,7 +231,7 @@ class MyNeedsPublish extends Component {
&& this.state.contactNumber && this.state.contactNumber
&& this.state.content && this.state.needsStateSelected) { && this.state.content && this.state.needsStateSelected) {
showLoading({ Taro.showLoading({
title: '发布中' title: '发布中'
}) })
this.setState({ isPublishAndNew: true }, () => { this.setState({ isPublishAndNew: true }, () => {
@ -268,15 +259,11 @@ 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 = decodeURIComponent(this.$router.params.id) const isRenderingPic = this.$router.params.id
if (parseInt(isRenderingPic)) { if (parseInt(isRenderingPic)) {
this.setState({ needsTypeSelected: { name: '效果图', id: '5' } }) this.setState({ needsTypeSelected: { name: '效果图', id: '5' } })
} }
@ -287,8 +274,11 @@ class MyNeedsPublish extends Component {
componentWillUnmount() { } componentWillUnmount() { }
componentDidShow() { componentDidShow() {
isUserLogin() if (!getGlobalStorage('userInfo').user_id) {
LoginService()
return
}
} }
componentDidHide() { } componentDidHide() { }
@ -298,156 +288,131 @@ 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></View> : <AliIndustryTypeInteraction url={URL.GetIndustryTypeList} ></InteractionComponent>
onPassDataToChild={this.getDataFromChild.bind(this)} {/* 需求类型 */}
selectedValue={this.state.industryTypeSelected} />} <View className='page-section'>
<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>
<View className='input-box'> <View style='margin-left:5%;'>
<Text className='require'>*</Text> <Input name='value'
<AtInput maxLength='11'
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' type='number'
value={this.state.contactNumber} value={this.state.contactNumber}
border={false} onInput={this.contactNumberChange.bind(this)}
onChange={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' 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>
{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>
</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='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>
</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,9 +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;
display: flex display: flex
@ -77,14 +76,4 @@ $themeColor:#FF7142;
.title-box{ .title-box{
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,7 +10,6 @@ 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';
@ -43,14 +42,13 @@ 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:id , demandId: this.$router.params.id,
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -196,7 +194,7 @@ class SupplyDemandView extends Component {
} }
componentDidMount() { componentDidMount() {
showLoading({ title: '加载中' }) Taro.showLoading({ title: '加载中' })
this.getSingleMyNeedInfo() this.getSingleMyNeedInfo()
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {

View File

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

@ -8,7 +8,7 @@ $themeColor:#FF7142;
top:100px; top:100px;
left:60px; left:60px;
font-size: 50px; font-size: 50px;
} }
} }
.show-blur{ .show-blur{
@ -20,7 +20,7 @@ $themeColor:#FF7142;
width: 100% width: 100%
} }
.nav-box{ .nav-box{
background-color: black; background-color: black;
position: relative; position: relative;
.shopcate-selection{ .shopcate-selection{
@ -40,7 +40,7 @@ $themeColor:#FF7142;
font-size: 25px; font-size: 25px;
} }
} }
.nav{ .nav{
display: flex; display: flex;
line-height: 55px; line-height: 55px;
@ -59,9 +59,7 @@ $themeColor:#FF7142;
position: relative; position: relative;
.interaction{ .interaction{
position: absolute; position: absolute;
// opacity: 0; opacity: 0;
top:-100px;
} }
} }
.homepage-link{ .homepage-link{
@ -73,13 +71,13 @@ $themeColor:#FF7142;
flex:1; flex:1;
} }
} }
} }
.filter-box{ .filter-box{
display: flex; display: flex;
flex-wrap: nowrap; flex-wrap: nowrap;
flex-direction: row; flex-direction: row;
.filter-title{ .filter-title{
box-sizing:border-box; box-sizing:border-box;
flex:1; flex:1;
@ -134,7 +132,7 @@ $themeColor:#FF7142;
} }
} }
} }
} }
.show{ .show{
left:0px; left:0px;
@ -151,32 +149,32 @@ $themeColor:#FF7142;
box-sizing:border-box; box-sizing:border-box;
width: 50%; width: 50%;
padding:10px; padding:10px;
} }
.no-more-title{ .no-more-title{
width:100%; width:100%;
margin-top:20%; margin-top:20%;
} }
} }
.pagination{ .pagination{
margin-top: 50px; margin-top: 50px;
margin-bottom: 50px; margin-bottom: 50px;
} }
.copyright-box{ .copyright-box{
padding:0 20px; padding:0 20px;
.title{ .title{
text-align: center; text-align: center;
line-height: 100px; line-height: 100px;
font-size: 25px; font-size: 25px;
} }
} }
.gap{ .gap{
height:150px; height:150px;
} }
//--------- 店铺说明样式 //--------- 店铺说明样式
@ -203,7 +201,7 @@ margin-top:20%;
} }
} }
} }
} }
.shop-description2{ .shop-description2{
@ -242,7 +240,7 @@ margin-top:20%;
text-align: center; text-align: center;
font-size: 0; font-size: 0;
margin-bottom: 5px; margin-bottom: 5px;
} }
} }
} }

View File

@ -1,19 +1,15 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Button, Input, Picker } from '@tarojs/components' import { View, Text, Button, Input } from '@tarojs/components'
import { AtInput, AtImagePicker, AtTextarea } from 'taro-ui' import { AtInput, AtImagePicker, AtTextarea, Picker } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import AliPictureUploadComponent from '../../component/aliPictureUploadComponent/aliPictureUploadComponent'
import LoginService from '../../util/LoginService' 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 = {
@ -27,8 +23,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: '', contactName: getGlobalStorage('user_identity').username||'',
contactNumber: '', contactNumber: getGlobalStorage('user_identity').userphone||'',
contactAddress: '', contactAddress: '',
content: '', content: '',
pickerImageUrl: [], // 上传的图片 pickerImageUrl: [], // 上传的图片
@ -86,6 +82,7 @@ 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({
@ -169,12 +166,6 @@ class SupplyDemand extends Component {
}) })
} }
} }
// 从图片子组件获取信息
getImageDetails(value) {
this.setState({
ImagesInfo: value
})
}
// 修改供求类型 // 修改供求类型
demandingSupplyCate = e => { demandingSupplyCate = e => {
this.setState({ this.setState({
@ -212,11 +203,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) {
showLoading({ title: '发布中' }) Taro.showLoading({ title: '发布中' }).then(() => {
this.setState({ isPublishAndNew: false }, () => { this.setState({ isPublishAndNew: false }, () => {
this.uploadDemSup({}) this.uploadDemSup({})
})
}) })
} else { } else {
Taro.showToast({ Taro.showToast({
title: '请填写完表格', title: '请填写完表格',
@ -232,11 +223,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) {
showLoading({ title: '发布中' }) Taro.showLoading({ title: '发布中' }).then(() => {
this.setState({ isPublishAndNew: true }, () => { this.setState({ isPublishAndNew: true }, () => {
this.uploadDemSup({}) this.uploadDemSup({})
})
}) })
} else { } else {
Taro.showToast({ Taro.showToast({
title: '请填写完表格', title: '请填写完表格',
@ -259,10 +250,7 @@ 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)
@ -271,7 +259,16 @@ class SupplyDemand extends Component {
componentWillUnmount() { } componentWillUnmount() { }
componentDidShow() { componentDidShow() {
isUserShopOwner() if (!getGlobalStorage('userInfo').user_id) {
LoginService()
return
}
if (!getGlobalStorage('shopInfo').shop_id && getGlobalStorage('userInfo').user_id) {
Taro.showToast({
title: '您还没有店铺,不能使用该功能,快去申请吧',
icon: 'none'
})
}
} }
componentDidHide() { } componentDidHide() { }
@ -314,18 +311,7 @@ class SupplyDemand extends Component {
border={false} border={false}
/> />
</View> </View>
<View className='input-box'> <View className='input-box' style='padding:24rpx 0;font-size:32rpx'>
<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>
@ -337,51 +323,38 @@ 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>
{platformChecker() ? <AtTextarea <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}
@ -390,9 +363,7 @@ 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> : <AliPictureUploadComponent maxLength={4} isReceiveImageUrl={false} url={URL.UploadDSPorductImage} onGetImageDetails={this.getImageDetails.bind(this)} /> </View>
}
</View> </View>
<View className='page-section'> <View className='page-section'>

View File

@ -71,14 +71,4 @@ $themeColor:#FF7142;
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

@ -10,7 +10,6 @@ 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';
@ -36,14 +35,12 @@ 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: sdId, sdID: this.$router.params.sdId,
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -67,15 +64,15 @@ class SupplyDemandView extends Component {
images: res.data.sdInfo.file_path, images: res.data.sdInfo.file_path,
itemId: res.data.sdInfo.sd_id itemId: res.data.sdInfo.sd_id
}) })
} 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'
}) })
} }
} }
) )
@ -123,7 +120,7 @@ class SupplyDemandView extends Component {
} }
) )
} }
goToSDPublishPage() { goToSDPublishPage() {
Taro.redirectTo({ Taro.redirectTo({
@ -132,9 +129,8 @@ class SupplyDemandView extends Component {
} }
// 跳转到我的供求编辑页面 // 跳转到我的供求编辑页面
goToMyDSEditPage() { goToMyDSEditPage() {
let sdId=encodeURIComponent(this.state.itemId)
Taro.redirectTo({ Taro.redirectTo({
url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + sdId url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + this.state.itemId
}) })
} }
@ -157,15 +153,15 @@ class SupplyDemandView extends Component {
} }
handleWindowConfirm() { handleWindowConfirm() {
this.setState({ isDeleteModal: false }) this.setState({ isDeleteModal: false })
showLoading({ Taro.showLoading({
title: '加载中' title: '加载中'
}) })
this.onDelete({ sdID: this.state.itemId }) this.onDelete({ sdID: this.state.itemId })
} }
componentDidMount() {
showLoading({ title: '加载中' })
componentDidMount() {
Taro.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,

588
src/todo list.txt Normal file
View File

@ -0,0 +1,588 @@
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

View File

@ -1,31 +0,0 @@
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,7 +3,10 @@ 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(key, value) Taro.setStorageSync({
key: key,
data: value
})
} else if (process.env.TARO_ENV === 'alipay') { } else if (process.env.TARO_ENV === 'alipay') {
my.setStorageSync({ my.setStorageSync({
@ -15,20 +18,15 @@ const setGlobalStorage = (key, value) => {
const getGlobalStorage = (key) => { const getGlobalStorage = (key) => {
if (process.env.TARO_ENV === 'weapp') { if (process.env.TARO_ENV === 'weapp') {
return Taro.getStorageSync(key) getGlobalStorage(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,
}) })
if (res.data || res.APDataStorage) { res.data=res.data?res.data:{username:'',userphone:'',user_id:''}
return res.data || res.APDataStorage return res.data ||res.APDataStorage
} else {
return
}
} }
} }
export { setGlobalStorage, getGlobalStorage } export { setGlobalStorage, getGlobalStorage }

View File

@ -1,24 +0,0 @@
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(value) { export default function onClickValueService(e) {
let value
if (process.env.TARO_ENV === 'alipay') { if (process.env.TARO_ENV === 'alipay') {
return value value = e.currentTarget.dataset.eOnTapAA
} else if (process.env.TARO_ENV === 'weapp') { } else if (process.env.TARO_ENV === 'weapp') {
return value value = e.currentTarget.dataset.eTapAA
} }
value=typeof(value)==='string'?encodeURIComponent(value):value
return value
} }

View File

@ -1,8 +0,0 @@
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,59 +4,60 @@ 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 => {
if (res.data.err_msg === 'success') {
setGlobalStorage('user_identity', { username: res.data.otherData.userName, userphone: res.data.otherData.userPhone })
} else {
Taro.showToast({
title: res.data.err_msg,
icon: 'none',
duration: 1500
})
}
}) })
.then(res => {
if (res.data.err_msg === 'success') {
setGlobalStorage('user_identity', { username: res.data.otherData.userName, userphone: res.data.otherData.userPhone })
} else {
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 => {
console.log('普通登录', res)
if (res.data.err_code === 0) {
Taro.showToast({
title: '登入成功',
icon: 'success',
duration: 1000
})
setGlobalStorage('session_id', res.data.session_id)
setGlobalStorage('shopInfo', res.data.shop_info)
setGlobalStorage('userInfo', res.data.user_info)
setGlobalStorage('accountInfo', { username: username, password: password })
setUserInfoToStorage()
resolve('success')
} else {
reject(res)
} }
}) })
}) .then(res => {
console.log('普通登录',res)
if (res.data.err_code === 0) {
Taro.showToast({
title: '登入成功',
icon: 'success',
duration: 1000
})
setGlobalStorage('session_id', res.data.session_id)
setGlobalStorage('shopInfo', res.data.shop_info)
setGlobalStorage('userInfo', res.data.user_info)
setGlobalStorage('accountInfo', { username: username, password: password })
setUserInfoToStorage()
resolve('success')
} else {
reject(res)
}
})
})
} }

View File

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

View File

@ -1,220 +0,0 @@
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