| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 | 
							- import ColHeader from '@/components/col-header'
 
- import { Button, Cell, CellGroup, Col, Image, Popup, Row } from 'vant'
 
- import { defineComponent } from 'vue'
 
- import styles from './trade-detail.module.less'
 
- import { goodsType } from '@/constant'
 
- import iconTeacher from '@common/images/icon_teacher.png'
 
- import request from '@/helpers/request'
 
- import Payment from '../order-detail/payment'
 
- import { orderStatus } from '../order-detail/orderStatus'
 
- import { state } from '@/state'
 
- export const getAssetsHomeFile = (fileName: string) => {
 
-   const path = `./images/${fileName}`
 
-   const modules = import.meta.globEager('./images/*')
 
-   return modules[path].default
 
- }
 
- // WAIT_PAY 待支付 PAYING 支付中 PAID 已付款 CLOSE 已关闭 FAIL 支付失败
 
- type orderType = 'WAIT_PAY' | 'PAYING' | 'PAID' | 'CLOSE' | 'FAIL'
 
- export default defineComponent({
 
-   name: 'tradeDetail',
 
-   data() {
 
-     const query = this.$route.query
 
-     return {
 
-       type: (query.type as string) || 'ING',
 
-       path: query.path, // 来源
 
-       orderNo: query.orderNo || '',
 
-       paymentStatus: false,
 
-       order: {
 
-         ING: {
 
-           img: getAssetsHomeFile('icon_paying.png'),
 
-           background: '#FF802C',
 
-           title: '支付中'
 
-         },
 
-         SUCCESS: {
 
-           img: getAssetsHomeFile('icon_success.png'),
 
-           background:
 
-             state.projectType === 'tenant' ? '#FF5461' : 'var(--van-primary)',
 
-           title: '支付成功'
 
-         },
 
-         FAILED: {
 
-           img: getAssetsHomeFile('icon_close.png'),
 
-           background: '#BDBDBD',
 
-           title: '支付失败'
 
-         },
 
-         CLOSE: {
 
-           img: getAssetsHomeFile('icon_close.png'),
 
-           background: '#BDBDBD',
 
-           title: '订单关闭'
 
-         }
 
-       },
 
-       result: {} as any,
 
-       loading: true,
 
-       timerOut: null as any,
 
-       timer: 3
 
-     }
 
-   },
 
-   computed: {
 
-     orderDetailList() {
 
-       const result: any = this.result
 
-       return result.orderDetailList || []
 
-     }
 
-   },
 
-   async mounted() {
 
-     setTimeout(async () => {
 
-       this.loading = true
 
-       this.orderNo && (await this.getOrder())
 
-       this.loading = false
 
-       this.type === 'ING' && this.path !== 'tradeRecord' && this.interval()
 
-     }, 0)
 
-   },
 
-   unmounted() {
 
-     clearInterval(this.timerOut)
 
-   },
 
-   methods: {
 
-     onRePay() {
 
-       orderStatus.orderInfo = {
 
-         orderNo: this.result.orderNo,
 
-         actualPrice: this.result.actualPrice,
 
-         payStatus: true
 
-       }
 
-       this.paymentStatus = true
 
-       this.interval()
 
-     },
 
-     interval() {
 
-       let countTime = 0
 
-       this.timerOut = setInterval(async () => {
 
-         countTime === 25 && clearInterval(this.timerOut)
 
-         await this.getOrder(true)
 
-         countTime++
 
-       }, 5000)
 
-     },
 
-     async getOrder(status?: true) {
 
-       try {
 
-         const urlFix =
 
-           state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student'
 
-         const res = await request.get(
 
-           `${urlFix}/open/userOrder/detailByOrderNo/${this.orderNo}`,
 
-           {
 
-             hideLoading: status
 
-           }
 
-         )
 
-         this.result = res.data
 
-         // WAIT_PAY 待支付 PAYING 支付中 PAID 已付款 CLOSE 已关闭 FAIL 支付失败
 
-         this.type = this.formatType(this.result.status)
 
-         this.type !== 'ING' && clearInterval(this.timerOut)
 
-       } catch {}
 
-     },
 
-     formatType(type: orderType) {
 
-       let str = 'PAYING'
 
-       switch (type) {
 
-         case 'WAIT_PAY':
 
-         case 'PAYING':
 
-           str = 'ING'
 
-           break
 
-         case 'PAID':
 
-           str = 'SUCCESS'
 
-           break
 
-         case 'CLOSE':
 
-           str = 'CLOSE'
 
-           break
 
-         case 'FAIL':
 
-           str = 'FAILED'
 
-           break
 
-         default:
 
-           str = 'ING'
 
-           break
 
-       }
 
-       return str
 
-     }
 
-   },
 
-   render() {
 
-     return (
 
-       <div class={[styles.tradeDetail, styles[this.type]]}>
 
-         {!this.loading && (
 
-           <>
 
-             <ColHeader
 
-               background={this.order[this.type].background}
 
-               color="#fff"
 
-               title="交易详情"
 
-               backIconColor="white"
 
-               border={false}
 
-             />
 
-             <div
 
-               class={[
 
-                 styles.orderType,
 
-                 state.projectType === 'tenant' && styles.orderTypeTenant
 
-               ]}
 
-             >
 
-               <p>
 
-                 <Image
 
-                   class={styles.orderImg}
 
-                   src={this.order[this.type].img}
 
-                   fit="cover"
 
-                 />
 
-                 <span>{this.order[this.type].title}</span>
 
-               </p>
 
-             </div>
 
-             <CellGroup
 
-               border={false}
 
-               class={[
 
-                 styles.orderContent,
 
-                 state.projectType === 'tenant' && styles.orderContentTenant,
 
-                 'mb12'
 
-               ]}
 
-             >
 
-               <Cell
 
-                 v-slots={{
 
-                   title: () => (
 
-                     <div class={styles.payPrice}>
 
-                       <span>¥</span>
 
-                       {(this as any).$filters.moneyFormat(
 
-                         this.result.actualPrice
 
-                       )}
 
-                     </div>
 
-                   )
 
-                 }}
 
-               />
 
-               {this.orderDetailList.map((item: any) => (
 
-                 <Cell
 
-                   border={false}
 
-                   style={{ paddingBottom: '15px' }}
 
-                   v-slots={{
 
-                     icon: () => (
 
-                       <Image
 
-                         class={styles.tradeLogo}
 
-                         src={item.goodUrl || iconTeacher}
 
-                         fit="cover"
 
-                       />
 
-                     ),
 
-                     title: () => (
 
-                       <div class={styles.title}>
 
-                         <span>{item.goodName}</span>
 
-                         <span class={styles.desc}>
 
-                           {goodsType[item.goodType]}
 
-                         </span>
 
-                       </div>
 
-                     ),
 
-                     default: () => (
 
-                       <div class={styles.content}>
 
-                         <span class={styles.price}>
 
-                           ¥
 
-                           {(this as any).$filters.moneyFormat(item.expectPrice)}
 
-                         </span>
 
-                         <span class={styles.num}>x{1}</span>
 
-                       </div>
 
-                     )
 
-                   }}
 
-                 />
 
-               ))}
 
-               <Row class={styles.optionRow}>
 
-                 <Col span="8" offset={1}>
 
-                   订单号:
 
-                 </Col>
 
-                 <Col span="14">{this.result.orderNo}</Col>
 
-                 <Col span="1"> </Col>
 
-               </Row>
 
-               <Row class={styles.optionRow}>
 
-                 <Col span="8" offset={1}>
 
-                   交易流水号:
 
-                 </Col>
 
-                 <Col span="14">{this.result.transNo}</Col>
 
-                 <Col span="1"> </Col>
 
-               </Row>
 
-               <Row class={styles.optionRow}>
 
-                 <Col span="8" offset={1}>
 
-                   创建时间:
 
-                 </Col>
 
-                 <Col span="14">{this.result.createTime}</Col>
 
-                 <Col span="1"> </Col>
 
-               </Row>
 
-               <Row class={styles.optionRow}>
 
-                 <Col span="8" offset={1}>
 
-                   付款时间:
 
-                 </Col>
 
-                 <Col span="14">{this.result.payTime}</Col>
 
-                 <Col span="1"> </Col>
 
-               </Row>
 
-             </CellGroup>
 
-             {/* {this.type === 'ING' && this.path === 'tradeRecord' && (
 
-               <div class="btnGroup">
 
-                 <Button type="primary" round block onClick={this.onRePay}>
 
-                   重新支付
 
-                 </Button>
 
-               </div>
 
-             )}
 
-             <Popup
 
-               show={this.paymentStatus}
 
-               closeOnClickOverlay={false}
 
-               position="bottom"
 
-               round
 
-               closeOnPopstate
 
-               safeAreaInsetBottom
 
-               style={{ minHeight: '30%' }}
 
-             >
 
-               <Payment
 
-                 v-model={this.paymentStatus}
 
-                 orderInfo={orderStatus.orderInfo}
 
-               />
 
-             </Popup> */}
 
-           </>
 
-         )}
 
-       </div>
 
-     )
 
-   }
 
- })
 
 
  |