lex-xin 5 months ago
parent
commit
78454551fb

+ 4 - 28
src/teacher/layout/login-cert.tsx

@@ -10,13 +10,11 @@ import topBg from './image-cert/top.png'
 import activeButtonIcon from '@common/images/icon_checkbox.png'
 import inactiveButtonIcon from '@common/images/icon_checkbox_default.png'
 
-type loginType = 'PWD' | 'SMS'
 export default defineComponent({
   name: 'login',
   data() {
     return {
       checked: false,
-      loginType: 'SMS' as loginType,
       username: '',
       password: '',
       smsCode: '',
@@ -29,11 +27,8 @@ export default defineComponent({
   computed: {
     codeDisable() {
       let status = true
-      if (this.loginType === 'PWD') {
-        this.username && this.password && (status = false)
-      } else {
         this.username && this.smsCode && this.checked && (status = false)
-      }
+      
       return status
     }
   },
@@ -72,28 +67,16 @@ export default defineComponent({
     },
     async onLogin() {
       try {
-        let res: any
-        if (this.loginType === 'PWD') {
-          res = await request.post('/api-auth/usernameLogin', {
-            requestType: 'form',
-            data: {
-              username: this.username,
-              password: this.password,
-              clientId: 'teacher',
-              clientSecret: 'teacher'
-            }
-          })
-        } else {
-          res = await request.post('/api-auth/smsLogin', {
+        let res = await request.post('/api-auth/smsLogin', {
             requestType: 'form',
             data: {
               clientId: 'teacher',
               clientSecret: 'teacher',
               phone: this.username,
-              smsCode: this.smsCode
+              smsCode: this.smsCode,
+              isSurportRegister: true
             }
           })
-        }
 
         const { authentication } = res.data
         setAuth(authentication.token_type + ' ' + authentication.access_token)
@@ -120,13 +103,6 @@ export default defineComponent({
     onFinished() {
       this.countDownStatus = true
       this.countDownRef.reset()
-    },
-    onChange() {
-      if (this.loginType === 'PWD') {
-        this.loginType = 'SMS'
-      } else if (this.loginType === 'SMS') {
-        this.loginType = 'PWD'
-      }
     }
   },
   render() {

+ 3 - 2
src/views/order-detail/add-discount/index.tsx

@@ -8,6 +8,7 @@ import request from '@/helpers/request'
 import { state } from '@/state'
 import { moneyFormat } from '@/helpers/utils'
 import dayjs from 'dayjs'
+import { numberToTwoDown } from '..'
 
 type DiscountDetail = {
   /** 编号 */
@@ -69,10 +70,10 @@ export default defineComponent({
     // 格式化显示
     const formatShowTime = () => {
       if(checked.value) {
-        params.discountPrice = (
+        params.discountPrice = numberToTwoDown((
           props.actualPrice -
           (props.actualPrice * discountDetail.value.discountRate / 100)
-        ).toFixed(2)
+        ))
         const users = state.user.data
         const startTime = users.discountEndTime || new Date()
         let endTime = dayjs(new Date()).format('YYYY-MM-DD')

+ 28 - 3
src/views/order-detail/index.tsx

@@ -48,8 +48,13 @@ import AddDiscount from './add-discount'
 /** 保留两位小数向上取整 */
 export const numberToTwoUp = (num: number | string) => {
   num = Number(num)
+  return Math.ceil(num * 1000) / 1000
+}
 
-  return Math.ceil(num * 100) / 100
+/** 保留两位小数向下取整 */
+export const numberToTwoDown = (num: number | string) => {
+  num = Number(num)
+  return Math.floor(num * 1000) / 1000
 }
 
 export default defineComponent({
@@ -63,7 +68,7 @@ export default defineComponent({
       dialogBtnText: '确定',
       dialogType: 'back' as 'back' | 'refresh',
       orderType: query.orderType as string,
-      orderGoodsType: [],
+      orderGoodsType: [] as any[],
       recomUserId: query.recomUserId, // 推荐人id
       activityId: query.activityId, // 活动编号
       id: query.id,
@@ -166,6 +171,7 @@ export default defineComponent({
 
     this.orderAmount = orderStatus.orderObject.actualPrice || 0
     this.orderPrice = orderStatus.orderObject.actualPrice || 0
+    console.log(this.orderAmount, this.orderPrice, 'orderPrice')
 
     this.disabledCoupon = orderStatus.orderObject.orderNo ? true : false
     this.dataLoading = false
@@ -637,12 +643,14 @@ export default defineComponent({
                   vipType: string
                 }) => {
                   // 畅学卡变更状态时需要重新选择优惠券
+                  // debugger
                   orderStatus.orderObject.couponId = ''
                   orderStatus.orderObject.couponDiscountPrice = 0
                   // 是否选中畅学卡
                   const index = this.selectGoods?.findIndex(
                     (child: any) => child.id === item.id
                   )
+                  const tempType = this.orderGoodsType
                   if (item.checked) {
                     orderStatus.orderObject.discountCardPrice = Number(
                       item.discountPrice
@@ -655,15 +663,30 @@ export default defineComponent({
                         num: 1,
                         id: item.id
                       })
+                      const typeIndex = tempType.findIndex((child: any) => child === item.vipType)
+                      if(typeIndex === -1) {
+                        tempType.push(item.vipType)
+                      }
                     }
                   } else {
                     orderStatus.orderObject.discountCardPrice = 0
                     if (index !== -1) {
                       this.selectGoods.splice(index, 1)
                       this.orderAmount = this.orderAmount - item.salePrice
+
+                      const typeIndex = tempType.findIndex((child: any) => child === item.vipType)
+                      if(typeIndex !== -1) {
+                        tempType.splice(typeIndex, 1)
+                      }
                     }
                   }
-
+                  this.orderGoodsType = tempType
+                  // 更新优惠券列表
+                  const useCouponRef: any =  this.$refs.useCouponRef
+                  if(useCouponRef) {
+                    console.log(useCouponRef, 'useCouponRef')
+                    useCouponRef.resetCouponList()
+                  }
                   this.orderPrice = Number(
                     numberToTwoUp(
                       Number(this.orderAmount) -
@@ -671,6 +694,7 @@ export default defineComponent({
                       Number(orderStatus.orderObject.couponDiscountPrice)
                     )
                   )
+                  this.$forceUpdate()
                 }}
               />
             ) : (
@@ -700,6 +724,7 @@ export default defineComponent({
             {/* 优惠券使用 */}
             {!this.dataLoading && (
               <UseCoupon
+                ref="useCouponRef"
                 couponId={orderStatus.orderObject.couponId}
                 discountPrice={orderStatus.orderObject.discountPrice}
                 orderType={this.orderType}

+ 1 - 1
src/views/order-detail/use-coupons/choice-coupon.tsx

@@ -142,7 +142,7 @@ export default defineComponent({
       if(this.usedLength === 'SINGLE') {
         // 判断使用优惠券之后还有没有其它优惠券可用
         this.list.forEach((item: any) => {
-          if (!item.checked && useList.length > 0) {
+          if (!item.checked && (useList.length > 0  || Number(item.useLimit) > useLastAmount)) {
             item.disabled = true
           } else {
             item.disabled = false

+ 9 - 0
src/views/order-detail/use-coupons/index.tsx

@@ -109,6 +109,10 @@ export default defineComponent({
         }
       });
       this.useCouponList = selectCouponList
+    },
+    orderGoodsType(val: any) {
+      console.log(val, '121221')
+      this.getList()
     }
   },
   mounted() {
@@ -116,6 +120,10 @@ export default defineComponent({
     this.getList()
   },
   methods: {
+    resetCouponList() {
+      this.list = []
+      this.getList()
+    },
     async getList() {
       if (this.dataLoading) return
       this.dataLoading = true
@@ -142,6 +150,7 @@ export default defineComponent({
           // 如果使用金额大于订单金额则优惠券不可用
           if (item.useLimit > this.orderAmount) {
             item.disabled = true
+            console.log(this.orderAmount, item.useLimit)
           } else {
             item.disabled = false
           }