Ver Fonte

购物车对接

liude há 1 ano atrás
pai
commit
f68f90d155

+ 15 - 0
src/api/client/business.js

@@ -137,6 +137,21 @@ export function getShoppingCart(data) {
   });
 }
 
+/**
+ * 购物车接口 - 获取购物车商品列表2
+ * @param {*} data
+ * @returns
+ */
+export function getCartList(id) {
+  return request({
+    url: `/maintain/listCartItem/${id}`,
+    method: 'GET',
+    header: {
+      'Content-Type': 'application/json',
+    },
+  });
+}
+
 
 /**
  * 购物车接口 - 删除购物车

+ 38 - 24
src/pages/client/clientPackage/storeDetail.vue

@@ -127,7 +127,7 @@
 </template>
 
 <script>
-  import { getSellsDetail, addReservation , addShoppingCart } from '@/api/client/business.js';
+  import { getSellsDetail, addReservation , addShoppingCart  } from '@/api/client/business.js';
   import { getCurrentLocation, hotMerchant } from '@/api/client/home';
   import settleBottomBtn from "@/components/settleBottomBtn/settleBottomBtn.vue"
   export default {
@@ -181,27 +181,37 @@
     methods: {
       // 获取当前经纬度
       handlerInitLocation() {
-        uni.getLocation({
-          type: 'gcj02',
-          success: res => {
-            this.queryParams.longitude = res.longitude;
-            this.queryParams.latitude = res.latitude;
-            let point = {
-              latitude: res.latitude,
-              longitude: res.longitude,
-            };
-            getCurrentLocation(point).then(rc => {
-              this.queryParams.region = rc.data.id;
-              this.handlerInitList();
-            });
-          },
-          fail: rs => {
-            uni.showToast({
-              title: rs,
-              icon: 'none',
-            });
-          },
-        });
+        // uni.getLocation({
+        //   type: 'gcj02',
+        //   success: res => {
+        //     this.queryParams.longitude = res.longitude;
+        //     this.queryParams.latitude = res.latitude;
+        //     let point = {
+        //       latitude: res.latitude,
+        //       longitude: res.longitude,
+        //     };
+        //     getCurrentLocation(point).then(rc => {
+        //       this.queryParams.region = rc.data.id;
+        //       this.handlerInitList();
+        //     });
+        //   },
+        //   fail: rs => {
+        //     uni.showToast({
+        //       title: rs,
+        //       icon: 'none',
+        //     });
+        //   },
+        // });
+        this.queryParams.longitude = 119.13279;
+        this.queryParams.latitude = 36.70864;
+        let point = {
+          latitude: 36.70864,
+          longitude: 119.13279,
+        };
+        // getCurrentLocation(point).then(rc => {
+          this.queryParams.region = 370705;
+          this.handlerInitList();
+        // });
       },
       // 初始化列表
       handlerInitList() {
@@ -213,6 +223,10 @@
         });
         // 获取锚点
         hotMerchant(this.queryParams.id).then();
+
+        addShoppingCart({}).then(res=>{
+          console.log('addShoppingCart',res);
+        })
       },
       // 点击拨打电话
       handlerMakeCall() {
@@ -293,12 +307,12 @@
       // 添加购物车
       handlerAddCart(e){
         let params = {
-          merchantId:this.queryParams.id,
+          merchantId:this.ids,
           goodsId:e.id,
           quantity:1,
           price:e.specialPrice,
           goodsName:e.name,
-          goodsPic:e.logo,
+          goodsPic:e.logo, // 这个没了
           // goodsSubTitle:this.goods.description
         }
         this.goodsCateList.push(params)

+ 24 - 18
src/pages/client/clientPackage/uptickOrder.vue

@@ -31,9 +31,9 @@
 			</view>
 
 			<view class="message-box">
-				<view class="goods-title"> 猫牙米·卖瓜的(红雷店) </view>
+				<view class="goods-title"> {{ init_list.merchantDTO.name }} </view>
 				<u-line margin='20rpx 0'></u-line>
-				<view class="goods-item" v-for="(item,index) of init_list" :key='item.goodsId'>
+				<view class="goods-item" v-for="(item,index) of init_list.cartItems" :key='item.goodsId'>
 					<view class="item-left">
 						<image class="left-img" src="@/static/QR57a.jpg"></image>
 						<view class="left-text">
@@ -41,7 +41,7 @@
 							<view class="text-number">×{{ item.quantity }}</view>
 							<view class="price-box">
 								<p class="price red-color"> <span style="font-size: 24rpx;">¥</span>{{ item.price }}</p><span
-									class="false-price">¥{{ item.price }}</span>
+									class="false-price">¥{{ item.originalPrice }}</span>
 							</view>
 						</view>
 					</view>
@@ -77,8 +77,8 @@
 				<view class="message-item">
 					<view class="item-left"> 订单总价 </view>
 					<view class=" flex-end red-color" style="align-items: center;">
-						<p style="margin-right: 20rpx; font-size: 36rpx; font-weight: bold;">¥{{ orderParams.allPrice.toFixed(2) }}</p>
-						<p>( 已优惠¥{{ orderParams.discountPrice.toFixed(2) }} )</p>
+						<p style="margin-right: 20rpx; font-size: 36rpx; font-weight: bold;">¥{{ orderParams.price.toFixed(2) }}</p>
+						<p>( 已优惠¥{{ orderParams.allPrice.toFixed(2) }} )</p>
 					</view>
 				</view>
 			</view>
@@ -139,7 +139,7 @@
 </template>
 
 <script>
-  import { getShoppingCart ,generateOrder } from "@/api/client/business.js"
+  import { getShoppingCart ,generateOrder ,getCartList} from "@/api/client/business.js"
 	export default {
 		data() {
 			return {
@@ -190,37 +190,43 @@
         let price = 0
         let discountPrice = 0
         let allPrice = 0
-        this.init_list.map(rs=>{
+        this.init_list.cartItems.map(rs=>{
           price += Number( rs.price * rs.quantity )
-          discountPrice += Number( rs.price * rs.quantity )
+          discountPrice += Number( rs.originalPrice * rs.quantity )
         })
-        allPrice = price - discountPrice
-        return { allPrice , discountPrice }
+        allPrice = discountPrice - price
+        return { allPrice , price }
       }
     },
 		methods:{
       handlerInitList(){
-        getShoppingCart().then(res=>{
+        getCartList(this.merchantId).then(res=>{
           this.init_list = res.data
+
         })
       },
 			// 结算按钮
 			handlerSettleBtn(){
 
-        // uni.navigateTo({
-        //   url:'/pages/client/clientPackage/settleStatusPage'
-        // })
-
         let params = {
           payType:'2',
           cartIds:[],
-          merchantId:this.merchantId
+          merchantId:this.init_list.merchantDTO.id
         }
-        this.init_list.map(rs=>{
+        this.init_list.cartItems.map(rs=>{
           params.cartIds.push(rs.goodsId)
         })
         generateOrder(params).then(res=>{
-          console.log("@@@@res",res)
+          if(res.code == 200){
+            uni.navigateTo({
+              url:'/pages/client/clientPackage/settleStatusPage'
+            })
+          }else{
+            uni.showToast({
+              title:res.msg,
+            })
+            return
+          }
         })
 
 

+ 21 - 15
src/pages/client/tabBar/home/index.vue

@@ -161,23 +161,29 @@ export default {
     },
   },
 
-  watch: {
-    location: {
-      handler: async function (newVal) {
-        const result = await getCurrentLocation(newVal);
-        const param = Object.assign(
-          {},
-          {
-            region: result.data.id,
-          },
-          newVal,
-        );
-        this.getHomeData(param);
-      },
-    },
-  },
+  // watch: {
+  //   location: {
+  //     handler: async function (newVal) {
+  //       const result = await getCurrentLocation({latitude: 36.70864,longitude: 119.13279});
+  //       const param = Object.assign(
+  //         {},
+  //         {
+  //           region: result.data.id,
+  //         },
+  //         newVal,
+  //       );
+  //       this.getHomeData(param);
+  //     },
+  //   },
+  // },
   onShow() {
     this.getSwiperList();
+    let params = {
+          region: 370705,
+          longitude: 119.13279,
+          latitude: 36.70864
+        }
+        this.getHomeData(params)
   },
 
   //页面加载

+ 2 - 2
src/utils/request.js

@@ -3,8 +3,8 @@ import {
 } from '@/utils/system';
 import store from '@/store';
 
-// const BASE_URL = 'http://192.168.68.77:11000';
-const BASE_URL = 'https://test.api.chelvc.com';
+ const BASE_URL = 'http://192.168.43.175:11000';
+// const BASE_URL = 'https://test.api.chelvc.com';
 const TIME_OUT = 60000;
 const errStatus = {
   200: '成功',