lex-xin 5 months ago
parent
commit
117c05a0f9

+ 1 - 1
miniprogram/config.ts

@@ -1,4 +1,4 @@
-const environmentVariable = "dev";
+const environmentVariable = "test";
 const apiUrlInfo = {
   dev: "https://dev.kt.colexiu.com",
   test: "https://test.kt.colexiu.com",

BIN
miniprogram/pages/address/image/icon-close1.png


+ 8 - 1
miniprogram/pages/address/index.json

@@ -1,3 +1,10 @@
 {
-  "usingComponents": {}
+  "usingComponents": {
+    "navigation-bar": "/components/navigation-bar/navigation-bar",
+    "van-cell": "@vant/weapp/cell/index",
+    "van-cell-group": "@vant/weapp/cell-group/index",
+    "van-field": "@vant/weapp/field/index",
+    "van-popup": "@vant/weapp/popup/index",
+    "van-area": "@vant/weapp/area/index"
+  }
 }

+ 284 - 1
miniprogram/pages/address/index.less

@@ -1 +1,284 @@
-/* pages/address/index.wxss */
+/* pages/address/index.wxss */
+.container {
+  height: 100vh;
+  display: flex;
+  flex-direction: column;
+  background: #F5F6F7;
+}
+
+.record-list {
+  flex: 1;
+  overflow-y: scroll;
+  box-sizing: border-box;
+}
+
+
+.address-list {
+  padding: 40rpx 26rpx 0;
+}
+
+.address-item {
+  padding: 24rpx 24rpx 16rpx;
+  background: #fff;
+  border-radius: 20rpx;
+  border: 2rpx solid #fff;
+  margin-bottom: 22rpx;
+
+  &.active {
+    border: 2rpx solid rgba(254, 36, 81, 0.7);
+    background: #FFF4F6;
+  }
+
+  .item-title {
+    font-size: 26rpx;
+    color: rgba(0, 0, 0, 0.5);
+    line-height: 36rpx;
+  }
+
+  .detailAddress {
+    padding: 16rpx 0;
+    font-weight: 600;
+    font-size: 32rpx;
+    color: #131415;
+    line-height: 48rpx;
+  }
+
+  .item-users {
+    display: flex;
+    justify-content: space-between;
+
+    .item-user {
+      font-size: 26rpx;
+      color: rgba(0, 0, 0, 0.5);
+      line-height: 36rpx;
+
+      text {
+        padding-right: 16rpx;
+      }
+    }
+  }
+
+  .item-btn-group {
+    display: flex;
+    flex: 1;
+    justify-content: flex-end;
+    margin-top: 24rpx;
+    padding-top: 16rpx;
+    border-top: 2rpx solid rgba(0, 0, 0, 0.06);
+
+    .btn {
+      width: 104rpx;
+      padding: 0 !important;
+      margin: 0 0 0 24rpx !important;
+      line-height: 46rpx;
+      border-radius: 46rpx;
+      font-weight: 400;
+      font-size: 24rpx;
+      color: #333333;
+      background-color: #fff;
+      border-radius: 24rpx;
+      border: 1rpx solid #DCDCDC;
+    }
+
+    .update-btn {
+      background: #fff;
+      color: #FE2451;
+      border: 1rpx solid #FE2451;
+    }
+  }
+}
+
+
+.dialog-section {
+  width: 552rpx;
+  background: linear-gradient(180deg, #FFDEE7 0%, #FFFFFF 19%, #FFFFFF 100%);
+  border-radius: 32rpx;
+  padding: 40rpx;
+  box-sizing: border-box;
+
+  .dialog-title {
+    text-align: center;
+    font-weight: 600;
+    font-size: 36rpx;
+    color: #000000;
+    line-height: 50rpx;
+  }
+
+  .dialog-content {
+    padding: 40rpx 0 50rpx;
+    font-size: 32rpx;
+    color: #777777;
+    line-height: 44rpx;
+    text-align: center;
+  }
+
+  .dialog-btn-group {
+    display: flex;
+    align-items: center;
+
+    .btn {
+      flex: 1;
+      text-align: center;
+      line-height: 68rpx;
+      background: #F4F4F5;
+      border-radius: 36rpx;
+      font-size: 28rpx;
+      color: #131415;
+    }
+
+    .del-btn {
+      margin-left: 32rpx;
+      background: linear-gradient(270deg, #FF204B 0%, #FE5B71 100%);
+      border-radius: 36rpx;
+      border: 2rpx solid #FE2451;
+      color: #FFFFFF;
+    }
+  }
+}
+
+
+.empty-box {
+  position: absolute;
+  left: 50%;
+  top: 50%;
+  transform: translate(-50%, -80%);
+  font-size: 32rpx;
+  font-family: PingFangSC-Regular, PingFang SC;
+  font-weight: 400;
+  color: #999999;
+
+  image {
+    width: 436rpx;
+    height: 364rpx;
+  }
+
+  .empty-text {
+    font-size: 28rpx;
+    color: #777777;
+    line-height: 40rpx;
+    text-align: center;
+    padding-top: 24rpx;
+  }
+}
+
+.pop-btn-list {
+  padding: 24rpx 32rpx 58rpx;
+  box-shadow: inset 0rpx 2rpx 0rpx 0rpx #F0F0F0;
+  background-color: #fff;
+
+  .submit-btn {
+    width: 100% !important;
+    margin: 0 !important;
+    padding: 0 !important;
+    line-height: 88rpx;
+    background: linear-gradient(270deg, #FF204B 0%, #FE5B71 100%);
+    border-radius: 88rpx;
+    font-weight: 500;
+    font-size: 32rpx;
+    color: #fff;
+  }
+}
+
+
+.van-picker__toolbar,
+.toolbar-top {
+  margin: 0 40rpx !important;
+  padding: 0 14rpx !important;
+  border-bottom: 2rpx solid #F2F2F2;
+  height: auto !important;
+  line-height: normal !important;
+}
+
+.van-picker__cancel,
+.van-picker__confirm,
+.toolbar-cancel,
+toolbar-confirm {
+  font-size: 32rpx !important;
+  padding: 28rpx 0 !important;
+  color: #777777 !important;
+}
+
+.van-picker__confirm,
+.toolbar-confirm {
+  color: #FE2451 !important;
+}
+
+.toolbar-top {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+}
+
+
+.addressContainer {
+  background: linear-gradient(180deg, #FFDEE7 0%, #FFFFFF 12%, #FFFFFF 100%);
+  border-radius: 32rpx 32rpx 0rpx 0rpx;
+  height: 928rpx;
+  display: flex;
+  flex-direction: column;
+
+  .icon-close {
+    position: absolute;
+    z-index: 2;
+    top: 28rpx;
+    right: 12rpx;
+    padding: 20rpx;
+    width: 30rpx;
+    height: 30rpx;
+  }
+
+  .pop-address-title {
+    position: relative;
+    z-index: 1;
+    text-align: center;
+    padding-top: 36rpx;
+    padding-bottom: 20rpx;
+    font-weight: 600;
+    font-size: 36rpx;
+    color: #131415;
+    line-height: 50rpx;
+  }
+
+  .cell-group {
+    flex: 1 auto;
+
+    .van-cell {
+      padding: 36rpx 40rpx;
+      font-size: 30rpx;
+    }
+
+    .van-field__label {
+      color: #666666;
+    }
+
+    .van-icon-arrow {
+      color: #BFBFBF;
+    }
+
+    .textarea {
+      max-height: 72rpx;
+    }
+  }
+
+  .van-picker-column__item--selected {
+    font-weight: 600;
+    font-size: 32rpx;
+    color: #6D4718 !important;
+  }
+
+  .pop-btn-group {
+    padding: 32rpx 32rpx 58rpx;
+  }
+
+  .submit-btn {
+    width: 100% !important;
+    margin: 0 !important;
+    padding: 0 !important;
+    line-height: 88rpx;
+    background: linear-gradient(270deg, #FF204B 0%, #FE5B71 100%);
+    border-radius: 88rpx;
+    font-weight: 500;
+    font-size: 32rpx;
+    color: #fff;
+  }
+}

+ 284 - 38
miniprogram/pages/address/index.ts

@@ -1,3 +1,5 @@
+import { api_sysAreaQueryAllProvince, api_userReceiveAddressPage, api_userReceiveAddressRemove, api_userReceiveAddressSave, api_userReceiveAddressUpdate } from "../../api/new"
+
 // pages/address/index.ts
 Page({
 
@@ -5,62 +7,306 @@ Page({
    * 页面的初始数据
    */
   data: {
+    selectAddressId: '', // 选中地址编号
+    addressList: [] as any,
+    addressShow: false,
+    addressAfterLeave: false,
+    showDialog: false,
+
+    showArea: false,
+    areaList: [] as any,
+    currentValues: [] as any,
 
+    // 添加地址表单信息
+    id: "",
+    name: '',
+    phoneNumber: '',
+    detailAddress: '',
+    cityCode: 0,
+    cityName: "",
+    provinceCode: 0,
+    provinceName: "",
+    regionCode: '',
+    regionName: "",
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad() {
-
+    this.getAddress()
+    this.getAreas()
   },
-
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady() {
-
+  /** 地址列表 */
+  async getAddress() {
+    try {
+      const { data } = await api_userReceiveAddressPage({ page: 1, rows: -1 })
+      this.setData({
+        addressList: data.data.rows || []
+      })
+    } catch {
+      // 
+    }
   },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow() {
-
+  /** 获取省市区 */
+  async getAreas() {
+    try {
+      const { data } = await api_sysAreaQueryAllProvince({})
+      const areaList: any = this.formateArea(data.data)
+      const currentValues = []
+      if (areaList?.province_list) {
+        // 获取第一个键值对
+        const firstKey = Object.keys(areaList?.province_list)[0];
+        // 通过键获取值
+        const firstValue = areaList?.province_list[firstKey];
+        currentValues.push({
+          code: firstKey,
+          name: firstValue
+        })
+      }
+      if (areaList?.city_list) {
+        // 获取第一个键值对
+        const firstKey = Object.keys(areaList?.city_list)[0];
+        // 通过键获取值
+        const firstValue = areaList?.city_list[firstKey];
+        currentValues.push({
+          code: firstKey,
+          name: firstValue
+        })
+      }
+      if (areaList?.county_list) {
+        // 获取第一个键值对
+        const firstKey = Object.keys(areaList?.county_list)[0];
+        // 通过键获取值
+        const firstValue = areaList?.county_list[firstKey];
+        currentValues.push({
+          code: firstKey,
+          name: firstValue
+        })
+      }
+      console.log(areaList,
+        currentValues)
+      this.setData({
+        areaList,
+        currentValues
+      })
+    } catch {
+      // 
+    }
   },
-
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide() {
-
+  formateArea(area: any[]) {
+    const province_list: { [_: string]: string } = {};
+    const city_list: { [_: string]: string } = {};
+    const county_list: { [_: string]: string } = {};
+    area.forEach((item: any) => {
+      province_list[item.code] = item.name;
+    });
+    area.forEach((item: any) => {
+      item.areas && item.areas.forEach((city: any) => {
+        city_list[city.code] = city.name;
+      });
+    });
+    area.forEach((item: any) => {
+      item.areas && item.areas.forEach((city: any) => {
+        city.areas && city.areas.forEach((county: any) => {
+          county_list[county.code] = county.name;
+        });
+      });
+    });
+    return {
+      province_list,
+      city_list,
+      county_list
+    };
   },
-
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload() {
-
+  /** 显示选择地区 */
+  onShowAreaList() {
+    this.setData({
+      showArea: true
+    })
+  },
+  /** 关闭选择地区 */
+  onCloseAreaList() {
+    this.setData({
+      showArea: false
+    })
+  },
+  /** 确定选择地区 */
+  submitArea(e: any) {
+    const selectedOptions: any = e.detail.values
+    this.setData({
+      provinceCode: selectedOptions[0].code,
+      cityCode: selectedOptions[1].code,
+      regionCode: selectedOptions[2].code,
+      provinceName: selectedOptions[0].name,
+      cityName: selectedOptions[1].name,
+      regionName: selectedOptions[2].name,
+      showArea: false,
+    })
+  },
+  onShowAddress() {
+    this.setData({
+      addressAfterLeave: false,
+      addressShow: true
+    })
+  },
+  onCloseAddress() {
+    this.setData({
+      addressShow: false
+    })
+  },
+  onAddressAfterLeave() {
+    this.setData({
+      addressAfterLeave: false
+    })
   },
 
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh() {
+  /** Dialog 隐藏 */
+  onDialogClose() {
+    this.setData({
+      showDialog: false
+    })
+  },
+  /** 删除地址 */
+  onRemoveAddress(e: any) {
+    this.setData({
+      showDialog: true,
+      selectAddressId: e.target.dataset.id
+    })
+  },
+  /** 修改地址 */
+  onUpdateAddress(e: any) {
+    const id = e.target.dataset.id
+    const addressInfo = this.data.addressList.find((item: any) => item.id === id)
 
+    this.setData({
+      addressShow: true,
+      id: addressInfo.id,
+      name: addressInfo.name,
+      phoneNumber: addressInfo.phoneNumber,
+      detailAddress: addressInfo.detailAddress,
+      cityCode: addressInfo.city,
+      cityName: addressInfo.cityName,
+      provinceCode: addressInfo.province,
+      provinceName: addressInfo.provinceName,
+      regionCode: addressInfo.region,
+      regionName: addressInfo.regionName,
+    })
   },
+  /** 选择地址 */
+  onSelectAddress(e: any) {
+    const id = e.currentTarget.dataset.id
+    const addressInfo = this.data.addressList.find((item: any) => item.id === id)
 
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom() {
+    // this.setData({
+    // receiveAddress: addressInfo.id,
+    // 'receiveAddressInfo.addressDetail': addressInfo.provinceName + addressInfo.cityName + addressInfo.regionName + addressInfo.detailAddress,
+    // 'receiveAddressInfo.name': addressInfo.name,
+    // 'receiveAddressInfo.phoneNumber': addressInfo.phoneNumber,
+    // addressListShow: false
+    // })
+
+    const pages = getCurrentPages();
+    const prevPage = pages[pages.length - 2]; // 获取上一个页面实例
+    prevPage?.setData({
+      backParams: {
+        receiveAddress: addressInfo.id,
+        receiveAddressInfo: {
+          addressDetail: addressInfo.provinceName + addressInfo.cityName + addressInfo.regionName + addressInfo.detailAddress,
+          name: addressInfo.name,
+          phoneNumber: addressInfo.phoneNumber
+        }
+      }
+    });
 
+    wx.navigateBack()
   },
+  /** Dialog 确定 */
+  async onDialogConfirm() {
+    try {
+      await api_userReceiveAddressRemove({
+        id: this.data.selectAddressId
+      })
 
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage() {
+      this.getAddress()
+      // 如果删除的是已经选中的地址,则需要重置数据
+      // if (this.data.selectAddressId === this.data.receiveAddress) {
+      //   this.setData({
+      //     selectAddressId: '',
+      //     receiveAddress: '',
+      //     'receiveAddressInfo.name': '',
+      //     'receiveAddressInfo.phoneNumber': '',
+      //     'receiveAddressInfo.addressDetail': ''
+      //   })
+      // }
+      this.onDialogClose()
+    } catch {
 
-  }
+    }
+  },
+  /** 创建/修改收货地址 */
+  async onOperationAddress() {
+    const addressForm = this.data
+    try {
+      if (!addressForm.name) {
+        wx.showToast({
+          title: '请输入收货人姓名',
+          icon: "none"
+        })
+        return
+      }
+      if (!addressForm.phoneNumber || !/^1[3456789]\d{9}$/.test(addressForm.phoneNumber)) {
+        wx.showToast({
+          title: '请输入正确的手机号码',
+          icon: "none"
+        })
+        return
+      }
+      if (!addressForm.provinceCode || !addressForm.cityCode || !addressForm.regionCode) {
+        wx.showToast({
+          title: '请选择地区',
+          icon: "none"
+        })
+        return
+      }
+      if (!addressForm.detailAddress) {
+        wx.showToast({
+          title: '请输入详细地址',
+          icon: "none"
+        })
+        return
+      }
+      const params = {
+        name: addressForm.name,
+        phoneNumber: addressForm.phoneNumber,
+        province: addressForm.provinceCode,
+        city: addressForm.cityCode,
+        region: addressForm.regionCode,
+        detailAddress: addressForm.detailAddress
+      }
+      if (addressForm.id) {
+        await api_userReceiveAddressUpdate({
+          id: addressForm.id,
+          ...params
+        })
+        wx.showToast({
+          title: '修改成功',
+          icon: 'none'
+        })
+      } else {
+        await api_userReceiveAddressSave({
+          ...params
+        })
+        wx.showToast({
+          title: '添加成功',
+          icon: 'none'
+        })
+      }
+      this.getAddress()
+      this.onCloseAddress()
+    } catch (e) {
+      // 
+      console.log(e, '1212')
+    }
+  },
 })

+ 74 - 1
miniprogram/pages/address/index.wxml

@@ -1,2 +1,75 @@
 <!--pages/address/index.wxml-->
-<text>pages/address/index.wxml</text>
+<view class="container">
+  <navigation-bar title="收货地址"></navigation-bar>
+  <scroll-view class="record-list" type="list" scroll-y>
+    <view class="address-list">
+      <view class="empty-box" wx:if="{{ addressList.length <= 0 }}">
+        <image src="https://oss.dayaedu.com/ktyq/1731839238916.png"></image>
+        <view class="empty-text">暂无收货地址</view>
+      </view>
+      <view wx:for="{{ addressList }}" wx:key="index">
+        <view class="address-item {{ item.id === receiveAddress ? 'active' : '' }}" bind:tap="onSelectAddress" data-id="{{ item.id }}">
+          <view class="item-title">
+            {{ item.provinceName }}{{ item.cityName }}{{ item.regionName }}
+          </view>
+          <view class="detailAddress">
+            {{ item.detailAddress }}
+          </view>
+          <view class="item-users">
+            <view class="item-user">
+              <text>{{ item.name }}</text>
+              <text>{{ item.phoneNumber }}</text>
+            </view>
+          </view>
+          <view class="item-btn-group">
+            <button class="btn del-btn" catch:tap="onRemoveAddress" data-id="{{ item.id }}">删除</button>
+            <button class="btn update-btn" catch:tap="onUpdateAddress" data-id="{{ item.id }}">修改</button>
+          </view>
+        </view>
+      </view>
+    </view>
+  </scroll-view>
+
+
+  <view class="pop-btn-list">
+    <button class="submit-btn" bind:tap="onShowAddress">新建收货地址</button>
+  </view>
+
+  <van-popup show="{{ addressShow }}" safe-area-inset-bottom="{{false}}" lock-scroll="{{true}}" bind:close="onCloseAddress" position="bottom" round z-index="101" bind:after-leave="onAddressAfterLeave">
+    <view class="addressContainer" wx:if="{{ !addressAfterLeave }}">
+      <image src="./image/icon-close1.png" class="icon-close" bind:tap="onCloseAddress" />
+      <view class="pop-address-title">
+        {{ id ? '修改收货地址' : '新建收货地址' }}
+      </view>
+
+      <van-cell-group border="{{ false }}" class="cell-group">
+        <van-field model:value="{{ name }}" label="收货人" placeholder="请填写收货人姓名" placeholder-style="color: #bbb" />
+        <van-field model:value="{{ phoneNumber }}" label="电话号码" type="number" placeholder-style="color: #bbb" placeholder="请输入手机号码" maxlength="11" />
+        <van-field value="{{ provinceName ? provinceName + '/' + cityName + '/' + regionName : '' }}" label="选择地区" placeholder-style="color: #bbb" placeholder="请选择省/市/区" readonly is-link bind:tap="onShowAreaList" />
+        <van-field model:value="{{ detailAddress }}" label="详细地址" type="textarea" placeholder-style="color: #bbb" placeholder="请填写小区/楼号/单元/门牌号" input-class="textarea" autosize />
+      </van-cell-group>
+
+      <view class="pop-btn-group">
+        <button class="submit-btn" bind:tap="onOperationAddress">确认</button>
+      </view>
+    </view>
+  </van-popup>
+
+  <!-- 地区 -->
+  <van-popup round="{{true}}" lock-scroll="{{true}}" z-index="{{103}}" show="{{showArea}}" position="bottom" safe-area-inset-bottom="{{false}}" bind:close="onCloseAreaList">
+    <van-area id='area1' areaList="{{areaList}}" visible-item-count="9" item-height="46" value="{{ regionCode }}" bind:cancel="onCloseAreaList" bind:confirm="submitArea" />
+  </van-popup>
+
+  <van-popup round lock-scroll="{{true}}" z-index="{{102}}" show="{{showDialog}}">
+      <view class="dialog-section">
+        <view class="dialog-title">删除地址</view>
+
+        <view class="dialog-content">确认要删除该收货地址吗?</view>
+
+        <view class="dialog-btn-group">
+          <view class="btn" bind:tap="onDialogClose">取消</view>
+          <view class="btn del-btn" bind:tap="onDialogConfirm">删除</view>
+        </view>
+      </view>
+    </van-popup>
+</view>

+ 4 - 0
miniprogram/pages/index/index.ts

@@ -396,6 +396,8 @@ Page({
         params.push({
           pic: selected.pic,
           name: selected.name,
+          period: selected.period,
+          num: selected.num,
           originalPrice: selected.originalPrice,
           salePrice: selected.salePrice,
           shopId: selected.shopId,
@@ -408,6 +410,8 @@ Page({
         params.push({
           pic: selectedInstrument.pic,
           name: selectedInstrument.name,
+          period: selectedInstrument?.period,
+          num: selectedInstrument?.num || 0,
           originalPrice: selectedInstrument.originalPrice,
           salePrice: selectedInstrument.salePrice,
           shopId: selectedInstrument.shopId,

+ 1 - 1
miniprogram/pages/index/index.wxml

@@ -175,7 +175,7 @@
                 <van-field label="电话号码" model:value="{{ phone }}" maxlength="11" type="number" placeholder="请填写电话号码" />
                 <van-field label="性别" placeholder="请选择性别" value="{{ gender ? (gender === '1' ? '男' : '女') : '' }}" is-link readonly bind:tap="onCheckedGender"></van-field>
 
-                <van-field label="学校地区" value="{{ provinceName ? provinceName + ' ' + cityName + ' ' + regionName : '' }}" bind:tap="onShowAreaList" placeholder="请选择学校地区" is-link readonly />
+                <van-field label="学校地区" value="{{ provinceName ? provinceName + '/' + cityName + '/' + regionName : '' }}" bind:tap="onShowAreaList" placeholder="请选择学校地区" is-link readonly />
 
                 <van-field model:value="{{ schoolAreaName }}" label="所在学校" placeholder="请选择所在学校" is-link readonly bind:tap="onSelectSchool" />
                 <van-field value="{{ currentGradeTxt }}" label="所在年级" placeholder="请选择所在年级" is-link readonly bind:tap="onSelectGradeClass" />

+ 103 - 43
miniprogram/pages/orders/order-detail.less

@@ -6,6 +6,12 @@ page {
   background: #F5F6F7;
 }
 
+.record-list {
+  flex: 1;
+  overflow-y: scroll;
+  box-sizing: border-box;
+}
+
 .order-status {
   margin: 24rpx 26rpx 0;
   background-color: #FFFFFF;
@@ -108,12 +114,12 @@ page {
   width: 100%;
 
   &+.item-content {
-    padding-top: 60rpx;
+    padding-top: 40rpx;
   }
 
   .goods-icon {
-    width: 140rpx;
-    height: 140rpx;
+    width: 160rpx;
+    height: 160rpx;
     margin-right: 24rpx;
     flex-shrink: 0;
     border-radius: 6px;
@@ -140,7 +146,19 @@ page {
       color: #131415;
       line-height: 50rpx;
       text-overflow: ellipsis;
-      max-width: 480rpx;
+      max-width: 280rpx;
+    }
+
+    .goods-current-price {
+      font-weight: bold;
+      font-size: 28rpx;
+      color: #131415;
+      line-height: 48rpx;
+
+      text {
+        font-size: 32rpx;
+        padding-left: 4rpx;
+      }
     }
   }
 
@@ -175,20 +193,20 @@ page {
   .goods-type {
     display: flex;
     align-items: center;
-    padding-top: 28rpx;
+    padding-top: 10rpx;
+    justify-content: space-between;
 
     .goods-card {
-      height: 40rpx;
-      background: #fdf2e2;
+      background: #FEEDF0;
       border-radius: 6rpx;
       font-size: 26rpx;
-      color: #502f00;
+      color: #FE2451;
       line-height: 40rpx;
       padding: 0 12rpx;
     }
 
     .goods-num {
-      font-size: 28rpx;
+      font-size: 26rpx;
       color: #777;
       line-height: 36rpx;
     }
@@ -196,35 +214,36 @@ page {
 }
 
 .goodsInfos {
-  margin-top: 32rpx;
+  margin-top: 30rpx;
   // border-top: 2rpx solid #F2F2F2;
 
   .qrcode-line {
     position: relative;
-    background: linear-gradient(to right, transparent 50%, rgba(219, 219, 219, 1) 50%) repeat-x; // 设置水平方向的线性渐变,透明与半透明色交替,模拟虚线线段
-    background-size: 10px 1px; // 设置背景大小,控制虚线的线段长度和粗细,这里线段长度为10px,粗细为1px
+    // background: linear-gradient(to right, transparent 50%, rgba(219, 219, 219, 1) 50%) repeat-x; // 设置水平方向的线性渐变,透明与半透明色交替,模拟虚线线段
+    // background-size: 10px 1px; // 设置背景大小,控制虚线的线段长度和粗细,这里线段长度为10px,粗细为1px
+    background-color: #F2F2F2;
     height: 2rpx; // 元素高度,可根据实际需求调整,用于展示虚线效果的高度范围
-    // margin: 42rpx 0 32rpx;
-
-    &::before,
-    &::after {
-      content: '';
-      position: absolute;
-      top: -20rpx;
-      display: block;
-      width: 40rpx;
-      height: 40rpx;
-      background-color: #F4F4F4;
-      border-radius: 50%;
-    }
-
-    &::before {
-      left: -50rpx;
-    }
-
-    &::after {
-      right: -50rpx;
-    }
+    margin: 24rpx 0 28rpx;
+
+    // &::before,
+    // &::after {
+    //   content: '';
+    //   position: absolute;
+    //   top: -20rpx;
+    //   display: block;
+    //   width: 40rpx;
+    //   height: 40rpx;
+    //   background-color: #F4F4F4;
+    //   border-radius: 50%;
+    // }
+
+    // &::before {
+    //   left: -50rpx;
+    // }
+
+    // &::after {
+    //   right: -50rpx;
+    // }
   }
 }
 
@@ -232,12 +251,19 @@ page {
   display: flex;
   justify-content: space-between;
   align-items: center;
-  padding-top: 32rpx;
+  padding-top: 28rpx;
+
+  &:first-child {
+    padding-top: 0;
+    .title {
+      color: #777;
+    }
+  }
 
   .title {
     font-weight: 400;
     font-size: 28rpx;
-    color: #131415;
+    color: #FE2451;
     line-height: 40rpx;
   }
 
@@ -249,24 +275,58 @@ page {
     line-height: 48rpx;
 
     .stuff {
-      font-size: 32rpx;
+      font-size: 28rpx;
       padding-right: 4rpx;
     }
 
     .priceZ {
-      font-size: 48rpx;
+      font-size: 32rpx;
     }
 
     .priceF {
-      font-size: 32rpx;
+      font-size: 24rpx;
     }
   }
 
   .calc-price {
-    font-weight: bold;
-    font-size: 28rpx;
+    // font-weight: bold;
+    // font-size: 28rpx;
     color: #FF0047;
-    line-height: 32rpx;
+    // line-height: 32rpx;
+  }
+}
+
+.goodsInfo-count {
+  display: flex;
+  justify-content: flex-end;
+
+  .goods-price {
+    flex-shrink: 0;
+    font-family: DINAlternate, DINAlternate;
+    font-weight: bold;
+    color: #131415;
+    line-height: 48rpx;
+
+    .before {
+      font-weight: 400;
+      font-size: 24rpx;
+      color: #777777;
+      vertical-align: middle;
+    }
+
+    .stuff {
+      font-size: 38rpx;
+      padding-right: 4rpx;
+    }
+
+    .priceZ {
+      font-size: 40rpx;
+      line-height: 1;
+    }
+
+    .priceF {
+      font-size: 24rpx;
+    }
   }
 }
 
@@ -373,7 +433,6 @@ page {
     align-items: flex-end;
 
     .desc {
-      font-weight: 500;
       font-size: 28rpx;
       color: #777;
       line-height: 40rpx;
@@ -389,6 +448,7 @@ page {
 
       .stuff {
         font-size: 32rpx;
+        padding: 0 4rpx;
       }
 
       .priceZ {
@@ -409,7 +469,7 @@ page {
     }
 
     .discountPrice {
-      // padding-bottom: 6rpx;
+      padding-bottom: 2rpx;
       font-size: 24rpx;
       color: #FE2451;
     }

+ 64 - 11
miniprogram/pages/orders/order-detail.ts

@@ -17,6 +17,7 @@ Page({
         content: '请尽快完成支付,以便我们为您处理订单'
       },
     },
+    backParams: null,
     goodsInfo: {} as any,
     hasInstrument: false, // 是否有乐器
     receiveAddress: '', // 选择的地址信息
@@ -44,6 +45,8 @@ Page({
         allSalePrice: 0,
         allOriginPrice: 0,
         allDiscountPrice: '',
+        discountIntegerPart: '',
+        discountDecimalPart: '',
         integerPart: '',
         decimalPart: '',
         name: '',
@@ -63,8 +66,10 @@ Page({
         infos.shopId = item.shopId
 
         const afterPrice: any = formatPrice(item.salePrice)
+        // console.log(infos.goodsList, 'infos.goodsList')
         infos.goodsList.push({
           ...item,
+          typePeriod: this.formatPeriod(item.num, item.period),
           ...afterPrice
         })
 
@@ -75,16 +80,33 @@ Page({
       const allAfterPrice: any = formatPrice(infos.allSalePrice)
       // console.log(infos.allOriginPrice, infos.allSalePrice)
       infos.allDiscountPrice = formatPrice(infos.allOriginPrice - infos.allSalePrice, 'ALL') as string
+      const allDiscount: any = formatPrice(infos.allOriginPrice - infos.allSalePrice)
       infos.integerPart = allAfterPrice.integerPart
       infos.decimalPart = allAfterPrice.decimalPart
+      infos.discountIntegerPart = allDiscount.integerPart
+      infos.discountDecimalPart = allDiscount.decimalPart
       // console.log(infos, 'infos')
       this.setData({
         goodsInfo: infos,
+        userBeneficiaryId: options.userBeneficiaryId,
         status: options.status || '',
         hasInstrument
       });
     }
   },
+  // 格式化类型
+  formatPeriod(num: number, type: string) {
+    if(!type) return ''
+    const template: any = {
+      DAY: "天",
+      MONTH: "个月",
+      YEAR: "年"
+    }
+    if (type === "YEAR" && num >= 99) {
+      return '永久'
+    }
+    return num + (template[type] || '')
+  },
   // 获取后台配置的支付方式
   async queryPayType() {
     try {
@@ -106,7 +128,7 @@ Page({
   /** 添加收货地址 */
   onSelectAddress() {
     wx.navigateTo({
-      url: `../address/index`,
+      url: `../address/index?receiveAddress=${this.data.receiveAddress}`,
     })
   },
   onPayError(message?: string) {
@@ -118,12 +140,29 @@ Page({
   },
   // 购买
   async onSubmit() {
+    if (!this.data.receiveAddress && this.data.hasInstrument) {
+      wx.showToast({
+        title: '请选择收货地址',
+        icon: 'none'
+      })
+      return
+    }
     wx.showLoading({
       mask: true,
       title: "订单提交中...",
     });
     try {
-      const { salePrice, shopId, name, id, orderNo } = this.data.goodsInfo
+      const { allSalePrice, shopId, name, orderNo, goodsList } = this.data.goodsInfo
+      const goodsInfos: any = []
+      goodsList.forEach((item: any) => {
+        goodsInfos.push({
+          "goodsId": item.id,
+          "goodsNum": 1,
+          "goodsType": item.goodsType,
+          "paymentCashAmount": item.salePrice,
+          "paymentCouponAmount": 0
+        })
+      })
       if (orderNo) {
         const { data } = await api_userPaymentOrderUnpaid({
           orderNo: orderNo,
@@ -139,17 +178,13 @@ Page({
         const { data } = await api_executeOrder({
           "orderType": "WECHAT_MINI",
           "paymentType": this.data.paymentType,
-          "paymentCashAmount": salePrice,
+          "paymentCashAmount": allSalePrice,
           "paymentCouponAmount": 0,
           "shopId": shopId,
           "openId": app.globalData.userInfo?.liteOpenid,
-          "goodsInfos": [{
-            "goodsId": id,
-            "goodsNum": 1,
-            "goodsType": "ACTIVATION_CODE",
-            "paymentCashAmount": salePrice,
-            "paymentCouponAmount": 0
-          }],
+          "goodsInfos": goodsInfos,
+          receiveAddress: this.data.receiveAddress,
+          userBeneficiaryId: this.data.userBeneficiaryId,
           "orderName": name,
           "orderDesc": name
         })
@@ -162,6 +197,16 @@ Page({
             title: data.message,
             icon: 'none'
           })
+        }  else if([5435, 5436, 5437, 5439, 5442, 5443, 5408, 5427, 5432].includes(data.code)) {
+          wx.hideLoading()
+          wx.showToast({
+            title: data.message,
+            icon: 'none'
+          })
+
+          setTimeout(() => {
+            wx.navigateBack()
+          }, 1000);
         } else {
           this.onPayError()
         }
@@ -247,7 +292,15 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow() {
-
+    if (this.data.backParams) {
+      console.log(this.data.backParams, 'backParams'); // { key: 'value' }
+      const backParams: any = this.data.backParams || {};
+      this.setData({
+        receiveAddress: backParams.receiveAddress,
+        receiveAddressInfo: backParams.receiveAddressInfo,
+        backParams: null // 清空参数
+      })
+    }
   },
 
   /**

+ 29 - 30
miniprogram/pages/orders/order-detail.wxml

@@ -2,7 +2,7 @@
 <view class="container">
   <navigation-bar title="核对订单"></navigation-bar>
 
-  <scroll-view class="record-list" type="list" scroll-y bindscrolltolower="loadMore">
+  <scroll-view class="record-list" type="list" scroll-y>
     <!-- <view class="order-status">
       <view class="status">
         <image src="{{ statusList[status].logo }}"></image>
@@ -12,17 +12,17 @@
     </view> -->
 
     <!-- 添加权益人 -->
-    <view class="addBuyer" bind:tap="onSelectAddress">
+    <view class="addBuyer" bind:tap="onSelectAddress" wx:if="{{ hasInstrument }}">
       <image src="./images/address-top.png" mode="widthFix" class="addressTop"></image>
       <view class="addBuyer-left">
         <image src="./images/icon-address.png" class="icon-man"></image>
-        <view class="info" wx:if="{{ userBeneficiaryId }}">
+        <view class="info" wx:if="{{ receiveAddress }}">
           <view class="users">
-            {{ userBeneficiaryInfo.schoolInfo }}
+            {{ receiveAddressInfo.addressDetail }}
           </view>
           <view class="address">
-            <text>{{ userBeneficiaryInfo.name }}</text>
-            <text>{{ userBeneficiaryInfo.phoneNumber }}</text>
+            <text>{{ receiveAddressInfo.name }}</text>
+            <text>{{ receiveAddressInfo.phoneNumber }}</text>
           </view>
         </view>
         <view class="info" wx:else>
@@ -41,31 +41,18 @@
         <view class="goods-desc">
           <view class="goodsInfo">
             <view class="goods-name">{{ item.name }}</view>
+            <view class="goods-current-price">¥<text>{{ item.integerPart }}.{{ item.decimalPart }}</text></view>
           </view>
           <view class="goods-type">
-            <view class="goods-price">
-              <text class="stuff">¥</text>
-              <text class="priceZ">{{ item.integerPart }}</text>
-              <text class="priceF">.{{ item.decimalPart }}</text>
+            <view>
+              <text class="goods-card" wx:if="{{ item.typePeriod }}">{{ item.typePeriod }}</text>
             </view>
-            <view class="origin-price">|日常价 ¥ {{item.originalPrice}}</view>
+            <view class="goods-num">x 1</view>
           </view>
         </view>
-        <!-- <image class='goods-icon' src="{{ goodsInfo.pic }}" mode="" />
-        <view class="goods-desc">
-          <view class="goodsInfo">
-            <view class="goods-name">{{ goodsInfo.name }}</view>
-            <view class="goods-price"><text>¥</text>{{ goodsInfo.salePrice }}</view>
-          </view>
-          <view class="goods-type">
-            <view class="goods-card">{{ goodsInfo.typeName }}</view>
-            <view class="goods-num">x1</view>
-          </view>
-        </view> -->
       </view>
 
       <view class="goodsInfos">
-        <view class="qrcode-line"></view>
         <view class="goodsInfo-item">
           <text class="title">商品总额</text>
 
@@ -79,7 +66,23 @@
         <view class="goodsInfo-item" wx:if="{{ goodsInfo.allOriginPrice > goodsInfo.allSalePrice }}">
           <text class="title">惊喜优惠</text>
 
-          <view class="calc-price">-¥ {{ goodsInfo.allDiscountPrice }}</view>
+          <!-- <view class="calc-price">-¥ {{ goodsInfo.allDiscountPrice }}</view> -->
+          <view class="goods-price calc-price">
+            <text class="stuff">¥</text>
+            <text class="priceZ">{{ goodsInfo.discountIntegerPart }}</text>
+            <text class="priceF">.{{ goodsInfo.discountDecimalPart }}</text>
+          </view>
+        </view>
+
+        <view class="qrcode-line"></view>
+
+        <view class="goodsInfo-count">
+          <view class="goods-price">
+            <text class="before">共{{ goodsInfo.goodsList.length }}件:</text>
+            <text class="stuff">¥</text>
+            <text class="priceZ">{{ goodsInfo.integerPart }}</text>
+            <text class="priceF">.{{ goodsInfo.decimalPart }}</text>
+          </view>
         </view>
       </view>
     </view>
@@ -106,14 +109,10 @@
   </scroll-view>
 
   <view class="order-btn">
-    <!-- <view class="orders" bind:tap="onService">
-      <image src="./images/icon-service.png" />
-      <text>客服</text>
-    </view> -->
     <view class="more">
       <view class="price-section">
         <view class="price">
-          <view class="desc">共计</view>
+          <view class="desc">共计</view>
           <view class="currentPrice">
             <text class="stuff">¥</text>
             <text class="priceZ">{{ goodsInfo.integerPart }}</text>
@@ -129,5 +128,5 @@
     </view>
   </view>
 
-  <service popShow="{{ showService }}" bind:changePop="changePop"></service>
+  <!-- <service popShow="{{ showService }}" bind:changePop="changePop"></service> -->
 </view>

+ 7 - 0
project.private.config.json

@@ -9,6 +9,13 @@
     "miniprogram": {
       "list": [
         {
+          "name": "pages/address/index",
+          "pathName": "pages/address/index",
+          "query": "receiveAddress=",
+          "launchMode": "default",
+          "scene": null
+        },
+        {
           "name": "pages/orders/order-detail",
           "pathName": "pages/orders/order-detail",
           "query": "orderInfo=%257B%25220%2522%253A%257B%2522pic%2522%253A%2522https%253A%252F%252Foss.dayaedu.com%252Fktyq%252Fbasic%252F1739175447189.png%2522%252C%2522name%2522%253A%2522%25E7%25BB%2588%25E8%25BA%25AB%2522%252C%2522originalPrice%2522%253A%25223888.00%2522%252C%2522salePrice%2522%253A3680.01%252C%2522shopId%2522%253A%25221860977507241574402%2522%252C%2522id%2522%253A%25221861228127462633474%2522%252C%2522goodsType%2522%253A%2522ACTIVATION_CODE%2522%257D%252C%25221%2522%253A%257B%2522pic%2522%253A%2522https%253A%252F%252Foss.dayaedu.com%252Fktyq%252Fbasic%252F1739174280217.png%2522%252C%2522name%2522%253A%2522%25E5%25BE%25B7%25E5%25BC%258F%25E7%25AB%2596%25E7%25AC%259B%2522%252C%2522originalPrice%2522%253A199%252C%2522salePrice%2522%253A99%252C%2522shopId%2522%253A%25221860977507241574402%2522%252C%2522id%2522%253A%25221888860066698870786%2522%252C%2522goodsType%2522%253A%2522INSTRUMENTS%2522%257D%257D&userBeneficiaryId=1889266174420692993",