1. 修复价格获取的bug,应该获取诊所|药店价格而不是总仓库的
This commit is contained in:
30
common/utils/drug.js
Normal file
30
common/utils/drug.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
export function isWesternRxDrug(drug) {
|
||||||
|
return drug && drug.type == 2 && (drug.is_otc === 0 || drug.is_otc === '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isHealthFood(drug) {
|
||||||
|
return drug && (drug.type == 3 || drug.category_type === 'health_food');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canShowFunction(drug, prescriptionApproved) {
|
||||||
|
if (isHealthFood(drug)) return false;
|
||||||
|
if (isWesternRxDrug(drug)) return !!prescriptionApproved;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canShowUsage(drug, prescriptionApproved) {
|
||||||
|
if (isHealthFood(drug)) return false;
|
||||||
|
if (isWesternRxDrug(drug)) return !!prescriptionApproved;
|
||||||
|
return drug && drug.type != 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canShowInstruction(drug, prescriptionApproved) {
|
||||||
|
if (isWesternRxDrug(drug)) return !!prescriptionApproved;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isPrescriptionApprovedStatus(data) {
|
||||||
|
if (!data) return false;
|
||||||
|
const ps = data.prescription_status ?? data.status;
|
||||||
|
return data.status === true || ps === 1 || ps === '1' || ps === 3 || ps === '3' || ps === 4 || ps === '4';
|
||||||
|
}
|
||||||
@@ -164,7 +164,7 @@
|
|||||||
<view class="prod-bottom">
|
<view class="prod-bottom">
|
||||||
<view class="price-box">
|
<view class="price-box">
|
||||||
<text class="price-symbol">¥</text>
|
<text class="price-symbol">¥</text>
|
||||||
<text>{{ item.price || (item.drug && item.drug.drugStoreDrug ? item.drug.drugStoreDrug.price : '0.00') }}</text>
|
<text>{{ item.price || '0.00' }}</text>
|
||||||
</view>
|
</view>
|
||||||
<!-- 简化点击事件,防止 template 编译错误 -->
|
<!-- 简化点击事件,防止 template 编译错误 -->
|
||||||
<view class="buy-btn" @click.stop="handleAddToCart(item)">
|
<view class="buy-btn" @click.stop="handleAddToCart(item)">
|
||||||
|
|||||||
@@ -371,8 +371,8 @@ export async function articleInfo(params) {
|
|||||||
|
|
||||||
// v1/product-order/list
|
// v1/product-order/list
|
||||||
export async function getOrdlist(params) {
|
export async function getOrdlist(params) {
|
||||||
let data = await http('/oldApi/v1/product-order/list', params)
|
let data = await http('/xkApi/product-order/list', params)
|
||||||
return data
|
return normalizeXkApiResponse(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// v1/product-order/list
|
// v1/product-order/list
|
||||||
|
|||||||
@@ -234,7 +234,15 @@ function request(url, params, method = 0) {
|
|||||||
|
|
||||||
// 加密
|
// 加密
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
|
if (!params.data) {
|
||||||
|
params.data = {};
|
||||||
|
}
|
||||||
params.data = getRes(params.data, false);
|
params.data = getRes(params.data, false);
|
||||||
|
const isProductApi = url.indexOf('/product/') !== -1;
|
||||||
|
if (isProductApi && !params.data.store_id) {
|
||||||
|
const localStoreId = uni.getStorageSync('store_id');
|
||||||
|
params.data.store_id = localStoreId || getGuestStoreId();
|
||||||
|
}
|
||||||
// 如果是guest模式,设置store_id(优先使用用户传入或本地存储的值)
|
// 如果是guest模式,设置store_id(优先使用用户传入或本地存储的值)
|
||||||
if (isGuestRequest && params.data) {
|
if (isGuestRequest && params.data) {
|
||||||
// 优先使用用户传入的 store_id
|
// 优先使用用户传入的 store_id
|
||||||
|
|||||||
@@ -251,6 +251,10 @@ export default {
|
|||||||
return ['是', '否'];
|
return ['是', '否'];
|
||||||
},
|
},
|
||||||
productPrice() {
|
productPrice() {
|
||||||
|
const rel = this.productDetail.drug_store_relations;
|
||||||
|
if (rel && rel.price) {
|
||||||
|
return parseFloat(rel.price);
|
||||||
|
}
|
||||||
if (this.productDetail.drug_store_drug && this.productDetail.drug_store_drug.price) {
|
if (this.productDetail.drug_store_drug && this.productDetail.drug_store_drug.price) {
|
||||||
return parseFloat(this.productDetail.drug_store_drug.price);
|
return parseFloat(this.productDetail.drug_store_drug.price);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="list_west" v-if="orderInfo.ProductOrder.prescription_type==2||orderInfo.ProductOrder.prescription_type==5||orderInfo.ProductOrder.prescription_type==7">
|
<view class="list_west" v-if="orderInfo.ProductOrder.prescription_type==2||orderInfo.ProductOrder.prescription_type==5||orderInfo.ProductOrder.prescription_type==7">
|
||||||
<view class="list" v-for="(item,index) in orderInfo.ProductOrderItems" :key="item.id">
|
<view class="list" v-for="(item,index) in orderInfo.ProductOrderItems" :key="item.id" @click.stop="goDrugDetail(item)">
|
||||||
<view class="img">
|
<view class="img">
|
||||||
<image :src="item.drug_image || 'https://xiaokang88.oss-cn-hangzhou.aliyuncs.com/xk-client-wx/static/empty/gwc.png'" mode=""></image>
|
<image :src="item.drug_image || 'https://xiaokang88.oss-cn-hangzhou.aliyuncs.com/xk-client-wx/static/empty/gwc.png'" mode=""></image>
|
||||||
</view>
|
</view>
|
||||||
@@ -80,13 +80,13 @@
|
|||||||
<text
|
<text
|
||||||
v-if="item.drug && item.drug.specification"
|
v-if="item.drug && item.drug.specification"
|
||||||
class="drug-spec">{{ item.drug.specification }}</text>
|
class="drug-spec">{{ item.drug.specification }}</text>
|
||||||
<text v-if="item.drug && item.drug.function">{{ item.drug.function }}</text>
|
<text v-if="item.drug && item.drug.function && canShowFunction(item.drug, prescriptionStatus)">{{ item.drug.function }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="it_info" v-if="orderInfo.ProductOrder.prescription_type==2 && item.drug">
|
<view class="it_info" v-if="orderInfo.ProductOrder.prescription_type==2 && item.drug && canShowUsage(item.drug, prescriptionStatus)">
|
||||||
{{ item.drug.usage }}
|
{{ item.drug.usage }}
|
||||||
</view>
|
</view>
|
||||||
<!-- 添加查看说明书按钮 -->
|
<!-- 添加查看说明书按钮 -->
|
||||||
<view class="instruction-btn" v-if="prescriptionStatus && item.drug && item.drug.instruction" @click="previewInstruction(item.drug.instruction)">
|
<view class="instruction-btn" v-if="canShowInstruction(item.drug, prescriptionStatus) && item.drug && item.drug.instruction" @click.stop="previewInstruction(item.drug.instruction)">
|
||||||
<text>查看说明书</text>
|
<text>查看说明书</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="it_price">
|
<view class="it_price">
|
||||||
@@ -185,6 +185,7 @@ import {
|
|||||||
import { getOrderTextApi } from '../../../request/api/product'
|
import { getOrderTextApi } from '../../../request/api/product'
|
||||||
// 导入订单相关接口
|
// 导入订单相关接口
|
||||||
import { getPrescriptionStatusApi } from '../../../request/api/order'
|
import { getPrescriptionStatusApi } from '../../../request/api/order'
|
||||||
|
import { canShowFunction, canShowUsage, canShowInstruction, isPrescriptionApprovedStatus } from '@/common/utils/drug'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@@ -265,6 +266,27 @@ export default {
|
|||||||
this.getOrderText();
|
this.getOrderText();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
canShowFunction,
|
||||||
|
canShowUsage,
|
||||||
|
canShowInstruction,
|
||||||
|
goDrugDetail(item) {
|
||||||
|
const drugId = item.drug_id || (item.drug && item.drug.id);
|
||||||
|
if (!drugId) return;
|
||||||
|
const orderStoreId = (this.orderInfo.ProductOrder && this.orderInfo.ProductOrder.store_id)
|
||||||
|
|| uni.getStorageSync('store_id')
|
||||||
|
|| '11001';
|
||||||
|
const q = [
|
||||||
|
`id=${encodeURIComponent(drugId)}`,
|
||||||
|
`store_id=${encodeURIComponent(orderStoreId)}`,
|
||||||
|
`order_id=${encodeURIComponent(this.order_id || '')}`,
|
||||||
|
`drug_name=${encodeURIComponent(item.drug_name || '')}`,
|
||||||
|
`image=${encodeURIComponent(item.drug_image || '')}`,
|
||||||
|
`price=${encodeURIComponent(item.price || '')}`,
|
||||||
|
].join('&');
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/subPackages/product/symptoms?${q}`,
|
||||||
|
});
|
||||||
|
},
|
||||||
// 获取订单提示文本
|
// 获取订单提示文本
|
||||||
getOrderText() {
|
getOrderText() {
|
||||||
getOrderTextApi().then((res) => {
|
getOrderTextApi().then((res) => {
|
||||||
@@ -628,8 +650,7 @@ export default {
|
|||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
if (res.data && (res.data.code == 0 || res.data.errcode == 0)) {
|
if (res.data && (res.data.code == 0 || res.data.errcode == 0)) {
|
||||||
const data = res.data.data || res.data.result || {};
|
const data = res.data.data || res.data.result || {};
|
||||||
const ps = data.prescription_status ?? data.status;
|
this.prescriptionStatus = isPrescriptionApprovedStatus(data);
|
||||||
this.prescriptionStatus = data.status === true || ps === 1 || ps === '1' || ps === 3 || ps === '3' || ps === 4 || ps === '4';
|
|
||||||
} else {
|
} else {
|
||||||
this.prescriptionStatus = false;
|
this.prescriptionStatus = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<!-- 头部 -->
|
<!-- 头部 -->
|
||||||
<view class="head">
|
<view class="head">
|
||||||
<u-tabs :list="list" :is-scroll="false" :current="current" @change="onTabChange"></u-tabs>
|
<u-tabs :list="list" :is-scroll="true" :current="current" @change="onTabChange"></u-tabs>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<swiper class="order-swiper" :current="current" @change="onSwiperChange">
|
<swiper class="order-swiper" :current="current" @change="onSwiperChange">
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
:refresher-triggered="isRefreshing"
|
:refresher-triggered="isRefreshing"
|
||||||
@refresherrefresh="onRefresherRefresh"
|
@refresherrefresh="onRefresherRefresh"
|
||||||
>
|
>
|
||||||
<block v-if="current === tabIdx">
|
<block v-if="Number(current) === tabIdx">
|
||||||
<!-- 空页 orderList.length==0 -->
|
<!-- 空页 orderList.length==0 -->
|
||||||
<view class="empty" v-if="orderList.length==0">
|
<view class="empty" v-if="orderList.length==0">
|
||||||
<image src="https://xiaokang88.oss-cn-hangzhou.aliyuncs.com/xk-client-wx/static/empty/orders.png" mode="aspectFit"></image>
|
<image src="https://xiaokang88.oss-cn-hangzhou.aliyuncs.com/xk-client-wx/static/empty/orders.png" mode="aspectFit"></image>
|
||||||
@@ -103,11 +103,11 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="_specit">
|
<view class="_specit">
|
||||||
<!-- 抛弃三元表达式,使用 v-if 防小程序编译 BUG -->
|
<!-- 抛弃三元表达式,使用 v-if 防小程序编译 BUG -->
|
||||||
<text class="xy_func" v-if="it.drug && it.drug.function">{{ it.drug.function }}</text>
|
<text class="xy_func" v-if="it.drug && it.drug.function && canShowFunction(it.drug, false)">{{ it.drug.function }}</text>
|
||||||
<text class="xy_func" v-else></text>
|
<text class="xy_func" v-else></text>
|
||||||
<view class="number_specit">
|
<view class="number_specit">
|
||||||
<!-- 最原生、最安全的取值方式,确保多商品列表下规格渲染不会被吞 -->
|
<!-- 最原生、最安全的取值方式,确保多商品列表下规格渲染不会被吞 -->
|
||||||
<text class="xy_spec" v-if="it.drug && it.drug.specification">{{ it.drug.specification }}1</text>
|
<text class="xy_spec" v-if="it.drug && it.drug.specification">{{ it.drug.specification }}</text>
|
||||||
<text v-else></text>
|
<text v-else></text>
|
||||||
<text class="xy_num">x{{it.number}}</text>
|
<text class="xy_num">x{{it.number}}</text>
|
||||||
</view>
|
</view>
|
||||||
@@ -147,10 +147,6 @@
|
|||||||
<view class="order_info active" v-else-if="item.status==2 && item.is_pay==1" @tap.stop="getReceive(item.id)">
|
<view class="order_info active" v-else-if="item.status==2 && item.is_pay==1" @tap.stop="getReceive(item.id)">
|
||||||
签收
|
签收
|
||||||
</view>
|
</view>
|
||||||
<view class="order_info active" v-else-if="item.is_pay==0 && item.status==0 && item.cancel_status==0"
|
|
||||||
@tap.stop="goCancel(item.id)">
|
|
||||||
取消
|
|
||||||
</view>
|
|
||||||
<view class="order_info" v-else-if="item.status==9 || item.cancel_status==1">
|
<view class="order_info" v-else-if="item.status==9 || item.cancel_status==1">
|
||||||
已取消
|
已取消
|
||||||
</view>
|
</view>
|
||||||
@@ -167,6 +163,11 @@
|
|||||||
<view class="order_info active" v-else-if="(item.status===2||item.status===6||item.status===7) && item.is_pay==1 && item.cancel_status==0 && item.delivery_method === 0" @tap.stop="toDevilty(item.id)">
|
<view class="order_info active" v-else-if="(item.status===2||item.status===6||item.status===7) && item.is_pay==1 && item.cancel_status==0 && item.delivery_method === 0" @tap.stop="toDevilty(item.id)">
|
||||||
查看物流
|
查看物流
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- <view class="order_info active" v-if="item.is_pay==0 && item.status==0 && item.cancel_status==0"-->
|
||||||
|
<!-- @tap.stop="goCancel(item.id)">-->
|
||||||
|
<!-- 取消-->
|
||||||
|
<!-- </view>-->
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<u-loadmore :status="loadMoreStatus" v-if="orderList.length!=0" margin-top="30" margin-bottom="30" />
|
<u-loadmore :status="loadMoreStatus" v-if="orderList.length!=0" margin-top="30" margin-bottom="30" />
|
||||||
@@ -187,6 +188,7 @@ import {
|
|||||||
getPayConfig,
|
getPayConfig,
|
||||||
postRefundBased
|
postRefundBased
|
||||||
} from '../../../request/api/api';
|
} from '../../../request/api/api';
|
||||||
|
import { canShowFunction } from '@/common/utils/drug';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@@ -207,6 +209,12 @@ export default {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '已完成'
|
name: '已完成'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '退款'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '已取消'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
keyword: "",
|
keyword: "",
|
||||||
@@ -231,7 +239,8 @@ export default {
|
|||||||
},
|
},
|
||||||
onLoad(e) {
|
onLoad(e) {
|
||||||
this.order_id = e.id
|
this.order_id = e.id
|
||||||
this.change(e.index);
|
const tabIndex = parseInt(e.index, 10);
|
||||||
|
this.change(Number.isNaN(tabIndex) ? 0 : tabIndex);
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
||||||
@@ -240,6 +249,7 @@ export default {
|
|||||||
this.scrollTop = e.scrollTop;
|
this.scrollTop = e.scrollTop;
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
canShowFunction,
|
||||||
// scroll-view 专用下拉刷新响应
|
// scroll-view 专用下拉刷新响应
|
||||||
onRefresherRefresh() {
|
onRefresherRefresh() {
|
||||||
this.isRefreshing = true;
|
this.isRefreshing = true;
|
||||||
@@ -280,24 +290,10 @@ export default {
|
|||||||
},
|
},
|
||||||
// 点击切换
|
// 点击切换
|
||||||
change(index) {
|
change(index) {
|
||||||
// console.log(index);
|
const tabIndex = Number(index) || 0;
|
||||||
this.current = index;
|
this.current = tabIndex;
|
||||||
if (this.current == 0) {
|
const statusMap = ['', 'unpaid', 'wait_send', 'wait_accept', 'finished', 'refund', 'cancel'];
|
||||||
this.status = ''
|
this.status = statusMap[tabIndex] ?? '';
|
||||||
}
|
|
||||||
if (this.current == 1) {
|
|
||||||
// unpaid未支付 wait_send代发货 wait_accept已发货 finished已完成
|
|
||||||
this.status = 'unpaid'
|
|
||||||
}
|
|
||||||
if (this.current == 2) {
|
|
||||||
this.status = 'wait_send'
|
|
||||||
}
|
|
||||||
if (this.current == 3) {
|
|
||||||
this.status = 'wait_accept'
|
|
||||||
}
|
|
||||||
if (this.current == 4) {
|
|
||||||
this.status = 'finished'
|
|
||||||
}
|
|
||||||
this.orderList = []
|
this.orderList = []
|
||||||
this.page = 1
|
this.page = 1
|
||||||
this.getList()
|
this.getList()
|
||||||
|
|||||||
@@ -97,12 +97,12 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="it">
|
<view class="it">
|
||||||
<view class="it_name">{{item.content.drug_name}}{{item.content.specification}}</view>
|
<view class="it_name">{{item.content.drug_name}}{{item.content.specification}}</view>
|
||||||
<view class="it_info">
|
<view class="it_info" v-if="canShowUsage(item.content, prescriptionStatus)">
|
||||||
{{item.content.usage}}
|
{{item.content.usage}}
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="instruction-btn"
|
class="instruction-btn"
|
||||||
v-if="prescriptionStatus && item.content && item.content.instruction"
|
v-if="canShowInstruction(item.content, prescriptionStatus) && item.content && item.content.instruction"
|
||||||
@click="previewInstruction(item.content.instruction)"
|
@click="previewInstruction(item.content.instruction)"
|
||||||
>
|
>
|
||||||
<text>查看说明书</text>
|
<text>查看说明书</text>
|
||||||
@@ -206,6 +206,7 @@
|
|||||||
// 导入 getOrderTextApi 接口方法
|
// 导入 getOrderTextApi 接口方法
|
||||||
import { getOrderTextApi } from '../../request/api/product'
|
import { getOrderTextApi } from '../../request/api/product'
|
||||||
import { getPrescriptionStatusApi } from '../../request/api/order'
|
import { getPrescriptionStatusApi } from '../../request/api/order'
|
||||||
|
import { canShowUsage, canShowInstruction, isPrescriptionApprovedStatus } from '@/common/utils/drug'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@@ -287,6 +288,8 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
canShowUsage,
|
||||||
|
canShowInstruction,
|
||||||
// 获取订单提示文本
|
// 获取订单提示文本
|
||||||
getOrderText() {
|
getOrderText() {
|
||||||
getOrderTextApi().then((res) => {
|
getOrderTextApi().then((res) => {
|
||||||
@@ -518,8 +521,7 @@
|
|||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
if (res.data && (res.data.code == 0 || res.data.errcode == 0)) {
|
if (res.data && (res.data.code == 0 || res.data.errcode == 0)) {
|
||||||
const data = res.data.data || res.data.result || {}
|
const data = res.data.data || res.data.result || {}
|
||||||
const ps = data.prescription_status ?? data.status
|
this.prescriptionStatus = isPrescriptionApprovedStatus(data)
|
||||||
this.prescriptionStatus = data.status === true || ps === 1 || ps === '1' || ps === 3 || ps === '3' || ps === 4 || ps === '4'
|
|
||||||
} else {
|
} else {
|
||||||
this.prescriptionStatus = false
|
this.prescriptionStatus = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 保健食品不展示用法用量 -->
|
<!-- 保健食品不展示用法用量 -->
|
||||||
<view class="info-card" v-if="productDetail.type != 3">
|
<view class="info-card" v-if="showUsageSection">
|
||||||
<view class="section-title-modern">
|
<view class="section-title-modern">
|
||||||
<view class="indicator"></view>
|
<view class="indicator"></view>
|
||||||
<text>用法用量</text>
|
<text>用法用量</text>
|
||||||
@@ -104,8 +104,8 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 说明书入口 - 处方药不展示 -->
|
<!-- 说明书入口 - 处方药未审核通过不展示 -->
|
||||||
<view class="info-card" v-if="!(productDetail.is_otc == 0 && productDetail.type == 2)">
|
<view class="info-card" v-if="showInstructionSection">
|
||||||
<view class="section-title-modern">
|
<view class="section-title-modern">
|
||||||
<view class="indicator"></view>
|
<view class="indicator"></view>
|
||||||
<text>说明书</text>
|
<text>说明书</text>
|
||||||
@@ -146,7 +146,7 @@
|
|||||||
<view class="footer-placeholder"></view>
|
<view class="footer-placeholder"></view>
|
||||||
|
|
||||||
<!-- 底部操作栏 -->
|
<!-- 底部操作栏 -->
|
||||||
<view class="footer-bar safe-area-inset-bottom">
|
<view class="footer-bar safe-area-inset-bottom" v-if="!hidePurchase">
|
||||||
<view class="icons-area">
|
<view class="icons-area">
|
||||||
<view class="icon-item" @click="goBack">
|
<view class="icon-item" @click="goBack">
|
||||||
<u-icon name="home" size="40" color="#606266"></u-icon>
|
<u-icon name="home" size="40" color="#606266"></u-icon>
|
||||||
@@ -243,8 +243,9 @@
|
|||||||
<script>
|
<script>
|
||||||
// 完整引入原有API
|
// 完整引入原有API
|
||||||
import { getOrderTextApi, getStoreDrugDetailApi } from "@/request/api/product";
|
import { getOrderTextApi, getStoreDrugDetailApi } from "@/request/api/product";
|
||||||
import { genOrderApi } from "@/request/api/order";
|
import { genOrderApi, getPrescriptionStatusApi } from "@/request/api/order";
|
||||||
import { getCartCountsApi, saveCartApi } from "@/request/api/cart";
|
import { getCartCountsApi, saveCartApi } from "@/request/api/cart";
|
||||||
|
import { canShowFunction, canShowUsage, canShowInstruction, isPrescriptionApprovedStatus } from '@/common/utils/drug';
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -291,10 +292,18 @@ export default {
|
|||||||
orderText: '本次商品物流配送,由萧康医药提供服务。',
|
orderText: '本次商品物流配送,由萧康医药提供服务。',
|
||||||
introductionImages: [], // 商品介绍图数组
|
introductionImages: [], // 商品介绍图数组
|
||||||
delegateStoreId: '', // 委托诊所ID
|
delegateStoreId: '', // 委托诊所ID
|
||||||
|
fromOrderId: '',
|
||||||
|
orderStoreId: '',
|
||||||
|
prescriptionApproved: false,
|
||||||
|
hidePurchase: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
productPrice() {
|
productPrice() {
|
||||||
|
const rel = this.productDetail.drug_store_relations;
|
||||||
|
if (rel && rel.price) {
|
||||||
|
return parseFloat(rel.price);
|
||||||
|
}
|
||||||
if (this.productDetail.drug_store_drug && this.productDetail.drug_store_drug.price) {
|
if (this.productDetail.drug_store_drug && this.productDetail.drug_store_drug.price) {
|
||||||
return parseFloat(this.productDetail.drug_store_drug.price);
|
return parseFloat(this.productDetail.drug_store_drug.price);
|
||||||
}
|
}
|
||||||
@@ -308,12 +317,23 @@ export default {
|
|||||||
return (this.productDetail.supplier && this.productDetail.supplier.name) || '';
|
return (this.productDetail.supplier && this.productDetail.supplier.name) || '';
|
||||||
},
|
},
|
||||||
showFunctionSection() {
|
showFunctionSection() {
|
||||||
if (this.productDetail.category_type === 'health_food') return false;
|
return canShowFunction(this.productDetail, this.prescriptionApproved);
|
||||||
if (this.productDetail.type == 2 && this.productDetail.is_otc === 0) return false;
|
},
|
||||||
return true;
|
showUsageSection() {
|
||||||
|
return canShowUsage(this.productDetail, this.prescriptionApproved);
|
||||||
|
},
|
||||||
|
showInstructionSection() {
|
||||||
|
return canShowInstruction(this.productDetail, this.prescriptionApproved);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
if (options.store_id) {
|
||||||
|
this.orderStoreId = options.store_id;
|
||||||
|
}
|
||||||
|
if (options.order_id) {
|
||||||
|
this.fromOrderId = options.order_id;
|
||||||
|
this.hidePurchase = true;
|
||||||
|
}
|
||||||
if (options.id) {
|
if (options.id) {
|
||||||
this.productDetail.id = options.id;
|
this.productDetail.id = options.id;
|
||||||
this.formData.id = options.id;
|
this.formData.id = options.id;
|
||||||
@@ -327,21 +347,48 @@ export default {
|
|||||||
this.productDetail.price = parseFloat(options.price || 0);
|
this.productDetail.price = parseFloat(options.price || 0);
|
||||||
// 获取委托诊所ID(如果有)
|
// 获取委托诊所ID(如果有)
|
||||||
this.delegateStoreId = options.delegate_store_id || '';
|
this.delegateStoreId = options.delegate_store_id || '';
|
||||||
this.getDetail();
|
this.initPageData();
|
||||||
} else {
|
} else {
|
||||||
const savedId = uni.getStorageSync('symptoms_id');
|
const savedId = uni.getStorageSync('symptoms_id');
|
||||||
if (savedId) {
|
if (savedId) {
|
||||||
this.productDetail.id = savedId;
|
this.productDetail.id = savedId;
|
||||||
this.formData.id = savedId;
|
this.formData.id = savedId;
|
||||||
this.getDetail();
|
this.initPageData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.updateCartCount();
|
if (!this.hidePurchase) {
|
||||||
|
this.updateCartCount();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
this.updateCartCount();
|
if (!this.hidePurchase) {
|
||||||
|
this.updateCartCount();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
initPageData() {
|
||||||
|
if (this.fromOrderId) {
|
||||||
|
this.fetchPrescriptionStatus().then(() => {
|
||||||
|
this.getDetail();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.getDetail();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fetchPrescriptionStatus() {
|
||||||
|
return getPrescriptionStatusApi({
|
||||||
|
order_id: this.fromOrderId,
|
||||||
|
}).then((res) => {
|
||||||
|
if (res.data && (res.data.code == 0 || res.data.errcode == 0)) {
|
||||||
|
const data = res.data.data || res.data.result || {};
|
||||||
|
this.prescriptionApproved = isPrescriptionApprovedStatus(data);
|
||||||
|
} else {
|
||||||
|
this.prescriptionApproved = false;
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
this.prescriptionApproved = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
getOrderText() {
|
getOrderText() {
|
||||||
getOrderTextApi().then((res) => {
|
getOrderTextApi().then((res) => {
|
||||||
if (res.data && res.data.result) {
|
if (res.data && res.data.result) {
|
||||||
@@ -352,14 +399,27 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
getDetail() {
|
getDetail() {
|
||||||
let that = this;
|
|
||||||
this.getOrderText();
|
this.getOrderText();
|
||||||
getStoreDrugDetailApi({
|
const params = {
|
||||||
id: this.productDetail.id,
|
id: this.productDetail.id,
|
||||||
}).then((res) => {
|
store_id: this.orderStoreId || uni.getStorageSync('store_id') || '11001',
|
||||||
|
};
|
||||||
|
if (this.fromOrderId) {
|
||||||
|
params.order_id = this.fromOrderId;
|
||||||
|
}
|
||||||
|
getStoreDrugDetailApi(params).then((res) => {
|
||||||
if (res.data.code === 0) {
|
if (res.data.code === 0) {
|
||||||
const data = res.data.result;
|
const data = res.data.result;
|
||||||
Object.assign(this.productDetail, data);
|
Object.assign(this.productDetail, data);
|
||||||
|
if (data.prescription_approved !== undefined) {
|
||||||
|
this.prescriptionApproved = !!data.prescription_approved;
|
||||||
|
}
|
||||||
|
if (data.hide_purchase !== undefined) {
|
||||||
|
this.hidePurchase = !!data.hide_purchase;
|
||||||
|
}
|
||||||
|
if (data.order_store_id && !this.orderStoreId) {
|
||||||
|
this.orderStoreId = data.order_store_id;
|
||||||
|
}
|
||||||
this.productImages = data.image ? [data.image] : [];
|
this.productImages = data.image ? [data.image] : [];
|
||||||
if (!this.productDetail.indications && data.function) {
|
if (!this.productDetail.indications && data.function) {
|
||||||
this.productDetail.indications = data.function;
|
this.productDetail.indications = data.function;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
<!-- 价格与数量控制器 -->
|
<!-- 价格与数量控制器 -->
|
||||||
<view class="it_price">
|
<view class="it_price">
|
||||||
<!-- 显示价格 -->
|
<!-- 显示价格 -->
|
||||||
<text>¥{{ item.drug.drugstore_drug ? item.drug.drugstore_drug.price : (item.drug.drug_store_relations ? item.drug.drug_store_relations.price : '0.00') }}</text>
|
<text>¥{{ item.drug.drug_store_relations ? item.drug.drug_store_relations.price : '0.00' }}</text>
|
||||||
|
|
||||||
<!-- 步进器:点击阻止冒泡,防止触发选中 -->
|
<!-- 步进器:点击阻止冒泡,防止触发选中 -->
|
||||||
<view class="it_num" @click.stop>
|
<view class="it_num" @click.stop>
|
||||||
@@ -125,11 +125,8 @@ export default {
|
|||||||
const checkedItems = this.cartLists.data.filter(item => item.checked);
|
const checkedItems = this.cartLists.data.filter(item => item.checked);
|
||||||
|
|
||||||
checkedItems.forEach(item => {
|
checkedItems.forEach(item => {
|
||||||
// 兼容不同字段结构获取价格
|
|
||||||
let price = 0;
|
let price = 0;
|
||||||
if(item.drug && item.drug.drugstore_drug && item.drug.drugstore_drug.price) {
|
if (item.drug && item.drug.drug_store_relations && item.drug.drug_store_relations.price) {
|
||||||
price = item.drug.drugstore_drug.price;
|
|
||||||
} else if (item.drug && item.drug.drug_store_relations && item.drug.drug_store_relations.price) {
|
|
||||||
price = item.drug.drug_store_relations.price;
|
price = item.drug.drug_store_relations.price;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,9 +155,7 @@ export default {
|
|||||||
|
|
||||||
// 获取显示价格,逻辑与模板保持一致
|
// 获取显示价格,逻辑与模板保持一致
|
||||||
let price = '0';
|
let price = '0';
|
||||||
if (item.drug.drugstore_drug && item.drug.drugstore_drug.price) {
|
if (item.drug.drug_store_relations && item.drug.drug_store_relations.price) {
|
||||||
price = item.drug.drugstore_drug.price;
|
|
||||||
} else if (item.drug.drug_store_relations && item.drug.drug_store_relations.price) {
|
|
||||||
price = item.drug.drug_store_relations.price;
|
price = item.drug.drug_store_relations.price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user