From 6da3c1365a9f54c043a4ec2547163b1226e11412 Mon Sep 17 00:00:00 2001 From: jazz <jazzxhunter@163.com> Date: 星期三, 06 十二月 2023 20:01:51 +0800 Subject: [PATCH] update_202312052001_项目-治疗室屏幕web-切图接口对接v2 --- src/utils/jun_httpEvent.js | 581 +++++++++++++++++--------------- src/utils/xio_fn.js | 102 +++++ src/components/xio_room_status_chg/index.vue | 12 package-lock.json | 6 config/index.js | 3 src/assets/css/common.css | 4 src/components/xio_customer_select/index.vue | 12 src/pages/room/list.vue | 78 ++++ package.json | 1 src/utils/jun_http.js | 36 +- src/router/index.js | 4 src/pages/room/detail.vue | 225 +++++++++-- 12 files changed, 701 insertions(+), 363 deletions(-) diff --git a/config/index.js b/config/index.js index 6a3d140..e044b51 100644 --- a/config/index.js +++ b/config/index.js @@ -23,7 +23,8 @@ }, '/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/', // 鏂伴绾his鍚庡彴 // target: 'http://hymctest.huoxiongit.com/',// 杩欎釜鏄綘鏈嶅姟鍣ㄥ紑鍚殑鎺ュ彛 changeOrigin: true,// 鏄惁璺ㄥ煙 pathRewrite: { diff --git a/package-lock.json b/package-lock.json index de3367c..c5857c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "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", @@ -7904,6 +7905,11 @@ "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", diff --git a/package.json b/package.json index 2456f98..4ce3306 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "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", diff --git a/src/assets/css/common.css b/src/assets/css/common.css index 021caf0..dd7193b 100644 --- a/src/assets/css/common.css +++ b/src/assets/css/common.css @@ -215,6 +215,10 @@ min-height: 100px; } +.page_header .left { + cursor: pointer; +} + .page_logo_1 { width: 50px; height: 45px; diff --git a/src/components/xio_customer_select/index.vue b/src/components/xio_customer_select/index.vue index 4c6dfbe..ff560fd 100644 --- a/src/components/xio_customer_select/index.vue +++ b/src/components/xio_customer_select/index.vue @@ -1,14 +1,14 @@ <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">娌荤枟椤圭洰锛歱his-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"> @@ -42,7 +42,7 @@ }, // 鎻愪氦 submit() { - this.$emit('submit', {}) + this.$emit('submit', this.dialogData) }, noop() { return diff --git a/src/components/xio_room_status_chg/index.vue b/src/components/xio_room_status_chg/index.vue index 208e4d2..0bba5ad 100644 --- a/src/components/xio_room_status_chg/index.vue +++ b/src/components/xio_room_status_chg/index.vue @@ -5,13 +5,13 @@ <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> @@ -19,13 +19,13 @@ </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> @@ -57,8 +57,8 @@ return }, // 鏇存崲鐘舵�� - changeStatus(tx) { - this.$emit('changeStatus', { statusTx: tx }) + changeStatus(tx, status) { + this.$emit('changeStatus', { statusTx: tx, status: status * 1 }) }, // 鏄剧ず寮圭獥 showDialog() { diff --git a/src/pages/room/detail.vue b/src/pages/room/detail.vue index e0101a0..fec7abc 100644 --- a/src/pages/room/detail.vue +++ b/src/pages/room/detail.vue @@ -1,8 +1,8 @@ <!--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> @@ -17,31 +17,31 @@ </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> @@ -51,16 +51,16 @@ </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"> @@ -68,18 +68,18 @@ <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"> @@ -90,22 +90,22 @@ </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"> @@ -114,25 +114,25 @@ <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 瓒匳鍏夈�乸his-琛ユ按瀚╄偆(F)娑傛姽</div> + <div class="tx">{{ occupyInfoView.projectName || '' }}</div> </div> </div> </div> @@ -140,18 +140,18 @@ <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"> @@ -170,11 +170,17 @@ </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: { @@ -184,12 +190,31 @@ inject: ['noop'], data() { return { - list: ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], - timeObj: {}// week锛氭槦鏈燂紝date锛氬勾鏈堟棩锛宼imeMin锛氭椂鍒嗭紝time锛氭椂鍒嗙锛宼imeStamp锛氭椂闂存埑 + id: this.$route.query.id || '', + roomInfo: {}, + occupyInfo: '', // 褰撳墠鍗犵敤浜虹殑淇℃伅 + assignTreatList: [], + statusTx: ['绌洪棽', '浣跨敤涓�', '瀹汉浼戞伅', '鎵撴壂涓�'], + timeObj: {} // week锛氭槦鏈燂紝date锛氬勾鏈堟棩锛宼imeMin锛氭椂鍒嗭紝time锛氭椂鍒嗙锛宼imeStamp锛氭椂闂存埑 } }, 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') @@ -200,13 +225,95 @@ }, 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() { @@ -215,14 +322,23 @@ }, // 鏇存敼鎴块棿鐘舵�� 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) }, // 閫夋嫨瀹㈡埛鍙栨秷 @@ -233,7 +349,12 @@ // 閫夋嫨瀹㈡埛纭畾 selectCustomerSubmit(opt) { console.log('submit', opt) - this.$refs['XioCustomerSelect'].hideDialog() + this.changeStatusFn(opt, 1, () => { + // 鍒锋柊璇︽儏 + this.getData() + // 鍏抽棴寮圭獥 + this.$refs['XioCustomerSelect'].hideDialog() + }) } } } @@ -250,6 +371,7 @@ font-size: 24px; text-align: center; font-family: Microsoft Yahei; + cursor: pointer; } .page_container .main { height: 100%; @@ -292,6 +414,7 @@ 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; diff --git a/src/pages/room/list.vue b/src/pages/room/list.vue index a7e191e..f88839d 100644 --- a/src/pages/room/list.vue +++ b/src/pages/room/list.vue @@ -7,6 +7,11 @@ <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> @@ -19,9 +24,13 @@ <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> @@ -31,14 +40,16 @@ <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锛氬勾鏈堟棩锛宼imeMin锛氭椂鍒嗭紝time锛氭椂鍒嗙锛宼imeStamp锛氭椂闂存埑 } }, @@ -55,6 +66,43 @@ 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() { @@ -64,13 +112,22 @@ }, 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%; @@ -106,9 +163,18 @@ 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> diff --git a/src/router/index.js b/src/router/index.js index 932b582..6c556fb 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -15,8 +15,8 @@ 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', diff --git a/src/utils/jun_http.js b/src/utils/jun_http.js index 71aca81..15ec604 100644 --- a/src/utils/jun_http.js +++ b/src/utils/jun_http.js @@ -1,7 +1,7 @@ /** * Http 璇锋眰 * * 灏忕▼搴忚浣跨敤澧炲己缂栬瘧 - * + * * 璋冪敤渚嬪瓙 * Req.http.post({ * url: '', @@ -12,24 +12,24 @@ import Axios from '../libs/axios' /* json杞琭ormdata锛堝簭鍒楀寲锛夛紝浠呮敮鎸佷竴绾у瓧闈㈤噺鍜屽瓧闈㈤噺鏁扮粍 */ -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('&') } /** diff --git a/src/utils/jun_httpEvent.js b/src/utils/jun_httpEvent.js index 6b25175..ff51b2f 100644 --- a/src/utils/jun_httpEvent.js +++ b/src/utils/jun_httpEvent.js @@ -1,6 +1,6 @@ /** * http浜嬩欢濮旀墭 - * + * * udData 璇存槑 * udData.noloading 涓嶉渶瑕佽姹� * udData.fullData 浣跨敤 reponse 杩斿洖鐨勫璞¤繘琛� success 鍥炶皟 锛坖un_http.js锛� @@ -11,13 +11,29 @@ 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, '') +} +// 瀵硅薄杞瑄rl鍙傛暟 +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 } /** @@ -39,65 +55,80 @@ // } // 寮�濮媗oading -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 + + // 璇锋眰澶磎d5澶勭悊 + 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 // 鐧诲綍璇锋眰娆℃暟 @@ -109,268 +140,272 @@ var g_flag_config_requested = false // 鍏朵綑閰嶇疆璇锋眰 var g_config_result = null // 閰嶇疆璇锋眰杩斿洖 // 璇锋眰鍓� -function beforeRequest (res) { - // 寮�鍚痩oading - 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) { + // 寮�鍚痩oading + 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) => { - // 棰勭暀璇锋眰鍓嶅鐞� - // 璁剧疆涓簍rue锛屼笅娆″鐞嗚烦杩� beforeFlow锛岄伩鍏嶆寰幆 - res.request_option.skip_before_flow = true - // 鍐嶆璇锋眰 - resolve(res.Request(res.request_option)) - }) +function beforeFlow(res) { + return new Promise(async(resolve) => { + // 棰勭暀璇锋眰鍓嶅鐞� + // 璁剧疆涓簍rue锛屼笅娆″鐞嗚烦杩� 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 || `璇锋眰鏈夎锛宻tatus=${data.res.status}`, - // confirmText: '纭畾', - // confirmColor: '#576B95', - // showCancel: false - // }) - - // element-ui - // Message.error(data.res.errMsg || `璇锋眰鏈夎锛宻tatus=${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 || `璇锋眰鏈夎锛宻tatus=${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 || `璇锋眰鏈夎锛宻tatus=${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 = `杩炴帴鏈嶅姟鍣ㄥけ璐ワ紝鐐瑰嚮纭畾閲嶈瘯锛歴tatusCode=${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 = `杩炴帴鏈嶅姟鍣ㄥけ璐ワ紝鐐瑰嚮纭畾閲嶈瘯锛歴tatusCode=${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, -} \ No newline at end of file + beforeRequest, + afterRequest, + afterMultiRequests, + + mockFlow, + beforeFlow, + afterFlow +} diff --git a/src/utils/xio_fn.js b/src/utils/xio_fn.js new file mode 100644 index 0000000..d5d0a9f --- /dev/null +++ b/src/utils/xio_fn.js @@ -0,0 +1,102 @@ +/* + * @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 = '' + // } + // 闈瀖ock妯″紡 + 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 -- Gitblit v1.8.0