From 4ebb7babe7e392d62662d09f97f48647c114cc5f Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期一, 29 五月 2023 14:37:47 +0800
Subject: [PATCH] 45

---
 src/views/jifenShangCheng/index.vue |   62 +++++++++++++++++++++++++++----
 1 files changed, 54 insertions(+), 8 deletions(-)

diff --git a/src/views/jifenShangCheng/index.vue b/src/views/jifenShangCheng/index.vue
index af25a31..b03180e 100644
--- a/src/views/jifenShangCheng/index.vue
+++ b/src/views/jifenShangCheng/index.vue
@@ -11,8 +11,15 @@
                 :items="items"
             >
                 <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
+                        style="border-bottom: #e6e8eb solid 1px; text-align: right;
+                    padding-right: 15px; height: 50px;
+                    line-height: 30px; color: #409eff;
+                    font-size: 16px;">
+                        <!-- 订单 -->
+                        <van-icon @click="openOrder" size="26px" name="balance-list-o" color="#67C23A" style="margin-top: 10px; margin-right: 20px;" />
+                        <!-- 购物车 -->
+                        <van-icon @click="openGwc" size="26px" name="cart-circle-o" color="#F56C6C" style="margin-top: 10px;" />
                     </div>
                     <div v-if="items.length > 0" style="border-left: 1px solid rgb(229, 226, 225); background: #f7f8fa;">
                         <van-card
@@ -54,8 +61,11 @@
                             <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;">
-                            <div>{{defaultDizhi.patientAddress}} </div>
-                            <div>联系电话:{{defaultDizhi.receivePersonMobile}} </div>
+                            <div v-if="defaultDizhi.patientAddress !== ''">{{defaultDizhi.patientAddress}} </div>
+                            <div v-if="defaultDizhi.patientAddress !== ''">联系电话:{{defaultDizhi.receivePersonMobile}} </div>
+                            <div @click="openDizhi" v-else style="margin-top: 18px; color: #e6a23c;">
+                                请设置你的收货地址
+                            </div>
                         </van-col>
                         <van-col :span="2" style="height: 60px; line-height: 60px;">
                             <van-icon size="20px" @click="openDizhi" name="arrow" />
@@ -73,7 +83,7 @@
                         <template #thumb>
                             <van-image
                                 style="border: 1px solid #ebedf0;"
-                                fit="cover"
+                                fit="contain"
                                 width="100%"
                                 height="100%"
                                 :src="setItem.itemPhoto"
@@ -105,7 +115,7 @@
                     <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-button type="danger" @click="liJiGouMai" text="立即购买" />
                 </van-action-bar>
             </van-popup>
         </div>
@@ -115,6 +125,9 @@
         </div>
         <div>
             <gouwuche ref="gouwucheRef"></gouwuche>
+        </div>
+        <div>
+            <myOrder ref="myOrderRef"></myOrder>
         </div>
         <van-tabbar v-model="active" @change="tabChang">
             <van-tabbar-item name="home" icon="like">首页</van-tabbar-item>
@@ -129,6 +142,7 @@
     import { useWindowSize } from '@vant/use'
     import dizhi from '../jifenShangCheng/components/dizhi.vue'
     import gouwuche from './components/gouwuche.vue'
+    import myOrder from './components/myOrder.vue'
     import { userInfoStore } from '@/stores/userInfo'
     const userInfo = userInfoStore()
     import { ajaxPost} from '@/utils/axios'
@@ -137,6 +151,7 @@
     const router=useRouter()
     const { height } = useWindowSize()
     const dizhiRef=ref()
+    const myOrderRef=ref()
     const gouwucheRef=ref()
     const show=ref(false)
     const loading=ref(true)
@@ -172,6 +187,9 @@
     const openGwc=()=>{
         gouwucheRef.value.openShow()
     }
+    const openOrder=()=>{
+        myOrderRef.value.openShow()
+    }
     const tabChang=(index:any)=>{
         if (index==='home'){
             router.push('/')
@@ -199,7 +217,7 @@
 
         })
     }
-    // 购买
+    // 打开购买
     const goumai=(item:any)=>{
         console.log(item)
         setItem.value={
@@ -210,7 +228,35 @@
             itemPhoto:item.itemPhoto,
             id:item.id
         }
-        show.value=true
+        AddGwc()
+        // show.value=true
+    }
+    // 立即购买
+    const liJiGouMai=()=>{
+        if (defaultDizhi.value.id>0){
+            console.log(setItem.value,defaultDizhi.value)
+            const pasm={
+                addressCode:defaultDizhi.value.code,
+                cartCodes:setItem.value.code
+            }
+            console.log(pasm)
+            ajaxPost('/eshop/order/checkout',`addressCode=${defaultDizhi.value.code}&cartCodes=${setItem.value.code}`)
+                .then(re=>{
+                    console.log(re)
+                    if (re.data==='OK'){
+                        Toast.success('您已经兑换成功')
+                    } else {
+                        Toast('兑换失败')
+                    }
+
+                }).catch((error)=>{
+                    console.log(error)
+                    Toast('兑换失败')
+                })
+        } else {
+            Toast('请先选择您的收货地址')
+        }
+
     }
     // 编辑地址
     const openDizhi=()=>{

--
Gitblit v1.8.0