You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hezhiying/pages/ConfirmOrder/ConfirmOrder.vue

261 lines
5.9 KiB

1 year ago
<template>
<view class="page">
1 year ago
<view v-if="qgSuccess">
<!-- 地址 -->
<view class="address-data">
<view class="address-list" @click="onSkip('address')">
<view v-if="hasAddr">
<view class="list">
<view class="moren" v-show="addressObj.is_default">
默认
</view>
<text>{{addressObj.consignee}}</text>
<text style="font-weight: normal;">{{addressObj.mobile}}</text>
</view>
<view class="list">
<text style="font-weight: normal;">{{addressObj.province_name}}{{addressObj.city_name}}{{addressObj.district_name}}</text>
</view>
<view class="list">
<text class="address">{{addressObj.address}}</text>
</view>
</view>
<view v-if="!hasAddr" class="nothasAddr">
<view class="text">
请选择收货地址
</view>
<text class="iconfont icon-more"></text>
1 year ago
</view>
1 year ago
</view>
1 year ago
1 year ago
<!-- 商品 -->
<view class="goods-data">
<view class="goods-list">
<view class="list">
<view class="thumb">
1 year ago
<image :src="productObj.image" mode="aspectFill"></image>
1 year ago
</view>
1 year ago
<view class="item">
<view class="title">
<text class="name one-omit">{{productObj.name}}</text>
1 year ago
</view>
1 year ago
<view class="price-number">
<view class="price">
<text class="min">{{productObj.price}}</text>
</view>
<view class="number">
<text>x 1</text>
</view>
1 year ago
</view>
1 year ago
1 year ago
</view>
</view>
</view>
1 year ago
1 year ago
</view>
1 year ago
1 year ago
</view>
1 year ago
<!-- 订单金额 -->
<view class="order-price">
<view class="price-list">
<view class="list">
<view class="title">
<text>备注</text>
</view>
<view class="price">
<text></text>
<text class="iconfont icon-more"></text>
</view>
1 year ago
</view>
1 year ago
<view class="list">
<view class="title">
<text>商品总额</text>
</view>
<view class="price">
<text>{{productObj.price}}</text>
</view>
1 year ago
</view>
1 year ago
1 year ago
</view>
1 year ago
</view>
<!-- 地址提示 -->
<view class="address-tips" :style="scrollTop >= 100 ? '':'display:none'">
<text>{{addressObj.province_name}}{{addressObj.city_name}}{{addressObj.district_name}}{{addressObj.address}}</text>
</view>
<!-- 底部合计提交 -->
<view class="footer-submit">
<view class="price">
<text class="min">合计{{productObj.price}}</text>
</view>
<view class="submit" @click="onSubmit">
<text>提交订单</text>
1 year ago
</view>
</view>
</view>
1 year ago
<view class="noqg" v-if="!qgSuccess">
<image src="../../static/image/ku.png" mode="widthFix"></image>
<view class="yihan">
很遗憾您抢购的宝贝已被别人抢先一步...
1 year ago
</view>
1 year ago
<view class="back" @click="backHandle">
返回继续抢购
1 year ago
</view>
</view>
1 year ago
<u-toast ref="uToast"></u-toast>
<u-popup mode="center" round="10" :customStyle="{'width':'70%'}" :show="show" @close="close">
<view class="showcontent">
<image src="../../static/image/alert-bg.png" mode="widthFix"></image>
<view class="contentContainer">
<view class="text">
<view class="textTitle">
温馨提示
</view>
<view class="intrTitle">
恭喜您抢购成功
</view>
<view class="intr">
您可以在我的->我的仓库中查看订单
</view>
</view>
<view class="btnContent">
<view class="submitBtn" @click="onSkip('cangku')">
确定
</view>
</view>
</view>
</view>
</u-popup>
1 year ago
</view>
</template>
<script>
1 year ago
import {getAddrList,createOrder} from '@/common/api.js'
1 year ago
export default {
1 year ago
1 year ago
data() {
return {
scrollTop: 0,
1 year ago
hasAddr:false,
addressObj:{
id:null,
consignee:'',
mobile:'',
is_default:false,
province_name:'',
city_name:'',
district_name:'',
address:''
},
productObj:{
id:null,
image:'',
name:'',
price:''
},
show:false,
qgSuccess:true,
1 year ago
};
},
onPageScroll(e){
this.scrollTop = e.scrollTop;
},
methods:{
1 year ago
close() {
this.show = false
},
backHandle(){
uni.navigateTo({
url:'/pages/qianggou/productList'
})
},
1 year ago
/**
* 提交订单
*/
onSubmit(){
1 year ago
if(!this.hasAddr){
this.$refs.uToast.show({
message:'请选择收货地址'
})
return;
}
let params={
address_id:this.addressObj.id,
goods_id:this.productObj.id
}
console.log(params)
createOrder(params).then(res=>{
console.log(res,"==")
if(res.code==1){
this.show = true;
1 year ago
setTimeout(()=>{
uni.redirectTo({
url: '/pages/qianggou/productList',
})
},1000)
1 year ago
}else{
this.qgSuccess = false;
}
1 year ago
})
},
1 year ago
onSkip(type){
switch (type){
case 'address':
uni.navigateTo({
url: '/pages/AddressList/AddressList',
})
break;
1 year ago
case 'cangku':
1 year ago
// uni.navigateTo({
// url: '/pages/warehouse/buy?type=-1',
// })
1 year ago
uni.navigateTo({
1 year ago
url: '/pages/qianggou/productList',
1 year ago
})
break;
1 year ago
}
1 year ago
},
getList(){
getAddrList().then(res=>{
let arr = res.data.filter(item=>{
return item.is_default
})
if(arr.length>0){
this.hasAddr = true;
this.addressObj = Object.assign({},this.addressObj,arr[0])
}else{
this.hasAddr = false;
this.addressObj = this.$options.data().addressObj
}
})
1 year ago
}
},
1 year ago
onLoad(option){
if(option.item){
this.addressObj = Object.assign({},this.addressObj,JSON.parse(option.item));
this.hasAddr = true;
}
this.productObj = Object.assign({},this.productObj,uni.getStorageSync('qgPro'))
if(!this.addressObj.id){
this.getList()
}
1 year ago
},
1 year ago
}
</script>
<style scoped lang="scss">
@import 'ConfirmOrder.scss';
</style>