diff --git a/api/goods/index.js b/api/goods/index.js index 350ed77..e7b80b4 100644 --- a/api/goods/index.js +++ b/api/goods/index.js @@ -10,7 +10,8 @@ const api = { skuInfo: 'goods/skuInfo', recommended: 'goods/recommended', poster: 'goods/poster', - serveList:'goods.service/list' + serveList:'goods.service/list', + presale:'goods/presale' } // 商品浏览记录 @@ -18,6 +19,10 @@ export const browseHistory = (param, option) => { return request.get(api.browseHistory, param, option) } // 商品浏览记录 +export const presale = (param, option) => { + return request.get(api.presale, param, option) +} +// 服务 export const serveList = (param, option) => { return request.get(api.serveList, param, option) } diff --git a/api/home/index.js b/api/home/index.js index d5f6c32..0c7d7d8 100644 --- a/api/home/index.js +++ b/api/home/index.js @@ -5,14 +5,18 @@ const api = { list: 'goods/list', chartsGoodsJing:'goods/chartsGoodsJing', brandList:'goods/brandList', - typeList:'category/list' + typeList:'category/list', + cityInfo:'goods/cityInfo' } +// 商品列表 +export const cityInfo = (param, option) => { + return request.get(api.cityInfo, param, option) +} // 商品列表 export const list = (param, option) => { return request.get(api.list, param, option) } - // 首页排行榜 export const chartsGoodsJing = (param, option) => { return request.get(api.chartsGoodsJing, param, option) diff --git a/api/preList/index.js b/api/preList/index.js new file mode 100644 index 0000000..45416e9 --- /dev/null +++ b/api/preList/index.js @@ -0,0 +1,20 @@ +import request from '@/utils/request' + +// api地址 +const api = { + list: 'goods/presaleList', + canlpresale: 'goods/canlpresale' + +} + +/** + * 获取支付订单的信息 + * @param {Number} orderId + * @param {Object} param + */ +export function list(param) { + return request.get(api.list, param) +} +export function canlpresale(param) { + return request.get(api.canlpresale, param) +} \ No newline at end of file diff --git a/pages/category/index.vue b/pages/category/index.vue index aef3e7d..ddc287f 100644 --- a/pages/category/index.vue +++ b/pages/category/index.vue @@ -26,10 +26,10 @@ 热门分类 - - + + - TCL + {{item.name}} @@ -60,7 +60,7 @@ return { secondChose:'', menuList: [], - typeName: '空调', + typeName: '', goodsList: [], isChose: '', hotList: [], @@ -76,11 +76,14 @@ this.isChose = item.category_id; this.secondMenu = item.children; this.secondChose='' + this.hotList = item.children // this.secondChose = this.secondMenu[0].category_id; this.getSonList(this.isChose) }, choseSecondMenu(item){ this.secondChose = item.category_id; + this.typeName = item.name + this.getSonList(this.secondChose) }, getGoodsTypeList() { diff --git a/pages/goods/components/SkuPopup.vue b/pages/goods/components/SkuPopup.vue index 23abfbb..9d4e591 100644 --- a/pages/goods/components/SkuPopup.vue +++ b/pages/goods/components/SkuPopup.vue @@ -168,7 +168,7 @@ // 立即购买 buyNow(selectShop) { // 跳转到订单结算页 - this.$navTo('pages/checkout/index', { + this.$navTo('pages/sureOrder/index', { mode: 'buyNow', goodsId: selectShop.goods_id, goodsSkuId: selectShop.goods_sku_id, diff --git a/pages/goods/detail.vue b/pages/goods/detail.vue index e61a16d..fc57e9c 100644 --- a/pages/goods/detail.vue +++ b/pages/goods/detail.vue @@ -10,7 +10,7 @@ - + {{goods.skuList[0].goods_sku_id}} @@ -90,7 +90,7 @@ - {{}} + {{addressInfo.region.province +'-'+addressInfo.region.city+'-'+addressInfo.region.region}} @@ -107,15 +107,12 @@ 商家来源:平台认证商户 - - + 服务 - - 枪色 1件 + + {{item.name}} @@ -171,14 +168,14 @@ 立即购买 - + 立即预约 - + @@ -189,7 +186,7 @@ 我知道了 - + 设置秒杀价格 @@ -232,33 +229,33 @@ - + - 夏普4T-M70H7DA 70英寸 4K 高清进口屏智能语音平板液晶电视机6575 + {{goods.goods_name}} - ¥4980 + ¥{{goods.goods_price_min}} - + - + 复制文案 - + - 微信好友 + @@ -304,27 +301,94 @@ userInfo: {}, addressList:[], addressInfo:{}, + serveList:[], + token:'', } }, onLoad(options) { + this.isPre = options.isPre + this.goodsId = options.goodsId this.getGoodsDetail(options.goodsId) }, onShow() { + this.token = uni.getStorageSync('token') this.getAddressList() this.getSuggestGoods() this.userInfo = uni.getStorageSync('userInfo'); + this.getServeList() }, methods: { + copyText(val){ + // 获取要复制的文本内容 + let text = val; + + uni.setClipboardData({ + data: text, + success(res) { + console.log('成功复制到剪贴板'); + }, + fail(err) { + console.error('复制失败', err); + } + }); + + + }, + shareWechat(){ + uni.share({ + provider: "weixin", + scene: "WXSceneSession", + type: 2, + imageUrl: this.goods.goods_image, + success: function (res) { + console.log("success:" + JSON.stringify(res)); + }, + fail: function (err) { + console.log("fail:" + JSON.stringify(err)); + } + }); + }, + shareImg(){ + this.openDialog =true + this.shareType= 'share' + }, + preNow(){ + const that = this + let params={ + goods_id:that.goods.goods_id, + pre_id:1 + } + GoodsApi.presale(params).then(res => { + if (res.status == 200) { + that.$toast(res.message) + } + }) + .catch() + }, + getServeList(){ + const that = this + let params = { + goodsId:that.goodsId + } + return new Promise((resolve, reject) => { + GoodsApi.serveList(params).then(res => { + if (res.status == 200) { + that.serveList = res.data.list + } + }) + .catch() + }) + }, // 选择商品规格 getAddressList(){ const that = this return new Promise((resolve, reject) => { address.list().then(res => { - if (res.code == 200) { + if (res.status == 200) { that.addressList = res.data.list - console.log('58555559999') + console.log('58555559999',that.addressList) that.getDefaultAddress() } }) @@ -336,10 +400,12 @@ const that = this return new Promise((resolve, reject) => { address.defaultId().then(res => { - if (res.code == 200) { + if (res.status == 200) { for (var i = 0; i < that.addressList.length; i++) { if (res.data.defaultId == that.addressList[i].address_id) { - that.addressInfo = that.addressList[i] + that.addressInfo = that.addressList[i]; + + console.log(that.addressInfo,'获取地址') } } } @@ -413,8 +479,20 @@ }, buyNow() { // 立即下单 + console.log(this.token,'登录信息') + // if(!this.token){ + // this.$toast('请登录') + // uni.navigateTo({ + // url:'/pages/login/index' + // }) + // } + if(this.goods.stock_total==0){ + return this.$toast('库存不足,请选择其他商品购买') + } + const item = JSON.stringify(this.goods) + uni.navigateTo({ - url: '/pages/sureOrder/index?goodsInfo=' + JSON.stringify(this.goods) + url: '/pages/sureOrder/index?goodsID=' +encodeURIComponent(item) }) }, shareCancel() { @@ -936,8 +1014,8 @@ font-family: PingFang SC, PingFang SC; font-weight: 400; color: #000000; - line-height: 33rpx; - display: -webkit-box; + // line-height: 33rpx; + // display: -webkit-box; overflow: hidden; text-overflow: ellipsis; white-space: normal !important; diff --git a/pages/index/index.vue b/pages/index/index.vue index 39fcf55..39724e3 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -243,45 +243,52 @@ - + - 昆明湖店·YN_k121 + {{cityInfo.shop_name}} 营业中 - 5.0 - 营业时间:9:00-21:30 + 营业时间:{{cityInfo.shop_hours}} - - 手机选购 - - - - - 咨询 + + + {{item}} - - - - - - - 电话 + + + + + + + 咨询 + + + + + + + + + 电话 + + @@ -289,15 +296,15 @@ - 昆明市盘龙区盘江路瀑布公园广场 + {{cityInfo.address}} - 距地铁2号线大道站2号口600m + {{cityInfo.summary}} - + 附近停车场 @@ -335,8 +342,8 @@ - - + + @@ -353,15 +360,15 @@ - - Shark特 + + {{cityInfo.evaluate.nickname}} 1天前 - 非常棒,讲解细致,下次还来! + {{cityInfo.evaluate.content}} @@ -377,8 +384,8 @@ - - + + @@ -393,7 +400,15 @@ - + + + + + @@ -441,6 +456,7 @@ ], goodsType: [], + cityInfo:{} } }, onShow() { @@ -448,9 +464,22 @@ this.getRankingList(); this.getbrandList(); this.getSeckill(); - this.getSuggest() + this.getSuggest(); + this.getCityInfo() }, methods: { + getCityInfo(){ + const that =this + GoodsApi.cityInfo() + .then(res => { + if (res.status == 200) { + that.cityInfo = res.data + } + + + }) + .finally(() => {}) + }, getTypeList() { const that = this GoodsApi.typeList() @@ -551,6 +580,12 @@ url: '/pages/search/index' }) }, + toPark(){ + // 停车指引 + uni.navigateTo({ + url: '/pages/news/park/index' + }) + }, goDetails(item) { uni.navigateTo({ url: '/pages/goods/detail?goodsId=' + item.goods_id @@ -1710,7 +1745,7 @@ .shopInfo { width: 698rpx; - height: 400rpx; + min-height: 400rpx; background: linear-gradient(180deg, rgba(255, 255, 255, 0.86) 0%, #FFFFFF 100%); border-radius: 8rpx 8rpx 8rpx 8rpx; opacity: 1; @@ -1771,23 +1806,49 @@ .tip { display: flex; - + justify-content: space-between; margin-top: 10rpx; - - .tipItem { - margin-right: 10rpx; - width: 116rpx; - height: 42rpx; - background: #F5F5F5; - border-radius: 4rpx 4rpx 4rpx 4rpx; - opacity: 1; - text-align: center; - line-height: 42rpx; - font-size: 24rpx; - font-weight: 400; - color: #818181; + .tipleft{ + display: flex; + .tipItem { + margin-right: 10rpx; + width: 116rpx; + height: 42rpx; + background: #F5F5F5; + border-radius: 4rpx 4rpx 4rpx 4rpx; + opacity: 1; + text-align: center; + line-height: 42rpx; + font-size: 24rpx; + font-weight: 400; + color: #818181; + } } + .tipRight{ + display: flex; + align-items: center; + .ask { + margin-left: 16rpx; + + position: relative; + top: -20rpx; + + .weChat { + width: 32rpx; + height: 32rpx; + } + + .askText { + height: 28rpx; + font-size: 20rpx; + font-weight: 400; + color: #989898; + line-height: 28rpx; + } + } + } + .al { width: 0rpx; @@ -1797,25 +1858,7 @@ margin-left: 8rpx; } - .ask { - margin-left: 16rpx; - - position: relative; - top: -20rpx; - - .weChat { - width: 32rpx; - height: 32rpx; - } - - .askText { - height: 28rpx; - font-size: 20rpx; - font-weight: 400; - color: #989898; - line-height: 28rpx; - } - } + } .hline { @@ -1841,7 +1884,7 @@ } .adInfo { - height: 40rpx; + min-height: 40rpx; font-size: 28rpx; font-family: PingFang SC, PingFang SC; font-weight: 400; diff --git a/pages/news/coupon/list.vue b/pages/news/coupon/list.vue index f5cadc9..4342303 100644 --- a/pages/news/coupon/list.vue +++ b/pages/news/coupon/list.vue @@ -5,7 +5,7 @@ :is-scroll="false" v-model="tabIndex" @change="change"> - + {{item.reduce_price}} {{item.discount}}折 有效期:{{item.end_time}} @@ -39,6 +39,7 @@ export default { data() { return { + choseId:'', list: [{ name: '未使用', val:'isUsable' @@ -50,13 +51,23 @@ val:'isExpire' }], tabIndex: 0, - couponList:[] + couponList:[], + isChose:false } }, + onLoad(o){ + this.isChose = o.chose + }, onShow() { this.getCoupon(this.tabIndex) }, methods: { + choseItem(item){ + if(this.isChose){ + uni.setStorageSync('couponId',item.coupon_id) + uni.navigateBack() + } + }, getCoupon(e) { const that = this let param={ diff --git a/pages/news/park/recordHistory.vue b/pages/news/park/recordHistory.vue index 4051df7..0295d39 100644 --- a/pages/news/park/recordHistory.vue +++ b/pages/news/park/recordHistory.vue @@ -1,30 +1,63 @@ - @@ -119,5 +152,13 @@ } } } +} +.content{ + padding-top: 50%; + text-align: center; + width: 100%; + color: gray; + font-size: 28rpx; + line-height: 30rpx; } diff --git a/pages/news/rules/rulesList.vue b/pages/news/rules/rulesList.vue index dabe8a8..1a9cf99 100644 --- a/pages/news/rules/rulesList.vue +++ b/pages/news/rules/rulesList.vue @@ -1,39 +1,39 @@ \ No newline at end of file diff --git a/pages/search/index.vue b/pages/search/index.vue index a6848fb..e6539db 100644 --- a/pages/search/index.vue +++ b/pages/search/index.vue @@ -79,10 +79,13 @@ this.searchList = uni.getStorageSync('searchList') this.searchList = Array.from(new Set(this.searchList)); } - + this.getHot() }, methods: { + getHot(){ + + }, searchGoods(item){ this.searchList.push(this.searchValue) this.searchList = Array.from(new Set(this.searchList)); diff --git a/pages/sureOrder/index.vue b/pages/sureOrder/index.vue index 68675ae..8d0e35d 100644 --- a/pages/sureOrder/index.vue +++ b/pages/sureOrder/index.vue @@ -23,7 +23,7 @@ - + 花梨服务站 @@ -33,9 +33,9 @@ - {{addressInfo.name}} + {{addressInfo.name}} {{addressInfo.region.province +addressInfo.region.city+addressInfo.region.region}} - + 距您16.39km @@ -94,7 +94,7 @@ - + + @@ -121,14 +121,14 @@ - + - iphone13 绿色 128GB + {{goodsInfo.goods_name}} - ¥ 7599 + ¥ {{goodsInfo.goods_price_min}} @@ -137,13 +137,11 @@ - + 留言 + - - 建议留言前与客服沟通确认 - - + @@ -151,7 +149,7 @@ 商品总额 - ¥7599 + ¥{{goodsInfo.goods_price_min}} @@ -159,7 +157,7 @@ 运费 - ¥7599 + ¥{{goodsInfo.goods_price_min}} @@ -174,8 +172,8 @@ 优惠券 - - 0张可用 + + {{couponList.length}}张可用 @@ -188,7 +186,7 @@ 共1件,合计: - ¥7664 + ¥{{goodsInfo.goods_price_min}} @@ -204,30 +202,32 @@ - - - 找微信好友代付 + + + + 余额支付 + + - - + - + + --> 应付款 - 7640 + {{goodsInfo.goods_price_min}} - + 提交订单 @@ -239,9 +239,16 @@ import img from "@/static/member/head.png" import * as storeShop from '@/api/shop.js' import * as address from '@/api/address.js' + import * as cashier from '@/api/cashier/index.js' + import * as CouponApi from '@/api/coupon' + import { + Wechat + } from '@/core/payment' export default { data() { return { + remark: '', + payType: 'weChat', buyType: 'sm', background: { background: 'url(' + img + ') center top no-repeat', @@ -250,31 +257,61 @@ goodsInfo: {}, shopInfo: {}, addressList: [], - addressInfo: {} + addressInfo: {}, + payMethList: [], + orderID: '', + couponList: [], } }, onLoad(options) { - if (options.goodsInfo) { - this.goodsInfo = JSON.parse(options.goodsInfo) - } + console.log(options, 'kkkkkk') + // if (options.goodsInfo) { + let goodsInfo = options.goodsID; + console.log(goodsInfo, '5555555', typeof(goodsInfo)); + this.goodsInfo = JSON.parse(decodeURIComponent(goodsInfo)) + console.log(this.goodsInfo, '666666'); + // } }, onShow() { - this.getGoodsInfo() + this.getShopInfo() this.getAddressList(); + this.orderSubmit() + this.getCoupon() }, methods: { + getCoupon() { + const that =this + let param = { + dataType:'isUsable' + } + CouponApi.myCouponList(param) + .then(res => { + that.couponList = res.data.list.data + }) + .finally() + }, + choseCoupon() { + // 选择优惠券 + uni.navigateTo({ + url: '/pages/news/coupon/list?chose=true', + }) + }, + chosePayType(item) { + this.payType = item.method + }, choseType(val) { this.buyType = val }, getDefaultAddress() { + const that = this return new Promise((resolve, reject) => { address.defaultId().then(res => { - if (res.code == 200) { + if (res.status == 200) { for (var i = 0; i < that.addressList.length; i++) { if (res.data.defaultId == that.addressList[i].address_id) { that.addressInfo = that.addressList[i] - that.getOrderInfo() + console.log(that.addressInfo, '获取收货地址') } } } @@ -282,23 +319,11 @@ .catch() }) }, - getOrderInfo() { - const that = this - return new Promise((resolve, reject) => { - address.list().then(res => { - if (res.code == 200) { - that.addressList = res.data.list - that.getDefaultAddress() - } - }) - .catch() - }) - }, getAddressList() { const that = this return new Promise((resolve, reject) => { address.list().then(res => { - if (res.code == 200) { + if (res.status == 200) { that.addressList = res.data.list that.getDefaultAddress() } @@ -306,7 +331,7 @@ .catch() }) }, - getGoodsInfo() { + getShopInfo() { return new Promise((resolve, reject) => { storeShop.list().then(res => { console.log(res, '获取店铺信息') @@ -316,25 +341,131 @@ }, orderSubmit() { - const that = this + const that = this; + console.log(that.goodsInfo, '55555') let params = { - mode: '结算模式', - delivery: '配送方式(10快递配送 20上门自提', + mode: 'buyNow', + delivery: '10', couponId: '', isUsePoints: 0, - remark: '留言', + remark: that.remark, shopId: '', - linkman: '姓名', - phone: '手机哈', - goodsId: '商品id', + linkman: '', + phone: '', + goodsId: that.goodsInfo.goods_id, goodsNum: 1, - goodsSkuId: '', + goodsSkuId: that.goodsInfo.skuList[0].goods_sku_id, cartIds: '' } - order.submit(params) + order.submit('buyNow', params) + .then(res => { + if (res.status == 200) { + that.orderId = res.data.orderId + that.getOrderInfoPay(res.data.orderId) + } + }) + .catch() + }, + getOrderInfoPay(val) { + cashier.orderInfo(val).then(res => { + if (res.status == 200) { + this.payMethList = res.data.paymentMethods + } + }) + .catch() + }, + onShowSuccess(res) { + this.$toast(message || '订单支付成功') + uni.navigateTo({ + url: '/pages/news/recycling/orderList' + }) + }, + orderPay() { + const that = this + if (that.payType == 'balance') { + that.payBanlance() + return + } + cashier.orderPay(that.orderID).then(res => { + if (res.status == 200) { + + let paymentData = res.data.payment + Wechat.payment({ + orderKey: res.data.payment.out_trade_no, + ...paymentData + }) + .then((result) => { + console.log(result) + that.onShowSuccess(result) + }) + .catch(err => { + console.log(err) + }) + + + } + }) + .catch() + + }, + payBanlance() { + const that = this + let params = { + extra: {}, + method: 'balance', + client: 'weChat' + } + cashier.orderPay(that.orderID, params).then(res => { + that.$toast(res.message) + if (res.status == 200) { + + setTimeout(() => { + uni.navigateTo({ + url: '/pages/news/recycling/orderList' + }) + }, 1000) + + } + }) + .catch() + + }, + // getOrderInfo() { + // const that = this + // let params = { + // orderId: 10202, + // client: 'wechat' + // } + // cashier.orderInfo(params) + // .then(res => { + // if (res.status == 200) { + // that.payOrderInfo() + // } + // }) + // .catch() + // }, + payOrderInfo() { + const that = this + let form = { + client: 'wechat', + method: 'wechat', + extra: {} + } + cashier.orderInfo(10202, form) .then(res => { if (res.status == 200) { - // that.$toast(res.message) + + let paymentData = res.data.payment + Wechat.payment({ + orderKey: res.data.payment.out_trade_no, + ...paymentData + }) + .then((result) => { + console.log(result) + }) + .catch(err => { + console.log(err) + }) } }) .catch() @@ -607,7 +738,7 @@ .goodsDetail { width: 694rpx; - height: 266rpx; + min-height: 266rpx; background: #FFFFFF; border-radius: 10rpx 10rpx 10rpx 10rpx; opacity: 1; @@ -656,7 +787,7 @@ margin-left: 20rpx; .goodsName { - height: 40rpx; + min-height: 40rpx; font-size: 28rpx; font-family: PingFang SC, PingFang SC; font-weight: 400; diff --git a/pages/user/index.vue b/pages/user/index.vue index 7f151b8..8830ce6 100644 --- a/pages/user/index.vue +++ b/pages/user/index.vue @@ -126,7 +126,7 @@ - + 235 @@ -486,6 +486,11 @@ this.getSuggest() }, methods: { + preList(){ + uni.navigateTo({ + url:'/pages/news/park/recordHistory' + }) + }, getSuggest() { // 获取推荐商品 const that = this