为什么从接口请求后,不管点击哪个模块都会跳转到同一个页面(例如点击开心取药或上门助浴都是条装到下方的那个页面)
前端代码:
<template>
<view>
<block v-if="service.stype == 10 || service.stype == 15 || service.stype == 20 ">
<view class="pub-box">
<view class="pub-box-bd">
<view class="weui-cell weui-cell_input">
.....
</view>
<view class="weui-cell weui-cell_input">
....
</view>
<view class="weui-cell weui-cell_input" @click="onClientChange">
....
</view>
</view>
</view>
</block>
</view>
</template>
<script setup>
import { ref, reactive ,computed,toRaw} from 'vue'
import {onLoad} from '@dcloudio/uni-app'
const app = getApp()
onLoad((options) => {
console.log(options,'options')
main_load(options)
})
//页面服务详情数据
const service = ref({})
//医院的数据
const hospitals = ref([])
//选中的医院索引
const hospital_index = ref(0)
//订单数据
const order = reactive({
price:'',
starttime:'',
address:{
userName:'',
cityName:'',
countyName:'',
detailInfo:''
}
})
const main_load = (options) => {
app.globalData.utils.request({
url:'/Service/order',
data:{
svid:options.svid
},
success:(res) => {
console.log(res)
service.value = res.data.service;
hospitals.value = res.data.hospitals;
//默认选中
const hospitalsData = toRaw(hospitals.value);
if(options.hid>0){
//自动选中
for(let i=0;i<hospitalsData.length;i++){
if(hospitalsData[i].id==options.hid){
hospital_index.value=i
order.price=hospitalsData[i].service_price
break;
}
}
}
}
})
}
//改变医院的数据
const onHospitalChange = (e) =>{
const value = parseInt(e.detail.value)
hospital_index.value = value
order.price=toRaw(hospitals.value)[value].service_price
}
//创建监听全局的自定义事件
uni.$on('clientChange',(data)=>{
console.log(data)
client.name=data.name
})
</script>
后端部分数据:①
{
"code": 10000,
"msg": "",
"time": "1707110701",
"data": {
"now": 1707110701,
"services": [
{
"id": 1,
"code": "dp",
"stype": "40",
"name": "代跑取药",
"intro": "人工带跑取药,省时省力",
"price": "0.01",
"priceo": "100.00",
"use_switch": 1,
"stype_text": "Stype 40"
},
{
"id": 2,
"code": "pz",
"stype": "15",
"name": "就医陪诊(半天)",
"intro": "就医陪诊,值得托付",
"price": "0.01",
"priceo": "150.00",
"use_switch": 1,
"stype_text": "Stype 15"
}
]
}
}
②
{
"code": 10000,
"msg": "",
"time": "1700982698",
"data": {
"now": 1700982698,
"navs": [
{
"id": 3,
"stype": "1",
"stype_link": "/pages/service/index?svid=1&hid=5",
"title": "开心取药",
"tcolor": "",
"cat_text": "",
"stype_text": "Stype 1"
},
{
"id": 4,
"stype": "1",
"stype_link": "/pages/service/index?svid=4&hid=5",
"title": "上门助浴",
"tcolor": "",
"cat_text": "",
"stype_text": "Stype 1"
}
],
}
}
前端调用后端的stype,但运行后总感觉部分获取不到,就只能出现stype为40的
..