Browse Source

refactor: 修改文件权限

- 修改 .env.development 文件权限- 多次修改 index.vue 文件权限
- 修改 models.ts 文件权限
- 修改 requests.ts 文件权限
EvilDragon 3 months ago
parent
commit
8dfcb00a4b

+ 2 - 2
packages/app/env/.env.development

@@ -5,14 +5,14 @@ VITE_DELETE_CONSOLE = false
 # 是否开启sourcemap
 VITE_SHOW_SOURCEMAP = true
 
-VITE_SERVER_BASEURL = 'https://www.zhuchaohui.com'
+# VITE_SERVER_BASEURL = 'https://www.zhuchaohui.com'
 # VITE_SERVER_BASEURL = 'http://39.106.91.179:48080'
 # VITE_SERVER_BASEURL = 'http://192.168.2.34:48080'
 # 王超
 # VITE_SERVER_BASEURL = 'http://192.168.2.39:48080'
 # VITE_SERVER_BASEURL = 'http://192.168.0.157:48080'
 # 刘岁成
-# VITE_SERVER_BASEURL = 'http://192.168.2.38:48080'
+VITE_SERVER_BASEURL = 'http://192.168.2.38:48080'
 # 赵要军
 # VITE_SERVER_BASEURL = 'http://192.168.2.41:48080'
 # 姚逊涛

+ 35 - 0
packages/app/src/core/libs/models.ts

@@ -492,6 +492,41 @@ export interface Message {
   viewCount: any
   viewTime: any
 }
+export interface Coupon {
+  id: number
+  couponId: number
+  userId: number
+  sendTime: string
+  /**
+   * 优惠卷有效开始时间
+   */
+  validityStartDate: string
+  /**
+   * 优惠卷有效结束时间
+   */
+  validityEndDate: string
+  /**
+   * 是否有效
+   */
+  isValid: number
+  isUse: number
+  useTime: string
+  /**
+   * 材料商id
+   */
+  material: number
+  brandId: number
+  buinessId: number
+  productId: number
+  createTime: string
+  brandPoints: number
+  couponName: string
+  couponType: number
+  brandIds: string
+  productIds: string
+  materialName: string
+  couponImgUrl: string
+}
 export enum DictType {
   /**
    *  擅长空间类型

+ 23 - 3
packages/app/src/core/libs/requests.ts

@@ -17,6 +17,7 @@ import {
   UserAuthInfo,
   ResPageData,
   Message,
+  Coupon,
 } from './models'
 import dayjs from 'dayjs'
 import { pointsCancel } from '../../../../merchant/node_modules/@designer-hub/app/src/core/libs/requests'
@@ -482,6 +483,10 @@ export const productPlacing = (data: {
     nums?: number
     productName: string
     orderImgUrl: string
+    /**
+     * 商家id
+     */
+    vendorId: string | number
   }[]
   couponList: {
     couponId: number
@@ -624,12 +629,12 @@ export const updateMessage = (data: Partial<Message>) =>
  * 积分订单取消
  */
 export const orderPointsCancel = (query: { id: string; cancelReason: string }) =>
-  httpGet('/app-api/member/message-manage/points-cancel', query)
+  httpGet('/app-api/member/points-details/points-cancel', query)
 /**
  * 积分订单确认
  */
-export const orderPointsSubmit = (query: { id: string }) =>
-  httpGet('/app-api/member/message-manage/order-points-confirm', query)
+export const orderPointsSubmit = (data: { id: number; userId: number; couponUserId: number }) =>
+  httpPost('/app-api/member/points-details/confirm', data)
 /**
  * 获取Banner
  */
@@ -845,6 +850,21 @@ export const storeAndPunchIn = (data: { id: number }) =>
     hideErrorToast: true,
     method: 'POST',
   })
+/**
+ * 获取优惠券
+ */
+export const getCoupons = (query) =>
+  httpGet<ResPageData<Coupon>>('/app-api/member/coupon-user/page', query)
+/**
+ * 获取商品优惠券
+ */
+export const getProductCoupons = (query) =>
+  httpGet<Coupon[]>('/app-api/member/coupon-user/coupon-user-by-product-ids-page', query)
+/**
+ * 获取积分券
+ */
+export const getPointsCoupons = (query) =>
+  httpGet<Coupon[]>('/app-api/member/coupon-user/coupon-user-by-point-ids-page', query)
 export const refreshToken = (refreshToken: string) =>
   httpPost<any>('/app-api/member/auth/refresh-token', {}, { refreshToken })
 export const httpGetMock = <T>(data: T) =>

