123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- import { connect } from 'herculex';
- import { setPagesQuery } from "../../../../core/utils";
- import { createSubscribe } from 'applet-page-component';
- import { getMyCardInfo } from './service';
- import history from '../../utils/history';
- import doLogin from '../../utils/doLogin';
- const app = getApp();
- const qrImage = 'https://gw.alipayobjects.com/mdn/rms_373ab8/afts/img/A*z8duR6vAPp0AAAAAAAAAAAAAARQnAQ';
- const addIcon = 'https://gw.alipayobjects.com/mdn/rms_373ab8/afts/img/A*dqcsTZEuGTgAAAAAAAAAAAAAARQnAQ';
- Component(createSubscribe({
- onShow() {
- const {
- isLogin
- } = this.data;
- if (isLogin) this.fetchCardInfo();
- }
- })(connect({
- mapStateToProps: {
- scopes: ({
- $global
- }) => $global.scopes,
- userInfo: ({
- $global
- }) => $global.userInfo || {},
- isLogin: ({
- $global
- }) => $global.userInfo.isLogin
- }
- })({
- props: {
- componentData: {}
- },
- data: {
- addIcon,
- qrImage,
- cardInfo: null,
- showPatient: false,
- imgSrcPrefix: app.globalData.imgSrcPrefix
- },
- async didUpdate(_, preState) {
- const {
- isLogin = false
- } = preState;
- const {
- isLogin: curLogin
- } = this.data;
- if (isLogin !== curLogin && curLogin) {
- await this.fetchCardInfo();
- }
- },
- methods: {
- async fetchCardInfo() {
- const info = await getMyCardInfo();
- this.setData({
- cardInfo: info
- });
- },
- setQuery(patientId) {
- setPagesQuery({
- currentUserId: patientId
- });
- },
- /**
- * 去登陆
- */
- async onLogin() {
- await doLogin.call(this, {
- scopes: 'auth_user'
- });
- },
- /**
- * 切换就诊人
- */
- changeBtn() {
- this.setData({
- showPatient: true
- });
- },
- onClose() {
- this.setData({
- showPatient: false
- });
- },
- onChange(item) {
- const {
- cardInfo
- } = this.data;
- const {
- id: patientId,
- bindCardNum: cardNum
- } = item;
- this.setData({
- showPatient: false,
- cardInfo: { ...cardInfo,
- cardNum,
- patientId
- }
- });
- my.showToast({
- duration: 1500,
- content: '就诊人切换成功'
- });
- },
- toPatientDetail() {
- const {
- patientId
- } = this.data.cardInfo;
- history.push({
- title: '就诊人详情',
- query: {
- id: patientId
- },
- pageType: 'patient-detail'
- });
- },
- toAddCard() {
- const {
- userInfo
- } = this.data;
- const {
- phone,
- gender,
- idCardNo,
- fullName
- } = userInfo || {};
- const editForm = {
- idCardNo,
- name: fullName,
- defaultCard: '是',
- phoneNumber: phone,
- relationShip: '本人',
- sex: gender === 'm' ? '男' : '女'
- };
- history.push({
- title: '添加就诊卡',
- pageType: 'edit-patient',
- query: {
- editType: 'card'
- },
- componentData: {
- editForm
- }
- });
- }
- }
- })));
|