From c4b4e37ea3bbbd9d3fc3bdf181362bc59ca29ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=93=E5=B9=B3=E8=89=BA?= <52643018@qq.com> Date: Tue, 28 Sep 2021 19:29:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E4=B8=8B=E5=8D=95=E6=94=AF?= =?UTF-8?q?=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .hbuilderx/launch.json | 15 +- .../lf-shopGoodsCard/lf-shopGoodsCard.vue | 2 +- .../lf-waterfall-pointgoods/lf-waterfall.vue | 2 +- .../lf-waterfall-shopdetails/lf-waterfall.vue | 2 +- pages/address/list/list.vue | 25 +- pages/index/list/monthlyList.vue | 2 +- pages/index/list/selected.vue | 2 +- pages/order/cashier/cashier.vue | 210 ++++++++- pages/order/confirm/confirm.vue | 421 +++++++++++++++--- pages/shop/goodsdetail.vue | 135 +++++- pages/shop/seckillList.vue | 2 +- pages/shop/shopdetail.vue | 2 +- pages/store/cart/cart.vue | 78 ++-- 13 files changed, 757 insertions(+), 141 deletions(-) diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json index c9abd4b..81f13f4 100644 --- a/.hbuilderx/launch.json +++ b/.hbuilderx/launch.json @@ -2,10 +2,15 @@ // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数 "version": "0.0", "configurations": [{ - "type": "uniCloud", - "default": { - "launchtype": "local" - } - } + "default" : + { + "launchtype" : "local" + }, + "mp-weixin" : + { + "launchtype" : "local" + }, + "type" : "uniCloud" + } ] } diff --git a/components/lf-shopGoodsCard/lf-shopGoodsCard.vue b/components/lf-shopGoodsCard/lf-shopGoodsCard.vue index 9b4fb9c..1ba3d2d 100644 --- a/components/lf-shopGoodsCard/lf-shopGoodsCard.vue +++ b/components/lf-shopGoodsCard/lf-shopGoodsCard.vue @@ -7,7 +7,7 @@ + @click="$url('/pages/shop/goodsdetail?id='+ item.associate.id)"> {{ item.associate.name }} diff --git a/components/lf-waterfall-pointgoods/lf-waterfall.vue b/components/lf-waterfall-pointgoods/lf-waterfall.vue index dc2d3d7..f288d3e 100644 --- a/components/lf-waterfall-pointgoods/lf-waterfall.vue +++ b/components/lf-waterfall-pointgoods/lf-waterfall.vue @@ -103,7 +103,7 @@ }, methods: { onClick(id){ - this.$url('/pages/shop/goodsdetail?type=point&id='+id); + this.$url('/pages/shop/goodsdetail?id='+id); this.$emit('click'); }, goAd(type,url){ diff --git a/components/lf-waterfall-shopdetails/lf-waterfall.vue b/components/lf-waterfall-shopdetails/lf-waterfall.vue index c58a37c..b9de73e 100644 --- a/components/lf-waterfall-shopdetails/lf-waterfall.vue +++ b/components/lf-waterfall-shopdetails/lf-waterfall.vue @@ -121,7 +121,7 @@ }, methods: { onClick(id){ - this.$url('/pages/shop/goodsdetail?type=mail&id='+id); + this.$url('/pages/shop/goodsdetail?id='+id); this.$emit('click'); }, goAd(type,url){ diff --git a/pages/address/list/list.vue b/pages/address/list/list.vue index d8164ef..d20dbc9 100644 --- a/pages/address/list/list.vue +++ b/pages/address/list/list.vue @@ -2,7 +2,12 @@ - + + + 留言 + + - - 商品金额 - ¥385 - - - 运费 - ¥0 - - - 优惠 - ¥0 + + + 优惠券 + + {{ showCouponTitle }} + + + + + 商品金额 + ¥{{ order_detail.order.items_total_yuan }} + + + 运费 + +¥{{ order_detail.order.payable_freight }} + + + 优惠 + -¥{{ order_detail.order.adjustments_total_yuan }} + - - - - - 共1件 - - 合计 ¥385 - 提交订单 + + + + 共{{ order_detail.order.count }}件 + + 合计 ¥{{ order_detail.order.total_yuan }} + 提交订单 + - + + + + + + + + + + + + + + + + + + + {{item.discount.action_type.value}} + + + {{item.discount.action_type.value}} + % + + + 已使用 + + + 已过期 + + + 待使用 + + + + {{item.discount.title}} + 有效期{{item.discount.starts_at}}~{{item.discount.ends_at}} + + + + + + + + + + 不使用优惠券 + + + + @@ -82,15 +134,128 @@ export default { data(){ return { - mode: 1, // 1邮寄,2自提 - value: '' // 备注 + mode: 0, // 0邮寄,1自提 + value: '', // 备注 + token: '', + address: {}, + address_id: null, + order_detail: {coupons: []}, + show_coupon: false, + coupon_index: null + } + }, + computed: { + showCouponTitle(){ + if(this.coupon_index != null){ + return this.order_detail.coupons[this.coupon_index].discount.title; + }else{ + if(this.order_detail.coupons.length){ + return '不使用优惠券'; + }else{ + return '暂无可用优惠券'; + } + } } }, onLoad(){ - + this.token = this.$cookieStorage.get('user_token'); + let options = this.$cookieStorage.get('order_confirm'); + if(this.$isRight(options)){ + this.orderCheckout(options); + } + }, + onUnload(){ + this.$cookieStorage.clear('order_confirm'); + }, + onShow(){ + if(this.address_id){ + this.getSelectAddress(); + } }, methods: { - + // 生成临时订单 + orderCheckout(options){ + uni.showLoading({ + title: '正在生成订单' + }) + this.$http.post({ + api: 'api/shopping/order/checkout', + data: options, + header: { + Authorization: this.token + } + }).then(res => { + let detail = res.data.data; + this.order_detail = detail; + this.address = res.data.data.address; + uni.hideLoading() + }).catch(err => uni.hideLoading()) + }, + // 获取默认地址 + getDefaultAddress(){ + this.$http.get({ + api: 'api/address/default', + header: { + Authorization: this.token + } + }).then(res => { + this.address = res.data.data || {}; + }) + }, + // 获取用户自己选择的地址 + getSelectAddress(){ + this.$http.get({ + api: 'api/address/'+ this.address_id, + header: { + Authorization: this.token + } + }).then(res => { + this.address = res.data.data || {}; + }) + }, + // 打开选择优惠券 + openCheckCoupon(){ + if(this.order_detail.coupons.length){ + this.show_coupon = true; + }else{ + this.$msg('您没有可用的优惠券哦'); + } + }, + // 提交订单 + confirm(){ + this.$http.post({ + api: 'api/shopping/order/confirm', + data: { + order_no: this.order_detail.order.order_no, + // discount_id: 0, // 优惠券id? TODO + pick_self: this.mode, // 0 配送,1自提 + address_id: this.address.id, + note: this.value + }, + header: { + Authorization: this.token + } + }).then(res => { + console.log("`````````", res); + if(res.data.code == 200 || res.data.code == true){ + let order = res.data.data.order; + let url = '/pages/order/cashier/cashier'; + url += '?amount='+ order.total_yuan; + url += '&order_no='+ order.order_no; + this.$url(url, {type: 'redirect'}); + }else{ + this.$msg(res.data.message); + } + }) + }, + // 选择优惠券 + couponChange(event){ + if(event.detail.value == 'null'){ + this.coupon_index = null; + }else{ + this.coupon_index = Number(event.detail.value); + } + } } } @@ -210,4 +375,122 @@ } } } + + .popup-content{ + width: 750rpx; + height: max-content; + max-height: 70vh; + overflow-y: scroll; + padding: 40rpx 32rpx; + background: #FFFFFF; + } + .coupon-circle1 { + width: 40rpx; + height: 40rpx; + background-color: white; + border-radius: 50%; + } + .coupon-circle-top { + width: 50rpx; + height: 50rpx; + border-radius: 50%; + // background-color: red; + position: absolute; + border: 1px dashed #ccc; + left: 190rpx; + top: -20rpx; + display: flex; + align-items: center; + text-align: center; + justify-content: center; + } + .coupon-circle-bottom { + width: 50rpx; + height: 50rpx; + border-radius: 50%; + // background-color: red; + position: absolute; + border: 1px dashed #ccc; + left: 190rpx; + bottom: -20rpx; + display: flex; + align-items: center; + text-align: center; + justify-content: center; + } + .coupon-right { + text-align: left; + justify-content: center; + align-items: flex-start; + display: flex; + flex-direction: column; + margin-left: 90rpx; + } + .coupon-left { + margin-left: 30rpx; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + } + .coupon-tag { + width: max-content; + margin-top: 10rpx; + padding: 0 24rpx; + height: 43rpx; + border-radius: 22rpx; + border: 2rpx solid #FFFFFF; + font-size: 24rpx; + color: white; + } + .coupon-wrap { + display: flex; + justify-content: center; + margin-top: 30rpx; + flex-direction: column; + align-content: center; + align-items: center; + } + .coupon-card { + overflow: hidden; + position: relative; + display: flex; + align-items: center; + justify-content: center; + // width: 674rpx; + width: 626rpx; + height: 171rpx; + background: #15716E; + border-radius: 20rpx; + } + .invalid-bg{ + background-color: #999999; + } + .coupon-radius { + // width: 664rpx; + width: 616rpx; + display: flex; + height: 161rpx; + border: 1rpx dashed #ccc; + // background: #15716E; + border-radius: 20rpx; + } + /deep/.u-scroll-box { + display: flex; + justify-content: center; + align-items: center; + border-bottom: 1rpx solid rgba(0, 0, 0, 0.1); + } + /deep/.special_tab .u-tabs .u-scroll-box .u-tab-bar { + background-color: #15716E!important; + width: 80rpx!important; + position: absolute; + height: 10rpx; + left: 0; + border-radius: 8rpx 8rpx 0px 0px!important; + bottom: -12rpx; + } + /deep/ .u-tab-item { + font-size: 28rpx!important; + } diff --git a/pages/shop/goodsdetail.vue b/pages/shop/goodsdetail.vue index 4711b78..7177f0d 100644 --- a/pages/shop/goodsdetail.vue +++ b/pages/shop/goodsdetail.vue @@ -4,7 +4,7 @@ - + @@ -85,11 +85,10 @@ - 选择 - 选中的商品规格TODO + {{ showSpec }} @@ -99,7 +98,7 @@ - + @@ -184,14 +183,13 @@ - - ¥{{ goods_detail.min_price }}-¥{{ goods_detail.max_price }} + {{ showGoodsSpecPrice }} {{ goods_detail.name }} @@ -205,7 +203,7 @@ {{ item.value }} @@ -228,7 +226,7 @@ - + @@ -269,11 +267,42 @@ goods_num: 1 } }, + computed: { + showGoodsSpecPrice(){ + let goods_detail = this.goods_detail; + let stores = this.goods_stock.stores; + let specs = this.goods_stock.specs; + let specId = 1; + if(!this.$isRight(specs[specId])){ + return `¥${goods_detail.min_price} - ¥${goods_detail.max_price}`; + } + let spec_current = specs[specId].spec_current; + + if(specs[specId].spec_current != null){ + let id = specs[specId].list[spec_current].id; + return "¥"+ stores[specId +'-'+ id].price; + }else{ + return `¥${goods_detail.min_price} - ¥${goods_detail.max_price}`; + } + }, + showSpec(){ + let specs = this.goods_stock.specs; + let str = ''; + for(let i in specs){ + if(specs[i].spec_current != null){ + str += specs[i].list[specs[i].spec_current].value +';'; + } + } + if(str == ''){ + str = '请选择规格' + } + return str; + } + }, onLoad(options){ console.log("options", options) this.token = this.$cookieStorage.get('user_token'); this.goods_id = options.id; - // this.type = options.type || 'mail'; // TODO 改变思路,不是由外界控制 this.getNewdetail(); this.getGoodsStock(); // 获取商品库存、规格信息 }, @@ -313,13 +342,28 @@ this.confirm(); } }, + // 选规格提交 + specConfirm(){ + let specs = this.goods_stock.specs; + let flag = true; + for(let i in specs){ + if(specs[i].spec_current == null){ + flag = false; + } + } + if(flag){ + this.confirm(); + }else{ + this.$msg('您未选完整规格') + } + }, // 商品选规格 activeSpec(key, index){ let obj = this.goods_stock.specs; - if(obj[key].spec_current == index){ - obj[key].spec_current = null; + if(obj[key]['spec_current'] == index){ + obj[key]['spec_current'] = null; }else{ - obj[key].spec_current = index; + obj[key]['spec_current'] = index; } this.$set(this.goods_stock, 'specs', obj); }, @@ -337,8 +381,65 @@ }, // 跳转至下单页TODO confirm(){ - if(this.click_type == 2){ + let goods_detail = this.goods_detail; + let specs = this.goods_stock.specs; + let stores = this.goods_stock.stores; + let par = { + attributes: { + color: specs[2].list[specs[2].spec_current].value, + com_id: goods_detail.id, + img: goods_detail.img, + size: specs[1].list[specs[1].spec_current].value, + sku: goods_detail.goods_no +'-'+ specs[1].list[specs[1].spec_current].value + }, + id: stores[1 +'-'+ specs[1].list[specs[1].spec_current].id].id, + product_id: stores[1 +'-'+ specs[1].list[specs[1].spec_current].id].id, + market_price: goods_detail.market_price, + name: goods_detail.name, + price: stores[1 +'-'+ specs[1].list[specs[1].spec_current].id].price, + qty: this.goods_num, + store_count: stores[1 +'-'+ specs[1].list[specs[1].spec_current].id].store + } + + uni.showLoading({ + title: '正在提交' + }) + this.show_popup = false; + if(this.click_type == 1){ + // 加入购物车 + this.$http.post({ + api: 'api/shopping/cart', + data: {"0": par}, + header: { + Authorization: this.token + } + }).then(res => { + if(res.data.code == 200){ + this.$msg('加入购物车成功', {icon: 'success'}) + }else{ + this.$msg('加入购物车失败', {icon: 'error'}) + } + uni.hideLoading() + }).catch(err => uni.hideLoading()) + }else if(this.click_type == 2){ + // 直接结算 + this.$cookieStorage.set('order_confirm', par); + uni.hideLoading(); this.$url('/pages/order/confirm/confirm'); + // this.$http.post({ + // api: 'api/shopping/order/checkout', + // data: par, + // header: { + // Authorization: this.token + // } + // }).then(res => { + // if(res.data.code == 200){ + // this.$url('/pages/order/confirm/confirm'); + // }else{ + // this.$msg('提交失败', {icon: 'error'}) + // } + // uni.hideLoading() + // }).catch(err => uni.hideLoading()) } }, // 点击页面分享按钮 @@ -436,7 +537,11 @@ this.$http.get({ api: `api/store/detail/${this.goods_id}/stock` }).then(res => { - this.goods_stock = res.data.data; + let data = res.data.data; + for(let i in data.specs){ + data.specs[i].spec_current = null; + } + this.goods_stock = data; }) }, // 拨打电话 @@ -781,6 +886,8 @@ background: #FFFFFF; border-radius: 20rpx 20rpx 0rpx 0rpx !important; padding: 40rpx 32rpx; + max-height: 80vh; + overflow-y: scroll; .popup-head{ display: flex; justify-content: space-between; diff --git a/pages/shop/seckillList.vue b/pages/shop/seckillList.vue index 9b1ddb0..a85027f 100644 --- a/pages/shop/seckillList.vue +++ b/pages/shop/seckillList.vue @@ -5,7 +5,7 @@ @scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh"> + @click="$url('/pages/shop/goodsdetail?id='+ item.goods.id)"> 已有{{item.sell_num}}人购买 diff --git a/pages/shop/shopdetail.vue b/pages/shop/shopdetail.vue index 080fc70..4a6ddab 100644 --- a/pages/shop/shopdetail.vue +++ b/pages/shop/shopdetail.vue @@ -48,7 +48,7 @@ - + 已售{{item.sale_count}} diff --git a/pages/store/cart/cart.vue b/pages/store/cart/cart.vue index dcd2099..f9858a5 100644 --- a/pages/store/cart/cart.vue +++ b/pages/store/cart/cart.vue @@ -9,7 +9,7 @@ {{ s_item.name }} - + 满减 {{s_item.full_minus}} @@ -24,11 +24,11 @@ - + @@ -96,7 +96,7 @@ s.goods.map(g => { if(g.checked){ total_count++; - total_price += (g.price * g.count) + total_price += (g.price * g.qty) } }) }) @@ -118,39 +118,20 @@ } }).then(res => { console.log("===", res); - // TODO 此处为假数据 ------------------ - let list = [{ - name: '精品超市', - full_minus: '母婴产品教师节满1200减200', - goods: [{ - checked: false, - img: 'https://hainan.lanzulive.com/storage/images/v2-deb89623e0ee2a2dad34bcded6dfd1ed_1440w.png', - name: '爱他美较大婴儿配方奶粉较大婴儿配方奶粉较大婴儿配方奶粉2段 900g', - count: 1, - spec: '900g', - price: '385' - },{ - checked: false, - img: 'https://hainan.lanzulive.com/storage/images/v2-deb89623e0ee2a2dad34bcded6dfd1ed_1440w.png', - name: '基尼泰煤2000G', - count: 2, - spec: '900g', - price: '197' - }] - },{ - name: '精品超市', - full_minus: '母婴产品教师节满1200减200', - goods: [{ - checked: false, - img: 'https://hainan.lanzulive.com/storage/images/v2-deb89623e0ee2a2dad34bcded6dfd1ed_1440w.png', - name: '爱他美较大婴儿配方奶粉较大婴儿配方奶粉较大婴儿配方奶粉2段 900g', - count: 4, - spec: '900g', - price: '99' - }] - }] + let data = res.data.data; + let list = []; + for(let i in data){ + let goods = data[i].goods.map(item => { + item.checked = false; + return item; + }) + list.push({ + name: data[i].name, + full_minus: '', + goods: goods + }) + } this.list = list; - // TODO 此处为假数据 end -------------- }) }, // 商品被勾选 @@ -173,7 +154,30 @@ // 结算 submit(){ if(this.total_count){ - this.$url('/pages/order/confirm/confirm'); + let brand = []; + let cart_ids = []; + this.list.map(item => { + let checked = item.goods.every(g => g.checked); + item.goods.map(g => { + if(g.checked){ + cart_ids.push(g.__raw_id); + } + }) + if(checked){ + brand.push(item.name); + } + }) + if(brand.length > 1){ + this.$msg('只支持单个店铺结算哦'); + }else{ + let par = { + cart_ids: cart_ids, + type: "normal", + wechat_group_id: "" + }; + this.$cookieStorage.set('order_confirm', par); + this.$url('/pages/order/confirm/confirm'); + } }else{ this.$msg('您未选择需要结算的商品'); }