update_202312052001_项目-治疗室屏幕web-切图接口对接v2
| | |
| | | }, |
| | | '/api_test': { // 测试环境 |
| | | // target: 'http://192.168.31.69:8080', |
| | | target: 'https://test6.phiskin.com/phi_appt/', // 新预约 |
| | | target: 'https://test6.phiskin.com/guide/', // 导医 |
| | | // target: 'https://test6.phiskin.com/phi_appt/', // 新预约phis后台 |
| | | // target: 'http://hymctest.huoxiongit.com/',// 这个是你服务器开启的接口 |
| | | changeOrigin: true,// 是否跨域 |
| | | pathRewrite: { |
| | |
| | | "axios": "^0.19.2", |
| | | "clipboard": "^2.0.6", |
| | | "element-ui": "^2.15.6", |
| | | "js-md5": "^0.8.3", |
| | | "svg-sprite-loader": "^6.0.11", |
| | | "vue": "^2.5.2", |
| | | "vue-router": "^3.0.1", |
| | |
| | | "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.6.4.tgz", |
| | | "integrity": "sha512-pZe//GGmwJndub7ZghVHz7vjb2LgC1m8B07Au3eYqeqv9emhESByMXxaEgkUkEqJe87oBbSniGYoQNIBklc7IQ==" |
| | | }, |
| | | "node_modules/js-md5": { |
| | | "version": "0.8.3", |
| | | "resolved": "https://registry.npmjs.org/js-md5/-/js-md5-0.8.3.tgz", |
| | | "integrity": "sha512-qR0HB5uP6wCuRMrWPTrkMaev7MJZwJuuw4fnwAzRgP4J4/F8RwtodOKpGp4XpqsLBFzzgqIO42efFAyz2Et6KQ==" |
| | | }, |
| | | "node_modules/js-tokens": { |
| | | "version": "3.0.2", |
| | | "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", |
| | |
| | | "axios": "^0.19.2", |
| | | "clipboard": "^2.0.6", |
| | | "element-ui": "^2.15.6", |
| | | "js-md5": "^0.8.3", |
| | | "svg-sprite-loader": "^6.0.11", |
| | | "vue": "^2.5.2", |
| | | "vue-router": "^3.0.1", |
| | |
| | | min-height: 100px; |
| | | } |
| | | |
| | | .page_header .left { |
| | | cursor: pointer; |
| | | } |
| | | |
| | | .page_logo_1 { |
| | | width: 50px; |
| | | height: 45px; |
| | |
| | | <template> |
| | | <div v-if="isShow" class="mask" @click="hideDialog"> |
| | | <div class="xio_customer_select_dialog" @click.stop="noop"> |
| | | <div class="title">是否选择客人[张怀民],使用当前房间?</div> |
| | | <div class="title">是否选择客人[{{ dialogData.userName }}],使用当前房间?</div> |
| | | <div class="content flex flex-sb"> |
| | | <div class="tx flex-1" style="text-align: left;">医生:张怀民</div> |
| | | <div class="tx flex-1">护士:张怀民</div> |
| | | <div class="tx flex-1" style="text-align: right;">顾问:张怀民</div> |
| | | <div v-if="dialogData.aDoctorName" class="tx flex-1" style="text-align: left;">医生:{{ dialogData.aDoctorName }}</div> |
| | | <div v-if="dialogData.aNurseName" class="tx flex-1">护士:{{ dialogData.aNurseName }}</div> |
| | | <div v-if="dialogData.adviserName" class="tx flex-1" style="text-align: right;">顾问:{{ dialogData.adviserName }}</div> |
| | | </div> |
| | | <div class="content flex flex-ver"> |
| | | <div class="tx">治疗项目:phis-Fotona4D</div> |
| | | <div v-if="dialogData.projectName" class="tx">治疗项目:{{ dialogData.projectName }}</div> |
| | | </div> |
| | | <div class="btn_box flex flex-center"> |
| | | <div class="flex flex-ver"> |
| | |
| | | }, |
| | | // 提交 |
| | | submit() { |
| | | this.$emit('submit', {}) |
| | | this.$emit('submit', this.dialogData) |
| | | }, |
| | | noop() { |
| | | return |
| | |
| | | <div class="btn_box flex flex-center"> |
| | | <div style="width: 100%;"> |
| | | <div class="line flex flex-ver flex-sb"> |
| | | <div class="btn_box_item flex flex-center white" @click="changeStatus('空闲')"> |
| | | <div class="btn_box_item flex flex-center white" @click="changeStatus('空闲', 0)"> |
| | | <div class="flex flex-ver"> |
| | | <img class="icon" src="../../assets/img/free.png"> |
| | | <div class="tx">空闲</div> |
| | | </div> |
| | | </div> |
| | | <div class="btn_box_item flex flex-center blue" @click="changeStatus('使用中')"> |
| | | <div class="btn_box_item flex flex-center blue" @click="changeStatus('使用中', 1)"> |
| | | <div class="flex flex-ver"> |
| | | <img class="icon" src="../../assets/img/using.png"> |
| | | <div class="tx white">使用中</div> |
| | |
| | | </div> |
| | | </div> |
| | | <div class="line flex flex-ver flex-sb"> |
| | | <div class="btn_box_item flex flex-center yellow" @click="changeStatus('客人休息')"> |
| | | <div class="btn_box_item flex flex-center yellow" @click="changeStatus('客人休息', 2)"> |
| | | <div class="flex flex-ver"> |
| | | <img class="icon" src="../../assets/img/rest.png"> |
| | | <div class="tx">客人休息</div> |
| | | </div> |
| | | </div> |
| | | <div class="btn_box_item flex flex-center gray" @click="changeStatus('通知打扫')"> |
| | | <div class="btn_box_item flex flex-center gray" @click="changeStatus('通知打扫', 3)"> |
| | | <div class="flex flex-ver"> |
| | | <img class="icon" src="../../assets/img/clear.png"> |
| | | <div class="tx">通知打扫</div> |
| | |
| | | return |
| | | }, |
| | | // 更换状态 |
| | | changeStatus(tx) { |
| | | this.$emit('changeStatus', { statusTx: tx }) |
| | | changeStatus(tx, status) { |
| | | this.$emit('changeStatus', { statusTx: tx, status: status * 1 }) |
| | | }, |
| | | // 显示弹窗 |
| | | showDialog() { |
| | |
| | | <!--room-detail.vue--> |
| | | <template> |
| | | <div class="page"> |
| | | <div class="page_header flex flex-ver" @click="back"> |
| | | <div class="left flex flex-ver"> |
| | | <div class="page_header flex flex-ver"> |
| | | <div class="left flex flex-ver" @click="back"> |
| | | <img class="page_logo_1" src="../../assets/img/logo_1.png"> |
| | | <img class="page_logo_2" src="../../assets/img/logo_2.png"> |
| | | </div> |
| | |
| | | </div> |
| | | </div> |
| | | <!-- 未有安排 --> |
| | | <div class="page_container flex flex-ver hide"> |
| | | <div v-if="!occupyInfoView && (!assignTreatList || !assignTreatList.length)" class="page_container flex flex-ver"> |
| | | <div class="main flex-1"> |
| | | <div class="room_title">VIP-诊疗室-1</div> |
| | | <div class="room_main_tip" style="margin-top: 93px;line-height: 186px;font-size: 140px;">-使用中-</div> |
| | | <div v-if="roomInfo && roomInfo.roomNo" class="room_title">{{ roomInfo.roomNo }}</div> |
| | | <div v-if="roomInfo" class="room_main_tip" style="margin-top: 93px;line-height: 186px;font-size: 140px;">-{{ statusTx[roomInfo.status] }}-</div> |
| | | <div class="btn_box flex flex-center"> |
| | | <div class="flex flex-ver"> |
| | | <div class="btn_box__item flex flex-center white" data-tx="空闲"> |
| | | <div class="btn_box__item flex flex-center white" data-tx="空闲" data-status="0" @click="statusChg"> |
| | | <div class="flex flex-ver"> |
| | | <img class="icon" src="../../assets/img/free.png"> |
| | | <div class="tx">空闲</div> |
| | | </div> |
| | | </div> |
| | | <div class="btn_box__item flex flex-center blue" data-tx="使用中"> |
| | | <div class="btn_box__item flex flex-center blue" data-tx="使用中" data-status="1" @click="statusChg"> |
| | | <div class="flex flex-ver"> |
| | | <img class="icon" src="../../assets/img/using.png"> |
| | | <div class="tx white">使用中</div> |
| | | </div> |
| | | </div> |
| | | <div class="btn_box__item flex flex-center yellow" data-tx="客人休息"> |
| | | <div class="btn_box__item flex flex-center yellow" data-tx="客人休息" data-status="2" @click="statusChg"> |
| | | <div class="flex flex-ver"> |
| | | <img class="icon" src="../../assets/img/rest.png"> |
| | | <div class="tx">客人休息</div> |
| | | </div> |
| | | </div> |
| | | <div class="btn_box__item flex flex-center gray" data-tx="通知打扫"> |
| | | <div class="btn_box__item flex flex-center gray" data-tx="通知打扫" data-status="3" @click="statusChg"> |
| | | <div class="flex flex-ver"> |
| | | <img class="icon" src="../../assets/img/clear.png"> |
| | | <div class="tx">通知打扫</div> |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <!-- 没有默认客人和有安排 --> |
| | | <div class="page_container flex flex-ver hide"> |
| | | <!-- 没有客人和有安排 --> |
| | | <div v-if="!occupyInfoView && (assignTreatList && assignTreatList.length)" class="page_container flex flex-ver"> |
| | | <div class="main flex-1"> |
| | | <div class="room_title">VIP-诊疗室-1</div> |
| | | <div class="room_main_tip">-使用中-</div> |
| | | <div class="room_left_btn_box flex flex-ver"> |
| | | <div class="room_left_btn_box__item flex-1 flex flex-center yellow">客人休息</div> |
| | | <div class="room_left_btn_box__item flex-1 flex flex-center gray">通知打扫</div> |
| | | <!-- <div class="room_left_btn_box__item flex flex-center green">通知打扫</div> --> |
| | | <!-- <div class="room_left_btn_box__item flex flex-center green">结束打扫</div> --> |
| | | <div v-if="roomInfo && roomInfo.roomNo" class="room_title">{{ roomInfo.roomNo }}</div> |
| | | <div v-if="roomInfo" class="room_main_tip">-{{ statusTx[roomInfo.status] }}-</div> |
| | | <div v-if="roomInfo && roomInfo.status >= 1" class="room_left_btn_box flex flex-ver"> |
| | | <div v-if="roomInfo.status == 1" class="room_left_btn_box__item flex-1 flex flex-center yellow" @click="setStatus('客人休息', 2)">客人休息</div> |
| | | <div v-if="roomInfo.status == 1" class="room_left_btn_box__item flex-1 flex flex-center gray" @click="setStatus('打扫中', 3)">通知打扫</div> |
| | | <div v-if="roomInfo.status == 2" class="room_left_btn_box__item flex flex-center green" @click="setStatus('打扫中', 3)">通知打扫</div> |
| | | <div v-if="roomInfo.status == 3" class="room_left_btn_box__item flex flex-center green" @click="setStatus('空闲', 0)">结束打扫</div> |
| | | </div> |
| | | </div> |
| | | <div class="right"> |
| | |
| | | <div class="guest_title flex flex-center">等待诊疗</div> |
| | | <div class="guest_block flex-1"> |
| | | <div class="guest_list"> |
| | | <div v-for="(item, index) in list" :key="index" class="guest_list__row flex flex-ver" @click="selectCustomer"> |
| | | <div v-for="(item, index) in assignTreatList" :key="index" class="guest_list__row flex flex-ver" @click="selectCustomer(item)"> |
| | | <div class="guest_list__td flex flex-center"> |
| | | <div> |
| | | <div class="tx">张*民</div> |
| | | <div class="tx" style="font-size: 14px;line-height: 20px;">2300000000</div> |
| | | <div class="tx">{{ item.userName }}</div> |
| | | <div class="tx" style="font-size: 14px;line-height: 20px;">{{ item.ciq || '' }}</div> |
| | | </div> |
| | | </div> |
| | | <div class="guest_list__td flex flex-center"> |
| | | <span class="tx">15:00开始</span> |
| | | <span class="tx">{{ item.startTime?item.startTime+'开始':'' }}</span> |
| | | </div> |
| | | <div class="guest_list__td flex flex-center"> |
| | | <span class="tx">张怀民(医生)、张怀民(护士)</span> |
| | | <span class="tx">{{ item.aDoctorName?item.aDoctorName+'(医生)、':'' }}{{ item.aNurseName?item.aNurseName+'(护士)':'' }}</span> |
| | | </div> |
| | | <div class="guest_list__td flex flex-center"> |
| | | <img class="icon" src="../../assets/img/choose.png"> |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <!-- 默认客人和有安排 --> |
| | | <div class="page_container flex flex-ver"> |
| | | <!-- 客人和有安排 --> |
| | | <div v-if="occupyInfoView && (assignTreatList && assignTreatList.length)" class="page_container flex flex-ver"> |
| | | <div class="main flex-1"> |
| | | <div class="room_title">VIP-诊疗室-1</div> |
| | | <div v-if="roomInfo && roomInfo.roomNo" class="room_title">{{ roomInfo.roomNo }}</div> |
| | | <div class="room_content"> |
| | | <div class="tip">诊疗安排</div> |
| | | <div class="name">张怀民</div> |
| | | <div class="ciq">(2300000000)</div> |
| | | <div class="time">安排治疗时间:13:30 开始</div> |
| | | <div class="name">{{ occupyInfoView.userName }}</div> |
| | | <div v-if="occupyInfoView.ciq" class="ciq">({{ occupyInfoView.ciq }})</div> |
| | | <div v-if="occupyInfoView.startTime" class="time">安排治疗时间:{{ occupyInfoView.startTime }} 开始</div> |
| | | </div> |
| | | <div class="room_left_btn_box flex flex-ver" style="margin-top: 105px;"> |
| | | <div class="room_left_btn_box__item flex flex-center green btn_ani">开始治疗</div> |
| | | <!-- <div class="room_left_btn_box__item flex-1 flex flex-center yellow">客人休息</div> |
| | | <div class="room_left_btn_box__item flex-1 flex flex-center gray">通知打扫</div> --> |
| | | <!-- <div class="room_left_btn_box__item flex flex-center green">通知打扫</div> --> |
| | | <!-- <div class="room_left_btn_box__item flex flex-center green">结束打扫</div> --> |
| | | <div v-if="roomInfo" class="room_left_btn_box flex flex-ver" style="margin-top: 105px;"> |
| | | <div v-if="roomInfo.status == 0" class="room_left_btn_box__item flex flex-center green btn_ani" @click="setStatus('使用中', 1)">开始治疗</div> |
| | | <div v-if="roomInfo.status == 1" class="room_left_btn_box__item flex-1 flex flex-center yellow" @click="setStatus('客人休息', 2)">客人休息</div> |
| | | <div v-if="roomInfo.status == 1" class="room_left_btn_box__item flex-1 flex flex-center gray" @click="setStatus('打扫中', 3)">通知打扫</div> |
| | | <div v-if="roomInfo.status == 2" class="room_left_btn_box__item flex flex-center green" @click="setStatus('打扫中', 3)">通知打扫</div> |
| | | <div v-if="roomInfo.status == 3" class="room_left_btn_box__item flex flex-center green" @click="setStatus('空闲', 0)">结束打扫</div> |
| | | </div> |
| | | </div> |
| | | <div class="right flex flex-col"> |
| | |
| | | <div class="staff_box_item flex-1 flex flex-center"> |
| | | <div> |
| | | <div class="staff_box_item__title">分诊顾问</div> |
| | | <div class="staff_box_item__name">张怀民</div> |
| | | <div class="staff_box_item__name">{{ occupyInfoView.adviserName || '' }}</div> |
| | | </div> |
| | | </div> |
| | | <div class="staff_box_item flex-1 flex flex-center"> |
| | | <div> |
| | | <div class="staff_box_item__title">执行医生</div> |
| | | <div class="staff_box_item__name">张医生</div> |
| | | <div class="staff_box_item__name">{{ occupyInfoView.aDoctorName || '' }}</div> |
| | | </div> |
| | | </div> |
| | | <div class="staff_box_item flex-1 flex flex-center"> |
| | | <div> |
| | | <div class="staff_box_item__title">执行护士</div> |
| | | <div class="staff_box_item__name">张护士</div> |
| | | <div class="staff_box_item__name">{{ occupyInfoView.aNurseName || '' }}</div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="room_info_project"> |
| | | <div class="room_info_project_block"> |
| | | <div class="tx">phis-Fotona 超V光、phis-补水嫩肤(F)涂抹</div> |
| | | <div class="tx">{{ occupyInfoView.projectName || '' }}</div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | <div class="guest_title flex flex-center">等待诊疗</div> |
| | | <div class="guest_block flex-1"> |
| | | <div class="guest_list"> |
| | | <div v-for="(item, index) in list" :key="index" class="guest_list__row flex flex-ver" @click="selectCustomer"> |
| | | <div v-for="(item, index) in assignTreatList" :key="index" class="guest_list__row flex flex-ver" @click="selectCustomer(item)"> |
| | | <div class="guest_list__td flex flex-center"> |
| | | <div> |
| | | <div class="tx">张*民</div> |
| | | <div class="tx" style="font-size: 14px;line-height: 20px;">2300000000</div> |
| | | <div class="tx">{{ item.userName }}</div> |
| | | <div class="tx" style="font-size: 14px;line-height: 20px;">{{ item.ciq || '' }}</div> |
| | | </div> |
| | | </div> |
| | | <div class="guest_list__td flex flex-center"> |
| | | <span class="tx">15:00开始</span> |
| | | <span class="tx">{{ item.startTime?item.startTime+'开始':'' }}</span> |
| | | </div> |
| | | <div class="guest_list__td flex flex-center"> |
| | | <span class="tx">张怀民(医生)、张怀民(护士)</span> |
| | | <span class="tx">{{ item.aDoctorName?item.aDoctorName+'(医生)、':'' }}{{ item.aNurseName?item.aNurseName+'(护士)':'' }}</span> |
| | | </div> |
| | | <div class="guest_list__td flex flex-center"> |
| | | <img class="icon" src="../../assets/img/choose.png"> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | // 空闲 0 |
| | | // 使用中 1 |
| | | // 客人休息 2 |
| | | // 待打扫/通知打扫 3 |
| | | // import Login from '../utils/jun_login.js' |
| | | // 选择客人弹窗 |
| | | import XioCustomerSelect from '@/components/xio_customer_select' |
| | | // 更改房间状态窗 |
| | | import XioRoomStatusChg from '@/components/xio_room_status_chg' |
| | | import Req from '../../utils/jun_httpInstall' // http 请求 |
| | | var isUseDefault = false // 是否已使用默认客人 |
| | | export default { |
| | | name: 'RoomDetail', |
| | | components: { |
| | |
| | | inject: ['noop'], |
| | | data() { |
| | | return { |
| | | list: ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], |
| | | timeObj: {}// week:星期,date:年月日,timeMin:时分,time:时分秒,timeStamp:时间戳 |
| | | id: this.$route.query.id || '', |
| | | roomInfo: {}, |
| | | occupyInfo: '', // 当前占用人的信息 |
| | | assignTreatList: [], |
| | | statusTx: ['空闲', '使用中', '客人休息', '打扫中'], |
| | | timeObj: {} // week:星期,date:年月日,timeMin:时分,time:时分秒,timeStamp:时间戳 |
| | | } |
| | | }, |
| | | computed: { |
| | | |
| | | occupyInfoView() { |
| | | // 有占用 |
| | | if (this.occupyInfo) { |
| | | return this.occupyInfo |
| | | // 没有占用 |
| | | } else { |
| | | // 没使用默认客人值 |
| | | if (!isUseDefault && this.assignTreatList && this.assignTreatList.length) { |
| | | isUseDefault = true |
| | | return this.assignTreatList[0] |
| | | // 已使用过默认客人值 |
| | | } else { |
| | | return '' |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | mounted() { |
| | | console.log('roomDetail mounted') |
| | |
| | | }, |
| | | methods: { |
| | | init() { |
| | | // 计时 |
| | | this.countGetTime(this, 'timeObj', 'detail') |
| | | // 轮询getData,8秒一次 |
| | | this.pollingAjaxFn(this, 'getData', 'detail', 8000) |
| | | // this.getData() |
| | | }, |
| | | // 获取房间详情 |
| | | getData() { |
| | | var params = {} |
| | | // 房间id |
| | | if (this.id) { |
| | | params.shopRoomId = this.id |
| | | } |
| | | Req.http.post({ |
| | | url: 'treat/screen/room/info', |
| | | data: params, |
| | | udData: { noLoading: true }, |
| | | header: { 'Content-Type': 'application/json' }, |
| | | mockData: { |
| | | code: 100, |
| | | msg: '', |
| | | data: {} |
| | | } |
| | | }).then((res) => { |
| | | if (res && res.data) { |
| | | for (const key in res.data) { |
| | | this[key] = res.data[key] |
| | | } |
| | | } |
| | | // console.log('999999999999999999999999999', res) |
| | | }) |
| | | }, |
| | | // 返回 |
| | | back() { |
| | | // 关闭计时 |
| | | this.stopCountGetTime('detail') |
| | | // 关闭轮询 |
| | | this.stopPollingAjaxFn('detail') |
| | | // 返回 |
| | | this.$router.go(-1) |
| | | }, |
| | | // 直接状态变更 |
| | | statusChg(e) { |
| | | var { tx, status } = e.currentTarget.dataset |
| | | var { occupyInfoView, roomInfo } = this |
| | | console.log(tx, status) |
| | | // if (roomInfo && status * 1 == roomInfo.status) { |
| | | // return |
| | | // } |
| | | this.changeStatusFn(occupyInfoView, status, () => { |
| | | this.getData() |
| | | }) |
| | | }, |
| | | // 按流程设置房间状态 |
| | | setStatus(tx, status) { |
| | | var { occupyInfoView, roomInfo } = this |
| | | console.log(tx, status) |
| | | this.changeStatusFn(occupyInfoView, status, () => { |
| | | // 刷新详情 |
| | | this.getData() |
| | | }) |
| | | }, |
| | | // 改变房间状态异步 |
| | | changeStatusFn(item = {}, status, cb) { |
| | | var params = {} |
| | | // 状态 |
| | | // 房间id |
| | | if (this.id) { |
| | | params.shopRoomId = this.id |
| | | } |
| | | // 更改的状态 |
| | | params.status = status * 1 |
| | | // 治疗记录id |
| | | if (item && item.id) { |
| | | params.vAssignTreatId = item.id |
| | | } |
| | | Req.http.post({ |
| | | url: 'treat/screen/room/status/update', |
| | | data: params, |
| | | header: { 'Content-Type': 'application/json' }, |
| | | mockData: { |
| | | code: 100, |
| | | msg: '', |
| | | data: {} |
| | | } |
| | | }).then((res) => { |
| | | // console.log('8888888888888888888888888888888888', res) |
| | | cb && cb() |
| | | }) |
| | | }, |
| | | // 重置状态 |
| | | resetStatus() { |
| | |
| | | }, |
| | | // 更改房间状态 |
| | | changeStatus(opt) { |
| | | console.log(opt.statusTx) |
| | | // 关闭弹窗 |
| | | this.$refs['XioRoomStatusChg'].hideDialog() |
| | | var { occupyInfoView, roomInfo } = this |
| | | console.log(opt.statusTx, opt.status) |
| | | // if (roomInfo && opt.status * 1 == roomInfo.status) { |
| | | // return |
| | | // } |
| | | this.changeStatusFn(occupyInfoView, opt.status, () => { |
| | | // 刷新详情 |
| | | this.getData() |
| | | // 关闭弹窗 |
| | | this.$refs['XioRoomStatusChg'].hideDialog() |
| | | }) |
| | | }, |
| | | // 选择客户 |
| | | selectCustomer(item = {}) { |
| | | // 打开弹窗 |
| | | this.$refs['XioCustomerSelect'].showDialog() |
| | | // 组件客户数据处理 |
| | | this.$refs['XioCustomerSelect'].dataInit(item) |
| | | }, |
| | | // 选择客户取消 |
| | |
| | | // 选择客户确定 |
| | | selectCustomerSubmit(opt) { |
| | | console.log('submit', opt) |
| | | this.$refs['XioCustomerSelect'].hideDialog() |
| | | this.changeStatusFn(opt, 1, () => { |
| | | // 刷新详情 |
| | | this.getData() |
| | | // 关闭弹窗 |
| | | this.$refs['XioCustomerSelect'].hideDialog() |
| | | }) |
| | | } |
| | | } |
| | | } |
| | |
| | | font-size: 24px; |
| | | text-align: center; |
| | | font-family: Microsoft Yahei; |
| | | cursor: pointer; |
| | | } |
| | | .page_container .main { |
| | | height: 100%; |
| | |
| | | border-radius: 10px; |
| | | box-shadow: 0px 2px 6px 0px rgba(206,206,206,1); |
| | | margin-right: 70px; |
| | | cursor: pointer; |
| | | } |
| | | .page_container .main .btn_box__item:last-child { |
| | | margin-right: 0; |
| | |
| | | <img class="page_logo_2" src="../../assets/img/logo_2.png"> |
| | | </div> |
| | | <div class="right flex-1 flex flex-jcfe flex-ver"> |
| | | <div class="page_choose_shop"> |
| | | <el-select v-model="shopId" placeholder="请选择" style="width:400px;" clearable @change="getRoomList"> |
| | | <el-option v-for="item in shopList" :key="item.id" :label="item.name" :value="item.id" /> |
| | | </el-select> |
| | | </div> |
| | | <div class="page_date"> |
| | | <div class="page_week">{{ timeObj.week }}</div> |
| | | <div class="page_day">{{ timeObj.date }}</div> |
| | |
| | | <div class="list_container flex flex-col"> |
| | | <div class="list_container__title">请选择房间</div> |
| | | <div class="list_block flex-1"> |
| | | <div class="list flex flex-ver flex-wrap"> |
| | | <div v-if="list && list.length" class="list flex flex-ver flex-wrap"> |
| | | <!-- act --> |
| | | <div v-for="(item, index) in list" :key="index" class="list__item flex flex-center" @click="selectRoom()">VIP诊疗室-1</div> |
| | | <div v-for="(item, index) in list" :key="index" class="list__item flex flex-center" @click="selectRoom(item)">{{ item.roomNo }}</div> |
| | | </div> |
| | | <div v-if="!list || !list.length" class="list flex flex-center"> |
| | | <!-- act --> |
| | | <div class="notip flex flex-center">暂无数据</div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | |
| | | <script> |
| | | // import Login from '../utils/jun_login.js' |
| | | |
| | | import Req from '../../utils/jun_httpInstall' // http 请求 |
| | | export default { |
| | | name: 'RoomList', |
| | | components: {}, |
| | | inject: ['noop'], |
| | | data() { |
| | | return { |
| | | list: ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], |
| | | shopList: [], |
| | | shopId: '', |
| | | list: [], |
| | | timeObj: {}// week:星期,date:年月日,timeMin:时分,time:时分秒,timeStamp:时间戳 |
| | | } |
| | | }, |
| | |
| | | methods: { |
| | | init() { |
| | | this.countGetTime(this, 'timeObj', 'list') |
| | | this.getShopList() |
| | | this.getRoomList() |
| | | }, |
| | | // 获取门店列表 |
| | | getShopList() { |
| | | var params = {} |
| | | Req.http.post({ |
| | | url: 'treat/screen/shop/list', |
| | | data: params, |
| | | header: { 'Content-Type': 'application/json' }, |
| | | mockData: { |
| | | code: 100, |
| | | msg: '', |
| | | data: {} |
| | | } |
| | | }).then((res) => { |
| | | this.shopList = res.data || [] |
| | | }) |
| | | }, |
| | | // 获取列表 |
| | | getRoomList() { |
| | | var params = {} |
| | | if (this.shopId) { |
| | | params.shopId = this.shopId |
| | | } |
| | | Req.http.post({ |
| | | url: 'treat/screen/room/list', |
| | | data: params, |
| | | header: { 'Content-Type': 'application/json' }, |
| | | mockData: { |
| | | code: 100, |
| | | msg: '', |
| | | data: {} |
| | | } |
| | | }).then((res) => { |
| | | this.list = res.data || [] |
| | | }) |
| | | }, |
| | | // 返回 |
| | | back() { |
| | |
| | | }, |
| | | selectRoom(item = {}) { |
| | | this.$router.push({ |
| | | path: `./detail?id=${item.id || ''}` |
| | | path: `./room/detail?id=${item.id || ''}` |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | | .page_choose_shop .el-input__inner { |
| | | background-color: transparent; |
| | | border: 0; |
| | | line-height: 50px; |
| | | color: rgba(255,255,255,1); |
| | | font-size: 36px; |
| | | text-align: center; |
| | | } |
| | | </style> |
| | | <style scoped> |
| | | .list_container { |
| | | width: 100%; |
| | |
| | | line-height: 1; |
| | | margin-left: 48px; |
| | | margin-bottom: 30px; |
| | | box-sizing: border-box; |
| | | min-width: 280px; |
| | | cursor: pointer; |
| | | } |
| | | .list_block .list .list__item.act { |
| | | background-color: #5980FF; |
| | | color: #fff; |
| | | } |
| | | .list_block .list .notip { |
| | | color: rgba(0,0,0,.3); |
| | | font-size: 40px; |
| | | text-align: center; |
| | | font-family: Roboto; |
| | | } |
| | | </style> |
| | |
| | | path: '/', |
| | | name: 'root', |
| | | // component: () => import('@/pages/index') |
| | | component: () => import('@/pages/login/index') |
| | | // component: () => import('@/pages/room/list') |
| | | // component: () => import('@/pages/login/index') |
| | | component: () => import('@/pages/room/list') |
| | | }, |
| | | { |
| | | path: '/login', |
| | |
| | | /** |
| | | * Http 请求 |
| | | * * 小程序请使用增强编译 |
| | | * |
| | | * |
| | | * 调用例子 |
| | | * Req.http.post({ |
| | | * url: '', |
| | |
| | | import Axios from '../libs/axios' |
| | | |
| | | /* json转formdata(序列化),仅支持一级字面量和字面量数组 */ |
| | | function jsonToFormData (json) { |
| | | var arr = [] |
| | | var e = encodeURIComponent |
| | | for (var key in json) { |
| | | var item = json[key] |
| | | var res |
| | | if (item instanceof Array) { |
| | | res = []; |
| | | item.map(function (o, i) { |
| | | res.push(e(key) + '=' + e(o)) |
| | | }); |
| | | res = res.join('&') |
| | | } else { |
| | | res = e(key) + '=' + e(item) |
| | | } |
| | | arr.push(res) |
| | | function jsonToFormData(json) { |
| | | var arr = [] |
| | | var e = encodeURIComponent |
| | | for (var key in json) { |
| | | var item = json[key] |
| | | var res |
| | | if (item instanceof Array) { |
| | | res = [] |
| | | item.map(function(o) { |
| | | res.push(e(key) + '=' + e(o)) |
| | | }) |
| | | res = res.join('&') |
| | | } else { |
| | | res = e(key) + '=' + e(item) |
| | | } |
| | | return arr.join('&') |
| | | arr.push(res) |
| | | } |
| | | return arr.join('&') |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * http事件委托 |
| | | * |
| | | * |
| | | * udData 说明 |
| | | * udData.noloading 不需要请求 |
| | | * udData.fullData 使用 reponse 返回的对象进行 success 回调 (jun_http.js) |
| | |
| | | import Login from './jun_login' |
| | | // import { MessageBox, Message, Loading } from 'element-ui' |
| | | import fn from './fn' |
| | | import xioFn from '../utils/xio_fn.js' |
| | | import resStatusCode from './jun_httpStatus' |
| | | // 过滤 html |
| | | function filterHtml (str) { |
| | | if (typeof str !== 'string') { |
| | | return str |
| | | function filterHtml(str) { |
| | | if (typeof str !== 'string') { |
| | | return str |
| | | } |
| | | return str.replace(/\n|\t|\s/g, '').replace(/<script\s?.+><\/script>/g, '').replace(/<[^>]+>/g, '') |
| | | } |
| | | // 对象转url参数 |
| | | function urlEncode(param, key, encode) { |
| | | if (param == null) return '' |
| | | var paramStr = '' |
| | | var t = typeof (param) |
| | | if (t === 'string' || t === 'number' || t === 'boolean') { |
| | | paramStr += '&' + key + '=' + ((encode == null || encode) ? encodeURIComponent(param) : param) |
| | | } else { |
| | | for (var i in param) { |
| | | var k = key == null ? i : key + (param instanceof Array ? '[' + i + ']' : '.' + i) |
| | | paramStr += urlEncode(param[i], k, encode) |
| | | } |
| | | return str.replace(/\n|\t|\s/g, '').replace(/<script\s?.+><\/script>/g, '').replace(/<[^>]+>/g, '') |
| | | }screenLeft |
| | | return paramStr |
| | | } |
| | | |
| | | /** |
| | |
| | | // } |
| | | |
| | | // 开始loading |
| | | function startLoading(request_option){ |
| | | // |
| | | // console.log(request_option.udData) |
| | | // request_option.udData && typeof request_option.udData.loading === 'function' && request_option.udData.loading() |
| | | typeof window.appLoading === 'function' && window.appLoading() |
| | | function startLoading(__request_option) { |
| | | // console.log(request_option.udData) |
| | | // request_option.udData && typeof request_option.udData.loading === 'function' && request_option.udData.loading() |
| | | typeof window.appLoading === 'function' && window.appLoading() |
| | | } |
| | | |
| | | // 结束loading |
| | | function endLoading(request_option){ |
| | | // |
| | | // request_option.udData && typeof request_option.udData.hideLoading === 'function' && request_option.udData.hideLoading() |
| | | typeof window.appHideLoading === 'function' && window.appHideLoading() |
| | | function endLoading(_request_option) { |
| | | // request_option.udData && typeof request_option.udData.hideLoading === 'function' && request_option.udData.hideLoading() |
| | | typeof window.appHideLoading === 'function' && window.appHideLoading() |
| | | } |
| | | |
| | | // 请求前处理参数 - get |
| | | function getChangeRequestOption (get_option) { |
| | | if (!get_option.udData || !get_option.udData.nokey) { |
| | | if (!get_option.params) { |
| | | get_option.params = {} |
| | | } |
| | | // 补充参数 |
| | | // 需要 we_session |
| | | var we_session = fn.getLocalStorage('we_session') |
| | | if (we_session && we_session.we_session) { |
| | | get_option.params.key = we_session.we_session |
| | | get_option.params.mpToken = we_session.we_session |
| | | } |
| | | } |
| | | return get_option |
| | | function getChangeRequestOption(get_option) { |
| | | get_option = xioFn.httpOptionMd5Handle(get_option) |
| | | if (!get_option.udData || !get_option.udData.nokey) { |
| | | if (!get_option.params) { |
| | | get_option.params = {} |
| | | } |
| | | // 补充参数 |
| | | // 需要 we_session |
| | | var we_session = fn.getLocalStorage('we_session') |
| | | if (we_session && we_session.we_session) { |
| | | get_option.params.key = we_session.we_session |
| | | get_option.params.mpToken = we_session.we_session |
| | | } |
| | | } |
| | | return get_option |
| | | } |
| | | // 请求前处理参数 - post |
| | | function postChangeRequestOption (post_option) { |
| | | if (!post_option.udData || !post_option.udData.nokey) { |
| | | if (!post_option.data) { |
| | | post_option.data = {} |
| | | } |
| | | // 补充参数 |
| | | // 需要 we_session |
| | | var we_session = fn.getLocalStorage('we_session') |
| | | if (we_session && we_session.we_session) { |
| | | post_option.data.key = we_session.we_session |
| | | post_option.data.mpToken = we_session.we_session |
| | | } |
| | | } |
| | | return post_option |
| | | function postChangeRequestOption(post_option) { |
| | | // console.log('============================>', post_option) |
| | | // adminToken |
| | | // var adminToken = fn.getSessionStorage('adminToken') |
| | | // var urlEncodes = {} |
| | | // if (adminToken && (!post_option.udData || !post_option.udData.nokey)) { |
| | | // urlEncodes = { adminToken: adminToken, mpToken: adminToken } |
| | | // } |
| | | // // // 将请求参数放到链接后面 |
| | | // var paramsUrl = urlEncode(urlEncodes) |
| | | // if (!/\?/.test(post_option.url)) { |
| | | // paramsUrl = paramsUrl.replace('&', '?') |
| | | // } |
| | | // post_option.url = post_option.url + paramsUrl |
| | | |
| | | // 请求头md5处理 |
| | | post_option = xioFn.httpOptionMd5Handle(post_option) |
| | | if (!post_option.udData || !post_option.udData.nokey) { |
| | | if (!post_option.data) { |
| | | post_option.data = {} |
| | | } |
| | | // 补充参数 |
| | | // 需要 we_session |
| | | var we_session = fn.getLocalStorage('we_session') |
| | | if (we_session && we_session.we_session) { |
| | | post_option.data.key = we_session.we_session |
| | | post_option.data.mpToken = we_session.we_session |
| | | } |
| | | } |
| | | return post_option |
| | | } |
| | | |
| | | var httpEventCode = { |
| | | code200 (data) { |
| | | // console.log(data, 200) |
| | | }, |
| | | code404 (data, url) { |
| | | // element-ui |
| | | // Message.error('无法访问接口,状态404:' + url) |
| | | }, |
| | | code500 (data, url) { |
| | | // element-ui |
| | | // Message.error('请求失败,状态500:' + url) |
| | | } |
| | | code200() { |
| | | // console.log(data, 200) |
| | | }, |
| | | code404(_url) { |
| | | // element-ui |
| | | // Message.error('无法访问接口,状态404:' + url) |
| | | }, |
| | | code500(_data, __url) { |
| | | // element-ui |
| | | // Message.error('请求失败,状态500:' + url) |
| | | } |
| | | } |
| | | |
| | | var g_login_counter = 0 // 登录请求次数 |
| | |
| | | var g_flag_config_requested = false // 其余配置请求 |
| | | var g_config_result = null // 配置请求返回 |
| | | // 请求前 |
| | | function beforeRequest (res) { |
| | | // 开启loading |
| | | if (!g_flag_loading && (!res.request_option.udData || !res.request_option.udData.noLoading)) { |
| | | res.http_option.debug && console.log('jun_httpEvent beforeRequest loading') |
| | | // wx.showLoading({ |
| | | // title: '加载中', |
| | | // mask: true |
| | | // }) |
| | | // loading |
| | | startLoading(res.request_option) |
| | | g_flag_loading = true |
| | | } |
| | | function beforeRequest(res) { |
| | | // 开启loading |
| | | if (!g_flag_loading && (!res.request_option.udData || !res.request_option.udData.noLoading)) { |
| | | res.http_option.debug && console.log('jun_httpEvent beforeRequest loading') |
| | | // wx.showLoading({ |
| | | // title: '加载中', |
| | | // mask: true |
| | | // }) |
| | | // loading |
| | | startLoading(res.request_option) |
| | | g_flag_loading = true |
| | | } |
| | | |
| | | // 重置登录请求标记 |
| | | var we_session = fn.getLocalStorage('we_session') |
| | | if (we_session && we_session.we_session) { |
| | | g_flag_login_requested = false |
| | | } |
| | | // 重置登录请求标记 |
| | | var we_session = fn.getLocalStorage('we_session') |
| | | if (we_session && we_session.we_session) { |
| | | g_flag_login_requested = false |
| | | } |
| | | } |
| | | |
| | | // 请求后 |
| | | function afterRequest (res) { |
| | | // console.log('请求后') |
| | | function afterRequest(_res) { |
| | | // console.log('请求后') |
| | | } |
| | | |
| | | // 处理返回数据 |
| | | // @return {Object} 处理过的数据 |
| | | function successChangeData (res) { |
| | | return res |
| | | function successChangeData(res) { |
| | | return res |
| | | } |
| | | |
| | | // 批量请求完成 |
| | | function afterMultiRequests (request_option) { |
| | | // console.log("多个请求结束之后") |
| | | // 关闭loading |
| | | if (g_flag_loading) { |
| | | // wx.hideLoading() |
| | | endLoading(request_option) |
| | | g_flag_loading = false |
| | | } |
| | | function afterMultiRequests(request_option) { |
| | | // console.log("多个请求结束之后") |
| | | // 关闭loading |
| | | if (g_flag_loading) { |
| | | // wx.hideLoading() |
| | | endLoading(request_option) |
| | | g_flag_loading = false |
| | | } |
| | | } |
| | | |
| | | function updateKey (res, key) { |
| | | // 更新 key 值 |
| | | if (res.request_option.method === 'GET' && (!res.request_option.udData || !res.request_option.udData.nokey)) { |
| | | res.request_option.url = res.request_option.url.replace(/mpToken=[^&]*/g, `mpToken=${key}`) |
| | | } |
| | | if (res.request_option.method === 'POST' && (!res.request_option.udData || !res.request_option.udData.nokey)) { |
| | | res.request_option.data.mpToken = key |
| | | } |
| | | return res |
| | | function updateKey(res, key) { |
| | | // 更新 key 值 |
| | | if (res.request_option.method === 'GET' && (!res.request_option.udData || !res.request_option.udData.nokey)) { |
| | | res.request_option.url = res.request_option.url.replace(/mpToken=[^&]*/g, `mpToken=${key}`) |
| | | } |
| | | if (res.request_option.method === 'POST' && (!res.request_option.udData || !res.request_option.udData.nokey)) { |
| | | res.request_option.data.mpToken = key |
| | | } |
| | | return res |
| | | } |
| | | |
| | | // 模拟数据处理流程 |
| | | function mockFlow (res) { |
| | | return new Promise(async (resolve, reject) => { |
| | | // 打印请求信息 |
| | | res.http_option.debug && console.log('模拟请求', res.request_option) |
| | | function mockFlow(res) { |
| | | return new Promise(async(resolve, _reject) => { |
| | | // 打印请求信息 |
| | | res.http_option.debug && console.log('模拟请求', res.request_option) |
| | | |
| | | var mockData = res.request_option.mockData || {code: 100, data: {}, message: 'success'} |
| | | var mockData = res.request_option.mockData || { code: 100, data: {}, message: 'success' } |
| | | |
| | | // 打印返回信息 |
| | | res.http_option.debug && console.log('模拟返回', {data: mockData}) |
| | | res.http_option.debug && console.log('开始模拟等待800ms') |
| | | var timer = setTimeout(()=>{ |
| | | clearTimeout(timer) |
| | | // 关闭loading |
| | | if (g_flag_loading) { |
| | | // wx.hideLoading() |
| | | endLoading(res.request_option) |
| | | g_flag_loading = false |
| | | } |
| | | res.http_option.debug && console.log('结束模拟等待800ms') |
| | | if (res.request_option.udData && res.request_option.fullData) { |
| | | resolve({data: mockData}) |
| | | } else { |
| | | resolve(mockData) |
| | | } |
| | | }, 800) |
| | | }) |
| | | // 打印返回信息 |
| | | res.http_option.debug && console.log('模拟返回', { data: mockData }) |
| | | res.http_option.debug && console.log('开始模拟等待800ms') |
| | | var timer = setTimeout(() => { |
| | | clearTimeout(timer) |
| | | // 关闭loading |
| | | if (g_flag_loading) { |
| | | // wx.hideLoading() |
| | | endLoading(res.request_option) |
| | | g_flag_loading = false |
| | | } |
| | | res.http_option.debug && console.log('结束模拟等待800ms') |
| | | if (res.request_option.udData && res.request_option.fullData) { |
| | | resolve({ data: mockData }) |
| | | } else { |
| | | resolve(mockData) |
| | | } |
| | | }, 800) |
| | | }) |
| | | } |
| | | |
| | | // 请求前处理流程 |
| | | function beforeFlow (res) { |
| | | return new Promise(async (resolve, reject) => { |
| | | // 预留请求前处理 |
| | | // 设置为true,下次处理跳过 beforeFlow,避免死循环 |
| | | res.request_option.skip_before_flow = true |
| | | // 再次请求 |
| | | resolve(res.Request(res.request_option)) |
| | | }) |
| | | function beforeFlow(res) { |
| | | return new Promise(async(resolve) => { |
| | | // 预留请求前处理 |
| | | // 设置为true,下次处理跳过 beforeFlow,避免死循环 |
| | | res.request_option.skip_before_flow = true |
| | | // 再次请求 |
| | | resolve(res.Request(res.request_option)) |
| | | }) |
| | | } |
| | | |
| | | // 预留其余处理 |
| | | function configRequest(){ |
| | | return new Promise((resolve, reject) => { |
| | | resolve({}) |
| | | }) |
| | | function configRequest() { |
| | | return new Promise((resolve, reject) => { |
| | | resolve({}) |
| | | }) |
| | | } |
| | | |
| | | // 登录处理 |
| | | function appLogin (option={}) { |
| | | return new Promise((resolve, reject) => { |
| | | // Login.checkLogin({ |
| | | // force: !!option.forceLogin, |
| | | // callback: (key)=>{ |
| | | // resolve(key) |
| | | // } |
| | | // }) |
| | | Login.toLongUrl() |
| | | }) |
| | | function appLogin(option = {}) { |
| | | return new Promise((resolve, reject) => { |
| | | // Login.checkLogin({ |
| | | // force: !!option.forceLogin, |
| | | // callback: (key)=>{ |
| | | // resolve(key) |
| | | // } |
| | | // }) |
| | | Login.toLongUrl() |
| | | }) |
| | | } |
| | | |
| | | // 请求后处理 |
| | | function afterFlow (res) { |
| | | return new Promise((resolve, reject)=>{ |
| | | var data = res.res.data |
| | | |
| | | // 登录超时 |
| | | if ( |
| | | (data && data.res && data.res.status == 2) |
| | | || (data && data.code == 603) |
| | | ) { |
| | | res.http_option.debug && console.log('登录超时,需要重新登录', res.res) |
| | | // 登录超时,需要重新登录 |
| | | // 清空we_session |
| | | // getApp().globalData.we_session = null |
| | | fn.removeLocalStorage('we_session') |
| | | resolve(retryLogin(res)) |
| | | return |
| | | } |
| | | function afterFlow(res) { |
| | | return new Promise((resolve, reject) => { |
| | | var data = res.res.data |
| | | // console.log('0000000000000000000', res) |
| | | // 登录超时 |
| | | if ( |
| | | (data && data.res && data.res.status == 2) || |
| | | (data && data.code == 603) |
| | | ) { |
| | | res.http_option.debug && console.log('登录超时,需要重新登录', res.res) |
| | | // 登录超时,需要重新登录 |
| | | // 清空we_session |
| | | // getApp().globalData.we_session = null |
| | | // fn.removeLocalStorage('we_session') |
| | | // resolve(retryLogin(res)) |
| | | // todo |
| | | // // 清空登录凭证和用户数据 |
| | | // sessionStorage.clear() |
| | | // // 未登录,跳转登录页面 |
| | | // this.$router.replace({ path: '/login' }) |
| | | return |
| | | } |
| | | |
| | | // status不为0 |
| | | if ( |
| | | (data && data.res && data.res.status != 0) |
| | | || (data && data.code != 100) |
| | | ) { |
| | | if (data.res) { |
| | | console.error('status不为0:' + (res.res.errMsg || ''), res.res) |
| | | // 弹出提示 |
| | | // wx.showModal({ |
| | | // title: '请求提示', |
| | | // content: data.res.errMsg || `请求有误,status=${data.res.status}`, |
| | | // confirmText: '确定', |
| | | // confirmColor: '#576B95', |
| | | // showCancel: false |
| | | // }) |
| | | |
| | | // element-ui |
| | | // Message.error(data.res.errMsg || `请求有误,status=${data.res.status}`) |
| | | |
| | | // 根据status处理 |
| | | if (typeof resStatusCode['status' + data.res.status] === 'function') { |
| | | resStatusCode['status' + data.res.status](data) |
| | | } |
| | | } |
| | | // status不为0 |
| | | if ( |
| | | (data && data.res && data.res.status != 0) || |
| | | (data && data.code != 100) |
| | | ) { |
| | | if (data.res) { |
| | | console.error('status不为0:' + (res.res.errMsg || ''), res.res) |
| | | // 弹出提示 |
| | | // wx.showModal({ |
| | | // title: '请求提示', |
| | | // content: data.res.errMsg || `请求有误,status=${data.res.status}`, |
| | | // confirmText: '确定', |
| | | // confirmColor: '#576B95', |
| | | // showCancel: false |
| | | // }) |
| | | |
| | | if (typeof data.code !== 'undefined') { |
| | | console.error('code不为100:' + data.code, data.msg, res.res) |
| | | } |
| | | // element-ui |
| | | // Message.error(data.res.errMsg || `请求有误,status=${data.res.status}`) |
| | | |
| | | reject(res.res) |
| | | return |
| | | } |
| | | |
| | | // 根据status处理 |
| | | if (typeof resStatusCode['status' + data.res.status] === 'function') { |
| | | resStatusCode['status' + data.res.status](data) |
| | | } |
| | | } |
| | | |
| | | // status为空 |
| | | if (data && !data.res && typeof data.code === 'undefined') { |
| | | console.error('status为空', res.res) |
| | | let tips = '' |
| | | if (res.res.statusCode=='500') { |
| | | tips = '当前网络状态不佳,请稍后再试:statusCode=500;' |
| | | } else if (res.res.statusCode=='200') { |
| | | if (typeof res.data === 'string') { |
| | | tips = filterHtml(res.data) |
| | | } |
| | | if (typeof res.data === 'object') { |
| | | tips = filterHtml(JSON.stringify(res.data)) |
| | | } |
| | | tips = '网络状况不佳,点击确定重试:statusCode=200;' + tips |
| | | } else { |
| | | tips = `连接服务器失败,点击确定重试:statusCode=${res.res.statusCode};` |
| | | } |
| | | // 请求提示 |
| | | if (typeof data.code !== 'undefined') { |
| | | console.error('code不为100:' + data.code, data.msg, res.res) |
| | | } |
| | | |
| | | // 小程序 |
| | | // wx.showModal({ |
| | | // title: '请求提示', |
| | | // content: tips, |
| | | // confirmText: '确定', |
| | | // confirmColor: '#576B95', |
| | | // showCancel: false, |
| | | // success (res) { |
| | | // if (res.confirm) { |
| | | // // 点击确认后重新请求 |
| | | // resolve(res.Request(res.request_option)) |
| | | // } |
| | | // } |
| | | // }) |
| | | reject(res.res) |
| | | return |
| | | } |
| | | |
| | | // element-ui |
| | | // MessageBox.alert(tips, '网络提示', { |
| | | // confirmButtonText: '确定', |
| | | // type: 'error' |
| | | // }).then(()=>{ |
| | | // resolve(res.Request(res.request_option)) |
| | | // }).catch(()=>{ |
| | | // // 点击取消 |
| | | // }) |
| | | return |
| | | } |
| | | // status为空 |
| | | if (data && !data.res && typeof data.code === 'undefined') { |
| | | console.error('status为空', res.res) |
| | | let tips = '' |
| | | if (res.res.statusCode == '500') { |
| | | tips = '当前网络状态不佳,请稍后再试:statusCode=500;' |
| | | } else if (res.res.statusCode == '200') { |
| | | if (typeof res.data === 'string') { |
| | | tips = filterHtml(res.data) |
| | | } |
| | | if (typeof res.data === 'object') { |
| | | tips = filterHtml(JSON.stringify(res.data)) |
| | | } |
| | | tips = '网络状况不佳,点击确定重试:statusCode=200;' + tips |
| | | } else { |
| | | tips = `连接服务器失败,点击确定重试:statusCode=${res.res.statusCode};` |
| | | } |
| | | // 请求提示 |
| | | |
| | | // 打印返回信息 |
| | | res.http_option.debug && console.log('返回', res.res) |
| | | if (res.request_option.udData) { |
| | | // 返回全部数据 |
| | | if (res.request_option.udData.fullData === true) { |
| | | resolve(res.res) |
| | | } |
| | | } |
| | | g_login_counter && (g_login_counter = 0) |
| | | resolve(data) |
| | | }) |
| | | // 小程序 |
| | | // wx.showModal({ |
| | | // title: '请求提示', |
| | | // content: tips, |
| | | // confirmText: '确定', |
| | | // confirmColor: '#576B95', |
| | | // showCancel: false, |
| | | // success (res) { |
| | | // if (res.confirm) { |
| | | // // 点击确认后重新请求 |
| | | // resolve(res.Request(res.request_option)) |
| | | // } |
| | | // } |
| | | // }) |
| | | |
| | | // element-ui |
| | | // MessageBox.alert(tips, '网络提示', { |
| | | // confirmButtonText: '确定', |
| | | // type: 'error' |
| | | // }).then(()=>{ |
| | | // resolve(res.Request(res.request_option)) |
| | | // }).catch(()=>{ |
| | | // // 点击取消 |
| | | // }) |
| | | return |
| | | } |
| | | |
| | | // 打印返回信息 |
| | | res.http_option.debug && console.log('返回', res.res) |
| | | if (res.request_option.udData) { |
| | | // 返回全部数据 |
| | | if (res.request_option.udData.fullData === true) { |
| | | resolve(res.res) |
| | | } |
| | | } |
| | | g_login_counter && (g_login_counter = 0) |
| | | resolve(data) |
| | | }) |
| | | } |
| | | |
| | | // 重新登录 |
| | | async function retryLogin (res) { |
| | | // 次数+1 |
| | | g_login_counter++ |
| | | return new Promise(async (resolve, reject) => { |
| | | // 等待登录 |
| | | var login_result = await appLogin({forceLogin: true}) |
| | | // 登录失败 |
| | | if (!login_result && g_login_counter < g_LOGIN_MAX) { |
| | | // 2秒后重试 |
| | | var timer = setTimeout(()=>{ |
| | | clearTimeout(timer) |
| | | resolve(retryLogin(res)) |
| | | }, 2000) |
| | | } |
| | | // 登录成功 |
| | | if (login_result) { |
| | | // 更新key值 |
| | | res = updateKey(res, login_result) |
| | | // 再次请求 |
| | | resolve(res.Request(res.request_option)) |
| | | } |
| | | }) |
| | | async function retryLogin(res) { |
| | | // 次数+1 |
| | | g_login_counter++ |
| | | return new Promise(async(resolve, _reject) => { |
| | | // 等待登录 |
| | | var login_result = await appLogin({ forceLogin: true }) |
| | | // 登录失败 |
| | | if (!login_result && g_login_counter < g_LOGIN_MAX) { |
| | | // 2秒后重试 |
| | | var timer = setTimeout(() => { |
| | | clearTimeout(timer) |
| | | resolve(retryLogin(res)) |
| | | }, 2000) |
| | | } |
| | | // 登录成功 |
| | | if (login_result) { |
| | | // 更新key值 |
| | | res = updateKey(res, login_result) |
| | | // 再次请求 |
| | | resolve(res.Request(res.request_option)) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | export default { |
| | | httpEventCode, |
| | | |
| | | getChangeRequestOption, |
| | | postChangeRequestOption, |
| | | successChangeData, |
| | | httpEventCode, |
| | | |
| | | beforeRequest, |
| | | afterRequest, |
| | | afterMultiRequests, |
| | | getChangeRequestOption, |
| | | postChangeRequestOption, |
| | | successChangeData, |
| | | |
| | | mockFlow, |
| | | beforeFlow, |
| | | afterFlow, |
| | | } |
| | | beforeRequest, |
| | | afterRequest, |
| | | afterMultiRequests, |
| | | |
| | | mockFlow, |
| | | beforeFlow, |
| | | afterFlow |
| | | } |
New file |
| | |
| | | /* |
| | | * @Author: xio |
| | | * @Date: 2023-12-06 12:06:00 |
| | | * @Last Modified by: xio |
| | | * @Last Modified time: 2023-12-06 12:06:00 |
| | | */ |
| | | // 通用function,通过全局安装,或import引用调用 |
| | | import config from '../config' // 域名配置 |
| | | import md5 from 'js-md5' |
| | | // 基础配置 - 获取当前环境 |
| | | var ismock = config.ismock |
| | | var isTestView = config.isTestView |
| | | var fn_obj = {}// fn.js对象 |
| | | var APPID, SECRET |
| | | if (isTestView) { |
| | | APPID = 'phi123' |
| | | SECRET = 'test123' |
| | | } else { |
| | | APPID = 'phiwyrnujZPOBRaGs' |
| | | SECRET = 'TmUlZWaBLQdbdpiDwMKUAjHwKdnkXMyQ' |
| | | } |
| | | /** |
| | | * 生成唯一id |
| | | */ |
| | | function uuid() { |
| | | var s = [] |
| | | var hexDigits = '0123456789abcdef' |
| | | for (var i = 0; i < 36; i++) { |
| | | s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1) |
| | | } |
| | | s[14] = '4' |
| | | s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1) |
| | | |
| | | s[8] = s[13] = s[18] = s[23] = '-' |
| | | var uuid = s.join('') |
| | | return uuid |
| | | } |
| | | |
| | | /** |
| | | * 请求参数md5加密处理 |
| | | * @param {Object} option 请求对象 |
| | | */ |
| | | function httpOptionMd5Handle(option) { |
| | | var timestamp = new Date().getTime() |
| | | var sign, params |
| | | // 参数处理 |
| | | params = JSON.stringify(option.data) |
| | | // if (params === '{}') { |
| | | // params = '' |
| | | // } |
| | | // 非mock模式 |
| | | if (option && !ismock) { |
| | | option.header[`appId`] = APPID |
| | | option.header[`timestamp`] = timestamp |
| | | // 签名大写 |
| | | sign = md5(`${APPID}${timestamp}${params}${SECRET}`).toUpperCase() |
| | | option.header[`sign`] = sign |
| | | } |
| | | console.log('==============================>', option, params, sign) |
| | | return option |
| | | } |
| | | |
| | | var fn = { |
| | | uuid, |
| | | httpOptionMd5Handle, |
| | | /** |
| | | * 深拷贝 |
| | | * @param {object} obj 被复制的对象 |
| | | * @return {object} 复制完成的对象 |
| | | */ |
| | | deepCopyFN(obj) { |
| | | if (typeof obj !== 'object') { |
| | | return obj |
| | | } |
| | | |
| | | let cloneObj = {} |
| | | switch (obj.constructor) { |
| | | case Array: |
| | | cloneObj = [] |
| | | // eslint-disable-next-line no-fallthrough |
| | | case Object: |
| | | for (var property in obj) { |
| | | cloneObj[property] = typeof obj[property] === 'object' ? this.deepCopyFN(obj[property]) : obj[property] |
| | | } |
| | | break |
| | | case Map: |
| | | cloneObj = new Map() |
| | | obj.forEach((value, key) => { |
| | | cloneObj.set(key, typeof value === 'object' ? this.deepCopyFN(value) : value) |
| | | }) |
| | | break |
| | | case Set: |
| | | cloneObj = new Set() |
| | | obj.forEach(value => { |
| | | cloneObj.add(typeof value === 'object' ? this.deepCopyFN(value) : value) |
| | | }) |
| | | break |
| | | } |
| | | return cloneObj |
| | | } |
| | | } |
| | | export default fn |