diff --git a/src/pages/goodsPublish/goodsPublish.js b/src/pages/goodsPublish/goodsPublish.js
index fbeee9a..ce83118 100644
--- a/src/pages/goodsPublish/goodsPublish.js
+++ b/src/pages/goodsPublish/goodsPublish.js
@@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Text, Radio, RadioGroup, Label } from '@tarojs/components'
-import { AtInput, AtImagePicker, AtTextarea, AtButton, Picker } from 'taro-ui'
+import { AtInput, AtImagePicker, AtTextarea, AtButton, Picker, AtToast } from 'taro-ui'
import SearchBarComponent from '../../component/searchBarComponent/searchBarComponent'
import copyrightComponent from '../../component/copyrightComponent/copyrightComponent'
@@ -23,15 +23,11 @@ class GoodsPublish extends Component {
productPrice: '',
productUnit: '',
productDescript: '',
- files: [{
- url: 'https://jimczj.gitee.io/lazyrepay/aragaki1.jpeg',
- },
- {
- url: 'https://jimczj.gitee.io/lazyrepay/aragaki2.jpeg',
- },
- {
- url: 'https://jimczj.gitee.io/lazyrepay/aragaki3.png',
- }], // 上传的图片
+ files: [], // 上传的图片
+ isUploadImageSuccess: false,
+ uploadImageTextTip: '',
+ isUploadProductSuccess: false,
+ uploadProductTextTip: '',
list: [
{
value: '美国',
@@ -59,7 +55,8 @@ class GoodsPublish extends Component {
}
// 发布商品api
- uploadGoods() {
+ //{ goods_name = "test2", goods_price= "1.00", goods_unit= "1",goods_profiles= "test2",class_id= "10103",shop_class_id= "1899", file_id= "27959",file_type= 1,if_cover= 1,file_sort= 1}
+ uploadGoods({ goods_name = "test2", goods_price = "1.00", goods_unit = "1", goods_profiles = "test2", class_id = "10103", shop_class_id = "1899", file_id = "27959", file_type = 1, if_cover = 1, file_sort = 1 }) {
Taro.request({
url: URL.UploadProduct,
method: 'POST',
@@ -67,38 +64,39 @@ class GoodsPublish extends Component {
data: {
deployType: 1,
action: 1,
- goods: JSON.stringify({ "goods_name": "test2", "goods_price": "1.00", "goods_unit": "1", "goods_profiles": "test2", "class_id": "10103", "shop_class_id": "1899" }),
- goodsFiles: JSON.stringify([{ "file_id": "27959", "file_type": 1, "if_cover": 1, "file_sort": 1 }])
+ goods: JSON.stringify({
+ goods_name: goods_name,
+ goods_price: goods_price,
+ goods_unit: goods_unit,
+ goods_profiles: goods_profiles,
+ class_id: class_id,
+ shop_class_id: shop_class_id
+ }),
+ goodsFiles: JSON.stringify([{
+ file_id: file_id,
+ file_type: file_type,
+ if_cover: if_cover,
+ file_sort: file_sort
+ }])
},
header: {
'content-type': 'application/x-www-form-urlencoded',
+ 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
+ 'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
+ this.setState({ uploadProductTextTip: '发布成功', isUploadProductSuccess: true })
console.log('上传商品', res) // 提示非法请求 ----- to be continue
}
)
+ .catch(error => {
+ this.setState({ uploadProductTextTip: '发布失败', isUploadProductSuccess: true })
+ })
}
- // 上传商品图片api
- uploadGoodsImage() {
- Taro.request({
- url: URL.UploadPorductImage,
- method: 'POST',
- dataType: 'json',
- data: {
- file: 1,
- },
- header: {
- 'content-type': 'application/x-www-form-urlencoded',
- }
- })
- .then(res => {
- console.log('上传商品图片', res)
- }
- )
- }
+
// 改变商品分类状态
- onChange(e) {
+ onChangeProductType(e) {
this.setState({
selectorChecked: this.state.selector[e.detail.value]
})
@@ -124,17 +122,37 @@ class GoodsPublish extends Component {
})
}
// 上传图片
- onChangeImg(files, operationType,index) {
+ onChangeImg(files, operationType, index) {
+ const that = this
if (operationType === 'add') {
- this.setState({
- files
+ Taro.uploadFile({
+ url: URL.UploadPorductImage, // 仅为示例,非真实的接口地址
+ filePath: files[files.length - 1].url,
+ name: 'file',
+ formData: {
+ user: 'test'
+ },
+ header: {
+ 'content-type': 'multipart/form-data',
+ 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
+ 'X-Requested-With': 'XMLHttpRequest'
+ },
+ success(response) {
+ const data = JSON.parse(response.data)
+ const imagePath = URL.Base + data.file_path
+ const newFiles = that.state.files.concat({ url: imagePath })
+
+ that.setState({ files: newFiles, isUploadImageSuccess: true, uploadImageTextTip: '上传成功' })
+
+
+ }
})
}
if (operationType === 'remove') {
this.state.files.splice(index, 1);
this.setState({ files: this.state.files });
+ that.setState({ isUploadImageSuccess: true, uploadImageTextTip: '删除成功' })
}
-
}
// 图片上传失败
onFail(mes) {
@@ -142,10 +160,29 @@ class GoodsPublish extends Component {
}
// 删除图片
onImageClick(index) {
-
}
- componentDidMount(){
-
+ onClickUploadGoods() {
+ if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.files.length) {
+ this.uploadGoods({
+ goods_name: this.state.productName,
+ goods_price: this.state.productPrice,
+ goods_unit: this.state.productUnit,
+ goods_profiles: this.state.productDescript,
+ class_id: "10103",
+ shop_class_id: "1899",
+ file_id: "27959",
+ file_type: 1,
+ if_cover: 1,
+ file_sort: 1
+ })
+ }else{
+ this.setState({ uploadProductTextTip: '请填写完表格', isUploadProductSuccess: true })
+ }
+ }
+
+
+ componentDidMount() {
+
}
componentWillReceiveProps(nextProps) {
@@ -159,14 +196,25 @@ class GoodsPublish extends Component {
componentDidHide() { }
render() {
+ const imageUploadSuccess =
+ const productUploadSuccess =
return (
+ {imageUploadSuccess}
+ {productUploadSuccess}
-
-
+
*商品分类: {this.state.selectorChecked}
@@ -295,7 +343,7 @@ class GoodsPublish extends Component {
- 发布
+ 发布
发布并新增
diff --git a/src/pages/home/home.js b/src/pages/home/home.js
index ad22c71..b28a429 100644
--- a/src/pages/home/home.js
+++ b/src/pages/home/home.js
@@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Button, Text, Swiper, SwiperItem, Image, } from '@tarojs/components'
-import { AtModal } from 'taro-ui'
+import { AtModal, AtButton } from 'taro-ui'
import filteredShopComponent from '../../component/filteredShopComponent/filteredShopComponent'
import bottomNav from '../../component/bottomNav/bottomNav'
import URL from '../../serviceAPI.config'
@@ -24,16 +24,7 @@ class Home extends Component {
isOpen: false, // 抢单消息提示
}
}
- componentWillMount() {
- }
- componentDidMount() {
- // 页面加载后 得到首页的基本信息和推荐店铺的信息
- Taro.showLoading({ title: '加载中' })
- this.getShops()
- this.getHomeCategoriesInfo()
- this.login()
- }
@@ -82,16 +73,12 @@ class Home extends Component {
}
// 登入api
-
-
-
login() {
Taro.login({
-
success(res) {
if (res.code) {
// 发起网络请求
- console.log(res)
+ console.log('手机端微信code:',res.code)
Taro.request({
url: URL.Login,
method: 'POST',
@@ -104,17 +91,41 @@ class Home extends Component {
}
})
.then(response => {
- console.log('登入', response)
-
+ // console.log('登入', response)
+ //储存后台返回的session_id 到local Storage
+ Taro.setStorageSync('session_id', response.data.session_id)
+
}
- )}
- else {
+ )
+ }
+ else {
console.log('登录失败!' + res.errMsg)
}
}
})
-
}
+ // 微信用户设置
+ // 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({
@@ -164,6 +175,19 @@ class Home extends Component {
// 确认抢单之后
this.GrabDemand({})
}
+
+ componentDidMount() {
+ // 页面加载后 得到首页的基本信息和推荐店铺的信息
+ Taro.showLoading({ title: '加载中' })
+ this.getShops()
+ this.getHomeCategoriesInfo()
+ this.login()
+
+ }
+
+ componentWillMount() {
+
+ }
componentWillUnmount() { }
componentDidShow() { }
@@ -171,10 +195,19 @@ class Home extends Component {
componentDidHide() { }
+// 微信用户信息
+ onGotUserInfo(e) {
+ console.log(e.detail.errMsg)
+ console.log(e.detail.userInfo)
+ console.log(e.detail.rawData)
+ }
+
+
+
render() {
// 提示弹窗element
- const modalMessage =
-
+
const demandingElemensArray = this.state.demanding.length ? this.state.demanding.map((item, index) => {
return < SwiperItem key={index} >
@@ -241,7 +274,10 @@ class Home extends Component {
return (
- {modalMessage}
+ {/* 获取微信用户的信息 */}
+ {/* 获取微信用户的信息 */}
+
+ {modalMessageGrab}
{/* 第一行图片滚动条 */}
diff --git a/src/pages/index/index.js b/src/pages/index/index.js
index 7cee317..5f22daf 100644
--- a/src/pages/index/index.js
+++ b/src/pages/index/index.js
@@ -27,14 +27,11 @@ class Index extends Component {
//http://ihome6.com/Shop-supplyShops
componentDidMount(){
- Taro.setStorageSync('PFWSSS','hq0erouhm4mea8b0mg34gdj0q7')
- Taro.setStorageSync('X-Token','eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.IntcInVzZXJfaWRcIjpcIjI3XCIsXCJsb2dpbl9uYW1lXCI6XCJ5YW5neGJcIixcImF0XCI6XCIyMDE4LTEyLTE4IDEzOjM1OjUxXCJ9Ig.gXvZxXgU5asfwUJAG-z7k5g2p3dbts2e1X9L902KksE')
- Taro.setStorageSync('PLU','%2Fm-more')
- Taro.setStorageSync('localCity','think%3A%7B%2214%22%3A%22%25E7%25A6%258F%25E5%25BB%25BA%25E7%259C%2581%22%2C%2214001%22%3A%22%25E7%25A6%258F%25E5%25B7%259E%25E5%25B8%2582%22%7D')
+
Taro.navigateTo({
url: '/pages/home/home'
- // url: '/pages/goodsPublish/goodsPublish'
+ // url: '/pages/goodsPublish/goodsPublish'
// url:'/pages/supplyDemandPublish/supplyDemandPublish'
})
}
diff --git a/src/pages/mySupplyDemand/mySupplyDemand.js b/src/pages/mySupplyDemand/mySupplyDemand.js
index 5674d20..58af0fb 100644
--- a/src/pages/mySupplyDemand/mySupplyDemand.js
+++ b/src/pages/mySupplyDemand/mySupplyDemand.js
@@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
-import { AtInput, AtButton, Picker,AtIcon } from 'taro-ui'
+import { AtInput, AtButton, Picker, AtIcon } from 'taro-ui'
import URL from '../../serviceAPI.config'
import copyrightComponent from '../../component/copyrightComponent/copyrightComponent'
@@ -19,37 +19,50 @@ class MySupplyDemand extends Component {
constructor() {
super(...arguments)
this.state = {
- demandSupplyCate: ['全部','需求', '供应', '人才'],
+ demandSupplyCate: ['全部', '需求', '供应', '人才'],
demandSupplyCateSelected: '全部',
- demandSupplyState: ['全部','上架', '下架'],
+ demandSupplyState: ['全部', '上架', '下架'],
demandSupplyStatesSelected: '全部',
- title:'',
+ title: '',
startDateSel: '2018-04-22',
endDateSel: '2018-04-22',
+ allDemandSupply: [],
+ totalDemandSupply:'',
+
}
}
//MySupplyDemand
- getMySupplyDemand({ curr_page=1, page_count=20}) {
+ getMySupplyDemand({ curr_page = 1, page_count = 20 }) {
Taro.request({
url: URL.MySupplyDemand,
method: 'POST',
dataType: 'json',
+
data: {
- curr_page: curr_page,
- page_count: page_count
+ param: JSON.stringify({
+ curr_page: curr_page,
+ page_count: page_count
+ })
},
header: {
+ 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'content-type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
}).then(res => {
console.log(res) // ------------------------------------------- to be continue----
- console.log('个人供求=》暂时无数据, 后台需要权限验证')
+ // console.log('个人供求=》暂时无数据, 后台需要权限验证')
+ if (res.data.err_msg === "success") {
+ this.setState({ allDemandSupply: res.data.supplys,totalDemandSupply:res.data.count })
+ }
+
})
}
+
+
//修改供求类型
demSupplyCateChange = e => {
this.setState({
@@ -62,8 +75,8 @@ class MySupplyDemand extends Component {
demandSupplyStatesSelected: this.state.demandSupplyState[e.detail.value]
})
}
- titleChange(event){
- this.setState({title:event})
+ titleChange(event) {
+ this.setState({ title: event })
}
// 修改开始日期
onStartDateChange = e => {
@@ -81,7 +94,7 @@ class MySupplyDemand extends Component {
console.log(this.props, nextProps)
}
- componentDidMount () {
+ componentDidMount() {
this.getMySupplyDemand({})
}
componentWillUnmount() { }
@@ -91,6 +104,47 @@ class MySupplyDemand extends Component {
componentDidHide() { }
render() {
+ const demandSupplyElementArray = this.state.allDemandSupply.length ? this.state.allDemandSupply.map((item, index) => {
+ return
+
+ 需求类型:
+ {item.type_name}
+
+
+ 需求标题:
+ {item.sd_title}
+
+
+ 联系人:
+ {item.user_name}
+
+
+ 电话号码:
+ {item.user_phone}
+
+
+ 需求状态:
+ {item.state}
+
+
+ 更新时间:
+ {item.update_date}
+
+
+
+ 查看
+
+
+ 编辑
+
+
+ 删除
+
+
+
+
+
+ }) : null
return (
@@ -124,12 +178,12 @@ class MySupplyDemand extends Component {
*
{/* 开始和结束日期 */}
@@ -140,17 +194,17 @@ class MySupplyDemand extends Component {
*开始日期: {this.state.startDateSel}
-
+
-
+
*结束日期: {this.state.endDateSel}
-
+
@@ -158,61 +212,20 @@ class MySupplyDemand extends Component {
- 搜索
+ 搜索
- 新增
+ 新增
- 一共20 条记录
+ 一共{this.state.totalDemandSupply} 条记录
{/* 我的供求信息 */}
-
-
-
- 需求类型:
- 1
-
-
- 需求标题:
- 1
-
-
- 联系人:
- 1
-
-
- 电话号码:
- 1
-
-
- 需求状态:
-
-
-
- 更新时间:
- 1
-
-
-
- 查看
-
-
- 编辑
-
-
- 删除
-
-
-
-
-
-
-
+ {demandSupplyElementArray}
-
+
diff --git a/src/serviceAPI.config.js b/src/serviceAPI.config.js
index 933f0e7..45c9dbe 100644
--- a/src/serviceAPI.config.js
+++ b/src/serviceAPI.config.js
@@ -18,7 +18,7 @@ const URL = {
BuyConsult: LOCALURL + 'Shop-consult',// 购买咨询
GetShopItemDetail: LOCALURL + 'GoodsQuery-wxGoodsDetail',// 商品详情
// 商品发布api接口
- UploadPorductImage: LOCALURL + 'Goods-fileUp',// 上传商品图片
+ UploadPorductImage: LOCALURL + 'Goods-fileUpload',// 上传商品图片
UploadProduct: LOCALURL + 'Goods-phonePost',// 上传商品
UploadSupplyDemand: LOCALURL + 'Supply-post',// 上传供求