import { Button, Cell, Icon, Image, Popup, showConfirmDialog, Toast } from 'vant' import { defineComponent } from 'vue' import styles from './index.module.less' import request from '@/helpers/request' import { setLogin, state } from '@/state' import iconStudent from '@common/images/icon_student.png' import iconTeacher from '@common/images/icon_teacher.png' import iconDiscount from './images/icon_discount.png' import iconMemberLogo from './images/member_logo.png' // import { orderStatus } from '@/views/order-detail/orderStatus' import dayjs from 'dayjs' import { memberType } from '@/constant' import { moneyFormat } from '@/helpers/utils' import OHeader from '@/components/o-header' export const getAssetsHomeFile = (fileName: string) => { const path = `./images/${fileName}` const modules = import.meta.globEager('./images/*') return modules[path].default } export default defineComponent({ name: 'MemberCenter', data() { const query = this.$route.query return { functionList: [] as any, selectMember: {} as any, users: {} as any } }, computed: { userInfo() { const users: any = this.users return { username: users?.nickname || '', phone: users?.phone || '', avatar: users?.avatar, id: users?.id, isVip: users?.vipMember, membershipDays: users?.membershipDays, membershipEndTime: users?.membershipEndTime } } }, async mounted() { try { const userInfo = await request.get('/api-student/student/member') this.users = userInfo.data || {} this.functionList = [ { title: '五线谱
跟播', icon: getAssetsHomeFile(`1.png`) }, { title: '演奏指法
跟播', icon: getAssetsHomeFile(`2.png`) }, { title: '原声/伴奏
切换', icon: getAssetsHomeFile(`3.png`) }, { title: '播放速度
调整', icon: getAssetsHomeFile(`4.png`) }, { title: '五线谱选段
播放', icon: getAssetsHomeFile(`5.png`) }, { title: '智能评测', icon: getAssetsHomeFile(`6.png`) }, { title: '评测报告', icon: getAssetsHomeFile(`7.png`) }, { title: '评测音视频
云储存', icon: getAssetsHomeFile(`8.png`) } ] const { data } = await request.post(`/api-student/cityFeeSetting/member`) this.selectMember = data this.paymentOrderUnpaid() } catch { // } // }, methods: { // 查询未支付订单 async paymentOrderUnpaid() { try { const { data } = await request.get('/api-student/userPaymentOrder/unpaid', { requestType: 'form', params: { paymentType: 'VIP' } }) // 判断是否有待支付订单 if (data.id) { showConfirmDialog({ message: '您有待支付的订单,是否继续支付', cancelButtonText: '取消订单', confirmButtonText: '继续支付' }) .then(() => { const paymentConfig = data.paymentConfig this.$router.push({ path: '/orderDetail', query: { config: JSON.stringify(paymentConfig.paymentConfig), orderNo: paymentConfig.orderNo } }) }) .catch(async () => { try { await request.post('/api-student/userPaymentOrder/cancelPayment/' + data.orderNo) } catch { // } }) } } catch { // } }, calcSalePrice(item: any) { // discount if (item.discount === 1) { const tempPrice = Number((item.salePrice - item.discountPrice).toFixed(2)) return tempPrice >= 0 ? tempPrice : 0 } return item.salePrice }, // 购买 async onSubmit() { try { const selectMember = this.selectMember const params: any = [ { goodsId: selectMember.id, goodsNum: 1, goodsType: 'VIP', paymentCashAmount: selectMember.salePrice, // 现金支付金额 paymentCouponAmount: 0 // 优惠券金额 } ] // 支付参数 // 创建订单 const { data } = await request.post('/api-student/userPaymentOrder/executeOrder', { data: { orderType: 'VIP', paymentCashAmount: this.selectMember.salePrice || 0, paymentCouponAmount: 0, goodsInfos: params, orderName: '团练宝购买', orderDesc: '团练宝购买' } }) console.log(data) this.$router.push({ path: '/orderDetail', query: { config: JSON.stringify(data.paymentConfig), orderNo: data.orderNo } }) } catch (e: any) { // console.log(e) } } }, render() { return (
(
), title: () => (
{this.userInfo.username} {!!this.userInfo.isVip && ( )} {this.userInfo.phone && ( )}
), label: () => (
{this.userInfo.isVip ? (
会员权益有效期剩余 {this.userInfo.membershipDays}
) : (
亲,您还不是会员哟
)}
) }} >
会员VIP

半年会员 (6个月)

{moneyFormat(this.selectMember.salePrice)}

¥{moneyFormat(this.selectMember.originalPrice)}

团练宝会员使用包括平台提供教材的所有训练乐谱,并专享“乐器练习云教练”八大核心功能,孩子在家就能轻松完成乐器自主规范练习。

会员功能
{this.functionList.map((item: any) => (
))}
支付金额:
{moneyFormat(this.calcSalePrice(this.selectMember) || 0)}
{this.selectMember?.discount == 1 && (
)}
) } })