123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- import store from './store';
- import { getOrderDetail, getVisitDetail, queryDetail, getPayDetail } from '../../components/utils/service';
- import { mapToArray, replaceStar } from '../../components/utils/index';
- const config = {
- order: {
- title: '预约记录',
- service: async ({
- queryId
- }) => {
- const [err, result] = await getOrderDetail({
- orderId: queryId
- });
- return [err, { ...result,
- viewCardNum: replaceStar(result.cardNum, 3, 4)
- }];
- }
- },
- visit: {
- title: '就诊记录',
- service: async ({
- queryId
- }) => {
- const [err, result] = await getVisitDetail({
- visitId: queryId
- });
- return [err, { ...result,
- viewCardNum: replaceStar(result.cardNum, 3, 4)
- }];
- }
- },
- charge: {
- title: '充值记录',
- service: async ({
- queryId
- }) => {
- const [err, result] = await getPayDetail({
- type: 2,
- outTradeNo: queryId
- });
- return [err, { ...result,
- customInfo: mapToArray(result.customInfo),
- viewCardNum: replaceStar(result.cardNum, 3, 4)
- }];
- }
- },
- report: {
- title: '报告详情',
- service: ({
- queryId
- }) => queryDetail({
- recordId: queryId
- })
- }
- };
- Page(store.register({
- data: {
- type: '',
- // 根据不同的类型展示不同的页面
- queryId: '',
- detail: {},
- // 页面展示的数据
- options: {} // 兼容框架bug取不到 options 的问题
- },
- onLoad(options) {
- const {
- type
- } = options;
- const {
- title
- } = config[type]; // 只需要服务首页上报,注释掉组件内部的调用
- // reportCmPV_YL({ title, query: options });
- my.setNavigationBar({
- title
- });
- this.setData({
- options
- }, () => this.onFetchDetail());
- },
- // 获取数据
- async onFetchDetail() {
- const {
- options
- } = this.data;
- const {
- service
- } = config[options.type];
- const [, result] = await service(options);
- if (result) {
- this.setData({
- type: options.type,
- queryId: options.queryId,
- detail: result
- });
- }
- },
- navigateBack() {
- my.navigateBack();
- },
- onReachBottom() {},
- onShareAppMessage() {
- const {
- type,
- queryId
- } = this.data;
- return {
- title: this.data.pageName || '',
- path: `${this.route}?type=${type}&queryId=${queryId}`
- };
- }
- }));
|