Browse Source

添加删除功能

黄琪勇 2 months ago
parent
commit
59ad257556

BIN
miniprogram/pages/index/images/delIcon.png


+ 83 - 8
miniprogram/pages/index/index.less

@@ -414,9 +414,10 @@ page {
         display: flex;
         flex-wrap: wrap;
 
-        &.lastGoodsList{
+        &.lastGoodsList {
           padding-bottom: 72rpx;
         }
+
         &.instrumentsList {
           .goodsItem {
             padding: 10rpx 24rpx;
@@ -496,8 +497,8 @@ page {
         border: 3rpx solid transparent;
 
         &.active {
-          background: linear-gradient( 315deg, #FFEEE9 0%, #FFF6EC 100%);
-          border-color: rgba(255,170,157,0.56);
+          background: linear-gradient(315deg, #FFEEE9 0%, #FFF6EC 100%);
+          border-color: rgba(255, 170, 157, 0.56);
         }
 
         &:last-child {
@@ -550,16 +551,22 @@ page {
         }
 
         .operate {
-          width: 62rpx;
-          height: 62rpx;
           display: flex;
           justify-content: center;
           align-items: center;
           flex-shrink: 0;
 
-          image {
-            width: 34rpx;
-            height: 34rpx;
+          .operateBtn {
+            display: flex;
+            justify-content: center;
+            align-items: center;
+            width: 62rpx;
+            height: 62rpx;
+
+            image {
+              width: 34rpx;
+              height: 34rpx;
+            }
           }
         }
       }
@@ -626,4 +633,72 @@ page {
       transform: translateY(-50rpx);
     }
   }
+}
+
+
+.del-popup-section {
+  .popup-mask {
+    position: fixed;
+    top: 0;
+    left: 0;
+    right: 0;
+    bottom: 0;
+    background-color: rgba(0, 0, 0, 0.6);
+    z-index: 99999;
+  }
+
+  .popup-container {
+    position: fixed;
+    left: 0;
+    right: 0;
+    top: 50%;
+    transform: translateY(-50%);
+    z-index: 999999;
+    margin: 0 100rpx;
+    padding: 50rpx 0 40rpx 0;
+    background: #FFFFFF;
+    border-radius: 32rpx;
+
+    .tit {
+      font-weight: 600;
+      font-size: 36rpx;
+      color: #000000;
+      line-height: 50rpx;
+      text-align: center;
+    }
+
+    .titCon {
+      margin-top: 40rpx;
+      font-weight: 400;
+      font-size: 32rpx;
+      color: #777777;
+      line-height: 44rpx;
+      text-align: center;
+    }
+
+    .btnCon {
+      display: flex;
+      justify-content: center;
+      margin-top: 50rpx;
+
+      view {
+        font-weight: 400;
+        font-size: 28rpx;
+        color: #000000;
+        line-height: 36rpx;
+        padding: 16rpx 72rpx;
+        border-radius: 36rpx;
+        border: 2rpx solid #DCDCDC;
+
+        &:last-child {
+          margin-left: 32rpx;
+          background: url("https://oss.dayaedu.com/ktyq/1739864864169.png") no-repeat;
+          background-size: 100% 100%;
+          font-weight: 500;
+          color: #fff;
+          border-color: transparent;
+        }
+      }
+    }
+  }
 }

+ 42 - 2
miniprogram/pages/index/index.ts

@@ -43,6 +43,7 @@ Page({
     memberPopupShow: false,
     memberList: [],
     memberInfo: {} as any, // 会员信息
+    selectedDelId: "",
     isShowMemberInfoTip: false, // 会员信息提示
     isFromPreviewImage: false,
     isShowOperation: false, // 是否显示操作按钮
@@ -165,6 +166,47 @@ Page({
       url: `/pages/member/addMember`
     });
   },
+  onDialogClose() {
+    this.setData({
+      delPopupShow: false
+    })
+  },
+  async onDialogOk() {
+    try {
+      const { data } = await api_userBeneficiaryRemove(this.data.selectedDelId)
+      if (data.code === 200) {
+        this.setData({
+          delPopupShow: false
+        })
+        try {
+          const resData = await api_getUserBeneficiaryPage()
+          const pageRows = resData?.data?.data?.rows || []
+          this.setData({
+            memberList: pageRows
+          })
+        } catch (e) {
+          console.log(e, 'e')
+        }
+        // 当删的是当前选中的
+        if (this.data.selectedDelId === this.data.memberInfo.id) {
+          let item: any
+          if (this.data.memberList.length) {
+            item = this.data.memberList[0]
+          }
+          this.setData({ memberInfo: item ? { id: item.id, name: item.name, phone: item.phone, schoolInfo: item.provinceName + item.cityName + (item.regionName || "") + item.schoolAreaName + GRADE_ENUM[item.currentGradeNum] + item.currentClass + "班" } : {} })
+        }
+      }
+    } catch (e: any) { }
+  },
+  onDel(e: any) {
+    const { dataset } = e.currentTarget
+    this.setData({
+      selectedDelId: dataset.id
+    })
+    this.setData({
+      delPopupShow: true
+    })
+  },
   onEdit(e: any) {
     const { dataset } = e.currentTarget
     wx.navigateTo({
@@ -179,8 +221,6 @@ Page({
   onSelect(e: any) {
     const { dataset } = e.currentTarget
     const item = dataset.item;
-    // api_userBeneficiaryRemove(item.id)
-    // return
     this.setData({ memberInfo: item ? { id: item.id, name: item.name, phone: item.phone, schoolInfo: item.provinceName + item.cityName + (item.regionName || "") + item.schoolAreaName + GRADE_ENUM[item.currentGradeNum] + item.currentClass + "班" } : {}, memberPopupShow: false })
   },
   async onMemberInfo() {

+ 18 - 2
miniprogram/pages/index/index.wxml

@@ -110,14 +110,30 @@
                 </text>
               </view>
             </view>
-            <view class="operate" catch:tap="onEdit" data-id="{{ item.id }}">
-              <image src="./images/editIcon.png"></image>
+            <view class="operate">
+              <view class="operateBtn" catch:tap="onEdit" data-id="{{ item.id }}">
+                <image src="./images/editIcon.png"></image>
+              </view>
+              <view class="operateBtn" catch:tap="onDel" data-id="{{ item.id }}">
+                <image src="./images/delIcon.png"></image>
+              </view>
             </view>
           </view>
         </scroll-view>
         <view class="btnSections"><button type="primary" bind:tap="onAdd">新建会员信息</button></view>
       </view>
     </view>
+    <view class="del-popup-section" wx:if="{{delPopupShow}}">
+      <view class="popup-mask" bind:tap="onDialogClose"></view>
+      <view class="popup-container">
+        <view class="tit">温馨提示</view>
+        <view class="titCon">是否要删除该收货信息?</view>
+        <view class="btnCon">
+          <view bind:tap="onDialogClose">取消</view>
+          <view bind:tap="onDialogOk">确认</view>
+        </view>
+      </view>
+    </view>
     <!-- <view class="showMoreContainer {{ !isShowOperation ? '' : 'hide' }}">
       <image src="./images/icon-up-scroll.png" class="iconUpScroll" />
     </view> -->