Browse Source

feat(front): h5支付页

Go 5 years ago
parent
commit
dc329ff840

+ 2 - 2
front/project/h5/routes/product/bought/index.js

@@ -1,6 +1,6 @@
 export default {
-  path: '/product/data',
-  key: 'product-data',
+  path: '/bought',
+  key: 'bought',
   title: '已购买',
   needLogin: true,
   component() {

front/project/h5/routes/product/bought/index.less → front/project/h5/routes/page/bought/index.less


front/project/h5/routes/product/bought/page.js → front/project/h5/routes/page/bought/page.js


+ 10 - 0
front/project/h5/routes/page/pay/index.js

@@ -0,0 +1,10 @@
+export default {
+  path: '/pay',
+  matchPath: '/pay/:id',
+  key: 'pay',
+  title: '购买确认',
+  needLogin: true,
+  component() {
+    return import('./page');
+  },
+};

+ 3 - 0
front/project/h5/routes/page/pay/index.less

@@ -0,0 +1,3 @@
+@charset "utf-8";
+
+#pay {}

+ 61 - 0
front/project/h5/routes/page/pay/page.js

@@ -0,0 +1,61 @@
+// import React from 'react';
+import './index.less';
+import Page from '@src/containers/Page';
+// import Assets from '@src/components/Assets';
+// import { getMap, formatDate } from '@src/services/Tools';
+// import Checkbox from '../../../components/CheckBox';
+// import Button from '../../../components/Button';
+// import Icon from '../../../components/Icon';
+import { Order } from '../../../stores/order';
+import { Main } from '../../../stores/main';
+// import { ServiceKey } from '../../../../Constant';
+
+// const ServiceKeyMap = getMap(ServiceKey, 'value', 'label');
+
+export default class extends Page {
+  initState() {
+    return {};
+  }
+
+  initData() {
+    const { id } = this.params;
+    Order.getOrder(id)
+      .then(result => {
+        this.setState({ data: result });
+      });
+    Main.getContract('course')
+      .then(result => {
+        this.setState({ contract: result });
+      });
+  }
+
+  pay() {
+    const { id } = this.params;
+    Order.wechatJs(id)
+      .then(() => {
+
+      });
+  }
+
+  renderView() {
+    const { productType } = this.state;
+    if (productType === 'data') {
+      return this.renderData();
+    }
+    if (productType === 'course_package') {
+      return this.renderCoursePackage();
+    }
+    return this.renderSingle();
+  }
+
+  renderData() {
+  }
+
+  renderCoursePackage() {
+
+  }
+
+  renderSingle() {
+
+  }
+}

+ 4 - 1
front/project/h5/routes/product/courseDetail/page.js

@@ -22,7 +22,10 @@ export default class extends Page {
   }
 
   buy() {
-    Order.speedPay({ productType: 'course', productId: this.params.id });
+    Order.speedPay({ productType: 'course', productId: this.params.id })
+      .then((result) => {
+        linkTo(`/pay/${result.id}`);
+      });
   }
 
   renderText() {

+ 4 - 1
front/project/h5/routes/product/coursePackage/page.js

@@ -22,7 +22,10 @@ export default class extends Page {
   }
 
   buy() {
-    Order.speedPay({ productType: 'course_package', productId: this.params.id });
+    Order.speedPay({ productType: 'course_package', productId: this.params.id })
+      .then((result) => {
+        linkTo(`/pay/${result.id}`);
+      });
   }
 
   renderView() {

+ 4 - 1
front/project/h5/routes/product/courseVs/page.js

@@ -48,7 +48,10 @@ export default class extends Page {
 
   buy() {
     const { number } = this.state;
-    Order.speedPay({ productType: 'course', productId: this.params.id, number });
+    Order.speedPay({ productType: 'course', productId: this.params.id, number })
+      .then((result) => {
+        linkTo(`/pay/${result.id}`);
+      });
   }
 
   renderText() {

+ 4 - 1
front/project/h5/routes/product/dataDetail/page.js

@@ -27,7 +27,10 @@ export default class extends Page {
   }
 
   buy() {
-    Order.speedPay({ productType: 'data', productId: this.params.id });
+    Order.speedPay({ productType: 'data', productId: this.params.id })
+      .then((result) => {
+        linkTo(`/pay/${result.id}`);
+      });
   }
 
   renderText() {

+ 4 - 1
front/project/h5/routes/product/serviceDetail/page.js

@@ -32,7 +32,10 @@ export default class extends Page {
     const { service } = this.params;
     const { index } = this.state;
     const param = ServiceParamMap[service] ? ServiceParamMap[service][index].value : '';
-    Order.speedPay({ productType: 'service', service, param });
+    Order.speedPay({ productType: 'service', service, param })
+      .then((result) => {
+        linkTo(`/pay/${result.id}`);
+      });
   }
 
   //   expire_info: '',

+ 8 - 0
front/project/h5/stores/order.js

@@ -38,6 +38,14 @@ export default class OrderStore extends BaseStore {
     return this.apiGet('/order/pay/query', { orderId });
   }
 
+  list({ page, size }) {
+    return this.apiGet('/order/list', { page, size });
+  }
+
+  getOrder(id) {
+    return this.apiGet('/order/detail', { id });
+  }
+
   /**
    * 获取所有已购记录
    * @param {*} param0