zhengnaiwen_citu 7 miesięcy temu
rodzic
commit
b90e33fe09
6 zmienionych plików z 283 dodań i 90 usunięć
  1. 14 1
      api/sign.js
  2. 6 0
      pages.json
  3. 73 59
      pages/index/welfare.vue
  4. 39 25
      pagesA/balance/index.vue
  5. 1 1
      pagesA/coupon/index.vue
  6. 150 4
      pagesA/integral/index.vue

+ 14 - 1
api/sign.js

@@ -126,7 +126,7 @@ export const getCouponTemplatePage = (params) => {
     method: 'GET',
     params,
     custom: {
-      auth: true,
+      auth: false,
       showError: false,
       showLoading: false,
     }
@@ -158,4 +158,17 @@ export const getUserWalletRechargePage = async (params) => {
       auth: true
     }
   })
+}
+
+// 账户变动记录
+export const getEnterpriseAccountRecordPage = async (params) => {
+  return request({
+    url: '/app-api/menduner/system/recruit/enterprise/account/record/page',
+    method: 'GET',
+    params,
+    custom: {
+      showLoading: false,
+      auth: true
+    }
+  })
 }

+ 6 - 0
pages.json

@@ -95,6 +95,12 @@
 					"style": {
 						"navigationBarTitleText": "我的余额"
 					}
+				},
+				{
+					"path": "integral/index",
+					"style": {
+						"navigationBarTitleText": "积分明细"
+					}
 				}
 			]
 		},

+ 73 - 59
pages/index/welfare.vue

@@ -114,8 +114,6 @@ const todaySignIn = ref(false)
 
 // 今天
 const todayNumber = ref()
-// 加载
-const signLoading = ref(false)
 
 const balance = ref({})
 
@@ -129,16 +127,21 @@ const more = ref('more')
 
 const myCoupon = ref(0)
 
