From 105f9eafa28696f86198650d342fc4875aa37179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=90=A6?= Date: Mon, 1 Jun 2026 09:52:26 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B5=E9=9D=A2UI=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/AssistantConsultationShell.vue | 60 +- request/api/api.js | 21 +- request/api/request.js | 6 + subPackages/chat/chat.vue | 58 +- subPackages/follow-up/medication-info.vue | 11 + subPackages/my/my-drug/drug-info.vue | 28 +- subPackages/my/my-drug/drug-list.vue | 1495 +++++++++-------- subPackages/my/mystore.vue | 368 ++-- subPackages/my/record-pay.vue | 28 +- subPackages/product/product.vue | 24 +- .../transfer/transfer-consultation.vue | 11 + 11 files changed, 1250 insertions(+), 860 deletions(-) diff --git a/components/AssistantConsultationShell.vue b/components/AssistantConsultationShell.vue index 214ed4f..49a8532 100644 --- a/components/AssistantConsultationShell.vue +++ b/components/AssistantConsultationShell.vue @@ -1,7 +1,7 @@ @@ -60,131 +100,175 @@ storeInfo, storeList } from '../../request/api/api' + import { isGuestMode } from '@/common/utils/auth.js' + export default { data() { return { - isshow: false, storeinfo: [], - infoList: [], - headerTitle: "", // 标题 + infoList: { + store: null + }, + headerTitle: '', + tabIndex: 0, + tabChanging: false, + tabList: [ + { name: '诊所' }, + { name: '药店' } + ], } }, - onLoad() { - // this.getStore(); - }, created() { this.getStore(); this.getInfo(); }, onReady() { - this.getStore(); uni.setNavigationBarTitle({ title: this.headerTitle, - success() { - console.log('success'); - } }); uni.setNavigationBarColor({ - frontColor: '#000000', //前景颜色值,包括按钮、标题、状态栏的颜色,仅支持 #ffffff 和 #000000 + frontColor: '#000000', }) }, methods: { - // 切换门店 - toChang(e) { - // console.log(e, 'id'); - storeChange({ - method: "post", - data: { - store_id: e + parseApiData(res) { + if (res.data.code === 0 || res.data.code === '0') { + return res.data.result; + } + if (res.data.errcode === 0 || res.data.errcode === '0') { + return res.data.data; + } + return null; + }, + isApiSuccess(res) { + return (res.data.code === 0 || res.data.code === '0') + || (res.data.errcode === 0 || res.data.errcode === '0'); + }, + getStoreTypeLabel(type) { + return (type === 1 || type === '1') ? '药店' : '诊所'; + }, + getStoreTypeTag(type) { + return (type === 1 || type === '1') ? 'success' : 'primary'; + }, + getFilteredStores(tabIdx) { + return this.storeinfo.filter((item) => { + if (!item.store) return false; + const storeType = item.store.type; + return tabIdx === 1 + ? (storeType === 1 || storeType === '1') + : (storeType === 0 || storeType === '0'); + }); + }, + isCurrentStore(storeId) { + const currentStoreId = this.infoList.store && this.infoList.store.id; + return currentStoreId && storeId === currentStoreId; + }, + onStoreItemClick(item) { + if (!item.store) return; + if (this.isCurrentStore(item.store.id)) { + uni.showToast({ + title: '当前已经在这个门店了', + icon: 'none', + duration: 2000 + }); + return; + } + this.toChang(item.store.id, item.store.type); + }, + setDefaultTabByStoreType(type) { + this.tabIndex = (type === 1 || type === '1') ? 1 : 0; + }, + onTabChange(index) { + if (this.tabChanging) return; + this.tabChanging = true; + this.tabIndex = index; + this.$nextTick(() => { + this.tabChanging = false; + }); + }, + onSwiperChange(e) { + if (this.tabChanging) return; + this.tabChanging = true; + this.tabIndex = e.detail.current; + this.$nextTick(() => { + this.tabChanging = false; + }); + }, + toChang(storeId, storeType) { + const token = uni.getStorageSync('token'); + if (!token || isGuestMode()) { + uni.setStorageSync('store_id', storeId); + uni.setStorageSync('stores_id', storeId); + if (storeType !== undefined && storeType !== null) { + uni.setStorageSync('store_type', storeType); } + uni.showToast({ + title: '切换成功', + duration: 2000, + icon: 'success' + }); + uni.switchTab({ url: '/pages/home/home' }); + return; + } + + storeChange({ + method: 'post', + data: { store_id: storeId } }).then((res) => { - if (res.data.errcode == 0) { - uni.setStorageSync('store_id', e) - uni.setStorageSync('stores_id', e) + if (this.isApiSuccess(res)) { + const data = this.parseApiData(res); + uni.setStorageSync('store_id', storeId); + uni.setStorageSync('stores_id', storeId); + const type = data && data.store ? data.store.type : storeType; + if (type !== undefined && type !== null) { + uni.setStorageSync('store_type', type); + } uni.showToast({ title: '切换成功', duration: 2000, - icon: "success" + icon: 'success' }); - // uni.removeStorageSync('stores_id') - // setTimeout(() => { - // uni.switchTab({ - // url: '/pages/home/home' - // }) - // }, 2000) - - uni.switchTab({ - url: '/pages/home/home' - }) + uni.switchTab({ url: '/pages/home/home' }); } - }) - - this.getStore(); + }); }, - - // 门店列表 getStore() { storeList({ - method: "post", + method: 'post', data: { - store_id: 11001 + store_id: uni.getStorageSync('store_id') || '11001' } }).then((res) => { - // console.log(res, 'list'); - if (res.data.errcode == 0) { - this.storeinfo = res.data.data.list + if (this.isApiSuccess(res)) { + const data = this.parseApiData(res); + if (data && data.list) { + this.storeinfo = data.list; + } } - }) + }); }, - - // 门店信息 getInfo() { storeInfo({ - method: "post", + method: 'post', data: { store_id: uni.getStorageSync('store_id') || '11001', } }).then((res) => { - // console.log(res, 'info'); - if (res.data.errcode == 0) { - this.infoList = res.data.data - this.headerTitle = this.infoList.store['name'] - uni.setNavigationBarTitle({ - title: this.headerTitle, - success() { - console.log(3333); - } - }); - uni.setNavigationBarColor({ - frontColor: '#000000', //前景颜色值,包括按钮、标题、状态栏的颜色,仅支持 #ffffff 和 #000000 - }) + if (this.isApiSuccess(res)) { + const data = this.parseApiData(res); + if (data && data.store) { + this.infoList = data; + this.headerTitle = data.store.name; + this.setDefaultTabByStoreType(data.store.type); + uni.setNavigationBarTitle({ + title: this.headerTitle, + }); + uni.setNavigationBarColor({ + frontColor: '#000000', + }); + } } - }) - }, - }, - mounted() { - // this.getStore(); - }, - onShow() { - // this.getStore(); - }, - onUnload() { - // uni.removeStorageSync('store_id') - }, - filters: { - //过滤器 用于格式化时间 - dateFormat: function(value) { - var date = new Date(value * 1000); //时间戳为10位需*1000,时间戳为13位的话不需乘1000 - var year = date.getFullYear(); - var month = ("0" + (date.getMonth() + 1)).slice(-2); - var sdate = ("0" + date.getDate()).slice(-2); - var hour = ("0" + date.getHours()).slice(-2); - var minute = ("0" + date.getMinutes()).slice(-2); - var second = ("0" + date.getSeconds()).slice(-2); - // 拼接 - var result = hour + ":" + minute //+ ":" + second; - // 返回 - return result; + }); }, }, } @@ -193,30 +277,38 @@ \ No newline at end of file + diff --git a/subPackages/my/record-pay.vue b/subPackages/my/record-pay.vue index b386cdb..3e76f28 100644 --- a/subPackages/my/record-pay.vue +++ b/subPackages/my/record-pay.vue @@ -604,7 +604,6 @@ let that = this if (this.flag) { this.flag = false - // 获取支付配置 getPayConfig({ method: "post", data: { @@ -647,30 +646,20 @@ }, 300) }, fail: function(err) { - that.flag = false + that.flag = true console.log('fail:' + JSON.stringify(err)); uni.hideLoading(); uni.showToast({ - title: '支付失败', + title: err.errMsg && err.errMsg.indexOf('cancel') !== -1 ? '支付已取消' : '支付失败', duration: 1500, mask: false, - icon: 'error' + icon: 'none' }) - setTimeout(() => { - if (res.data.msg) { - uni.showToast({ - title: res.data.msg, - duration: 1500, - mask: false, - icon: 'error' - }) - return - } - }, 1000) } }) } else { uni.hideLoading(); + that.flag = true this.$refs.uToast.show({ title: res.data.msg, type: 'default', @@ -678,6 +667,15 @@ }) } + }).catch((err) => { + console.error('getPayConfig error:', err); + uni.hideLoading(); + that.flag = true + uni.showToast({ + title: '获取支付配置失败', + icon: 'none', + duration: 1500 + }) }) } diff --git a/subPackages/product/product.vue b/subPackages/product/product.vue index dc06224..d69eb1e 100644 --- a/subPackages/product/product.vue +++ b/subPackages/product/product.vue @@ -39,7 +39,11 @@ - + @@ -185,6 +189,7 @@ export default { homeZones: [], selectedZoneIndex: 0, selectedZoneType: 'otc', + zoneTouch: { startX: 0, startY: 0 }, // 分类相关 categoryList: [], @@ -296,10 +301,25 @@ export default { this.selectedZoneIndex = index; this.selectedZoneType = this.homeZones[index]?.type || 'otc'; this.selectedCategoryId = 0; - // 重新获取分类和商品 this.getCategoryList(); }, + onZoneTouchStart(e) { + const touch = e.touches[0] || e.changedTouches[0]; + if (!touch) return; + this.zoneTouch.startX = touch.clientX; + this.zoneTouch.startY = touch.clientY; + }, + + onZoneTouchEnd(e) { + const dx = e.changedTouches[0].clientX - this.zoneTouch.startX; + const dy = e.changedTouches[0].clientY - this.zoneTouch.startY; + if (Math.abs(dx) < 60 || Math.abs(dx) < Math.abs(dy)) return; + const next = dx < 0 ? this.selectedZoneIndex + 1 : this.selectedZoneIndex - 1; + if (next < 0 || next >= this.homeZones.length) return; + this.onZoneChange(next); + }, + // 分类选择 selectCategory(categoryId) { this.selectedCategoryId = categoryId; diff --git a/subPackages/transfer/transfer-consultation.vue b/subPackages/transfer/transfer-consultation.vue index 8227edf..7fdbfd4 100644 --- a/subPackages/transfer/transfer-consultation.vue +++ b/subPackages/transfer/transfer-consultation.vue @@ -196,6 +196,13 @@ export default { this.loadAssistantConfig() this.loadAgreementInfo() }, + onBackPress() { + if (this.showAgreement) { + this.showAgreement = false + return true + } + return false + }, methods: { // 加载转诊详情(获取药品信息) async loadTransferDetail() { @@ -448,6 +455,10 @@ export default { }, // 返回 handleBack() { + if (this.showAgreement) { + this.showAgreement = false + return + } uni.showModal({ title: '提示', content: '确定要退出咨询吗?未完成的回答将不会保存。',