|
|
@@ -1,7 +1,14 @@
|
|
|
-import { computed, defineComponent, onMounted, reactive, shallowRef } from 'vue'
|
|
|
+import {
|
|
|
+ computed,
|
|
|
+ defineComponent,
|
|
|
+ nextTick,
|
|
|
+ onMounted,
|
|
|
+ reactive,
|
|
|
+ shallowRef
|
|
|
+} from 'vue'
|
|
|
import styles from './index.module.less'
|
|
|
import ColHeader from '@/components/col-header'
|
|
|
-import { Button, Image, Popup, Toast } from 'vant'
|
|
|
+import { Button, Image, NoticeBar, Popup, Toast } from 'vant'
|
|
|
import { state as baseState, setLogin } from '@/state'
|
|
|
import iconShare from './new-images/icon-share.png'
|
|
|
import { useEventListener } from '@vant/use'
|
|
|
@@ -19,6 +26,8 @@ import deepClone from '@/helpers/deep-clone'
|
|
|
import { memberSimpleType, memberType } from '@/constant'
|
|
|
import dayjs from 'dayjs'
|
|
|
import { orderStatus } from '../order-detail/orderStatus'
|
|
|
+import TheNoticeBar from '@/components/the-noticeBar'
|
|
|
+import { tradeOrder } from '@/student/trade/tradeOrder'
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'member-center',
|
|
|
@@ -33,6 +42,8 @@ export default defineComponent({
|
|
|
titleOpacity: 0,
|
|
|
shareStatus: false, // 分享
|
|
|
dialogVisiable: false,
|
|
|
+ orderVisiable: false,
|
|
|
+ orderDetail: {} as any,
|
|
|
shareUrl: '',
|
|
|
shareDiscount: 0,
|
|
|
discountTeacher: {
|
|
|
@@ -160,7 +171,7 @@ export default defineComponent({
|
|
|
window.scrollY ||
|
|
|
window.pageYOffset ||
|
|
|
document.documentElement.scrollTop
|
|
|
- state.titleOpacity = height > 100 ? 1 : height / 100
|
|
|
+ state.titleOpacity = height > 80 ? 1 : 0
|
|
|
})
|
|
|
|
|
|
/** 切换购买类型 */
|
|
|
@@ -173,6 +184,10 @@ export default defineComponent({
|
|
|
state.selectMember = state.memberShowList[0]
|
|
|
}
|
|
|
state.tabActive = type
|
|
|
+
|
|
|
+ nextTick(() => {
|
|
|
+ document.querySelector('.system-list')?.scroll(0, 0)
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
const calcSalePrice = (item: any) => {
|
|
|
@@ -211,20 +226,37 @@ export default defineComponent({
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 判断是否有待支付订单
|
|
|
+ const resPadding = await request.post(
|
|
|
+ `${state.apiSuffix}/userOrder/getPendingOrder`,
|
|
|
+ {
|
|
|
+ data: { goodType: state.tabActive }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ console.log(resPadding, 'resPadding')
|
|
|
+ if (resPadding?.data?.id) {
|
|
|
+ state.orderVisiable = true
|
|
|
+ state.orderDetail = resPadding.data || {}
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
const member: any = state.selectMember
|
|
|
// 判断是否有会员
|
|
|
let startTime = new Date()
|
|
|
// vip类型 VIP:会员 SVIP:SVIP,PERMANENT_SVIP:永久SVIP,NOT_VIP:不是vip
|
|
|
// vip过期类型 VIP:会员 SVIP:SVIP,ALL_VIP:全vip
|
|
|
- if (userInfo.value.userVip.vipType === 'SVIP') {
|
|
|
+ if (state.tabActive === 'SVIP') {
|
|
|
startTime = dayjs(
|
|
|
userInfo.value.userVip.svipEndDate || new Date()
|
|
|
).toDate()
|
|
|
- } else if (userInfo.value.userVip.vipType === 'VIP') {
|
|
|
+ } else if (state.tabActive === 'VIP') {
|
|
|
+ // 购买Vip时,先有vip的有效时间,如果没有则取SVIP有效时间,都没有默认当前
|
|
|
startTime = dayjs(
|
|
|
- userInfo.value.userVip.vipEndDate || new Date()
|
|
|
+ userInfo.value.userVip.vipEndDate ||
|
|
|
+ userInfo.value.userVip.svipEndDate ||
|
|
|
+ new Date()
|
|
|
).toDate()
|
|
|
- } else if (userInfo.value.userVip.vipType === 'PERMANENT_SVIP') {
|
|
|
+ } else if (isPermanent.value) {
|
|
|
Toast('您已是永久SVIP会员')
|
|
|
return
|
|
|
}
|
|
|
@@ -276,6 +308,30 @@ export default defineComponent({
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 取消支付
|
|
|
+ const onCancelOrder = async () => {
|
|
|
+ try {
|
|
|
+ await request.post(`${state.apiSuffix}/userOrder/orderCancel`, {
|
|
|
+ data: { orderNo: state.orderDetail.orderNo }
|
|
|
+ })
|
|
|
+ state.orderVisiable = false
|
|
|
+ } catch {
|
|
|
+ //
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 继续支付
|
|
|
+ const onContinueOrder = async () => {
|
|
|
+ const orderDetail = state.orderDetail || {}
|
|
|
+ tradeOrder(orderDetail, () => {
|
|
|
+ router.push({
|
|
|
+ path: '/orderDetail',
|
|
|
+ query: {
|
|
|
+ orderType: orderDetail.orderType
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
/** 格式化分类信息 */
|
|
|
const formatMemberList = () => {
|
|
|
// console.log(vipList.value, svipList.value, 'vipList.value')
|
|
|
@@ -366,6 +422,7 @@ export default defineComponent({
|
|
|
color={`rgba(0,0,0, ${state.titleOpacity})`}
|
|
|
backIconColor="black"
|
|
|
hideHeader={false}
|
|
|
+ border={false}
|
|
|
v-slots={{
|
|
|
right: () => (
|
|
|
<Image
|
|
|
@@ -413,7 +470,7 @@ export default defineComponent({
|
|
|
)}
|
|
|
{userMemberStatus.value === 'VIP' && (
|
|
|
<>
|
|
|
- 有效期至{' '}
|
|
|
+ {state.tabActive}有效期至{' '}
|
|
|
<span>
|
|
|
{state.tabActive === 'VIP'
|
|
|
? dayjs(userInfo.value.userVip.vipEndDate).format(
|
|
|
@@ -523,11 +580,11 @@ export default defineComponent({
|
|
|
src={state.discountTeacher.avatar || iconTeacher}
|
|
|
class={styles.discountAvatar}
|
|
|
/>
|
|
|
-
|
|
|
- <span class={styles.discountName}>
|
|
|
- {state.discountTeacher.username}老师的
|
|
|
+ <TheNoticeBar class={styles.discountName} isAnimation>
|
|
|
+ {state.discountTeacher.username}
|
|
|
+ 老师的
|
|
|
<span>专属优惠~</span>
|
|
|
- </span>
|
|
|
+ </TheNoticeBar>
|
|
|
|
|
|
<Image src={iconGift} class={styles.discountGift} />
|
|
|
</div>
|
|
|
@@ -535,6 +592,7 @@ export default defineComponent({
|
|
|
<div class={styles.system_list_section}>
|
|
|
<div
|
|
|
class={[
|
|
|
+ 'system-list',
|
|
|
styles['system-list'],
|
|
|
state.tabActive === 'VIP' ? styles.system_list_vip : '',
|
|
|
memberInfos.value.memberLength === 2
|
|
|
@@ -549,12 +607,12 @@ export default defineComponent({
|
|
|
<>
|
|
|
{state.memberShowList.map((member: any) => (
|
|
|
<div
|
|
|
+ key={member.id}
|
|
|
class={[
|
|
|
styles['system-item'],
|
|
|
member.id === state.selectMember.id
|
|
|
? styles.active
|
|
|
- : '',
|
|
|
- member.discount === 1 ? styles.discountItem : ''
|
|
|
+ : ''
|
|
|
]}
|
|
|
onClick={() => {
|
|
|
state.selectMember = member
|
|
|
@@ -565,10 +623,13 @@ export default defineComponent({
|
|
|
<span class={[styles.iconPermanent]}></span>
|
|
|
)}
|
|
|
|
|
|
- <p class={styles.s_title}>{member.title}</p>
|
|
|
- {member.discount === 1 && (
|
|
|
- <span class={styles.discountTag}></span>
|
|
|
- )}
|
|
|
+ <p class={styles.s_title}>
|
|
|
+ {member.title}
|
|
|
+ {/* 优惠标识 */}
|
|
|
+ {member.discount === 1 && (
|
|
|
+ <span class={styles.discountTag}></span>
|
|
|
+ )}
|
|
|
+ </p>
|
|
|
<p class={styles.price}>
|
|
|
<span>¥</span>
|
|
|
{moneyFormat(calcSalePrice(member), '0,0[.]00')}
|
|
|
@@ -615,19 +676,14 @@ export default defineComponent({
|
|
|
</p>
|
|
|
<p class={styles.s_title}>{member.title}</p>
|
|
|
</div>
|
|
|
- {/* 只有永久才会有数量提示 */}
|
|
|
- {member.period === 'PERPETUAL' ? (
|
|
|
- <div class={styles.oneMaxNum}>限量1000份</div>
|
|
|
- ) : (
|
|
|
- <div
|
|
|
- class={[
|
|
|
- styles.oneMaxNum,
|
|
|
- styles.oneMaxNumPrice
|
|
|
- ]}
|
|
|
- >
|
|
|
- ¥{member.originalPrice}
|
|
|
- </div>
|
|
|
- )}
|
|
|
+ <div
|
|
|
+ class={[
|
|
|
+ styles.oneMaxNum,
|
|
|
+ styles.oneMaxNumPrice
|
|
|
+ ]}
|
|
|
+ >
|
|
|
+ ¥{member.originalPrice}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<span
|
|
|
class={[
|
|
|
@@ -737,6 +793,34 @@ export default defineComponent({
|
|
|
</div>
|
|
|
</div>
|
|
|
</Popup>
|
|
|
+
|
|
|
+ <Popup
|
|
|
+ v-model:show={state.orderVisiable}
|
|
|
+ style={{ background: 'transparent' }}
|
|
|
+ closeOnClickOverlay={false}
|
|
|
+ >
|
|
|
+ <div class={styles.dialogContainer}>
|
|
|
+ <div class={styles.dialogTitle}>提示</div>
|
|
|
+ <div class={styles.dialogContent}>
|
|
|
+ 您有待支付的订单,是否继续支付
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class={[styles.dialogBtnGroup, styles.orderGroup]}>
|
|
|
+ <Button round type="default" plain block onClick={onCancelOrder}>
|
|
|
+ 取消
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ round
|
|
|
+ type="primary"
|
|
|
+ block
|
|
|
+ class={styles.dialogBtn}
|
|
|
+ onClick={onContinueOrder}
|
|
|
+ >
|
|
|
+ 继续支付
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </Popup>
|
|
|
</div>
|
|
|
)
|
|
|
}
|