+ 50 - 22
packages/app/src/pages/home/mall/confirm-order/index.vue

@@ -17,10 +17,12 @@ import Card from '@/components/card.vue'
 import SectionHeading from '@/components/section-heading.vue'
 import BottomAppBar from '@/components/bottom-app-bar.vue'
 import { requestToast } from '../../../../core/utils/common'
-import { orderPay } from '../../../../core/libs/requests'
+import { getProductCoupons, orderPay } from '../../../../core/libs/requests'
 import { useUserStore } from '../../../../store'
 import { storeToRefs } from 'pinia'
 import { useRouter } from '../../../../core/utils/router'
+import dayjs from 'dayjs'
+import { Coupon } from '../../../../core/libs/models'
 
 const router = useRouter()
 const userStore = useUserStore()
@@ -28,11 +30,26 @@ const { userInfo } = storeToRefs(userStore)
 const show = ref(false)
 const a = ref(1)
 const data = ref()
+const selectedCoupon = ref<Coupon>()
+const { data: coupons, run: setCoupons } = useRequest(() =>
+  getProductCoupons({
+    userId: userInfo.value.userId,
+    productIds: data.value.list.map((it) => it.productId).join(','),
+    isUse: 0,
+  }),
+)
 const handlePay = async () => {
   const { code } = await requestToast(
     () =>
       orderPay({
         ...data?.value,
+        couponList: [
+          {
+            couponId: selectedCoupon.value.id,
+            projectIds: selectedCoupon.value.productIds,
+            buinessId: selectedCoupon.value.buinessId,
+          },
+        ],
       }),
     { success: true, successTitle: '兑换成功' },
   )
@@ -40,6 +57,10 @@ const handlePay = async () => {
     router.replace('/pages/home/mall/purchased/success/index')
   }
 }
+const handleQ = async () => {
+  await setCoupons()
+  show.value = true
+}
 onLoad(async (query: { data: string }) => {
   data.value = JSON.parse(query.data)
 })
