瀏覽代碼

小程序二期

15102826049 3 周之前
父節點
當前提交
9c6a1908bb

+ 72 - 2
src/hooks/useDraw.ts

@@ -1,7 +1,77 @@
-export function useDraw(props: any, emit: any) {
+import { ref, reactive } from "vue";
+import { payment } from "@/services/ams";
+let isBtn = ref(true);
+const appid = uni.getStorageSync("appid");
+
+export function useDraw(props?: any, emit?: any) {
   const handleClose = () => {
     emit("update:show", false);
   };
 
-  return { handleClose };
+  const isWithDraw = (status: string) => {
+    return status === "3" || status === "5" || status === "6";
+  };
+
+  const onPayment = (data: any, type: string) => {
+    if (!isWithDraw(data.processStatus)) return;
+    if (!isBtn.value) return;
+    isBtn.value = false;
+    const status =
+      data.processStatus === "3" ||
+      data.processStatus === "5" ||
+      data.processStatus === "6";
+    if (!status) return;
+    payment(data.id)
+      .then((res: any) => {
+        if (res.code === 500) {
+          uni.showToast({ icon: "none", title: "提现中" });
+          return;
+        }
+
+        if (
+          wx.canIUse("requestMerchantTransfer") &&
+          res.data &&
+          res.data.packageInfo
+        ) {
+          wx.requestMerchantTransfer({
+            mchId: res.data.merchantId,
+            appId: appid,
+            package: res.data.packageInfo,
+            success: (response: any) => {
+              uni.showToast({ icon: "success", title: "请求成功" });
+              if (type === "1") {
+                setTimeout(() => {
+                  uni.switchTab({
+                    url: "/pages/my/index",
+                  });
+                }, 500);
+              } else {
+                handleClose();
+              }
+            },
+            fail: (response: any) => {
+              // uni.showToast({ icon: "none", title: "提现中" });
+            },
+          });
+        } else {
+          if (!res.data || !res.data.packageInfo) {
+            uni.showToast({ icon: "none", title: "提现中" });
+          } else {
+            wx.showModal({
+              content: "你的微信版本过低,请更新至最新版本。",
+              showCancel: false,
+            });
+          }
+        }
+      })
+      .catch((err) => {
+        console.log("-----------------------");
+        uni.showToast({ icon: "none", title: err.msg });
+      });
+    setTimeout(() => {
+      isBtn.value = true;
+    }, 1500);
+  };
+
+  return { handleClose, onPayment, isWithDraw };
 }

+ 9 - 7
src/pagesOne/record/claimList.vue

@@ -1,16 +1,17 @@
 <template>
-  <view class="claimList">
+  <scroll-view scroll-y class="claimList">
     <empty-box
       v-if="list.length == 0"
       text="暂无上传记录"
       src="https://qiuyu-daodian.oss-cn-beijing.aliyuncs.com/images/no-upload.png"
     ></empty-box>
-    <view @click="toDetail" class="itemBox">
-      <view class="clain">
+    <view class="itemBox">
+      <view v-for="item in 10" :key="item" @click="toDetail" class="clain">
         <claim-item></claim-item>
       </view>
     </view>
-  </view>
+    <wd-gap bg-color="#f7f8f9" height="50rpx"></wd-gap>
+  </scroll-view>
 </template>
 
 <script lang="ts" setup>
@@ -18,8 +19,6 @@ import claimItem from "./components/claimItem.vue";
 const list: any = [];
 
 const toDetail = () => {
-  console.log("1111111111111111111");
-
   uni.navigateTo({
     url: "/pagesOne/claim/claimRecord",
   });
@@ -30,8 +29,11 @@ const toDetail = () => {
 .claimList {
   background: #f7f8f9;
   height: calc(100vh - 84rpx);
+  padding: 32rpx;
+  box-sizing: border-box;
 
-  .itemBox {
+  .clain {
+    margin-bottom: 16rpx;
     // margin: 32rpx;
   }
 }

+ 84 - 80
src/pagesOne/record/winnerList.vue

@@ -2,7 +2,11 @@
   <view class="winnerListContent">
     <view class="title">奖励记录</view>
     <view class="content">
-			<empty-box v-if="list.length == 0" text="暂无奖励记录" src="https://qiuyu-daodian.oss-cn-beijing.aliyuncs.com/images/no-data.png"></empty-box>
+      <empty-box
+        v-if="list.length == 0"
+        text="暂无奖励记录"
+        src="https://qiuyu-daodian.oss-cn-beijing.aliyuncs.com/images/no-data.png"
+      ></empty-box>
       <view v-for="(item, index) in list" :key="item.id" class="activityItem">
         <view class="top flex-start-center">
           <image
@@ -31,7 +35,7 @@
           <view
             class="widthBtn"
             :class="isWithDraw(item.processStatus) ? 'active' : 'static'"
-            @click="onPayment(item)"
+            @click="onPayment(item, '1')"
             >{{ isWithDraw(item.processStatus) ? "提现" : "提现成功" }}</view
           >
         </view>
@@ -42,102 +46,102 @@
 
 <script lang="ts" setup>
 import { onLoad, onReachBottom } from "@dcloudio/uni-app";
-import { ref,reactive } from "vue";
+import { ref, reactive } from "vue";
 import { auditSuccessList, payment } from "@/services/ams";
-import emptyBox from '@/components/emptyBox.vue'
-
+import emptyBox from "@/components/emptyBox.vue";
+import { useDraw } from "@/hooks/useDraw";
 
+const { onPayment, isWithDraw } = useDraw();
 
 const openid = uni.getStorageSync("openid");
-const appid = uni.getStorageSync("appid");
+// const appid = uni.getStorageSync("appid");
 const list = <any>ref([]);
-const params =<any>reactive({
-	pageSize:10,
-	pageNum:1,
-	currentPage:0
-})
+const params = <any>reactive({
+  pageSize: 10,
+  pageNum: 1,
+  currentPage: 0,
+});
 
-let isBtn = ref(true);
+// let isBtn = ref(true);
 
 const getList = () => {
-  auditSuccessList({ openid,...params }).then((res: any) => {
-   params.currentPage = Math.ceil(res.total / params.pageSize)
-   list.value = [...list.value,...res.rows];
+  auditSuccessList({ openid, ...params }).then((res: any) => {
+    params.currentPage = Math.ceil(res.total / params.pageSize);
+    list.value = [...list.value, ...res.rows];
   });
 };
 
-const onPayment = (data: any) => {
-	if(!isWithDraw(data.processStatus)) return
-	if(!isBtn.value) return
-	isBtn.value = false
-  const status =
-    data.processStatus === "3" ||
-    data.processStatus === "5" ||
-    data.processStatus === "6";
-  if (!status) return;
-  payment(data.id)
-    .then((res: any) => {
-      if (res.code === 500) {
-        uni.showToast({ icon: "none", title: "提现中" });
-        return;
-      }
-			
-      if (wx.canIUse("requestMerchantTransfer") && res.data && res.data.packageInfo) {
-        wx.requestMerchantTransfer({
-          mchId: res.data.merchantId,
-          appId: appid,
-          package: res.data.packageInfo,
-          success: (response: any) => {
-            uni.showToast({ icon: "success", title: "请求成功" });
-            // getList();
-            setTimeout(() => {
-              uni.switchTab({
-                url: "/pages/my/index",
-              });
-            }, 500);
+// const onPayment = (data: any) => {
+//   if (!isWithDraw(data.processStatus)) return;
+//   if (!isBtn.value) return;
+//   isBtn.value = false;
+//   const status =
+//     data.processStatus === "3" ||
+//     data.processStatus === "5" ||
+//     data.processStatus === "6";
+//   if (!status) return;
+//   payment(data.id)
+//     .then((res: any) => {
+//       if (res.code === 500) {
+//         uni.showToast({ icon: "none", title: "提现中" });
+//         return;
+//       }
 
-            // res.err_msg将在页面展示成功后返回应用时返回ok,并不代表付款成功
-            // console.log("success:", res);
-          },
-          fail: (response: any) => {
-            // uni.showToast({ icon: "none", title: "提现中" });
-          },
-        });
-      } else {
-				if(!res.data || !res.data.packageInfo) {
-					uni.showToast({ icon: "none", title: "提现中" });
-				}else {
-					wx.showModal({
-					  content: "你的微信版本过低,请更新至最新版本。",
-					  showCancel: false,
-					});
-				}
-      }
-		})
-    .catch((err) => {
-			console.log('-----------------------')
-      uni.showToast({ icon: "none", title: err.msg });
-    });
-	setTimeout(()=>{
-		isBtn.value = true
-	},1500)
-};
-
-const isWithDraw = (status: string) => {
-  return status === "3" || status === "5" || status === "6";
-};
+//       if (
+//         wx.canIUse("requestMerchantTransfer") &&
+//         res.data &&
+//         res.data.packageInfo
+//       ) {
+//         wx.requestMerchantTransfer({
+//           mchId: res.data.merchantId,
+//           appId: appid,
+//           package: res.data.packageInfo,
+//           success: (response: any) => {
+//             uni.showToast({ icon: "success", title: "请求成功" });
+//             setTimeout(() => {
+//               uni.switchTab({
+//                 url: "/pages/my/index",
+//               });
+//             }, 500);
+//           },
+//           fail: (response: any) => {
+//             // uni.showToast({ icon: "none", title: "提现中" });
+//           },
+//         });
+//       } else {
+//         if (!res.data || !res.data.packageInfo) {
+//           uni.showToast({ icon: "none", title: "提现中" });
+//         } else {
+//           wx.showModal({
+//             content: "你的微信版本过低,请更新至最新版本。",
+//             showCancel: false,
+//           });
+//         }
+//       }
+//     })
+//     .catch((err) => {
+//       console.log("-----------------------");
+//       uni.showToast({ icon: "none", title: err.msg });
+//     });
+//   setTimeout(() => {
+//     isBtn.value = true;
+//   }, 1500);
+// };
 
+// const isWithDraw = (status: string) => {
+//   return status === "3" || status === "5" || status === "6";
+// };
 
 onLoad(() => {
   getList();
 });
 
-onReachBottom(()=>{
-	if (params.pageNum < params.currentPage) {
-		params.pageNum ++
-		getList()
-	}
-})
+onReachBottom(() => {
+  if (params.pageNum < params.currentPage) {
+    params.pageNum++;
+    getList();
+  }
+});
 </script>
 
 <style lang="scss" scoped>

+ 36 - 18
src/pagesOne/winner/components/winRecordPopup.vue

@@ -3,17 +3,23 @@
     <wd-popup
       v-model="props.show"
       custom-style="height: 880rpx;width:686rpx;background: transparent;"
-			@close="handleClose"
+      @close="handleClose"
     >
       <view class="content">
-				<scroll-view class="list" scroll-y @scrolltolower="scrolltolower">
-					<view>
-					  <view v-for="item in list" :key="item.id" class="record">
-					    <text>活动力度:{{ item.discountLevel }}</text>
-					    <text>奖励金额:{{ item.paymentAmount }}元</text>
-					  </view>
-					</view>
-				</scroll-view>
+        <scroll-view class="list" scroll-y @scrolltolower="scrolltolower">
+          <view>
+            <view v-for="item in list" :key="item.id" class="record">
+              <text>活动力度:{{ item.discountLevel }}</text>
+              <text>奖励金额:{{ item.paymentAmount }}元</text>
+              <view
+                class="btn"
+                :class="isWithDraw(item.processStatus) ? '' : 'static'"
+                @click="onPayment(item, '2')"
+                >提现</view
+              >
+            </view>
+          </view>
+        </scroll-view>
       </view>
       <image
         class="closed"
@@ -27,8 +33,9 @@
 
 <script lang="ts" setup>
 import { imgObj } from "../utils/source";
-import { ref } from "vue";
+// import { ref } from "vue";
 import { useDraw } from "@/hooks/useDraw";
+
 const props = defineProps({
   show: {
     type: Boolean,
@@ -39,12 +46,12 @@ const props = defineProps({
     default: () => [],
   },
 });
-const emit = defineEmits(["update:show","scrolltolower"]);
+const emit = defineEmits(["update:show", "scrolltolower"]);
 
-const { handleClose } = useDraw(props, emit);
-const scrolltolower = ()=>{
-	emit('scrolltolower')
-}
+const { handleClose, onPayment, isWithDraw } = useDraw(props, emit);
+const scrolltolower = () => {
+  emit("scrolltolower");
+};
 </script>
 
 <style lang="scss" scoped>
@@ -64,14 +71,17 @@ const scrolltolower = ()=>{
       // overflow-y: scroll;
       height: 798rpx;
       box-sizing: border-box;
-      width: 75%;
+      width: 90%;
       margin: auto;
       padding: 128rpx 0 95rpx;
       .record {
-        text-align: center;
-        text-align: left;
+        // text-align: center;
+        // text-align: left;
         padding: 32rpx 0;
         border-bottom: 1rpx solid rgba(191, 200, 219, 0.5);
+        display: flex;
+        justify-content: space-between;
+        align-items: flex-end;
         > text {
           line-height: 30rpx;
 
@@ -95,5 +105,13 @@ const scrolltolower = ()=>{
     bottom: 0;
     margin: auto;
   }
+  .btn {
+    @include btnStyle(108rpx, 38rpx);
+    font-weight: normal;
+    font-size: 22rpx;
+    &.static {
+      background: #d1d1d6;
+    }
+  }
 }
 </style>

+ 2 - 0
src/static/index.scss

@@ -10,6 +10,7 @@ $bg-green: #3a8b5c;
 $bg-green2: #337b52;
 
 @mixin btnStyle($width, $height) {
+  display: inline-block;
   background: $btn-green-linear;
   border-radius: 80rpx;
   font-weight: 600;
@@ -18,4 +19,5 @@ $bg-green2: #337b52;
   height: $height;
   text-align: center;
   line-height: $height;
+  // vertical-align: middle;
 }