-watch(() => useUserStore.isLogin, () => {
+// watch(() => useUserStore.isLogin, () => {
+//   if (useUserStore.isLogin) {
+//     init()
+//   }
+// })
+
+watch([() => useUserStore.refreshToken, () => useUserStore.isLogin], () => {
   if (useUserStore.isLogin) {
-    init()
+    getMyCoupon()
+    initCoupon()
+    getSummary()
+    getBalance()
   }
 })
 
-watch(() => useUserStore.refreshToken, () => {
-  init()
-})
-
 onShow(() => {
   const currentPage = getCurrentPages()[0];  // 获取当前页面实例
   const currentTabBar = currentPage?.getTabBar?.();
@@ -154,10 +157,9 @@ function init () {
   getSummary()
   // 获取余额积分
   getBalance()
-  pageInfo.value.pageNo = 1
-  items.value = []
-  // 获取模板
-  getAllCouponPage()
+  // 获取优惠券列表
+  initCoupon()
+  // 获取我的优惠券总数
   getMyCoupon()
 
 }
@@ -192,15 +194,19 @@ async function getSignIn () {
 }
 // 签到
 async function handleSignIn () {
-  if (signLoading.value) {
-    return
-  }
+  uni.showLoading({
+    title: '正在签到'
+  })
   try {
-    signLoading.value = true
-    await createRewardSignInRecord()
+    const { code } = await createRewardSignInRecord()
+    if (code !== 0) {
+      return
+    }
     setTimeout(async () => {
-      await getSummary()
-      
+      const { code: _code } = await getSummary()
+      if (_code !== 0) {
+        return
+      }
       uni.showToast({
         title: '签到成功',
         icon: 'success',
@@ -212,7 +218,7 @@ async function handleSignIn () {
   } catch (error) {
     
   } finally {
-    signLoading.value = false
+    uni.hideLoading()
   }
 }
 
@@ -221,7 +227,7 @@ async function handleSignIn () {
 async function getAllCouponPage () {
   try {
     const { data } = await getCouponTemplatePage({ ...pageInfo.value })
-    console.log(data)
+    // console.log(data)
     if (!data || !data.list || !data.list.length) {
       if (pageInfo.value.pageNo === 1) {
         more.value = 'more'
@@ -252,42 +258,42 @@ async function getMyCoupon () {
 }
 
 // 优惠券列表
-async function handleGetTmpUsed () {
-  try {
-    const { data } = await getDiyTemplateUsed()
-    if (!data?.home?.components) {
-      uni.showToast({
-        title: '暂无优惠券',
-        icon: 'none',
-        mask: true
-      })
-      return
-    }
-    const idsItem = data.home.components.find(e => e.id === 'CouponCard')
-    if (!idsItem) {
-      uni.showToast({
-        title: '暂无优惠券',
-        icon: 'none',
-        mask: true
-      })
-      return
-    }
-    const ids = idsItem?.property?.couponIds
-    if (!ids) {
-      uni.showToast({
-        title: '暂无优惠券',
-        icon: 'none',
-        mask: true
-      })
-      return
-    }
-    const { data: _data } = await getDiyTemplate(ids.join(','))
-    items.value = _data
-    more.value = 'noMore'
-  } catch (error) {
+// async function handleGetTmpUsed () {
+//   try {
+//     const { data } = await getDiyTemplateUsed()
+//     if (!data?.home?.components) {
+//       uni.showToast({
+//         title: '暂无优惠券',
+//         icon: 'none',
+//         mask: true
+//       })
+//       return
+//     }
+//     const idsItem = data.home.components.find(e => e.id === 'CouponCard')
+//     if (!idsItem) {
+//       uni.showToast({
+//         title: '暂无优惠券',
+//         icon: 'none',
+//         mask: true
+//       })
+//       return
+//     }
+//     const ids = idsItem?.property?.couponIds
+//     if (!ids) {
+//       uni.showToast({
+//         title: '暂无优惠券',
+//         icon: 'none',
+//         mask: true
+//       })
+//       return
+//     }
+//     const { data: _data } = await getDiyTemplate(ids.join(','))
+//     items.value = _data
+//     more.value = 'noMore'
+//   } catch (error) {
     
-  }
-}
+//   }
+// }
 
 async function loadingMore () {
   if (more.value === 'noMore') {
@@ -298,6 +304,12 @@ async function loadingMore () {
   getAllCouponPage()
 }
 
+function initCoupon () {
+  pageInfo.value.pageNo = 1
+  items.value = []
+  getAllCouponPage()
+}
+
 function handleLogin () {
   if (!useUserStore.isLogin) {
 		showAuthModal()
@@ -335,9 +347,7 @@ async function onGetCoupon(id, canTake) {
       icon: 'success'
     })
     getMyCoupon()
-    pageInfo.value.pageNo = 1
-    items.value = []
-    await getAllCouponPage()
+    initCoupon()
   } catch (error) {
     
   } finally {
@@ -346,6 +356,10 @@ async function onGetCoupon(id, canTake) {
 }
 
 function handleTo (page) {
+  if (!useUserStore.isLogin) {
+		showAuthModal()
+		return
+  }
   uni.navigateTo({
     url: `/pagesA/${page}/index`
   })

+ 39 - 25
pagesA/balance/index.vue

@@ -1,27 +1,32 @@
 <template>
   <layout-page>
-    <scroll-view class="scrollBox defaultBgc" scroll-y="true" @scrolltolower="loadingMore">
-      <view class="panel">
+    <view class="box defaultBgc">
+      <scroll-view class="scrollBox" scroll-y="true" @scrolltolower="loadingMore">
         <view>
-          <uni-icons color="#f30" type="icon-renminbi1688" size="16" custom-prefix="iconfont"></uni-icons>
-          <text class="text">{{ balance.balance > 0 ? (balance?.balance / 100.0).toFixed(2) : 0 }}</text>
+          <view class="panel">
+            <view>
+              <uni-icons color="#f30" type="icon-renminbi1688" size="16" custom-prefix="iconfont"></uni-icons>
+              <text class="text">{{ balance.balance > 0 ? (balance?.balance / 100.0).toFixed(2) : 0 }}</text>
+            </view>
+            <view>
+              <button class="btn">充值</button>
+            </view>
+          </view>
+          <view class="list">
+            <uni-list border-full>
+              <uni-list-item
+                v-for="item in items"
+                :key="item.id"
+                :title="item._payPrice"
+                :note="item._payTime"
+                :rightText="item.payChannelName"
+              />
+            </uni-list>
+            <uni-load-more :status="more" />
+          </view>
         </view>
-        <view>
-          <button class="btn">充值</button>
-        </view>
-      </view>
-      <view class="list">
-        <uni-list border-full>
-          <uni-list-item
-            v-for="item in items"
-            :key="item.id"
-            :title="item._payPrice"
-            :note="item._payTime"
-            :rightText="item.payChannelName"
-          />
-        </uni-list>
-      </view>
-    </scroll-view>
+      </scroll-view>
+    </view>
   </layout-page>
 </template>
 <!-- balance 余额 -->
@@ -65,15 +70,16 @@ async function getList () {
       more.value = 'more'
       return
     }
-    items.value.push(...data.list.map(e => {
+    const _data = data.list.map(e => {
       return {
         ...e,
         _payPrice: (e.payPrice / 100.0).toFixed(2),
         _payTime: timesTampChange(e.payTime)
       }
-    }))
+    })
+    items.value.push(..._data)
     total.value = +data.total
-    more.value = total.value === items.value.length ? 'noMore' : 'more'
+    more.value = total.value <= items.value.length ? 'noMore' : 'more'
   } catch (error) {
     if (pageInfo.value.pageNo === 1) {
       return
@@ -93,11 +99,17 @@ function loadingMore () {
 </script>
 
 <style lang="scss" scoped>
+.box {
+  height: 100vh;
+}
 .scrollBox {
   width: 100vw;
-  padding: 20rpx;
+  // padding: 20rpx;
   box-sizing: border-box;
   .panel {
+    position: sticky;
+    z-index: 2;
+    top: 0;
     width: 100%;
     padding: 20rpx;
     margin-bottom: 20rpx;
@@ -105,6 +117,8 @@ function loadingMore () {
     background: #FFF;
     display: flex;
     justify-content: space-between;
+    align-items: flex-end;
+    box-shadow: 0px 0px 10px 0px rgb(0, 0, 0, 0.25);
     .text {
       color: #F30;
       font-size: 54rpx;
@@ -122,7 +136,7 @@ function loadingMore () {
     }
   }
   .list {
-    padding: 20rpx;
+    // padding: 20rpx;
   }
 }
 </style>

+ 1 - 1
pagesA/coupon/index.vue

@@ -103,7 +103,7 @@ function handleTo (status) {
           icon: 'none'
         })
     }  
-});  
+  })
 }
 
 function loadingMore () {

+ 150 - 4
pagesA/integral/index.vue

@@ -1,13 +1,159 @@
 <template>
-  <div>
-
-  </div>
+  <layout-page>
+    <view class="box defaultBgc">
+      <scroll-view class="scrollBox" scroll-y="true" @scrolltolower="loadingMore">
+        <view>
+          <view class="panel">
+            <view>
+              <uni-icons color="#f30" type="icon-renminbi1688" size="16" custom-prefix="iconfont"></uni-icons>
+              <text class="text">{{ balance.point }}</text>
+            </view>
+            <view>
+              <button class="btn" @tap="handleUse">使用积分</button>
+            </view>
+          </view>
+          <view class="list">
+            <uni-list>
+              <uni-list-item
+                v-for="item in items"
+                :key="item.id"
+                :title="item.description"
+                :rightText="item._createTime"
+              />
+            </uni-list>
+            <uni-load-more :status="more" />
+          </view>
+        </view>
+      </scroll-view>
+    </view>
+  </layout-page>
 </template>
-<!-- integral 积分 -->
+<!-- balance 余额 -->
 <script setup>
+import { ref } from 'vue'
+import {
+  getUserAccount,
+  getEnterpriseAccountRecordPage
+} from '@/api/sign'
+import { timesTampChange } from '@/utils/date'
+
+const balance = ref({})
+
+const items = ref([])
+const pageInfo = ref({
+  pageNo: 1,
+  pageSize: 20
+})
+const total = ref(0)
+const more = ref('more')
+
+getBalance()
+getList()
+// 获取积分余额
+async function getBalance() {
+  const { data } = await getUserAccount()
+  if (!data) {
+    return
+  }
+  balance.value = data
+}
+
+async function getList () {
+  try {
+    const { data } = await getEnterpriseAccountRecordPage({ ...pageInfo.value, type: 0 })
+    if (!data || !data.list) {
+      if (pageInfo.value.pageNo === 1) {
+        return
+      }
+      pageInfo.value.pageNo--
+      more.value = 'more'
+      return
+    }
+    const _data = data.list.map(e => {
+      return {
+        ...e,
+        _createTime: timesTampChange(e.createTime)
+      }
+    })
+    items.value.push(..._data)
+    total.value = +data.total
+    more.value = total.value <= items.value.length ? 'noMore' : 'more'
+  } catch (error) {
+    if (pageInfo.value.pageNo === 1) {
+      return
+    }
+    pageInfo.value.pageNo--
+    more.value = 'more'
+  }
+}
+function loadingMore () {
+  if (more.value === 'noMore') {
+    return
+  }
+  more.value = 'loading'
+  pageInfo.value.pageNo++
+  getList()
+}
+
+function handleUse () {
+  wx.navigateToMiniProgram({  
+    appId: 'wx6decdf12f9e7a061', // 目标小程序的 appId
+    envVersion: 'develop',
+    success(res) {  
+        // 打开成功  
+        console.log('成功跳转至小程序:', res);  
+    },  
+    fail(err) {  
+        // 打开失败
+        uni.showToast({
+          title: '打开商城失败',
+          icon: 'none'
+        })
+    }  
+  })
+}
 
 </script>
 
 <style lang="scss" scoped>
+.box {
+  height: 100vh;
+}
+.scrollBox {
+  width: 100vw;
+  // padding: 20rpx;
+  box-sizing: border-box;
+  .panel {
+    position: sticky;
+    z-index: 2;
+    top: 0;
+    width: 100%;
+    padding: 20rpx;
+    margin-bottom: 20rpx;
+    box-sizing: border-box;
+    background: #FFF;
+    display: flex;
+    justify-content: space-between;
+    align-items: flex-end;
+    box-shadow: 0px 0px 10px 0px rgb(0, 0, 0, 0.25);
+    .text {
+      color: #F30;
+      font-size: 54rpx;
 
+    }
+    .btn {
+      width: 180rpx;
+      height: 60rpx;
+      line-height: 60rpx;
+      font-size: 28rpx;
+      text-align: center;
+      background: #00897B;
+      color: #FFF;
+      border-radius: 30rpx;
+    }
+  }
+  .list {
+    // padding: 20rpx;
+  }
+}
 </style>