|
@@ -0,0 +1,258 @@
|
|
|
+import dayjs from 'dayjs'
|
|
|
+import {
|
|
|
+ Button,
|
|
|
+ Cell,
|
|
|
+ CellGroup,
|
|
|
+ DatePicker,
|
|
|
+ Dialog,
|
|
|
+ Icon,
|
|
|
+ Image,
|
|
|
+ List,
|
|
|
+ Picker,
|
|
|
+ Popup,
|
|
|
+ Sticky
|
|
|
+} from 'vant'
|
|
|
+import { defineComponent, onMounted, reactive } from 'vue'
|
|
|
+import styles from '../index.module.less'
|
|
|
+import iconOrder from '../images/icon_order.png'
|
|
|
+import request from '@/helpers/request'
|
|
|
+import OEmpty from '@/components/o-empty'
|
|
|
+import { orderStatus, orderType } from '@/constant'
|
|
|
+import { moneyFormat } from '@/helpers/utils'
|
|
|
+import ODialog from '@/components/o-dialog'
|
|
|
+import { forms } from '@/school/train-planning/create'
|
|
|
+
|
|
|
+export default defineComponent({
|
|
|
+ name: 'wait_pay',
|
|
|
+ props: {
|
|
|
+ height: {
|
|
|
+ type: Number,
|
|
|
+ default: 50
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setup(props) {
|
|
|
+ const form = reactive({
|
|
|
+ isClick: false,
|
|
|
+ timeShow: false,
|
|
|
+ currentData: [dayjs().year() + ''],
|
|
|
+ typeShow: false,
|
|
|
+ currentType: 'ALL',
|
|
|
+ typeArray: [{ text: '全部', value: 'ALL' }] as any,
|
|
|
+ resionList: [] as any,
|
|
|
+ list: [] as any,
|
|
|
+ listState: {
|
|
|
+ dataShow: true, // 判断是否有数据
|
|
|
+ loading: false,
|
|
|
+ finished: false
|
|
|
+ },
|
|
|
+ params: {
|
|
|
+ paymentStatus: ['PAID', 'TIMEOUT', 'FAIL', 'CLOSED'],
|
|
|
+ page: 1,
|
|
|
+ rows: 20
|
|
|
+ },
|
|
|
+ refundStatus: false
|
|
|
+ })
|
|
|
+
|
|
|
+ // WAIT_PAY: '待支付',
|
|
|
+ // PAYING: '支付中',
|
|
|
+ // PAID: '已付款',
|
|
|
+ // TIMEOUT: '订单超时',
|
|
|
+ // FAIL: '支付失败',
|
|
|
+ // CLOSED: '订单关闭',
|
|
|
+ // REFUNDING: '退款中',
|
|
|
+ // REFUNDED: '已退款'
|
|
|
+
|
|
|
+ const getList = async () => {
|
|
|
+ try {
|
|
|
+ if (form.isClick) return
|
|
|
+ form.isClick = true
|
|
|
+ const res = await request.post('/api-student/userPaymentOrder/page', {
|
|
|
+ data: {
|
|
|
+ ...form.params,
|
|
|
+ orderType: form.currentType === 'ALL' ? null : form.currentType,
|
|
|
+ paymentYear: form.currentData[0]
|
|
|
+ }
|
|
|
+ })
|
|
|
+ form.listState.loading = false
|
|
|
+ const result = res.data || {}
|
|
|
+ // 处理重复请求数据
|
|
|
+ if (form.list.length > 0 && result.current === 1) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ form.list = form.list.concat(result.rows || [])
|
|
|
+ form.listState.finished = result.current >= result.pages
|
|
|
+ form.params.page = result.current + 1
|
|
|
+ form.listState.dataShow = form.list.length > 0
|
|
|
+ form.isClick = false
|
|
|
+ } catch {
|
|
|
+ form.listState.dataShow = false
|
|
|
+ form.listState.finished = true
|
|
|
+ form.isClick = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const onSearch = () => {
|
|
|
+ form.params.page = 1
|
|
|
+ form.list = []
|
|
|
+ form.listState.dataShow = true // 判断是否有数据
|
|
|
+ form.listState.loading = false
|
|
|
+ form.listState.finished = false
|
|
|
+ getList()
|
|
|
+ }
|
|
|
+
|
|
|
+ const formatOrderType = (orderType: string) => {
|
|
|
+ let select = {} as any
|
|
|
+ form.typeArray.forEach((item: any) => {
|
|
|
+ if (item.value === orderType) {
|
|
|
+ select = item
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return select.text
|
|
|
+ }
|
|
|
+
|
|
|
+ const getDefaultParams = async () => {
|
|
|
+ try {
|
|
|
+ const { data } = await request.get('/api-student/sysParamConfig/queryByParamName', {
|
|
|
+ params: {
|
|
|
+ paramName: 'refund_reason'
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ form.resionList = data.paramValue.split('\n')
|
|
|
+ form.resionList.push('其它')
|
|
|
+ console.log(form.resionList, 'resionList')
|
|
|
+ } catch {
|
|
|
+ //
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ onMounted(() => {
|
|
|
+ getList()
|
|
|
+ getDefaultParams()
|
|
|
+
|
|
|
+ Object.keys(orderType).forEach((key) => {
|
|
|
+ console.log(key)
|
|
|
+ form.typeArray.push({
|
|
|
+ text: orderType[key],
|
|
|
+ value: key
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ return () => (
|
|
|
+ <>
|
|
|
+ <Sticky position="top" offsetTop={props.height}>
|
|
|
+ <div style={{ padding: '12px 13px 16px', background: '#F8F8F8' }}>
|
|
|
+ <div class={styles.searchBand} onClick={() => (form.timeShow = true)}>
|
|
|
+ {form.currentData[0]}年 <Icon name={form.timeShow ? 'arrow-up' : 'arrow-down'} />
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ class={styles.searchBand}
|
|
|
+ onClick={() => (form.typeShow = true)}
|
|
|
+ style="margin-left: 16px"
|
|
|
+ >
|
|
|
+ {formatOrderType(form.currentType)}
|
|
|
+ <Icon name={form.typeShow ? 'arrow-up' : 'arrow-down'} />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </Sticky>
|
|
|
+
|
|
|
+ {form.listState.dataShow ? (
|
|
|
+ <List
|
|
|
+ v-model:loading={form.listState.loading}
|
|
|
+ finished={form.listState.finished}
|
|
|
+ finishedText=" "
|
|
|
+ class={[styles.liveList]}
|
|
|
+ onLoad={getList}
|
|
|
+ immediateCheck={false}
|
|
|
+ >
|
|
|
+ {form.list.map((item: any) => (
|
|
|
+ <CellGroup inset class={styles.cellGroup}>
|
|
|
+ <Cell center titleClass={styles.times}>
|
|
|
+ {{
|
|
|
+ title: () => <span class={styles.times}>{item.createTime}</span>,
|
|
|
+ value: () => <span class={styles.status}>{orderStatus[item.status]}</span>
|
|
|
+ }}
|
|
|
+ </Cell>
|
|
|
+ <Cell isLink center titleStyle={{ flex: '0 auto' }}>
|
|
|
+ {{
|
|
|
+ icon: () => <Image class={styles.img} src={iconOrder} />,
|
|
|
+ title: () => <span class={styles.name}>{orderType[item.orderType]}</span>,
|
|
|
+ value: () => (
|
|
|
+ <div class={styles.price}>
|
|
|
+ <span>¥</span>
|
|
|
+ {moneyFormat(item.paymentCashAmount)}
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }}
|
|
|
+ </Cell>
|
|
|
+ <Cell style={'padding: 0'}>
|
|
|
+ {{
|
|
|
+ title: () =>
|
|
|
+ item.status === 'PAID' && (
|
|
|
+ <Button
|
|
|
+ block
|
|
|
+ class={styles.refundBtn}
|
|
|
+ onClick={() => (form.refundStatus = true)}
|
|
|
+ >
|
|
|
+ 申请退费
|
|
|
+ </Button>
|
|
|
+ )
|
|
|
+ }}
|
|
|
+ </Cell>
|
|
|
+ </CellGroup>
|
|
|
+ ))}
|
|
|
+ </List>
|
|
|
+ ) : (
|
|
|
+ <OEmpty btnStatus={false} classImgSize="SMALL" tips="暂无订单" />
|
|
|
+ )}
|
|
|
+
|
|
|
+ <Popup v-model:show={form.timeShow} position="bottom" round>
|
|
|
+ <DatePicker
|
|
|
+ v-model={form.currentData}
|
|
|
+ columnsType={['year']}
|
|
|
+ onConfirm={(date: any) => {
|
|
|
+ form.currentData = date.selectedValues
|
|
|
+ form.timeShow = false
|
|
|
+ onSearch()
|
|
|
+ }}
|
|
|
+ onCancel={() => (form.timeShow = false)}
|
|
|
+ />
|
|
|
+ </Popup>
|
|
|
+
|
|
|
+ <Popup v-model:show={form.typeShow} position="bottom" round>
|
|
|
+ <Picker
|
|
|
+ columns={form.typeArray}
|
|
|
+ onCancel={() => (form.typeShow = false)}
|
|
|
+ onConfirm={(val: any) => {
|
|
|
+ form.currentType = val.selectedValues[0]
|
|
|
+ form.typeShow = false
|
|
|
+ onSearch()
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </Popup>
|
|
|
+
|
|
|
+ <Dialog
|
|
|
+ v-model:show={form.refundStatus}
|
|
|
+ message={
|
|
|
+ '您将要发起退款,退款需承担千分之六的手续费,确认退款后款项将原路返还到您的付款账户中。'
|
|
|
+ }
|
|
|
+ messageAlign="left"
|
|
|
+ confirmButtonText="取消"
|
|
|
+ cancelButtonText="确认退款"
|
|
|
+ showCancelButton
|
|
|
+ onConfirm={() => (form.refundStatus = false)}
|
|
|
+ onCancel={() => {}}
|
|
|
+ >
|
|
|
+ {{
|
|
|
+ title: () => (
|
|
|
+ <div class={styles.dialogTitle}>
|
|
|
+ <i></i>
|
|
|
+ 申请退款
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }}
|
|
|
+ </Dialog>
|
|
|
+ </>
|
|
|
+ )
|
|
|
+ }
|
|
|
+})
|