فهرست منبع

退货信息填写

wenjie 1 ماه پیش
والد
کامیت
f34192a7e5

+ 130 - 1
pages/DetailsOfRefund/DetailsOfRefund.js

@@ -50,7 +50,9 @@ Page({
     tomorrowDay: '',
     timeIntervals: [],
     columns: [],
-    combinedTextValue: '',
+    selectTimeshow: false,
+    time: '',//取件时间
+    userAddr: '',//取件地址
     sendInfo: {},
     currentSelectedIndex: -1, // 初始没有选中项,索引设为 -1
     cancelPay: false,
@@ -180,6 +182,133 @@ Page({
       }
     })
   },
+  /**
+   * 选择时间和地址
+   */
+  choose(e){
+    let type = e.currentTarget.dataset.type
+    if(type == 'time'){
+      this.getDayTime()
+      this.getTime()
+      let day = []
+      day.push({
+        id: 1,
+        text: this.data.nomDay
+      }, {
+        id: 2,
+        text: this.data.tomorrowDay
+      })
+      let data = []
+      data.push({
+        values: day,
+        className: 'column1',
+      }, {
+        values: this.data.timeIntervals,
+        defaultIndex: 2,
+        className: 'column2',
+      })
+      this.setData({
+        selectTimeshow: true,
+        columns: data
+      })
+    }else{//选择地址
+      wx.navigateTo({
+        url: '/pages/delivery-address/delivery-address?order=write',
+      })
+    }
+  },
+  onCancel: function () {
+    this.setData({
+      selectTimeshow: false
+    })
+  },
+  onConfirm(event) {
+    const {
+      picker,
+      value,
+      index
+    } = event.detail;
+    var currentDate = new Date();
+    var currentYear = currentDate.getFullYear();
+    if (value.length >= 2) {
+      const text1 = value[0].text; //text1为12月25日
+      const text2 = value[1].text.slice(0, 5); //text2为15:00
+      const month = ("0" + (parseInt(text1.split("月")[0]))).slice(-2); // 将中文月格式转换为数字(注意要减1,因为月份是从0开始计数),并补0
+      const day = text1.split("月")[1].split("日")[0];
+      const hour = text2.split(":")[0];
+      const minute = text2.split(":")[1];
+      const combinedText = `${currentYear}-${month}-${day} ${hour}:${minute}:00`;
+      let dateObj = new Date(combinedText);
+      let timestamp = Math.floor(dateObj.getTime() / 1000);
+      // 获取配送费
+      let that = this
+      console.log(combinedText);
+      this.setData({
+        time: combinedText,
+        selectTimeshow: false
+      });
+    }
+  },
+
+  // 获取今明天并转换
+  getDayTime: function () {
+    const today = new Date();
+    const month = (today.getMonth() + 1).toString().padStart(2, '0');
+    const day = today.getDate().toString().padStart(2, '0');
+    const todayFormat = `${month}月${day}日(今天)`;
+    const tomorrow = new Date(today.getTime() + 24 * 60 * 60 * 1000);
+    const tomorrowMonth = (tomorrow.getMonth() + 1).toString().padStart(2, '0');
+    const tomorrowDay = tomorrow.getDate().toString().padStart(2, '0');
+    const tomorrowFormat = `${tomorrowMonth}月${tomorrowDay}日(明天)`;
+    this.setData({
+      nomDay: todayFormat,
+      tomorrowDay: tomorrowFormat
+    })
+  },
+
+  // 时间段转换
+  getTime: function (selectedDate) {
+    const timeIntervals = [];
+    // 如果没有传入日期参数(首次加载等情况),则使用当前日期
+    const now = selectedDate ? new Date(selectedDate) : new Date();
+    if (isNaN(now.getTime())) {
+      console.error('传入的日期格式不正确,无法解析为有效日期');
+      return;
+    }
+    const currentTimeStamp = now.getTime();
+    for (let hour = 0; hour < 23; hour++) {
+      const start = hour.toString().padStart(2, '0') + ':00';
+      const end = (hour + 1).toString().padStart(2, '0') + ':00';
+      const interval = start + '~' + end;
+      // 创建对应时间段开始时间的日期对象
+      const startDate = new Date(now);
+      startDate.setHours(hour, 0, 0, 0);
+      const startTimestamp = startDate.getTime();
+      // 通过比较时间戳来判断时间段是否已过去
+      const hidden = startTimestamp < currentTimeStamp;
+      timeIntervals.push({
+        text: interval,
+        disabled: hidden
+      });
+    }
+    this.setData({
+      timeIntervals
+    });
+  },
+
+  // 日期转换方法
+  convertDateToNumber: function (dateStr) {
+    if (!dateStr) {
+      throw new Error('日期字符串不能为空');
+    }
+    dateStr = dateStr.trim();
+    let parts = dateStr.match(/(\d+)月(\d+)日/);
+    if (!parts) {
+      throw new Error('日期格式不正确,请按照XX月XX日的格式输入');
+    }
+    return new Date(2024, parseInt(parts[1]) - 1, parseInt(parts[2]));
+  },
+  
 
   /**
    * 生命周期函数--监听页面初次渲染完成

+ 49 - 0
pages/DetailsOfRefund/DetailsOfRefund.wxml

@@ -14,6 +14,48 @@
     </view>
   </view>
 
+  <view class="write-info box" wx:if="{{returnMoneySts == 65}}">
+    <view class="sub-title">配送信息</view>
+    <view class="form-box">
+      <view class="form-item">
+        <view class="label">
+          <view class="icon">*</view>
+          取件时间
+        </view>
+        <view class="value {{time?'black':''}}" data-type="time" bind:tap="choose">
+          {{time||'请选择时间'}} <image class="more" src="../../images/icon/black-down-arrow.png" mode=""/>
+        </view>
+      </view>
+      <view class="form-item">
+        <view class="label">
+          <view class="icon">*</view>
+          取件地址
+        </view>
+        <view class="value-box">
+          <view class="value {{userAddr?'black':''}}" data-type="address" bind:tap="choose">
+            {{userAddr?userAddr.addressName+userAddr.addrDetail:'请选择取件地址'}} <image class="more" src="../../images/icon/black-down-arrow.png" mode=""/>
+          </view>
+          <view class="value {{userAddr?'black':''}}" wx:if="{{userAddr}}">
+            {{userAddr.receiver + ' ' +userAddr.mobile}}  
+          </view>
+        </view>
+      </view>
+      <view class="form-item">
+        <view class="label">
+          <view class="icon">*</view>
+          退货方式
+        </view>
+        <view class="value black">
+          上门取件 
+        </view>
+      </view>
+    </view>
+    <view class="notice">无需支付配送费</view>
+    <view class="desc">1.因个人原因退货,需客户承担商品返还商家的运费</view>
+    <view class="desc">2.请确保商品不影响二次销售,否则商家会拒绝收货</view>
+    <view class="btn">提交</view>
+  </view>
+
   <!-- <view class="oprate-box box">
       <view class="item">
         <image class="icon" src="../../images/icon/del-icon.png" mode=""/>
@@ -129,4 +171,11 @@
       </view>
     </view>
 
+    <van-popup show="{{ selectTimeshow }}" round position="bottom" custom-style="height: 45%" bind:close="timeOnClose">
+    <view class="popup-box">
+      <view class="popup-title">选择上门时间</view>
+      <van-picker columns="{{ columns }}" show-toolbar bind:cancel="onCancel" bind:confirm="onConfirm" bind:change="onChange" />
+    </view>
+  </van-popup>
+
 </view>

+ 78 - 0
pages/DetailsOfRefund/DetailsOfRefund.wxss

@@ -39,6 +39,84 @@
   color: #FF4D3A;
 }
 
+.DetailsOfRefund .write-info{
+  padding: 28rpx 24rpx ;
+
+}
+.DetailsOfRefund .write-info .sub-title{
+  font-weight: bold;
+  font-size: 32rpx;
+  color: #222222;
+  margin-bottom: 28rpx;
+}
+.DetailsOfRefund .write-info .form-box{
+  border-bottom: 1rpx solid #F0F0F0;
+}
+.DetailsOfRefund .write-info .form-box .form-item{
+  display: flex;
+  /* align-items: center; */
+  justify-content: space-between;
+  margin-bottom: 24rpx;
+}
+
+.DetailsOfRefund .write-info .form-box .form-item .label{
+  display: flex;
+  font-size: 28rpx;
+  color: #222222;
+}
+.DetailsOfRefund .write-info .form-box .form-item .label .icon{
+  color: #FF4D3A;
+}
+.DetailsOfRefund .write-info .form-box .form-item .value{
+  display: flex;
+  align-items: center;
+  font-size: 28rpx;
+  color: #AAAAAA;
+}
+.DetailsOfRefund .write-info .form-box .form-item .value.black{
+  color: #222222;
+}
+.DetailsOfRefund .write-info .form-box .form-item .value .more{
+  width: 24rpx;
+  height: 24rpx;
+  margin-left: 14rpx;
+  transform: rotate(-90deg);
+}
+.DetailsOfRefund .write-info .notice{
+  font-weight: bold;
+  font-size: 28rpx;
+  color: #222222;
+  padding-top: 28rpx;
+}
+.DetailsOfRefund .write-info .desc{
+  font-size: 24rpx;
+  color: #AAAAAA;
+  padding-top: 24rpx;
+}
+.DetailsOfRefund .write-info .btn{
+  width: 654rpx;
+  height: 80rpx;
+  line-height: 80rpx;
+  text-align: center;
+  background: #006CE8;
+  border-radius: 40rpx 40rpx 40rpx 40rpx;
+  font-weight: bold;
+  font-size: 28rpx;
+  color: #FFFFFF;
+  margin-top: 24rpx;
+}
+popup-box {
+  background: #FFFFFF;
+  border-radius: 32rpx 32rpx 0rpx 0rpx;
+}
+.popup-title {
+  margin-top: 28rpx;
+  font-weight: bold;
+  font-size: 32rpx;
+  color: #222222;
+  text-align: center;
+}
+
 .box{
   background: #FFFFFF;
   border-radius: 16rpx 16rpx 16rpx 16rpx;

+ 10 - 0
pages/delivery-address/delivery-address.js

@@ -94,6 +94,16 @@ Page({
       })
       wx.setStorageSync('LATITUDE', e.currentTarget.dataset.item.latitude)
       wx.setStorageSync('LONGITUDE', e.currentTarget.dataset.item.longitude)
+    }else if(this.data.order == 'write'){//新增  退货选择地址逻辑
+      let address = e.currentTarget.dataset.item
+      var pages = getCurrentPages(); //当前页面
+      var prevPage = pages[pages.length - 2]; //上一页面
+      prevPage.setData({ //直接给上移页面赋值
+        userAddr: e.currentTarget.dataset.item,
+      });
+      wx.navigateBack({ //返回
+        delta: 1
+      })
     }
   },
 })