chenyc
2023-05-28 aae6cb63fac8f2956615481382c101cfd2e7d45c
gxapi
6个文件已修改
884 ■■■■ 已修改文件
src/stores/userInfo.ts 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/storage.ts 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/home/index.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/jifenShangCheng/components/dizhi.vue 263 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/jifenShangCheng/components/gouwuche.vue 291 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/jifenShangCheng/index.vue 302 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stores/userInfo.ts
@@ -21,6 +21,7 @@
            patientTelNo:'',
            patientAvatarIcon:'',
            patientCreditValue:0,
            patientAddress:'',
            clientCode:'',
        },
        pressure:'',
@@ -31,14 +32,12 @@
        info.value.headimgurl=userInfo.headimgurl
        info.value.nickname=userInfo.nickname
    }
    function setPatient(userInfo:object) {
    function setPatient(userInfo:any) {
        patient.value=userInfo
    }
    const setPatientApi= async ()=>{
         const res= await ajaxPost('/patient/info/getPatientInfo','')
         console.log('-----')
         console.log(res)
         setPatient(res)
    const setPatientApi= async()=>{
        const res= await ajaxPost('/patient/info/getPatientInfo','')
        setPatient(res)
    }
    return { info,patient,setPatient, setInfo,setPatientApi }
src/utils/storage.ts
@@ -1,5 +1,5 @@
import Cookies from "js-cookie"
import Cookies from 'js-cookie'
/**
 * window.localStorage 浏览器永久缓存
 * @method set 设置永久缓存
@@ -39,24 +39,23 @@
    set(key: string, val: any) {
        console.log('设置临时缓存')
        console.log(key,val)
        if (key === 'token') return Cookies.set(key, val);
        if (key === 'token') return Cookies.set(key, val)
        window.sessionStorage.setItem(key, JSON.stringify(val))
    },
    // 获取临时缓存
    get(key: string) {
        console.log(Cookies.get(key),key)
        if (key === 'token') return Cookies.get(key);
        if (key === 'token') return Cookies.get(key)
        const json: any = window.sessionStorage.getItem(key)
        return JSON.parse(json)
    },
    // 移除临时缓存
    remove(key: string) {
        if (key === 'token') return Cookies.remove(key);
        if (key === 'token') return Cookies.remove(key)
        window.sessionStorage.removeItem(key)
    },
    // 移除全部临时缓存
    clear() {
        Cookies.remove('token');
        Cookies.remove('token')
        window.sessionStorage.clear()
    },
}
src/views/home/index.vue
@@ -2,7 +2,7 @@
    <div class="page">
        <div class="box_1">
            <div class="userinfo">
                <div class="name">{{patientInfo.patientInfo.patientName}}</div>
                <div class="name" v-if="patientInfo.patientInfo.patientName !== undefined">{{patientInfo.patientInfo.patientName}}</div>
                <div class="userCode">卡号:{{patientInfo.patientInfo.patientCardNo}} </div>
                <div class="userQRcode">
                    <img
@@ -139,9 +139,9 @@
    const tabChang=(index:any)=>{
        if (index==='home'){
            router.push('/')
        } else if(index==='jifen') {
        } else if (index==='jifen') {
            router.push('jifenShangCheng')
        }else if(index==='my') {
        } else if (index==='my') {
            router.push('my')
        }
    }
src/views/jifenShangCheng/components/dizhi.vue
@@ -6,14 +6,14 @@
                left-text="返回"
                left-arrow
                @click-left="onClickLeft"
                />
            />
            <van-address-list
                v-model="chosenAddressId"
                :list="list"
                default-tag-text="默认"
                @add="onAdd"
                @edit="onEdit"
                />
            />
        </van-popup>
        <van-popup v-model:show="editDizhi" position="bottom" :style="{ height: '100%' }">
            <van-nav-bar
@@ -21,99 +21,186 @@
                left-text="返回"
                left-arrow
                @click-left="onClickLeft2"
                />
                <van-address-edit
                    ref="addressEditRef"
                    :area-list="areaList"
                    show-delete
                    show-set-default
                    show-search-result
                    :address-info="addressInfo"
                    :area-columns-placeholder="['请选择', '请选择', '请选择']"
                    @save="onSave"
                    @delete="onDelete"
                />
            />
            <van-address-edit
                ref="addressEditRef"
                :area-list="areaList"
                show-delete
                show-set-default
                show-search-result
                :address-info="addressInfo"
                :area-columns-placeholder="['请选择', '请选择', '请选择']"
                @save="onSave"
                @delete="onDelete"
            />
        </van-popup>
    </div>
</template>
<script setup lang="ts">
import { Toast } from 'vant';
import { ref } from 'vue';
import { areaList } from '@vant/area-data';
import type { AddressEditInstance } from 'vant';
name:"dizhibianji"
const emit = defineEmits(['fanhuiFun'])
const showDizhi=ref(false)
const editDizhi=ref(false)
const addressEditRef = ref<AddressEditInstance>();
const chosenAddressId = ref('1')
const addressInfo=ref({
    name:'',
    tel:'',
    province:'',
    city:"",
    county:'',
    addressDetail:'',
    isDefault:false
})
const list =[
{
        id: '1',
        name: '张三',
        tel: '13000000000',
        address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室',
        isDefault: true,
      },
      {
        id: '2',
        name: '李四',
        tel: '1310000000',
        address: '浙江省杭州市拱墅区莫干山路 50 号',
      },
]
const openShow=()=>{
    showDizhi.value=true
}
const onClickLeft=()=>{
    showDizhi.value=false
}
const onClickLeft2=()=>{
    addressEditRef.value?.setAddressDetail('3434343');
    editDizhi.value=false
}
const onAdd = () =>{
    editDizhi.value=true
    addressInfo.value={
    import { Toast } from 'vant'
    import { ref } from 'vue'
    import { areaList } from '@vant/area-data'
    import type { AddressEditInstance } from 'vant'
    import { ajaxPost } from '@/utils/axios'
    import { userInfoStore } from '@/stores/userInfo'
    const userInfo = userInfoStore()
    const emit = defineEmits(['fanhuiFun'])
    const showDizhi=ref(false)
    const editDizhi=ref(false)
    const addressEditRef = ref<AddressEditInstance>()
    const chosenAddressId = ref(1)
    const addressInfo=ref({
        id:0,
        name:'',
        tel:'17717874345',
        province:'',
        city:"",
        county:'',
        addressDetail:'',
        isDefault:false
    }
}
const onEdit = (item:any, index:number) =>{
    console.log(item)
    addressInfo.value={
        name:item.name,
        tel:item.tel,
        province:'',
        city:"",
        tel:'',
        city:'',
        county:'',
        addressDetail:item.address,
        isDefault:item.isDefault
        areaCode:'',
        address:'',
        isDefault:false
    })
    const list = ref([
        {
            id: 0,
            code:'',
            name:'',
            tel:'',
            province:'',
            city:'',
            county:'',
            areaCode:'',
            address:'',
            isDefault:false
        },
    ])
    const getDefDizhi=(isload:boolean)=>{
        const pasm=`page=0&size=0&wherecondition=patient_code="${userInfo.patient.patientInfo.code}"`
        ajaxPost('/patient/address/list', pasm).then((re: any) => {
            console.log('默认地址')
            console.log(re)
            if (re.list.length===0){
                onAdd()
            } else {
                list.value=[]
                re.list.forEach((e:any)=>{
                    list.value.push({
                        id: e.id,
                        code:e.code,
                        name:e.receivePersonName,
                        tel:e.receivePersonMobile,
                        province:'',
                        city:e.addressArea.split(',')[0],
                        county:e.addressArea.split(',')[1],
                        areaCode:e.remark,
                        address:e.patientAddress,
                        isDefault:e.patientIsDefault===1?true:false,
                    })
                    if (isload){
                        if (e.patientIsDefault===1){
                            chosenAddressId.value=(e.id)
                        }
                    }
                })
                console.log(list.value)
            }
        })
    }
    editDizhi.value=true
}
const onSave = (form:any) => {
    Toast('save');
    console.log(form)
}
const onDelete = () => Toast('delete');
defineExpose({
    openShow
} )
    // 打开地址列表
    const openShow=(id:number)=>{
        showDizhi.value=true
        chosenAddressId.value=id
        getDefDizhi(false)
    }
    const onClickLeft=()=>{
        showDizhi.value=false
        console.log('返回父级组件',chosenAddressId.value)
        const row=list.value.find((e:any)=> e.id===chosenAddressId.value)
        emit('fanhuiFun',row)
    }
    const onClickLeft2=()=>{
        addressEditRef.value?.setAddressDetail('3434343')
        editDizhi.value=false
    }
    const onAdd = () =>{
        editDizhi.value=true
        console.log('用户信息')
        console.log(userInfo.patient)
        addressInfo.value={
            id:0,
            name:userInfo.patient.patientInfo.patientName,
            addressDetail:userInfo.patient.patientInfo.patientAddress,
            tel:userInfo.patient.patientInfo.patientTelNo,
            city:'',
            county:'',
            areaCode:'',
            address:'',
            isDefault:false
        }
    }
    const onEdit = (item:any, index:number) =>{
        console.log(item,index)
        addressInfo.value={
            id:item.id,
            name:item.name,
            addressDetail:item.address,
            tel:item.tel,
            city:item.city,
            county:item.county,
            areaCode:item.areaCode,
            address:'',
            isDefault:item.isDefault
        }
        editDizhi.value=true
    }
    const onSave = (form:any) => {
        const pasm={
            addressArea: [form.city,form.county].toString(),
            id: addressInfo.value.id,
            patientAddress: form.addressDetail,
            patientCode: userInfo.patient.patientInfo.code,
            patientIsDefault: form.isDefault===true?1:0,
            receivePersonMobile: form.tel,
            receivePersonName: form.name,
            // 存地址code
            remark: form.areaCode,
        }
        if (pasm.id===0){
            ajaxPost('/patient/address/add', pasm).then((re: any) => {
                console.log('默认地址')
                console.log(re)
                Toast.success('保存成功')
                getDefDizhi(false)
                chosenAddressId.value=re.id
                editDizhi.value=false
            })
        } else {
            ajaxPost('/patient/address/update', pasm).then((re: any) => {
                console.log('默认地址')
                chosenAddressId.value=re.id
                console.log(re)
                Toast.success('保存成功')
                getDefDizhi(false)
                editDizhi.value=false
            })
        }
    }
    const onDelete = () => {
        ajaxPost('patient/address/delete','id='+addressInfo.value.id).then(re=>{
            editDizhi.value=false
            console.log(re)
            Toast.success('删除成功!')
        }).finally(()=>{
            getDefDizhi(true)
        })
    }
    defineExpose({
        openShow
    } )
</script>
src/views/jifenShangCheng/components/gouwuche.vue
@@ -0,0 +1,291 @@
<template>
    <div>
        <van-popup v-model:show="show" position="bottom" :style="{ height: '90%' }">
            <van-loading style="top: 100px;" v-if="loading" type="spinner" size="24px" vertical>
                加载中。。。。
            </van-loading>
            <div v-if="gwcList.length > 0" style="height: 100%; padding-left: 10px;padding-right: 10px; background: #f5f7fa;">
                <div>
                    <van-row style="padding-top: 10px;padding-bottom: 10px;">
                        <van-col @click="show = false" :span="7" style="height: 30px; line-height: 30px; font-size: 20px; font-weight: 600; color: #409eff;">
                            <van-icon name="arrow-left" />购物车<span style="font-size: 10px;">({{gwcList.length}})</span>
                        </van-col>
                        <van-col
                            :span="13" style="color: #e6a23c; height: 30px; line-height: 30px;white-space: nowrap;text-overflow: ellipsis;-o-text-overflow: ellipsis;
                        overflow: hidden;">
                            <van-icon name="location-o" />
                            <span v-if="defaultDizhi.code === ''" @click="setDizhi">设置地址</span>
                            <span v-else @click="setDizhi">{{defaultDizhi.patientAddress}}</span>
                        </van-col>
                        <van-col :span="4" style=" height: 30px; line-height: 30px;text-align: right;">
                            <span v-if="!isAdmin" @click="adminFun" style="color: #409eff;">管理</span>
                            <span v-else @click="adminFunCols" style="color: #f56c6c;">取消</span>
                        </van-col>
                    </van-row>
                </div>
                <div class="parent " v-for="(item,index) in gwcList" :key="index">
                    <div class="checkboxclss">
                        <van-checkbox v-model="item.checked"></van-checkbox>
                    </div>
                    <div class="parentzi">
                        <div>
                            <van-image
                                fit="contain"
                                width="100%"
                                height="100%"
                                :src="item.itemInfo.itemPhoto"
                            />
                        </div>
                        <div style="padding-left: 10px;">
                            <div style="height: 2rem; line-height: 2rem; color: #409eff;">{{item.itemInfo.itemName}}</div>
                            <div style="height: 2rem;">
                                <van-tag type="primary">{{item.itemInfo.itemCategory}}</van-tag>
                            </div>
                            <div style="height: 2rem;">
                                <van-row>
                                    <van-col :span="12" style="color: #f56c6c;">¥{{item.itemInfo.itemPrice}}</van-col>
                                    <van-col :span="12" style="text-align: right; padding-right: 10px;">
                                        <span><van-icon name="plus" @click="item.itemCount++" /></span>
                                        <span style="margin-left: 10px; margin-right: 10px;">x{{item.itemCount}}</span>
                                        <span><van-icon name="minus" v-if="item.itemCount > 1" @click="item.itemCount--" /></span>
                                    </van-col>
                                </van-row>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div v-if="gwcList.length === 0" style="margin-top: 200px; text-align: center; color: #409eff;">
                <van-icon name="cart-o" />
                你的购物车空空如也
                <br />
                <br />
                <span @click="show = false">
                    <van-icon name="revoke" />返回
                </span>
            </div>
            <div>
                <div class="divcaozuo">
                    <van-row>
                        <van-col :span="10" style="line-height: 50px;padding-left: 10px;">
                            <van-checkbox v-model="AllChecked" style="margin-top: 20px;">全选</van-checkbox>
                        </van-col>
                        <van-col :span="14" style="line-height: 50px; text-align: right; padding-right: 10px;">
                            <div style="float: right;">
                                <van-button v-if="!isAdmin" round style="width: 100px;" @click="jieshuan" type="danger">结 算</van-button>
                                <van-button v-if="isAdmin" round @click="delrows" style="width: 100px;" type="danger">删 除</van-button>
                            </div>
                            <div v-if="!isAdmin" style="float: right; margin-top: 5px;margin-right: 5px;">
                                合计:<span style="font-size: 20px;color: #f56c6c;">¥{{functionHj}}</span></div>
                        </van-col>
                    </van-row>
                </div>
                <div>
                    <dizhi @fanhuiFun="feihuDizhi" ref="dizhiRef"></dizhi>
                </div>
            </div>
        </van-popup>
    </div>
</template>
<script setup lang="ts">
    import { ajaxPost } from '@/utils/axios'
    import { Toast } from 'vant'
    import { watch } from 'vue'
    import { computed } from 'vue'
    import { ref } from 'vue'
    import dizhi from '../components/dizhi.vue'
    import { userInfoStore } from '@/stores/userInfo'
    const userInfo = userInfoStore()
    const AllChecked=ref(false)
    const loading = ref(false)
    const isAdmin=ref(false)
    const dizhiRef=ref()
    const defaultDizhi=ref({
        id:0,
        code:'',
        receivePersonName:'',
        receivePersonMobile:'',
        patientAddress:'',
    })
    const functionHj =computed(()=>{
        let num=0
        gwcList.value.forEach(el=>{
            if ( el.checked===true){
                num+=el.itemCount*el.itemInfo.itemPrice
            }
        })
        return num
    })
    watch(()=>AllChecked.value,()=>{
        if (AllChecked.value){
            gwcList.value.forEach(el=>{
                el.checked=true
            })
        } else {
            gwcList.value.forEach(el=>{
                el.checked=false
            })
        }
    })
    const gwcList = ref([
        {
            id:0,
            code:'',
            itemCount:1,
            checked:false,
            patientCode:'',
            itemCode:'',
            itemInfo:{
                itemName:'',
                itemPhoto:'',
                itemCategory:'',
                itemPrice:0,
            }
        }
    ])
    const show = ref(false)
    const getPages = () => {
        loading.value = true
        ajaxPost('/eshop/cart/list', '').then((re: any) => {
            console.log(re)
            gwcList.value=[]
            re.list.forEach((element:any) => {
                gwcList.value.push({
                    id:element.id,
                    code:element.code,
                    itemCount:element.itemCount,
                    checked:false,
                    itemCode:element.itemCode,
                    itemInfo:element.itemInfo,
                    patientCode:element.patientCode
                })
            })
        // gwcList.value = re.list
        }).finally(() => {
            loading.value = false
        })
    }
    const openShow = () => {
        show.value = true
        isAdmin.value=false
        AllChecked.value=false
        getPages()
        getDefDizhi()
    }
    const adminFun=()=>{
        gwcList.value.forEach(el=>{
            el.checked=false
        })
        AllChecked.value=false
        isAdmin.value=true
    }
    const adminFunCols=()=>{
        AllChecked.value=false
        gwcList.value.forEach(el=>{
            el.checked=false
        })
        isAdmin.value=false
    }
    const delrows=()=>{
        console.log(gwcList.value)
        const list: number[]=[]
        gwcList.value.forEach(el=>{
            if (el.checked){
                list.push(el.id)
            }
        })
        if (list.length===0){
            Toast.fail('没有选中删除项')
            return false
        }
        const ids=list.join(',')
        console.log(ids)
        ajaxPost('/eshop/cart/deleteAll', 'ids='+ids).then((re: any) => {
            Toast.success('删除成功')
            console.log(re)
            isAdmin.value=false
            getPages()
        })
    }
    const jieshuan=()=>{
        alert('结算')
    }
    const getDefDizhi=()=>{
        const pasm=`page=0&size=0&wherecondition=patient_is_default=1 and patient_code="${userInfo.patient.patientInfo.code}"`
        ajaxPost('/patient/address/list', pasm).then((re: any) => {
            console.log('默认地址')
            console.log(re)
            if (re.list.length===0){
                Toast('你还没有设置你的收货地址哦')
            } else {
                defaultDizhi.value=re.list[0]
            }
            console.log(defaultDizhi.value)
        })
    }
    const setDizhi=()=>{
        dizhiRef.value.openShow(defaultDizhi.value.id)
    }
    // 返回地址
    const feihuDizhi=(row:any)=>{
        defaultDizhi.value={
            id:row.id,
            code:row.code,
            receivePersonName:row.name,
            receivePersonMobile:row.tel,
            patientAddress:row.address,
        }
    }
    defineExpose({
        openShow
    })
</script>
<style scoped lang="css">
.parent {
    margin-top: 10px;
    background: #fff;
    padding-left: 5px;
    padding-right: 5px;
    border-radius: 10px;
    border: 1px solid #cdd0d6;
    /* background: red; */
    height: 6rem;
    display: grid;
    grid-template-columns: minmax(30px, 30px) 1fr;
}
.parentzi {
    padding-left: 5px;
    /* background: red; */
    height: 6rem;
    display: grid;
    grid-template-columns: minmax(30%, 30%) 1fr;
}
.checkboxclss {
    padding-top: 2.6rem;
    height: 6rem;
    line-height: 6rem;
}
.divcaozuo {
    height: 60px;
    width: 100%;
    /* background-color: yellow; */
    position: absolute;
    bottom: 10px;
    border-top: solid 1px #cdd0d6;
}
 </style>
src/views/jifenShangCheng/index.vue
@@ -1,28 +1,31 @@
<template>
    <div>
        <div>
        <van-loading style="top: 100px;" v-if="loading" type="spinner" size="24px" vertical>
            加载中。。。。
        </van-loading>
        <div v-else>
            <dizhi></dizhi>
            <van-tree-select
                :height="height"
                v-model:main-active-index="activeIndex"
                :items="items"
                >
                <template #content >
                    <div style="text-align: right; padding-right: 20px; height: 50px; line-height: 30px; color: #409EFF; font-size: 16px;">
                        <van-icon size="26px" name="cart-circle-o" style="margin-top: 20px;" />
            >
                <template #content>
                    <div style="text-align: right; padding-right: 15px; height: 50px; line-height: 30px; color: #409eff; font-size: 16px;">
                        <van-icon @click="openGwc" size="26px" name="cart-circle-o" style="margin-top: 20px;" />
                    </div>
                    <div style="border-left: 1px solid rgb(229, 226, 225); background:#f7f8fa;">
                        <van-card
                            style="background: #ffffff;"
                            v-for="(item) in items[activeIndex].items"
                            >
                            <template #desc >
                               <span style="color:#409EFF; font-size: 1rem;">{{item.itemName}}</span>
                    <div v-if="items.length > 0" style="border-left: 1px solid rgb(229, 226, 225); background: #f7f8fa;">
                        <van-card
                            style="background: #fff;"
                            v-for="(item,index) in items[activeIndex].items" :key="index"
                        >
                            <template #desc>
                                <span style="color: #409eff; font-size: 1rem;">{{item.itemName}}</span>
                            </template>
                            <template #price >
                               <span style="color: red; font-size: 1rem;">{{item.itemPrice}}¥</span>
                            <template #price>
                                <span style="color: #f56c6c; font-size: 1rem;">{{item.itemPrice}}¥</span>
                            </template>
                            <template #thumb >
                            <template #thumb>
                                <van-image
                                    fit="contain"
                                    width="100%"
@@ -35,82 +38,83 @@
                            </template>
                            <template #footer>
                                 <van-icon @click="goumai(item)" size="20" color="red" name="shopping-cart-o" />
                                <van-icon @click="goumai(item)" size="20" color="#F56C6C" name="shopping-cart-o" />
                            </template>
                            </van-card>
                        </van-card>
                    </div>
                </template>
            </van-tree-select>
        </div>
        <div>
        </div>
        <!-- 购买弹框 -->
        <div>
            <van-popup v-model:show="show" position="bottom" :style="{ height: '320px' }">
                <div style="padding-top: 20px;">
                    <van-row>
                        <van-col :span="2"  style="height: 60px; line-height: 60px; padding-top: 10px;">
                        <van-col :span="2" style="height: 60px; line-height: 60px; padding-top: 10px;">
                            <van-icon size="40px" color="#E6A23C" name="location-o" />
                        </van-col>
                        <van-col :span="20" style="font-size: 16px; padding-left: 10px; height: 60px; line-height: 30px;" >
                            王虎 燎原西路190弄3好107
                            <br/>联系电话:17717853034
                        <van-col :span="20" style="font-size: 16px; padding-left: 10px; height: 60px; line-height: 30px;">
                            <div>{{defaultDizhi.patientAddress}} </div>
                            <div>联系电话:{{defaultDizhi.receivePersonMobile}} </div>
                        </van-col>
                        <van-col :span="2" style="height: 60px; line-height: 60px;">
                        <van-col :span="2" style="height: 60px; line-height: 60px;">
                            <van-icon size="20px" @click="openDizhi" name="arrow" />
                        </van-col>
                    </van-row>
                </div>
                <div style="padding-top: 20px;" class="setItem">
                    <van-card>
                        <template #desc >
                            <span style="color:#409EFF; font-size: 1rem;">{{setItem.itemName}}</span>
                        <template #desc>
                            <span style="color: #409eff; font-size: 1rem;">{{setItem.itemName}}</span>
                        </template>
                        <template #price >
                            <span style="color: red; font-size: 1rem;">{{setItem.itemPrice}}¥</span>
                        <template #price>
                            <span style="color: #f56c6c; font-size: 1rem;">{{setItem.itemPrice}}¥</span>
                        </template>
                        <template #thumb >
                        <template #thumb>
                            <van-image
                                fit="contain"
                                style="border: 1px solid #ebedf0;"
                                fit="cover"
                                width="100%"
                                height="100%"
                                :src="setItem.itemPhoto"
                            />
                        </template>
                        <template #tags>
                            <br/>
                            <br />
                            <van-tag style="margin-top: 10px;" plain type="danger">选择人数多</van-tag>
                        </template>
                        <template #footer>
                            <span>
                                <van-icon size="1rem" v-if="setItem.number>1" @click="setItem.number--" name="minus" />
                                <van-icon size="1rem" v-if="setItem.number > 1" @click="setItem.number--" name="minus" />
                            </span>
                            <span  style="font-size: 1.2rem; margin-left: 1rem; margin-right: 1rem;">
                            <span style="font-size: 1.2rem; margin-left: 1rem; margin-right: 1rem;">
                                {{setItem.number}}
                            </span>
                            <span>
                                <van-icon size="1rem" @click="setItem.number++" name="plus" />
                            </span>
                        </template>
                    </van-card>
                </div>
                <div style="text-align: right; font-size: 18px; color: red; font-weight: 600; margin-top: 10px;padding-right: 20px;">
                    小计¥{{setItem.itemPrice*setItem.number}}
                <div style="text-align: right; font-size: 18px; color: #f56c6c; font-weight: 600; margin-top: 10px;padding-right: 20px;">
                    小计¥{{setItem.itemPrice * setItem.number}}
                </div>
                <van-action-bar>
                    <van-action-bar-icon icon="revoke" @click="show=false" text="返回" dot />
                    <van-action-bar-icon icon="cart-o" text="购物车" badge="5" />
                    <van-action-bar-button type="warning" text="加入购物车" />
                    <van-action-bar-icon icon="revoke" @click="show = false" text="返回" dot />
                    <van-action-bar-icon icon="cart-o" text="购物车" :badge="gwcBadge" />
                    <van-action-bar-button @click="AddGwc" type="warning" text="加入购物车" />
                    <van-action-bar-button type="danger" text="立即购买" />
                </van-action-bar>
            </van-popup>
        </div>
        <!-- 地址弹框 -->
        <div>
            <dizhi :fanhuiFun="feihuDizhi" ref="dizhiRef"></dizhi>
            <dizhi @fanhui-fun="feihuDizhi" ref="dizhiRef"></dizhi>
        </div>
        <div>
            <gouwuche ref="gouwucheRef"></gouwuche>
        </div>
        <van-tabbar v-model="active" @change="tabChang">
            <van-tabbar-item name="home" icon="like">首页</van-tabbar-item>
@@ -120,79 +124,147 @@
    </div>
</template>
<script lang="ts" setup>
import { computed, ref } from 'vue'
import {useRouter} from 'vue-router'
import { useWindowSize } from '@vant/use'
// import dizhiAdmin from '../jifenShangCheng/components/dizhiAdmin.vue'
import dizhi from '../jifenShangCheng/components/dizhi.vue'
import { userInfoStore } from '@/stores/userInfo'
const userInfo = userInfoStore()
import { ajaxGet ,ajaxPost} from '@/utils/axios'
import { onMounted } from 'vue'
const router=useRouter()
const { width, height } = useWindowSize();
const dizhiRef=ref()
const show=ref(false)
const patientInfo=computed(() => {
    return userInfo.patient
})
const setItem=ref({
    itemName:'dsd',
    itemPrice:0,
    itemPhoto:'',
    code:'',
    number:1,
    id:0
})
const activeIndex = ref(0);
const items=ref([
    {
        name:'',
        text:'',
        items:[]
    }
])
const active=ref('jifen')
const tabChang=(index:any)=>{
    if (index==='home'){
        router.push('/')
    } else if(index==='jifen') {
        router.push('jifenShangCheng')
    }else if(index==='my') {
        router.push('my')
    }
}
// 购买
const goumai=(item:any)=>{
    console.log(item)
    setItem.value={
        itemName:item.itemName,
        itemPrice:item.itemPrice,
        code:item.code,
        number:1,
        itemPhoto:item.itemPhoto,
        id:item.id
    }
    show.value=true
}
// 编辑地址
const openDizhi=()=>{
    dizhiRef.value.openShow()
}
// 返回地址
const feihuDizhi=()=>{
    console.log()
}
onMounted(()=>{
    ajaxPost('/eshop/listItems',`clientCode=${patientInfo.value.patientInfo.clientCode}`).then((re:any)=>{
        console.log(re.category)
        const list= re.category
        items.value =list.map((el:any)=>{
            el.text=el.name
            return el
        })
        console.log(items.value)
    import { computed, ref } from 'vue'
    import {useRouter} from 'vue-router'
    import { useWindowSize } from '@vant/use'
    import dizhi from '../jifenShangCheng/components/dizhi.vue'
    import gouwuche from './components/gouwuche.vue'
    import { userInfoStore } from '@/stores/userInfo'
    const userInfo = userInfoStore()
    import { ajaxPost} from '@/utils/axios'
    import { onMounted } from 'vue'
    import { Toast } from 'vant'
    const router=useRouter()
    const { height } = useWindowSize()
    const dizhiRef=ref()
    const gouwucheRef=ref()
    const show=ref(false)
    const loading=ref(true)
    const gwcBadge=ref(0)
    const gwcList=ref([])
    const defaultDizhi=ref({
        id:0,
        code:'',
        receivePersonName:'',
        receivePersonMobile:'',
        patientAddress:'',
    })
})
    const patientInfo=computed(() => {
        return userInfo.patient
    })
    const setItem=ref({
        itemName:'dsd',
        itemPrice:0,
        itemPhoto:'',
        code:'',
        number:1,
        id:0
    })
    const activeIndex = ref(0)
    const items=ref([
        {
            name:'',
            text:'',
            items:[]
        }
    ])
    const active=ref('jifen')
    const openGwc=()=>{
        gouwucheRef.value.openShow()
    }
    const tabChang=(index:any)=>{
        if (index==='home'){
            router.push('/')
        } else if (index==='jifen') {
            router.push('jifenShangCheng')
        } else if (index==='my') {
            router.push('my')
        }
    }
    const AddGwc=()=>{
        console.log(setItem.value)
        const row={
            code:'',
            id:0,
            itemCode:setItem.value.code,
            itemCount:setItem.value.number,
            patientCode:patientInfo.value.patientInfo.code
        }
        ajaxPost('/eshop/cart/add',row).then(re=>{
            console.log(re)
            Toast.success('已经加入购物车了')
            show.value=false
            getListGwc()
        }).catch(()=>{
        })
    }
    // 购买
    const goumai=(item:any)=>{
        console.log(item)
        setItem.value={
            itemName:item.itemName,
            itemPrice:item.itemPrice,
            code:item.code,
            number:1,
            itemPhoto:item.itemPhoto,
            id:item.id
        }
        show.value=true
    }
    // 编辑地址
    const openDizhi=()=>{
        dizhiRef.value.openShow(defaultDizhi.value.id)
    }
    // 返回地址
    const feihuDizhi=(row:any)=>{
        console.log(row)
        defaultDizhi.value={
            id:row.id,
            code:row.code,
            receivePersonName:row.name,
            receivePersonMobile:row.tel,
            patientAddress:row.address,
        }
    }
    const getListGwc=()=>{
        ajaxPost('/eshop/cart/list',`page=0&size=0&wherecondition=patient_code=\'${patientInfo.value.patientInfo.code}\'`)
            .then((re:any)=>{
                console.log('购物车')
                console.log(re)
                gwcBadge.value=re.list.length
                gwcList.value=re.list
            })
    }
    const getDefDizhi=()=>{
        const pasm=`page=0&size=0&wherecondition=patient_is_default=1 and patient_code="${userInfo.patient.patientInfo.code}"`
        ajaxPost('/patient/address/list', pasm).then((re: any) => {
            console.log('默认地址')
            console.log(re)
            if (re.list.length===0){
                console.log('没有默认地址')
            } else {
                defaultDizhi.value=re.list[0]
            }
            console.log(defaultDizhi.value)
        })
    }
    onMounted(()=>{
        getDefDizhi()
        loading.value=true
        ajaxPost('/eshop/listItems',`clientCode=${patientInfo.value.patientInfo.clientCode}`).then((re:any)=>{
            console.log(re.category)
            const list= re.category
            items.value =list.map((el:any)=>{
                el.text=el.name
                return el
            })
            console.log(items.value)
        }).finally(()=>{
            loading.value=false
        })
        getListGwc()
    })
</script>