diff --git a/App.vue b/App.vue index 231bca4..a4a6c6b 100644 --- a/App.vue +++ b/App.vue @@ -65,7 +65,9 @@ //团油数据 pelletoilList: '', //分享领取次数 - shareNum:0 + shareNum:0, + // 购物车数量 + cartNum:0, }, onLaunch: function() {}, @@ -73,18 +75,18 @@ // #ifdef MP let accountInfo = uni.getAccountInfoSync(); - // if (accountInfo.miniProgram.envVersion == 'develop' || accountInfo.miniProgram.envVersion == 'trial') { - // this.globalData.url = 'https://hsgcs.dctpay.com/crest'; - // this.globalData.v1url = 'https://hsgcs.dctpay.com/v1'; - // this.globalData.payurl = 'https://gratia-pay.dctpay.com/crest'; - // this.globalData.orderurl = 'https://hsgcs.dctpay.com/order'; - // this.globalData.userurl = 'https://hsgcs.dctpay.com/user'; - // this.globalData.brestUrl = 'https://hsgcs.dctpay.com/brest'; - // this.globalData.imgUrl = 'https://hsgcs.dctpay.com/filesystem/'; - // this.globalData.imageWxImg = 'https://hsgcs.dctpay.com/filesystem/wxApplets/'; - // this.globalData.imageqrImg = 'https://hsgcs.dctpay.com/filesystem/temporary/'; - // } - // if (accountInfo.miniProgram.envVersion == 'release') { + if (accountInfo.miniProgram.envVersion == 'develop' || accountInfo.miniProgram.envVersion == 'trial') { + this.globalData.url = 'https://hsgcs.dctpay.com/crest'; + this.globalData.v1url = 'https://hsgcs.dctpay.com/v1'; + this.globalData.payurl = 'https://gratia-pay.dctpay.com/crest'; + this.globalData.orderurl = 'https://hsgcs.dctpay.com/order'; + this.globalData.userurl = 'https://hsgcs.dctpay.com/user'; + this.globalData.brestUrl = 'https://hsgcs.dctpay.com/brest'; + this.globalData.imgUrl = 'https://hsgcs.dctpay.com/filesystem/'; + this.globalData.imageWxImg = 'https://hsgcs.dctpay.com/filesystem/wxApplets/'; + this.globalData.imageqrImg = 'https://hsgcs.dctpay.com/filesystem/temporary/'; + } + if (accountInfo.miniProgram.envVersion == 'release') { this.globalData.url = 'https://hsg.dctpay.com/crest'; this.globalData.v1url = 'https://hsg.dctpay.com/v1'; this.globalData.payurl = 'https://pay.dctpay.com/crest'; @@ -94,29 +96,29 @@ this.globalData.imgUrl = 'https://hsg.dctpay.com/filesystem/'; this.globalData.imageWxImg = 'https://hsg.dctpay.com/filesystem/wxApplets/'; this.globalData.imageqrImg = 'https://hsg.dctpay.com/filesystem/temporary/'; - // } + } // #endif // #ifdef H5 let that = this; - // that.globalData.url = 'https://hsgcs.dctpay.com/crest'; - // that.globalData.v1url = 'https://hsgcs.dctpay.com/v1'; - // that.globalData.payurl = 'https://gratia-pay.dctpay.com/crest'; - // that.globalData.orderurl = 'https://hsgcs.dctpay.com/order'; - // that.globalData.userurl = 'https://hsgcs.dctpay.com/user'; - // that.globalData.brestUrl = 'https://hsgcs.dctpay.com/brest'; - // that.globalData.imgUrl = 'https://hsgcs.dctpay.com/filesystem/'; - // that.globalData.imageWxImg = 'https://hsgcs.dctpay.com/filesystem/wxApplets/'; - // that.globalData.imageqrImg = 'https://hsgcs.dctpay.com/filesystem/temporary/'; + that.globalData.url = 'https://hsgcs.dctpay.com/crest'; + that.globalData.v1url = 'https://hsgcs.dctpay.com/v1'; + that.globalData.payurl = 'https://gratia-pay.dctpay.com/crest'; + that.globalData.orderurl = 'https://hsgcs.dctpay.com/order'; + that.globalData.userurl = 'https://hsgcs.dctpay.com/user'; + that.globalData.brestUrl = 'https://hsgcs.dctpay.com/brest'; + that.globalData.imgUrl = 'https://hsgcs.dctpay.com/filesystem/'; + that.globalData.imageWxImg = 'https://hsgcs.dctpay.com/filesystem/wxApplets/'; + that.globalData.imageqrImg = 'https://hsgcs.dctpay.com/filesystem/temporary/'; - that.globalData.url = 'https://hsg.dctpay.com/crest'; - that.globalData.v1url = 'https://hsg.dctpay.com/v1'; - that.globalData.payurl = 'https://pay.dctpay.com/crest'; - that.globalData.orderurl = 'https://hsg.dctpay.com/order'; - that.globalData.userurl = 'https://hsg.dctpay.com/user'; - that.globalData.brestUrl = 'https://hsg.dctpay.com/brest'; - that.globalData.imgUrl = 'https://hsg.dctpay.com/filesystem/'; - that.globalData.imageWxImg = 'https://hsg.dctpay.com/filesystem/wxApplets/'; - that.globalData.imageqrImg = 'https://hsg.dctpay.com/filesystem/temporary/'; + // that.globalData.url = 'https://hsg.dctpay.com/crest'; + // that.globalData.v1url = 'https://hsg.dctpay.com/v1'; + // that.globalData.payurl = 'https://pay.dctpay.com/crest'; + // that.globalData.orderurl = 'https://hsg.dctpay.com/order'; + // that.globalData.userurl = 'https://hsg.dctpay.com/user'; + // that.globalData.brestUrl = 'https://hsg.dctpay.com/brest'; + // that.globalData.imgUrl = 'https://hsg.dctpay.com/filesystem/'; + // that.globalData.imageWxImg = 'https://hsg.dctpay.com/filesystem/wxApplets/'; + // that.globalData.imageqrImg = 'https://hsg.dctpay.com/filesystem/temporary/'; uni.getStorage({ key: 'openId', success(e) { @@ -229,6 +231,15 @@ } } }) + uni.getStorage({ + key: 'cartNum', + success(e) { + if (e.data) { + that.globalData.cartNum = e.data; + console.log(that.globalData.cartNum,"getStorage") + } + } + }) // #endif }, onHide: function() {} diff --git a/Utils/Api.js b/Utils/Api.js index 98236e9..b2c6233 100644 --- a/Utils/Api.js +++ b/Utils/Api.js @@ -704,11 +704,11 @@ export const payReceiveDiscount = params => { } //获取二维码 export const generateWeChatMpQrCode = params => { - return POST('POST', `${payBase}/storeDiscountActivityPartakeUser/generateWeChatMpQrCode`, params).then(res => res.data); + return POST('GET', `${payBase}/storeDiscountActivityPartakeUser/generateWeChatMpQrCode`, params).then(res => res.data); } //查询订单详情 export const getOrderByOutTradeOrder = params => { - return POST('POST', `${payBase}/tradeOrder/getOrderByOutTradeOrder`, params).then(res => res.data); + return POST('GET', `${payBase}/tradeOrder/getOrderByOutTradeOrder`, params).then(res => res.data); } diff --git a/Utils/physicalObject.js b/Utils/physicalObject.js new file mode 100644 index 0000000..02c281f --- /dev/null +++ b/Utils/physicalObject.js @@ -0,0 +1,90 @@ +import { + POST +} from "./Request.js"; +let app = getApp(); +let base = app.globalData.url; +// let orderbase = app.globalData.orderurl; +// let userbase = app.globalData.userurl; +// let v1base = app.globalData.v1url; +// let brestBase = app.globalData.brestUrl; +// let payBase = app.globalData.payurl; + + +// 查询分类树 +export const getGoodsTypeTree = params => { + return POST('GET', `${base}/goods/getGoodsTypeTree`, params).then(res => res.data); +} + +// 查询商品列表 +export const getListGoodsDetail = params => { + return POST('GET', `${base}/goods/getListGoodsDetail`, params).then(res => res.data); +} + +//根据商品id查询商品详情 +export const findGoodsDetailById = params => { + return POST('GET', `${base}/goods/findGoodsDetailById`, params).then(res => res.data); +} +// 查询商品规格 +export const findGoodsSkuByGoodsId = params => { + return POST('GET', `${base}/goods/findGoodsSkuByGoodsId`, params).then(res => res.data); +} + + +// 新增购物车内容 +export const insertShoppingCart = params => { + + return POST('POST', `${base}/shoppingCart/insertShoppingCart`, params).then(res => res.data); +} + +// 增加商品数量 +export const goodsAddNum = params => { + return POST('GET', `${base}/shoppingCart/goodsAddNum`, params).then(res => res.data); +} +// 删除购物车商品 +export const deleteShoppingCart = params => { + return POST('GET', `${base}/shoppingCart/deleteShoppingCart`, params).then(res => res.data); +} + +// 查询购物车列表 +export const getShoppingCartList = params => { + return POST('GET', `${base}/shoppingCart/getShoppingCartList`, params).then(res => res.data); +} + +// 查询区域列表 +export const getRegional = params => { + return POST('GET', `${base}/common/getRegional`, params).then(res => res.data); +} + +// 新增收获地址 +export const insertDeliveryAddress = params => { + return POST('POST', `${base}/deliveryAddress/insertDeliveryAddress`, params).then(res => res.data); +} + +// 更新收货地址 +export const updateDeliveryAddress = params => { + return POST('POST', `${base}/deliveryAddress/updateDeliveryAddress`, params).then(res => res.data); +} + +// 查询收货地址列表 +export const getDeliveryAddressList = params => { + return POST('GET', `${base}/deliveryAddress/getDeliveryAddressList`, params).then(res => res.data); +} + +// 根据id 查询收货地址详情 +export const findDeliveryAddressById = params => { + return POST('GET', `${base}/deliveryAddress/findDeliveryAddressById`, params).then(res => res.data); +} + +// 根据id 删除收货地址 +export const deleteAddress = params => { + return POST('GET', `${base}/deliveryAddress/deleteShoppingCart`, params).then(res => res.data); +} + +// 查询物流信息 +export const getLogisticsMsg = params => { + return POST('GET', `${base}/goods/getLogisticsMsg`, params).then(res => res.data); +} +// 根据区域查询运费和包邮价格 +export const getRegionFreight = params => { + return POST('GET', `${base}/common/getRegionFreight`, params).then(res => res.data); +} \ No newline at end of file diff --git a/components/dataList/dataList.vue b/components/dataList/dataList.vue index 88894ae..aa305c2 100644 --- a/components/dataList/dataList.vue +++ b/components/dataList/dataList.vue @@ -1,10 +1,10 @@ @@ -21,43 +23,107 @@ \ No newline at end of file + diff --git a/pages/classify/goodsDetail/goodsDetail.vue b/pages/classify/goodsDetail/goodsDetail.vue index 14b0113..eb67af5 100644 --- a/pages/classify/goodsDetail/goodsDetail.vue +++ b/pages/classify/goodsDetail/goodsDetail.vue @@ -3,11 +3,11 @@ - - + + - {{currentSwiper+1}}/{{swiperList.length}} + {{currentSwiper+1}}/{{goodsDetail.bannerImg.length}} @@ -15,12 +15,12 @@ - ¥19.9 + ¥19 ¥26 - 天友利乐核桃花生奶 180ml*20 - 山东好花生 + {{goodsDetail.name || ''}} + {{goodsDetail.listDescribe || ''}} @@ -64,8 +64,8 @@ ———— 商品详情 ———— - + @@ -91,7 +91,7 @@ - + @@ -148,33 +148,34 @@ import cartChoose from '@/pages/classify/cart-choose/cart-choose.vue' import uniGoodsNav from '@/components/uni-goods-nav/components/uni-goods-nav/uni-goods-nav.vue' - let listData=require("./data.json") + + + import { findGoodsDetailById ,getShoppingCartList,insertShoppingCart,findGoodsSkuByGoodsId} from '@/Utils/physicalObject.js'; + const app = getApp(); export default { data(){ return{ - //轮播主图数据 - swiperList: [], - couponDesc: [], + imageUrl: app.globalData.imgUrl,//图片地址 //轮播图下标 currentSwiper: 0, isStar:false, - // chooseIndex:0, - // chooseNumber:1, // - options:[{ - icon: 'chat', - text: '客服', - }, { - icon: 'shoucang31', - text: '收藏', - }, { + options:[ + // { + // icon: 'chat', + // text: '客服', + // }, { + // icon: 'shoucang31', + // text: '收藏', + // }, + { icon: 'cart', text: '购物车', - info: 2, + info: 0, color:"#646566" }], buttonGroup: [{ @@ -193,7 +194,11 @@ // scIcon:'shoucang31' - // + goodsId:0, + goodsDetail:null, + specificationList:[] + + } @@ -209,6 +214,11 @@ return } }, + onLoad(options){ + this.goodsId = options.goodsId; + this.findGoodsById(); + this.refreshCartNum() + }, components:{ wybPopup, cartChoose, @@ -217,8 +227,6 @@ }, onShow(){ - this.swiperList = listData.images; - this.couponDesc = listData; // if(this.options[1].shoucang == true){ @@ -235,11 +243,53 @@ }, + methods:{ + // 刷新购物车数量 + refreshCartNum(){ + getShoppingCartList().then( res=>{ + if (res.return_code == '000000') { + this.options[0].info = res.return_data.length; + + }else{ + uni.showToast({ + title: res.return_msg, + icon: 'none', + duration: 2000 + }) + } + }) + }, + findGoodsById(){ + let _this = this; + let params ={ + id:_this.goodsId + } + findGoodsDetailById(params).then(res=>{ + if (res.return_code == '000000') { + + this.goodsDetail = res.return_data; + this.goodsDetail.bannerImg = res.return_data.bannerImg.split(",").map(temp=>this.imageUrl + temp); + this.goodsDetail.detailImg = res.return_data.detailImg.split(",").map(temp=>this.imageUrl + temp); + console.log(this.goodsDetail,) + + // let list =item.map(temp=>this.imageUrl + temp) + + }else{ + uni.showToast({ + title: res.return_msg, + icon: 'none', + duration: 2000 + }) + } + }) + }, + + //显示弹出 - showPopup(num) { + showPopup(num) { if(num == 1){ - this.$refs.popup.show(); + this.findGoodsSku(this.goodsId); }else if(num == 2){ this.$refs.popup2.show(); } @@ -255,11 +305,6 @@ }, //查看大图 perImage(index,item) { - console.log(index,item) - // uni.previewImage({ - // current: 0, //预览图片的下标 - // urls: [item] //预览图片的地址,必须要数组形式,如果不是数组形式就转换成数组形式就可以 - // }) uni.previewImage({ current: Number(index), //预览图片的下标 urls: item //预览图片的地址,必须要数组形式,如果不是数组形式就转换成数组形式就可以 @@ -283,29 +328,31 @@ onClick(e) { - // 客服 + // 购物车 if(e.index == 0){ - console.log("点击客服") - + // console.log("点击购物车") + uni.navigateTo({ + url:"/pages/classify/cart/cart" + }) return } // 收藏 - if(e.index == 1){ - this.isShowCang = !this.isShowCang; - console.log("点击收藏") - return + // if(e.index == 1){ + // this.isShowCang = !this.isShowCang; + // console.log("点击收藏") + // return - } + // } // 购物车 - if(e.index == 2){ - console.log("点击去购物车") - uni.navigateTo({ - url:"/pages/classify/cart/cart" - }) - return + // if(e.index == 2){ + // console.log("点击去购物车") + // uni.navigateTo({ + // url:"/pages/classify/cart/cart" + // }) + // return - } + // } // uni.showToast({ // title: `点击${e.content.text}`, @@ -327,7 +374,68 @@ return } - } + }, + //加入购物车 + toCart(){ + let params={ + // goodsId:this.specificationList[this.chooseIndex].goodsId, + // num:this.chooseNumber, + // sku:this.specificationList[this.chooseIndex].id, + // whetherCheck:true + } + + // insertShoppingCart(params).then(async res=>{ + // let title ; + // if (res.return_code == '000000') { + // title = res.return_data; + // this.$emit("refreshCartNum") + + // }else{ + // title = res.return_msg; + // } + // uni.showToast({ + // title: title, + // icon: 'none', + // duration: 2000 + // }) + + + + // this.$emit("close") + + // }) + + + }, + // 查询规格 + findGoodsSku(id){ + this.specificationList = []; + let params={ + goodsId:id + }; + + findGoodsSkuByGoodsId(params).then(res=>{ + if (res.return_code == '000000') { + if(res.return_data&&res.return_data.length>0){ + this.specificationList = res.return_data; + this.$refs.popup.show(); + }else{ + this.specificationList = []; + } + + }else{ + uni.showToast({ + title: res.return_msg, + icon: 'none', + duration: 2000 + }) + } + + + }) + + + }, } diff --git a/pages/goods/externalCoupon/externalCoupon.vue b/pages/goods/externalCoupon/externalCoupon.vue index eeae6b4..1d1920b 100644 --- a/pages/goods/externalCoupon/externalCoupon.vue +++ b/pages/goods/externalCoupon/externalCoupon.vue @@ -65,8 +65,7 @@ - + - + - + - {{item.name}} + {{item.title}} @@ -28,13 +28,11 @@ - - - - - {{item.name}} + + + + + {{item.title}} @@ -45,9 +43,9 @@ - 综合 - 销量 - + 综合 + 销量 + 价格 @@ -57,7 +55,7 @@ - + @@ -66,23 +64,24 @@ - - + - + \ No newline at end of file diff --git a/subPages/recharge/recharge.vue b/subPages/recharge/recharge.vue index 402bcea..f0d3a39 100644 --- a/subPages/recharge/recharge.vue +++ b/subPages/recharge/recharge.vue @@ -1,9 +1,9 @@