daisy vor 1 Jahr
Ursprung
Commit
c2eb8a998a

+ 13 - 3
fore-end/API/appraise.js

@@ -11,7 +11,8 @@ const API = {
 	getCategoryURL: '/category',
 	getCategoryGoodsURL: '/goods/category',
 	getAllGoodsURL: '/goods',
-    getSearchGoodsURL: '/goods/search'
+    getSearchGoodsURL: '/goods/search',
+    postGoodsURL: '/goods/create'
 }
 
 //查询列表时传参---注意参数数据类型
@@ -114,7 +115,15 @@ function getAllGoods(data) {
 //搜索获取商品
 function searchGoods(data) {
     return request.get(
-        API.getSearchGoodsURL + `/${data.page}/${data.pageSize}` + '?search=' + data.inputValue
+        API.getSearchGoodsURL + `/${data.page}/${data.pageSize}` + '?keyword=' + data.inputValue
+    )
+}
+
+//上传商品
+function upLoadGoods(data) {
+    return request.post(
+        API.postGoodsURL,
+        data
     )
 }
 module.exports = {
@@ -130,5 +139,6 @@ module.exports = {
 	loginURl: API.loginURL,
     registerURL: API.registerURL,
     getAllGoods,
-    searchGoods
+    searchGoods,
+    upLoadGoods
 }

+ 6 - 2
fore-end/app.json

@@ -13,7 +13,10 @@
 		"van-toast": "@vant/weapp/toast/index",
 		"van-card": "@vant/weapp/card/index",
 		"van-swipe-cell": "@vant/weapp/swipe-cell/index",
-        "van-search": "@vant/weapp/search/index"
+        "van-search": "@vant/weapp/search/index",
+        "van-uploader": "@vant/weapp/uploader/index",
+        "van-picker": "@vant/weapp/picker/index",
+        "van-popup": "@vant/weapp/popup/index"
     },
     "pages": [
         "pages/home/home",
@@ -26,7 +29,8 @@
         "pages/register/register",
         "pages/details/details",
         "pages/search/search",
-        "pages/classify_detail/classify_detail"
+        "pages/classify_detail/classify_detail",
+        "pages/com_search/com_search"
     ],
     "window": {
         "backgroundTextStyle": "light",

+ 119 - 18
fore-end/pages/append/append.js

@@ -1,33 +1,107 @@
 // pages/append/append.js
+const { getCategoryAPI, upLoadGoods } = require('../../API/appraise')
+const { upLoad, chooseImage } = require('../../utils/util')
+const baseURL = "http://192.168.31.30:8084";
+
 Page({
 
     /**
      * 页面的初始数据
      */
     data: {
-        fileList: [],
         latitude: 0,
         longtitude: 0,
-        mapName: ""
-    },
-
-    moveLocation() {
-        let _this = this;
-        wx.chooseLocation({
-            success: function(res) {
-                console.log(res.name);
-                _this.setData({
-                    mapName: res.name
-                })
-            },
-            fail: function() {
-                console.log(err);
-            }
+        mapName: "",
+        columns: [],
+        id: [],
+        popShow: false,
+        clssify: [],
+        valueKeyName: "",
+        index: 0,
+        // 页面数据们
+        title: "",
+        desc: "",
+        price: Number,
+        address: "",
+        fileList: [],
+        maxgoodsURL: 6
+        // clssify: Number
+    },
+    popChange() {
+        this.setData({
+            popShow: true
+        })
+        this.getClassifyList()
+    },
+    onConfirm(e) {
+        const { value, index} = e.detail;
+        this.setData({
+            popShow: false,
+            valueKeyName: value,
+            index: index
+        })
+    },
+    onCancel() {
+        this.setData({
+            popShow: false,
+            valueKeyName: ""
+        })
+    },
+    titleInput(e) {
+        const {value, cursor, keyCode} = e.detail;
+        this.setData({
+            title: value
+        })
+    },
+    describeInput(e) {
+        const {value, cursor, keyCode} = e.detail;
+        this.setData({
+            desc: value
         })
     },
     numInput(e){
         const {value, cursor, keyCode} = e.detail;
-        console.log(value);
+        this.setData({
+            price: value
+        })
+    },
+    adressInput(e) {
+        const { value, cursor, keyCode} = e.detail;
+        this.setData({
+            address: value
+        })
+    },
+    upData(){
+        // const price = this.data.price;
+        // const address = this.data.address;
+        // const classify = this.data.id[this.data.index];
+        // upLoadGoods(this.data).then((res) => {
+        //     console.log(res);
+        // }).catch((err) => {
+        //     console.log(err);
+        // })
+        wx.request({
+          url: baseURL + '/goods/create',
+          method: "POST",
+          header: {
+              "content-type": "application/x-www-form-urlencoded"
+          },
+          data: {
+            "categories": [
+               this.data.id[this.data.index]
+            ],
+            "desc": this.data.desc,
+            "ownerId": 0,
+            "pic": this.data.fileList,
+            "place": this.data.address,
+            "price": this.data.price,
+            "state": 0,
+            "title": this.data.title
+          },
+          success: function(res) {
+              console.log(res);
+          }
+        })
     },
     /**
      * 生命周期函数--监听页面加载
@@ -35,7 +109,23 @@ Page({
     onLoad(options) {
 
     },
-
+    getClassifyList() {
+		getCategoryAPI(this.data)
+		.then((res) => {
+            const { code, data, mesage } = res.data;
+            const name = [];
+            const id = [];
+            for (let i = 0; i < data.length; i++) {
+                name[i] = data[i].Name;
+                id[i] = data[i].Id; 
+            }
+            console.log(id);
+            this.setData({
+                columns: name,
+                id: id
+            })
+        })
+    },  
     /**
      * 生命周期函数--监听页面初次渲染完成
      */
@@ -83,5 +173,16 @@ Page({
      */
     onShareAppMessage() {
 
+    },
+    afterRead(e) {
+        const { file } = e.detail;
+        upLoad(file.url).then((res) => {
+            const { fileList = [] } = this.data;
+            fileList.push({ ...file, url: res.data });
+            this.setData({
+                fileList,
+            })
+            console.log(this.data.fileList);
+        })
     }
 })

+ 1 - 3
fore-end/pages/append/append.json

@@ -1,7 +1,5 @@
 {
-    "usingComponents": {
-        "van-uploader": "@vant/weapp/uploader/index"
-    },
+    "usingComponents": {},
     "navigationBarTitleText": "发布商品",
     "requiredPrivateInfos": [
       "getLocation"

+ 24 - 7
fore-end/pages/append/append.wxml

@@ -4,18 +4,26 @@
     <!-- 标题 -->
     <view style="float: left; font-weight: 700; font-size: 45rpx; margin-top: 10rpx;">发布商品</view>
     <!-- 存草稿--缓存 -->
-    <view style="float: left; margin-left: 300rpx; margin-top: 20rpx;">存草稿</view>
+    <!-- <view style="float: left; margin-left: 300rpx; margin-top: 20rpx;">存草稿</view> -->
     <!-- 发布 -->
-    <view style="float: right;">
+    <view style="float: right;" bind:tap="upData">
         <van-button round type="info">发布</van-button>
     </view>
 </view>
 
 <!-- 商品描述模块 -->
 <view class="discribe">
-    <input type="text" placeholder="描述一下商品..."/>
+    <view>
+        <textarea placeholder="标题" style="width: 690rpx; height: 100rpx;" bindinput="titleInput"/>
+    </view>
+    <view class="textLine">
+        <!-- <input type="text" placeholder="描述一下商品..."/> -->
+        <textarea placeholder="描述一下商品..." style="width: 690rpx;" bindinput="describeInput"/>
+    </view>
+    <!-- 选择图片 -->
     <view class="upLoad">
-        <van-uploader file-list="{{ fileList }}" bind:after-read="afterRead"/>
+        <!-- <van-image fit="cover" width="100" height="100" src="{{goodsURL}}" bindtap="chooseImage" style="float: left;"/> -->
+        <van-uploader file-list="{{ fileList }}" bind:after-read="afterRead" max-count="3" deletable="{{true}}"/>
     </view>
 </view>
 
@@ -26,10 +34,19 @@
         <view style="float: left; margin-left: 540rpx; margin-top: -50rpx; position: relative;">
                 <input type="number" placeholder="¥0.00" bindinput="numInput"/>
         </view>
-        <van-icon name="arrow" />
     </view>
-    <view class="nav" bind:tap="moveLocation">
+    <view class="nav">
         <text style="float: left; font-weight: 600; margin-top: 8rpx;">交易地点</text>
-        <van-icon name="map-marked" size="50rpx" style="float: right; margin-top: 10rpx; margin-right: 5rpx;"/>
+        <view style="float: left; margin-left: 310rpx; margin-top: -50rpx; margin-right: -70rpx; position: relative;">
+                <input type="number" placeholder="                           地点" bindinput="adressInput"/>
+        </view>
+    </view>
+    <view class="nav">
+        <text style="float: left; font-weight: 600; margin-top: 8rpx;">分类选择</text>
+        <van-icon name="arrow" style="float: right; margin-top: 20rpx;"  bind:tap="popChange"/>
+        <van-popup show="{{ popShow }}" position="bottom" custom-style="height: 50%;overflow:hidden">
+            <van-picker value-key="{{valueKeyName}}" id="picker" show-toolbar title="{{label}}" columns="{{ columns }}" bind:cancel="onCancel" bind:confirm="onConfirm" />
+        </van-popup>
+        <view style="float: right; margin-top: 10rpx; margin-right: 10rpx;">{{valueKeyName}}</view>
     </view>
 </view>

+ 10 - 2
fore-end/pages/append/append.wxss

@@ -13,11 +13,19 @@
     border-radius: 20rpx;
 }
 
+.textLine {
+    width: 95%;
+    height: 40rpx;
+    flex-wrap: wrap;
+    margin-top: 10rpx;
+}
+
 .upLoad {
-    margin-top: 350rpx;
-    width: 300rpx;height: 300rxp;
+    margin-top: 280rpx;
+    width: 100%;height: 300rxp;
     overflow: hidden;
 }
+
 .navigation {
     width: 90%;
     height: 240rpx;

+ 84 - 0
fore-end/pages/com_search/com_search.js

@@ -0,0 +1,84 @@
+// pages/com_search/com_search.js
+Page({
+
+	/**
+	 * 页面的初始数据
+	 */
+	data: {
+        resultList: []
+	},
+    searchTo(){
+        wx.navigateTo({
+          url: '../../pages/search/search',
+        })
+    },
+	/**
+	 * 生命周期函数--监听页面加载
+	 */
+	onLoad(options) {
+        var data = JSON.parse(decodeURIComponent(options.comList))
+        console.log(data);
+        this.setData({
+            resultList: data
+        })
+	},
+    //推荐商品传递数据
+    detailTo(e) {
+        console.log(e.currentTarget.dataset);
+        const id = e.currentTarget.dataset.id;
+        const title = e.currentTarget.dataset.title;
+        const price = e.currentTarget.dataset.price;
+        const comImg = e.currentTarget.dataset.pic;
+        wx.navigateTo({
+          url: '/pages/details/details?id=' + id + '&title=' + title + '&price=' + price + '&img=' + comImg,
+        })
+    },
+	/**
+	 * 生命周期函数--监听页面初次渲染完成
+	 */
+	onReady() {
+
+    },
+
+	/**
+	 * 生命周期函数--监听页面显示
+	 */
+	onShow() {
+
+	},
+
+	/**
+	 * 生命周期函数--监听页面隐藏
+	 */
+	onHide() {
+
+	},
+
+	/**
+	 * 生命周期函数--监听页面卸载
+	 */
+	onUnload() {
+
+	},
+
+	/**
+	 * 页面相关事件处理函数--监听用户下拉动作
+	 */
+	onPullDownRefresh() {
+
+	},
+
+	/**
+	 * 页面上拉触底事件的处理函数
+	 */
+	onReachBottom() {
+
+	},
+
+	/**
+	 * 用户点击右上角分享
+	 */
+	onShareAppMessage() {
+
+	}
+})

+ 3 - 0
fore-end/pages/com_search/com_search.json

@@ -0,0 +1,3 @@
+{
+	"usingComponents": {}
+}

+ 22 - 0
fore-end/pages/com_search/com_search.wxml

@@ -0,0 +1,22 @@
+<!--pages/com_search/com_search.wxml-->
+<!-- 搜素框 -->
+<view class="search_box">
+    <view class="base_search">
+        <van-icon name="search" size="50rpx" color="#696969" style="margin-top: 15rpx; margin-left: -430rpx;"/>
+        <input type="search" name="" placeholder="搜索..." value="{{inputValue}}" class="search_text" bind:tap="searchTo"/>
+        <van-icon name="cross" style="float: right; margin-top: 24rpx; margin-right: 15rpx;"/>
+    </view>
+    <!-- 搜索按钮 -->
+    <view class="search_button" bind:tap="onClose" catch:tap="searchBegin" data-searchdata="{{inputValue}}">搜索</view>
+</view>
+
+<view class="commodity">
+    <view class="commodity_show" wx:for="{{resultList}}" wx:key="index">
+        <view  bind:tap="detailTo" data-id='{{item.Id}}' data-price='{{item.Price}}' data-Title='{{item.Title}}' data-pic='{{item.Pic}}'>
+            <image src="{{item.Pic}}" alt="" class="commodity_image"/>
+            <text class="commodity_name">{{item.Title}}</text>
+            <text class="price">¥{{item.Price}}</text>
+            <avatar></avatar>
+        </view>
+    </view>
+</view>

+ 66 - 0
fore-end/pages/com_search/com_search.wxss

@@ -0,0 +1,66 @@
+/* pages/com_search/com_search.wxss */
+/* .search_box {
+
+} */
+/* 搜索 */
+.base_search {
+    width: 80%;
+    height: 80rpx;
+    background-color: #E8E7E7;
+    border-radius: 20rpx;
+}
+
+.search_text {
+    float: left;
+    padding-left: 95rpx;
+    padding-top: 15rpx;
+}
+
+.search_button {
+    float: right;
+    margin-top: -64rpx;
+    margin-right: 20rpx;
+    font-size: 35rpx;
+    color: #494545;
+}
+/* *********************** */
+
+/* 商品展示 */
+.commodity {
+    display: flex;
+    flex-wrap: wrap; /*自动换行*/
+    margin-top: 10rpx;
+}
+
+.commodity_show {
+    display: flex;
+    position: relative;
+    width: 48%;
+    height: 500rpx;
+    padding: 7rpx;
+    justify-content: center;
+}
+
+.commodity_image {
+    width: 340rpx;
+    height: 340rpx;
+    border-radius: 20rpx;
+}
+
+.commodity_name {
+    position: absolute;
+    top: 360rpx;
+    left: 15rpx;
+    width: 350rpx;
+    white-space: nowrap;
+    overflow: hidden;
+    text-overflow: ellipsis;
+}
+
+.price {
+    position: absolute;
+    top: 400rpx;
+    left: 12rpx;
+    color: #a08016;
+    font-weight: 600;
+}

+ 2 - 0
fore-end/pages/home/home.wxml

@@ -1,5 +1,7 @@
 <!--pages/home/home.wxml-->
 <!-- 头部 -->
+<view style="width: 100%; height: 20rpx; background-color: #f5f5f5; position: absolute; top: 0; left: -1rpx; position: fixed; z-index: 100;" ></view>
+
 <view class="bigBox">
     <view class="head" style="position: fixed;">
         <view bind:tap="userTo">

+ 27 - 5
fore-end/pages/search/search.js

@@ -15,7 +15,8 @@ Page({
         searchResult: [{title: "短裤"}, {title: "短裙"}, {title: "连衣裙"}, {title: "卫衣"}, {title: "外套"}],
         search: false,
         page: 1,
-        pageSize: 6
+        pageSize: 6,
+        searchTo: []
     },
 
     //输入数据显示搜索推荐
@@ -29,9 +30,10 @@ Page({
         this.setData({
             inputValue: value
         })
-        if(this.data.inputValue != "") {
-            this.getSearchGoods()
-        }
+        // 边输入边请求获取数据
+        // if(this.data.inputValue != "") {
+        //     this.getSearchGoods()
+        // }
     },
     putInputValue(e){
         this.setData({
@@ -48,6 +50,15 @@ Page({
             'historyStorage',
             _this.data.historyStorage.concat(_this.data.inputValue)   
         )
+        this.getSearchGoods()
+        setTimeout(() => {
+            console.log(this.data.searchTo);
+            var new_search = JSON.stringify(this.data.searchTo)
+            let new_arr = encodeURIComponent(new_search)
+            wx.navigateTo({
+                url: '../../pages/com_search/com_search?comList=' + new_arr,
+            })
+        }, 1000)
     },
     //删除搜索数据
     deleteInput(){
@@ -75,6 +86,13 @@ Page({
             }
           })
     },
+    //点击搜索历史复制到input框
+    copyHistory(e) {
+        var his = e.currentTarget.dataset.history
+        this.setData({
+            inputValue: his
+        })
+    },
     /**
      * 生命周期函数--监听页面加载
      */
@@ -91,7 +109,11 @@ Page({
 
     getSearchGoods() {
         searchGoods(this.data).then((res) => {
-            console.log(res);
+            const {code, message, data} = res.data.data;
+            console.log(data);
+            this.setData({
+                searchTo: data
+            })
         }).catch((err) => {
             console.log(err);
         })

+ 7 - 7
fore-end/pages/search/search.wxml

@@ -12,13 +12,13 @@
 
 <!-- 搜索结果展示 -->
 <!-- 当搜索框数据不为0才显示搜索结果 wx:if="{{inputValue != ''}}" -->
-<view class="searchResult" wx:if="{{inputValue != ''}}" hidden="{{show ? false : true}}">
+<!-- <view class="searchResult" wx:if="{{inputValue != ''}}" hidden="{{show ? false : true}}"> -->
     <!-- 单个结果 -->
-    <view class="preResult" wx:for="{{searchResult}}" wx:key="index" bind:tap="putInputValue" data-postname="{{item.title}}">
-        <text class="textResult">{{item.title}}</text>
-        <van-icon name="arrow" style="float: right; margin-top: 10rpx;"/>
-    </view>
-</view>
+    <!-- <view class="preResult" wx:for="{{searchResult}}" wx:key="index" bind:tap="putInputValue" data-postname="{{item.title}}"> -->
+        <!-- <text class="textResult">{{item.title}}</text> -->
+        <!-- <van-icon name="arrow" style="float: right; margin-top: 10rpx;"/> -->
+    <!-- </view> -->
+<!-- </view> -->
 <!-- 搜索历史 -->
 <view class="history">
     <view class="history_title">搜索历史</view>
@@ -30,7 +30,7 @@
     <!-- 历史记录展示 -->
     <scroll-view class="scroll" scroll-y="true">
         <view class="history_show">
-            <view class="history_card" wx:for="{{historyStorage}}" wx:key="index">
+            <view class="history_card" wx:for="{{historyStorage}}" wx:key="index" bind:tap="copyHistory" data-history="{{item}}">
                 <text space="nbsp">{{item}}</text>
             </view>
         </view>

+ 1 - 1
fore-end/project.private.config.json

@@ -2,7 +2,7 @@
 	"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
 	"projectname": "wechatTrading",
 	"setting": {
-		"compileHotReLoad": true,
+		"compileHotReLoad": false,
 		"urlCheck": false
 	},
 	"condition": {