Browse Source

日期选择

zhaoxiaohai 3 years ago
parent
commit
844141339f

+ 2 - 0
README.md

@@ -44,6 +44,8 @@
 
 ​	My_adsorbRight -- 右边吸附按钮 -- 发布需求
 
+​	My_selectTime -- 选择时间
+
 # 缓存
 
 ​	userData -- 用户基本数据 -- 保存数据:index-用户列表下标,token,fisadministrator--是否主账号,tagentsid,tenterpriseid,userid

+ 1 - 1
components/My_SupplyAndDemandItemBox/index.wxml

@@ -1,7 +1,7 @@
 <view class="SupplyAndDemandItemBox">
     <!-- 标题,按钮 -->
     <view class="title-and-but">
-        <view class="supply-and-demand-title u-line-2">{{title}}</view>
+        <view class="supply-and-demand-title u-line-2"><!-- <text style="color:#4DC2D4;">【供】</text> --><text style="color: brown;">【需】</text>{{title}}</view>
         <view class="supply-and-demand-but">
             <slot name='soldOutBut'></slot>
         </view>

+ 21 - 3
components/My_UploadFiles/index.js

@@ -15,7 +15,7 @@ Component({
         attinfos: {
             type: Object
         },
-        /* 上传类型 Logo-品牌logo userImage-用户头像  productImage-产品图片*/
+        /* 上传类型 Logo-品牌logo userImage-用户头像  productImage-产品图片 SupplyAndDemand-供需*/
         upType: {
             type: String
         },
@@ -60,6 +60,9 @@ Component({
         fisadministrator: {
             type: Boolean,
             value: false
+        },
+        tsupplyanddemand: {
+            type: Number
         }
     },
 
@@ -160,6 +163,20 @@ Component({
                         "ftype": "default"
                     }
                 }
+            } else if (this.data.upType == "SupplyAndDemand") {
+                //供需附件上传
+                data = {
+                    "accesstoken": wx.getStorageSync('userData').token,
+                    "classname": "system.system.docManage",
+                    "method": "getFileName",
+                    "content": {
+                        "filename": timestamp,
+                        "filetype": ext,
+                        "ownertable": "tsupplyanddemand",
+                        "ownerid": this.data.tsupplyanddemand,
+                        "ftype": "default"
+                    }
+                }
             }
             //发送请求
             wx.getFileSystemManager().readFile({
@@ -220,7 +237,6 @@ Component({
                             that.triggerEvent("imageChange", {
                                 fileList
                             })
-
                         }
                     }).catch(err => {
                         console.log(err)
@@ -230,7 +246,7 @@ Component({
         },
         /* 删除文件 */
         imagesDelete(e) {
-            if (this.data.fisadministrator) return;
+            if (this.data.fisadministrator && this.data.upType != 'SupplyAndDemand') return;
             const that = this;
             wx.showModal({
                 title: '提示',
@@ -255,6 +271,8 @@ Component({
             } else if (that.data.upType == 'userImage') {
                 //用户头像
                 ownertable = "tenterprise_users"
+            } else if (that.data.upType == "SupplyAndDemand") {
+                ownertable = "tsupplyanddemand"
             };
             let content = {}
             if (that.data.upType != "userImage") {

+ 67 - 0
components/My_selectTime/index.js

@@ -0,0 +1,67 @@
+// components/My_selectTime/index.js
+Component({
+    /**
+     * 组件的属性列表
+     */
+    properties: {
+        /* 最小时间 */
+        minDate: {
+            type: Number,
+            value: -284025600000, //1961.1.1
+        },
+        /* 最大选择时间 */
+        maxDate: {
+            type: Number,
+            value: Date.parse(new Date()) //当前时间
+        },
+        /* 弹窗显示 */
+        showSelectTime: {
+            type: Boolean,
+            value: false
+        },
+        /* 保存回调 */
+        getTimeData: {
+            type: Function,
+        }
+    },
+
+    /**
+     * 组件的初始数据
+     */
+    data: {
+        currentDate: new Date().getTime(),
+        formatter(type, value) {
+            if (type === 'year') {
+                return `${value}年`;
+            }
+            if (type === 'month') {
+                return `${value}月`;
+            }
+            return value;
+        },
+    },
+
+    /**
+     * 组件的方法列表
+     */
+    methods: {
+        submit() {
+            const time = new Date(this.data.currentDate),
+                setTime = time.getFullYear() + '-' + (time.getMonth() + 1) + "-" + time.getDate();
+            this.triggerEvent("getTimeData", setTime)
+            this.setData({
+                showSelectTime: false
+            })
+        },
+        onInput(event) {
+            this.setData({
+                currentDate: event.detail,
+            });
+        },
+        dateOnClose() {
+            this.setData({
+                showSelectTime: !this.data.showSelectTime
+            })
+        },
+    }
+})

+ 6 - 0
components/My_selectTime/index.json

@@ -0,0 +1,6 @@
+{
+    "component": true,
+    "usingComponents": {
+        "van-datetime-picker": "@vant/weapp/datetime-picker/index"
+    }
+}

+ 8 - 0
components/My_selectTime/index.wxml

@@ -0,0 +1,8 @@
+<!-- 时间选择器 -->
+<van-action-sheet show="{{ showSelectTime }}" bind:close="dateOnClose">
+    <van-datetime-picker type="date" show-toolbar="{{false}}" value="{{ currentDate }}" bind:input="onInput" min-date="{{ minDate }}" max-date="{{ maxDate }}" formatter="{{ formatter }}" />
+    <!-- 提交按钮 -->
+<view class="submit_but">
+    <van-button bindtap="submit" custom-class="custom-class" round color="linear-gradient(180deg, #82E0E9 0%, #4BBECF 100%);">确定</van-button>
+</view>
+</van-action-sheet>

+ 2 - 0
components/My_selectTime/index.wxss

@@ -0,0 +1,2 @@
+/* components/My_selectTime/index.wxss */
+@import "/css/form2.wxss";

+ 40 - 6
pages/announceDemand/index.js

@@ -11,6 +11,9 @@ Page({
      * 页面的初始数据
      */
     data: {
+        maxDate: Number,
+        minDate: Number,
+        showCalendar: false, //日历显示
         tsupplyanddemandid: 0, //ID 0为新增
         newAdd: false, //是否新增 新增未保存直接退出页面会删除该供需
         popups: false, //弹出层控制
@@ -18,7 +21,6 @@ Page({
         ftitle: "", //供需标题
         fcontent: "", //需求内容	
         fenddate: "", //截止日期
-        fissupply: "", //1供/0需,
         /* 必填 */
         errTips: {
             ftype: false,
@@ -31,6 +33,7 @@ Page({
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
+        this.setTime()
         if (options.data == undefined) {
             console.log('新增')
             //新增
@@ -43,6 +46,22 @@ Page({
 
         }
     },
+    setTime() {
+        this.setData({
+            maxDate: Date.parse(new Date()) + 1000 * 60 * 60 * 24 * 31,
+            minDate: Date.parse(new Date())
+        })
+    },
+    /* 打开时间选择器 */
+    setDate() {
+        this.selectComponent("#SetDate").dateOnClose()
+    },
+    /* 设置下架 */
+    setSoldOut(date) {
+        this.setData({
+            fenddate: date.detail
+        })
+    },
     /* 表单验证 */
     formVerify() {
         let errTips = this.data.errTips,
@@ -73,6 +92,10 @@ Page({
             title: '请检查表单内容',
             icon: "error"
         });
+        this.setData({
+            newAdd: false
+        })
+        this.addOrModify()
     },
     /* 新增或修改 */
     addOrModify() {
@@ -91,10 +114,9 @@ Page({
                 "ftitle": this.data.ftitle,
                 "fcontent": this.data.fcontent,
                 "fenddate": this.data.fenddate,
-                "fissupply": this.data.fissupply
+                "fissupply": 0
             }
         }
-        console.log(content)
         /* 发送请求 */
         _Http.basic({
             "accesstoken": wx.getStorageSync('userData').token,
@@ -103,9 +125,21 @@ Page({
             "content": content
         }).then(res => {
             console.log(res)
-            this.setData({
-                tsupplyanddemandid: res.data[0].tsupplyanddemandid
-            })
+            if (this.data.newAdd) {
+                this.setData({
+                    tsupplyanddemandid: res.data[0].tsupplyanddemandid
+                })
+            }else{
+                wx.showToast({
+                  title: '保存成功',
+                })
+                setTimeout(()=>{
+                    wx.navigateBack({
+                        delta: 1,
+                      })
+                },500)
+            }
+
         })
     },
     /* 弹出层 */

+ 3 - 1
pages/announceDemand/index.json

@@ -1,5 +1,7 @@
 {
   "usingComponents": {
-    "My_MultipleChoice":"/components/My_MultipleChoice/index"
+    "My_MultipleChoice": "/components/My_MultipleChoice/index",
+    "van-calendar": "@vant/weapp/calendar/index",
+    "My_selectTime": "/components/My_selectTime/index"
   }
 }

+ 8 - 2
pages/announceDemand/index.wxml

@@ -14,19 +14,25 @@
         </My_GreyRectangleForm>
 
         <My_GreyRectangleForm title="产品图">
-            <My_UploadFiles fileList="{{attinfos}}" upType="productImage" UploadShow="{{true}}" maxCount="3" tagents_productid="{{tagents_productid}}" previewSize="65px"></My_UploadFiles>
+            <My_UploadFiles fileList="{{attinfos}}" upType="SupplyAndDemand" UploadShow="{{true}}" maxCount="3" tsupplyanddemand="{{tsupplyanddemand}}" previewSize="65px"></My_UploadFiles>
         </My_GreyRectangleForm>
 
-
         <My_GreyRectangleForm title="下架日期">
+            <view style="width: 100%; height: 100%; z-index: 999; position: absolute;" bindtap="setDate"></view>
+            <van-field autosize model:value="{{ fenddate }}" input-class="input-class" placeholder="点击设置" border="{{ false }}" />
         </My_GreyRectangleForm>
 
     </view>
 </My_GeneralTemplate>
+
 <!-- 弹出层 -->
 <van-action-sheet show="{{ popups }}" bind:close="showPop">
     <My_MultipleChoice title="需求分类" dataList="{{ftypeList}}" pitchOnItem="{{ftype}}" bind:optionChange="radioChange"></My_MultipleChoice>
 </van-action-sheet>
+
+<!-- 时间选择器 -->
+<My_selectTime id="SetDate" maxDate="{{maxDate}}" minDate="{{minDate}}" bind:getTimeData="setSoldOut"></My_selectTime>
+
 <!-- 提交按钮 -->
 <view class="submit_but">
     <van-button bindtap="submit" custom-class="custom-class" round color="linear-gradient(180deg, #82E0E9 0%, #4BBECF 100%);">发 布</van-button>

+ 1 - 1
pages/tabbar-pages/supplyAndDemand/index.wxml

@@ -26,7 +26,7 @@
             </My_SupplyAndDemandItemBox>
         </van-tab>
         <van-tab title="正在对接">
-            <My_SupplyAndDemandItemBox wx:for="{{5}}" title="【窗帘布】各位老板看下有以下面料的联系" time="2021-11-10 14:23:43">
+            <My_SupplyAndDemandItemBox wx:for="{{5}}" title="各位老板看下有以下面料的联系" time="2021-11-10 14:23:43">
                 <!-- 内容信息插槽 -->
                 <view slot="dataAndBut">
                     <view class="dataAndBut">

+ 19 - 1
pages/userCenter/index.js

@@ -12,7 +12,15 @@ Page({
      * 页面的初始数据
      */
     data: {
-        userMessage: {}, //用户数据列表
+        userMessage: {}, //头像
+        fname: "",
+        fphonenumber: "",
+        fsex: "",
+        fbirthdate: "",
+        femail: "",
+        fwechatno: "",
+        faddress: "",
+        frole: "",
         /* 错误提示 */
         errTips: {
             fname: false, //用户名
@@ -41,6 +49,16 @@ Page({
             frole: userMessage.frole
         })
     },
+    /* 打开时间选择器 */
+    setDate() {
+        this.selectComponent("#SetDate").dateOnClose()
+    },
+    /* 设置生日 */
+    setBbirthday(date) {
+        this.setData({
+            fbirthdate: date.detail
+        })
+    },
     /* 表单验证 */
     formVerify() {
         let errTips = this.data.errTips,

+ 2 - 1
pages/userCenter/index.json

@@ -1,5 +1,6 @@
 {
   "usingComponents": {
-    "My_UploadFiles":"../../components/My_UploadFiles/index"
+    "My_UploadFiles": "../../components/My_UploadFiles/index",
+    "My_selectTime": "/components/My_selectTime/index"
   }
 }

+ 4 - 2
pages/userCenter/index.wxml

@@ -34,14 +34,16 @@
         <My_GreyRectangleForm title="性别">
         </My_GreyRectangleForm>
         <My_GreyRectangleForm title="生日">
-            <view></view>
+            <view style="width: 100%; height: 100%; z-index: 999; position: absolute;" bindtap="setDate"></view>
+            <van-field autosize model:value="{{ fbirthdate }}" input-class="input-class" placeholder="点击设置" border="{{ false }}" />
         </My_GreyRectangleForm>
         <My_GreyRectangleForm title="邮箱">
             <van-field autosize model:value="{{ femail }}" input-class="input-class" placeholder="邮箱地址" border="{{ false }}" />
         </My_GreyRectangleForm>
     </view>
 </My_GeneralTemplate>
-<!-- 时间选择器 -->
+<!-- 时间选择 -->
+<My_selectTime id="SetDate" bind:getTimeData="setBbirthday"></My_selectTime>
 <!-- 提交按钮 -->
 <view class="submit_but">
     <van-button bindtap="submit" custom-class="custom-class" round color="linear-gradient(180deg, #82E0E9 0%, #4BBECF 100%);">保存</van-button>