@@ -74,9 +95,9 @@ onLoad(async (query: { data: string }) => {
     <Card>
       <div class="flex flex-col gap-8">
         <SectionHeading title="总积分" :end-text="data?.totalsPoints" size="sm"></SectionHeading>
-        <!-- <div @click="show = true">
+        <div @click="handleQ">
           <SectionHeading title="优惠券" end-text="已选2张" end-arrow size="sm"></SectionHeading>
-        </div> -->
+        </div>
         <SectionHeading
           title="实付积分"
           :end-text="data?.totalsCurrPoints"
@@ -96,11 +117,9 @@ onLoad(async (query: { data: string }) => {
         </div>
         <div class="">
           <TrapeziumButton size="large">
-            <div
-              class="w-[49px] h-[22px] text-white text-base font-normal font-['PingFang_SC'] leading-tight"
-            >
+            <div class="text-white text-base font-normal font-['PingFang_SC'] leading-tight">
               <div
-                class="w-[65px] h-[22px] text-white text-base font-normal font-['PingFang_SC'] leading-tight"
+                class="text-white text-base font-normal font-['PingFang_SC'] leading-tight"
                 @click="handlePay"
               >
                 确认兑换
@@ -116,24 +135,33 @@ onLoad(async (query: { data: string }) => {
           <wd-tab title="可用优惠券"></wd-tab>
           <wd-tab title="不可用优惠券"></wd-tab>
         </wd-tabs>
-        <div class="bg-[#f6f6f6] p-3.5">
-          <div class="bg-white rounded-2xl p-3.5 flex gap-2.5">
-            <div class="w-[94px] h-[94px] bg-[#f6f6f6] rounded-[10px]"></div>
-            <div class="flex flex-col justify-around flex-1">
-              <div class="text-black text-sm font-normal font-['PingFang_SC'] leading-normal">
-                GELATO咖啡兑换券
-              </div>
-              <div class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal">
-                2024/04/01-2024/05/30
+        <div class="bg-[#f6f6f6] p-3.5 flex flex-col gap-4">
+          <template v-for="(it, i) in coupons" :key="i">
+            <div
+              class="bg-white rounded-2xl p-3.5 flex gap-2.5"
+              @click="(selectedCoupon = it), (show = false)"
+            >
+              <div class="w-[94px] h-[94px] bg-[#f6f6f6] rounded-[10px]"></div>
+              <div class="flex flex-col justify-around flex-1">
+                <div class="text-black text-sm font-normal font-['PingFang_SC'] leading-normal">
+                  <!-- GELATO咖啡兑换券 -->
+                  {{ it.couponName }}
+                </div>
+                <div class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal">
+                  <!-- 2024/04/01-2024/05/30 -->
+                  {{ dayjs(it.validityStartDate).format('YYYY/MM/DD') }}-{{
+                    dayjs(it.validityEndDate).format('YYYY/MM/DD')
+                  }}
+                </div>
+                <div class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal">
+                  使用说明
+                </div>
               </div>
-              <div class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal">
-                使用说明
+              <div class="flex items-center">
+                <div class="w-4 h-4 rounded-full border border-black/60 border-solid"></div>
               </div>
             </div>
-            <div class="flex items-center">
-              <div class="w-4 h-4 rounded-full border border-black/60 border-solid"></div>
-            </div>
-          </div>
+          </template>
         </div>
         <!-- <wd-button block :round="false">确认</wd-button> -->
       </view>

+ 3 - 6
packages/app/src/pages/home/mall/detail/index.vue

@@ -43,6 +43,7 @@ const handleConfirm = async () => {
             nums: 1,
             productName: data.value.prodcutName,
             orderImgUrl: data.value.productCoverImgUrl,
+            vendorId: data.value.vendorId,
           },
         ],
         couponList: [],
@@ -128,12 +129,8 @@ onLoad(async (query: { id: string }) => {
         </div>
         <div class="" @click="(show = true), (type = 'orderNow')">
           <TrapeziumButton size="large">
-            <div
-              class="w-[49px] h-[22px] text-white text-base font-normal font-['PingFang_SC'] leading-tight"
-            >
-              <div
-                class="w-[65px] h-[22px] text-white text-base font-normal font-['PingFang_SC'] leading-tight"
-              >
+            <div class="text-white text-base font-normal font-['PingFang_SC'] leading-tight">
+              <div class="text-white text-base font-normal font-['PingFang_SC'] leading-tight">
                 立即兑换
               </div>
             </div>

+ 2 - 3
packages/app/src/pages/home/mall/index.vue

@@ -30,7 +30,6 @@ import textGreatMoney from '@designer-hub/assets/src/libs/assets/textGreatMoney'
 import grabNow from '@designer-hub/assets/src/libs/assets/grabNow'
 import ProgressEvo from '@/components/progress-evo.vue'
 import SwiperEvo from '@/components/swiper-evo.vue'
-import { diff } from 'radash'
 import dayjs from 'dayjs'
 
 const router = useRouter()
@@ -190,7 +189,7 @@ onMounted(async () => {
     </div>
     <PageHelper
       v-if="category"
-      v-slot="{ data }"
+      v-slot="{ source }"
       class="flex-grow flex flex-col"
       :request="getProducts"
       :query="query"
@@ -200,7 +199,7 @@ onMounted(async () => {
         :loading="true"
       > -->
       <div class="grid grid-cols-2 gap-2.5">
-        <template v-for="(it, i) of data" :key="i">
+        <template v-for="(it, i) of source.list" :key="i">
           <Product :options="it" @change="handleChange"></Product>
         </template>
       </div>

+ 94 - 6
packages/app/src/pages/messages/index.vue

@@ -14,26 +14,36 @@ import PageHelper from '@/components/page-helper.vue'
 import {
   deleteMessage,
   getMessages,
+  getPointsCoupons,
   orderPointsCancel,
   orderPointsSubmit,
   updateMessage,
 } from '../../core/libs/requests'
-import { integral, interact, system } from '../../core/libs/svgs'
+import { integral, interact, message, system } from '../../core/libs/svgs'
 import { beforeNow } from '../../utils/date-util'
 import dayjs from 'dayjs'
 import { MessageType } from '../../core/libs/enums'
-import { group } from 'radash'
 import { ComponentExposed } from 'vue-component-type-helpers'
 import { Message } from '../../core/libs/models'
 import { requestToast } from '../../core/utils/common'
+import { useUserStore } from '../../store'
+import { storeToRefs } from 'pinia'
 
 const pageHelperRef = ref<ComponentExposed<typeof PageHelper>>()
+const userStore = useUserStore()
+const { userInfo } = storeToRefs(userStore)
+const show = ref(false)
+const businessId = ref()
 const tab = ref(0)
 const tabs = ref([
   { label: '积分消息', value: MessageType.Integral },
   { label: '系统消息', value: MessageType.System },
   { label: '互动消息', value: MessageType.Interact },
 ])
+const selectedCoupon = ref()
+const { data: coupons, run: setCoupons } = useRequest(() =>
+  getPointsCoupons({ userId: userInfo.value.userId, businessId: businessId.value }),
+)
 onShow(async () => {
   nextTick(() => {
     pageHelperRef.value?.refresh()
@@ -49,14 +59,32 @@ const handleCancel = async (message: Message) => {
   await pageHelperRef.value?.refresh()
 }
 const handleSubmit = async (message: Message) => {
-  await requestToast(() => orderPointsSubmit({ id: message.businessId.toString() }), {
-    success: true,
-    successTitle: '积分已确认',
-  })
+  await requestToast(
+    () =>
+      orderPointsSubmit({
+        id: message.businessId,
+        userId: message.designerId,
+        couponUserId: 19,
+      }),
+    {
+      success: true,
+      successTitle: '积分已确认',
+    },
+  )
   // await deleteMessage(message.id.toString())
   await updateMessage({ id: message.id, isRead: '1' })
   await pageHelperRef.value?.refresh()
 }
+const handleQ = async (message: Message) => {
+  // const { data } = await getPointsCoupons({
+  //   userId: message.designerId,
+  //   businessId: message.businessId,
+  // })
+  // console.log(data)
+  businessId.value = message.businessId
+  await setCoupons()
+  show.value = true
+}
 </script>
 
 <template>
@@ -111,6 +139,27 @@ const handleSubmit = async (message: Message) => {
                       v-if="it.messageType === MessageType.Integral"
                       v-html="it.detailBody"
                     ></div>
+                    <div class="grid grid-cols-[auto_1fr] gap-x-5 gap-y-4.5">
+                      <template v-if="true">
+                        <div
+                          class="text-black/40 text-sm font-normal font-['PingFang_SC'] h-5.5 flex items-center"
+                        >
+                          积分券
+                        </div>
+                        <div class="flex items-center">
+                          <div class="text-black/60 text-sm font-normal font-['PingFang_SC']">
+                            无可用
+                          </div>
+                          <div class="h-5.5 overflow-hidden">
+                            <wd-icon
+                              name="chevron-right"
+                              custom-class="text-black/60!"
+                              size="20"
+                            ></wd-icon>
+                          </div>
+                        </div>
+                      </template>
+                    </div>
                     <!-- {{ it.detailBody }} -->
                   </div>
                 </div>
@@ -173,6 +222,9 @@ const handleSubmit = async (message: Message) => {
                       </wd-button>
                     </div>
                     <div class="flex-1">
+                      <wd-button block :round="false" @click="handleQ(it)">积分券</wd-button>
+                    </div>
+                    <div class="flex-1">
                       <wd-button block :round="false" @click="handleSubmit(it)">确认</wd-button>
                     </div>
                   </div>
@@ -183,6 +235,42 @@ const handleSubmit = async (message: Message) => {
         </div>
       </template>
     </PageHelper>
+    <wd-action-sheet title="优惠券" v-model="show">
+      <view class="">
+        <wd-tabs>
+          <wd-tab title="可用优惠券"></wd-tab>
+          <wd-tab title="不可用优惠券"></wd-tab>
+        </wd-tabs>
+        <div class="bg-[#f6f6f6] p-3.5">
+          <template v-for="(it, i) in coupons" :key="i">
+            <div
+              class="bg-white rounded-2xl p-3.5 flex gap-2.5"
+              @click="(selectedCoupon = it), (show = false)"
+            >
+              <div class="w-[94px] h-[94px] bg-[#f6f6f6] rounded-[10px]"></div>
+              <div class="flex flex-col justify-around flex-1">
+                <div class="text-black text-sm font-normal font-['PingFang_SC'] leading-normal">
+                  {{ it.couponName }}
+                </div>
+                <div class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal">
+                  <!-- 2024/04/01-2024/05/30 -->
+                  {{ dayjs(it.validityStartDate).format('YYYY/MM/DD') }}-{{
+                    dayjs(it.validityEndDate).format('YYYY/MM/DD')
+                  }}
+                </div>
+                <div class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal">
+                  使用说明
+                </div>
+              </div>
+              <div class="flex items-center">
+                <div class="w-4 h-4 rounded-full border border-black/60 border-solid"></div>
+              </div>
+            </div>
+          </template>
+        </div>
+        <!-- <wd-button block :round="false">确认</wd-button> -->
+      </view>
+    </wd-action-sheet>
   </view>
 </template>
 

+ 60 - 24
packages/app/src/pages/mine/coupons/index.vue

@@ -3,37 +3,73 @@
 </route>
 <script setup lang="ts">
 import Card from '@/components/card.vue'
+import { getCoupons } from '../../../core/libs/requests'
+import PageHelper from '@/components/page-helper.vue'
+import dayjs from 'dayjs'
 
-const tab = ref()
-const tabs = ref([{ label: '商品优惠券' }, { label: '销售积分券' }])
-const data = ref([{}])
+const tab = ref(2)
+const tabs = ref([
+  { label: '商品优惠券', value: 2 },
+  { label: '销售积分券', value: 1 },
+])
+const query = computed(() => ({ couponType: tab.value }))
+// const {data, run: set} = useRequest(() => getCoupons({}))
 </script>
 <template>
   <div class="flex-grow flex flex-col gap-4">
     <wd-tabs v-model="tab">
-      <block v-for="({ label }, i) in tabs" :key="i">
-        <wd-tab :title="label"></wd-tab>
+      <block v-for="({ label, value }, i) in tabs" :key="i">
+        <wd-tab :title="label" :name="value"></wd-tab>
       </block>
     </wd-tabs>
-    <template v-for="(it, i) of data" :key="i">
-      <Card custom-class="mx-3.5">
-        <div class="flex gap-3">
-          <div class="w-[94px] h-[94px] bg-[#f6f6f6] rounded-[10px]"></div>
-          <div class="flex flex-col justify-around">
-            <div class="text-black text-sm font-normal font-['PingFang_SC'] leading-normal">
-              GELATO咖啡兑换券
-            </div>
-            <div
-              class="text-center text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal"
-            >
-              有效期:2024/04/01-2024/05/30
-            </div>
-            <div class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal">
-              使用说明
-            </div>
-          </div>
+    <PageHelper :request="getCoupons" :query="query">
+      <template #default="{ source }">
+        <div class="flex flex-col gap-4">
+          <template v-for="(it, i) of source.list" :key="i">
+            <Card custom-class="mx-3.5">
+              <div class="flex gap-3">
+                <div class="w-[94px] h-[94px] bg-[#f6f6f6] rounded-2.5 overflow-hidden">
+                  <template v-if="it.couponType === 1">
+                    <div
+                      class="bg-[#fff8f8] w-full h-full flex flex-col items-center justify-center"
+                    >
+                      <div class="text-[#ff7878] text-[26px] font-normal font-['PingFang_SC']">
+                        {{ it.brandPoints }}
+                      </div>
+                      <div class="text-[#ff7878] text-base font-normal font-['PingFang_SC']">
+                        积分
+                      </div>
+                    </div>
+                  </template>
+                  <template v-else>
+                    <wd-img width="100%" height="100%" :src="it.couponImgUrl"></wd-img>
+                  </template>
+                </div>
+                <div class="flex flex-col justify-around">
+                  <div class="text-black text-sm font-normal font-['PingFang_SC'] leading-normal">
+                    <!-- GELATO咖啡兑换券 -->
+                    {{ it.couponName }}
+                  </div>
+                  <div
+                    class="text-center text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal"
+                  >
+                    有效期:
+                    <!-- 2024/04/01-2024/05/30 -->
+                    {{ dayjs(it.validityStartDate).format('YYYY/MM/DD') }}-{{
+                      dayjs(it.validityEndDate).format('YYYY/MM/DD')
+                    }}
+                  </div>
+                  <div
+                    class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal"
+                  >
+                    使用说明
+                  </div>
+                </div>
+              </div>
+            </Card>
+          </template>
         </div>
-      </Card>
-    </template>
+      </template>
+    </PageHelper>
   </div>
 </template>