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.
 
 
 
 
 
 

910 lines
25 KiB

<template>
<view>
<view class="address" @click="goAddress">
<view class="address_left" >
<view class="address_title" >
<image src="../../static/img/address.png" mode=""></image>
<view class="address_title_name" v-if="address">{{address.consignee}}</view>
<text v-if="address">{{address.mobile}}</text>
</view>
<view class="address_content" v-if="address">
{{address.sign_building}}
{{address.country_name}}{{address.province_name}}{{address.city_name}}{{address.address}}{{address.zipcode}}
</view>
<view class="address_title" v-if="!address">Add Shipping Address</view>
</view>
<image src="../../static/img/right.png" class="address_more"></image>
<image src="../../static/img/address_xian.png" class="address_xian" mode=""></image>
</view>
<view class="order_info" @click="openMore(0)">
<view class="info_title">
<text>Items in cart</text>
<view class="info_title_right">
<text>{{goods_list.length}} ltems</text>
<image src="../../static/img/right.png" class="address_more"></image>
</view>
</view>
<view class="info_image">
<image class="info_image_item" :src="item.goods_thumb" v-for="(item,index) in goods_list" :key="index"/>
</view>
</view>
<view class="method">
<view class="method_title">Shipping Method</view>
<view class="method_item" v-for="(item,index) in shipping_list " :key="index">
<view class="method_item_image" @click="cartselectshipping(item.shipping_id)">
<image src="../../static/img/select1.png" style="width: 30rpx;height: 30rpx;" v-if="orderId==item.shipping_id"></image>
<image src="../../static/img/select2.png" style="width: 30rpx;height: 30rpx;"v-else ></image>
</view>
<view class="method_item_right">
<view class="item_price">
<text>{{item.shipping_name}}:</text>
<text class="item_price_span">US${{item.shipping_fee}}</text>
</view>
<view class="item_time">
<text class="item_time_span">{{item.shipping_desc}} </text>
<!-- <text> 15/05/2022-04/05/2022</text> -->
</view>
</view>
</view>
</view>
<view class="discount">
<view class="discount_item" @click="openMore(1)">
<text>Coupons</text>
<view class="discount_item_right">
<text v-show="bonus>0">-US${{bonus}}</text>
<image src="../../static/img/right.png" mode="" class="address_more"></image>
</view>
</view>
<view class="discount_item" @click="openMore(3)">
<view class="discount_item_left">
<text>Points</text>
<text class="discount_item_left_span">({{count}})</text>
</view>
<view class="discount_item_right">
<text v-if="use&&Points >0 ">-US${{ Points}}</text>
<image src="../../static/img/right.png" mode="" class="address_more"></image>
</view>
</view>
</view>
<view class="settlement">
<view class="settlement_item">
<text>Subtotal:</text>
<text class="settlement_item_right">US${{total.goods_price}}</text>
</view>
<view class="settlement_item">
<text>Shipping fee:</text>
<text class="settlement_item_right">US${{total.shipping_fee}}</text>
</view>
<view class="settlement_item">
<text>Discount :</text>
<text class="settlement_item_right1">-US${{bonus || 0}}</text>
</view>
</view>
<view class="total">
<text>Total: US${{total.amount}}</text>
<button @click="openMore(2)">PLACE ORDER</button>
</view>
<view class="mask" v-show="isShow" @click="isShow=false"></view>
<view class="order_popup" v-show="isShow">
<view class="order_popup_title">
<text>
{{popup_index==0?'Commodity information':popup_index==1?'Coupons':popup_index==2?'Payment Method':'Points'}}<text v-show="popup_index==3">(total:<text class="order_popup_title_span" >{{orderDate.your_integral || 0}}</text>)</text>
</text>
<image src="../../static/img/close1.png" mode="" @click="isShow=false"></image>
</view>
<view class="order_popup_commodity" v-show="popup_index==0">
<view class="good_info" v-for="(item,index) in goods_list " :key="index">
<view class="good_info_left ">
<view class="good_info_image" >
<image :src="item.goods_thumb" mode=""></image>
</view>
<view class="left_info">
<view class="info_name">{{item.goods_name}}</view>
<view class="left_info_bottom">
<view class="info_lable" v-if="item.goods_attr">
<text>{{item.goods_attr |goodsAttr}}</text>
<!-- <image src="/static/img/bottom.png" mode=""></image> -->
</view>
<text>x{{item.goods_number}}</text>
</view>
<view class="info_price">US${{item.goods_price}}</view>
</view>
</view>
</view>
</view>
<view class="order_popup_coupons" v-show="popup_index==1">
<view class="coupons_item" v-for="(item,index) in bonus_list " :key="item.bonus_id">
<view class="coupons_item_left">
<view class="item_left_prcie">${{item.type_money}}</view>
<text class="item_left_span">Min.spend</text>
<view>$200.00</view>
</view>
<view class="coupons_item_right">
<view class="coupons_right_info">
<view class="coupons_right_info_title">{{item.type_name}}</view>
<text>The tide zone is available</text>
<view class="coupons_right_info_time">2022.09.23 10:37 - 2022.12.23 10:37</view>
</view>
<button @click="useCoupons(item.bonus_id)">Use Now</button>
<image src="../../static/img/select3.png" mode="" class="coupons_item_right_select" v-if="order.bonus==item.bonus_id"></image>
<image src="../../static/img/select.png" mode="" class="coupons_item_right_select" v-else></image>
</view>
</view>
</view>
<view class="order_popup_pay" v-show="popup_index==2">
<view class="pay_item" @click="selectPay(0)">
<image src="../../static/img/select1.png" mode="" class="pay_item_select" v-if="pay_index==0"></image>
<image src="../../static/img/select2.png" mode="" class="pay_item_select" v-else></image>
<view class="pay_item_right">
<image src="../../static/img/pay_pal.png" mode=""></image>
<text>Pay Pal</text>
</view>
</view>
<view class="pay_item" @click="selectPay(1)">
<image src="../../static/img/select1.png" mode="" class="pay_item_select" v-if="pay_index==1"></image>
<image src="../../static/img/select2.png" mode="" class="pay_item_select" v-else></image>
<view class="pay_item_right">
<image src="../../static/img/card.png" mode=""></image>
<text>Credit/Debit Card</text>
</view>
</view>
<view class="pay_item" @click="selectPay(2)">
<image src="../../static/img/select1.png" mode="" class="pay_item_select" v-if="pay_index==2"></image>
<image src="../../static/img/select2.png" mode="" class="pay_item_select" v-else></image>
<view class="pay_item_right">
<image src="../../static/img/GPay.png" mode=""></image>
<text>Google Pay</text>
</view>
</view>
<view class="pay_item" @click="selectPay(3)">
<image src="../../static/img/select1.png" mode="" class="pay_item_select" v-if="pay_index==3"></image>
<image src="../../static/img/select2.png" mode="" class="pay_item_select" v-else></image>
<view class="pay_item_right">
<image src="../../static/img/APay.png" mode=""></image>
<text>Apple pay</text>
</view>
</view>
<!-- <navigator url="/pages/order/paySuccess"> -->
<button @click="submitorder">PAY NOW</button>
<!-- </navigator> -->
</view>
<!-- <view class="order_popup_points" v-show="popup_index==3">
<view class="points_item">
<image src="../../static/img/select2.png" mode=""></image>
<text>Use points</text>
</view>
<view class="points_item">
<image src="../../static/img/select1.png" mode=""></image>
<text>Do not use points</text>
</view>
</view> -->
</view>
<view class="mask" @click="isCoupons=false,isPoints= false" v-show="(isCoupons && list)||isPoints"></view>
<view class="coupons" v-show="isCoupons &&list">
<view class="order_popup_title">
<text>Coupons</text>
<image src="../../static/img/close1.png" mode="" @click="isCoupons=false"></image>
</view>
<view class="coupons_item" v-for="(item,index) in list " :key="item.bonus_id">
<view class="coupons_item_left">
<view class="item_left_prcie">${{item.type_money}}</view>
<text class="item_left_span">Min.spend</text>
<view>${{item.min_goods_amount}}</view>
</view>
<view class="coupons_item_right">
<view class="coupons_right_info">
<view class="coupons_right_info_title">{{item.type_name}}</view>
<text>The tide zone is available</text>
<view class="coupons_right_info_time">{{item.use_start_date}} - {{item.use_end_date}}</view>
</view>
<view>
<view class="select_cop" v-show="current!=index&&parseFloat(item.min_goods_amount) <totalnum ||parseFloat(item.min_goods_amount) ==totalnum ">
<image src="../../static/icon/flase.png" @click="current=index,useCoupons(index,item)"></image>
</view>
<view class="select_cop"v-show="current==index ">
<image src="../../static/icon/true.png" @click="current=-1,bonus=0,total.bonus = 0,useCoupons(index,item)"></image>
</view>
<button @click="gotoindex()">Use Now</button>
</view>
</view>
</view>
</view>
<!-- point -->
<view class="coupons" v-show="isPoints">
<view class="order_popup_title">
<text>Points (total:</text><text style="color:darkred">{{ count}} </text>)
<image src="../../static/img/close1.png" mode="" @click="isPoints=false"></image>
</view>
<view class="order_popup_points" @click="Thepoint()" >
<view class="points_item">
<image src="../../static/img/select2.png" mode="" v-if="!use" @click="use=true,nouse=false"></image>
<image src="../../static/img/select1.png" mode="" v-if="use" @click="use=false,nouse=true"></image>
<text>Use points</text>
</view>
<view class="points_item"@click="Thepoint()">
<image src="../../static/img/select2.png" mode="" v-if="!nouse " @click="nouse=true,use=false"></image>
<image src="../../static/img/select1.png" mode="" v-if="nouse" @click="nouse=false,use=true"></image>
<text>Do not use points</text>
</view>
</view>
</view>
</view>
</template>
<script>
import {defaultRequest2,defaultRequest3} from '../../api/index.js'
export default {
data() {
return {
isShow:false,
popup_index:'',
isCoupons:false,
isPoints:false,
query:{
_action:'cartcheckout',
is_new:0,
direct_shopping:0,
consignee:''
},
orderDate:{},
address:{},
goods_list:[],
shipping_list:[],
bonus_list:[],
bonus:0,
total:{},
order:{
shipping_id:11
},
// 支付方式: 0、支付宝 1、银行卡、信用卡 2、谷歌支付 4、苹果支付
pay_index:0,
tag:0,
orderId:0,
list:[] ,//红包列表
current:-1,
count:0,
Points:0,
use:false,
nouse:true,
bouns_id:'',
totalnum:0,
}
},
filters: {
fnum(a,b) {
let tag = false
if(parseFloat(a) < parseFloat(b)|| parseFloat(a) == parseFloat(b))
{
tag = true
}
return tag;
}
},
methods:{
// 使用红包
useCoupons(index,item){
// this.current = index
let total = this.total
console.log(this.current)
// this.bouns_id = item.bonus_id
//console.log(total)
if(this.current == index ){
this.bonus = item.type_money
//console.log(this.bonus)
this.total.bonus = item.type_money
let id = item.bonus_id
this.bouns_id = item.bonus_id
let data={_action:'cartselectbonus',bonus:id,consignee:this.address}
console.log(data)
defaultRequest3(data,'consignee').then(res=>{
if(res.error==0){
this.total=res.data.total
console.log(this.total.bonus)
uni.setStorageSync('Total',this.total)
this.order=res.data.order
console.log(this.use)
//使用了余额
// console.log(this.count,this.total.amount,this.Points)
if(this.use){
console.log(this.count > this.total.amount)
if(this.count > this.total.amount){
this.Points = this.total.amount
this.total.amount = 0
}else if (this.count < this.total.amount || this.count == this.total.amount){
this.Points = this.count
let a = (parseFloat(this.Points) + parseFloat(this.total.bonus)).toFixed(2)
console.log(this.total.amount)
this.total = uni.getStorageSync('total')
let b = (this.total.amount - a ).toFixed(2)
console.log(b)
this.total.amount = b
}
}
//不使用
else{
this.Points = 0
//console.log(222)
}
}
})
}
else{
this.bonus = 0
this.total = uni.getStorageSync('total')
this.bouns_id = 0
// this.Points = this.total.amount
//console.log(this.total)
}
},
gotoindex(){
uni.switchTab({
url:'../index/index'
})
},
// 获取调用支付信息数据
getPayDate(id,will_get_integral){
let data
//console.log(222)
if(this.pay_index ==0){
data={_action:'payorder',order_id:id,order_type:'GOODSBUY',payment_method:'paypal'}
defaultRequest2(data).then(res=>{
////console.info(data,'支付')
//console.log(res)
if(res.error == 0){
if(res.data.need_pay_amount==0)
this.isShow = false
{
setTimeout(() =>{
uni.showToast({
icon:'none',
title:'ok!'
})
},2000)
uni.navigateTo({
url:'../account/myOrders'
})
}
// plus.runtime.openURL(res.data.prepay_data.checkoutnow_url)
// this.src = res.data.prepay_data.checkoutnow_url
uni.navigateTo({
url:'./paypalWebview?src='+res.data.prepay_data.checkoutnow_url
})
}
})
}else{
data={_action:'payorder',order_id:id,order_type:'GOODSBUY',payment_method:'alipay.native'}
defaultRequest2(data).then(res=>{
//console.info(res,'支付宝')
if(res.error==0){
//订单对象,从服务器获取
if(res.data.need_pay_amount==0) {
if(res.data.need_pay_amount==0)
this.isShow = false
{
setTimeout(() =>{
uni.showToast({
icon:'none',
title:'ok!'
})
},2000)
uni.navigateTo({
url:'../account/myOrders'
})
}
}
uni.requestPayment({
provider: 'alipay',
orderInfo: res.data.prepay_data.order_info, //支付宝订单数据
success: function (res) {
////console.log('success:' + JSON.stringify(res));
uni.redirectTo({
url: 'paySuccess?type=0&order_id='+id+'&will_get_integral='+will_get_integral
});
},
fail: function (err) {
////console.log('fail:' + JSON.stringify(err));
uni.redirectTo({
url: 'paySuccess?type=1&order_id='+id+'&will_get_integral='+will_get_integral
});
}
});
}
})
}
},
Thepoint(){
//使用余额 使用红包
////console.log(this.total)
if(this.use && this.current!=-1){
this.total = uni.getStorageSync('Total')
if(parseFloat(this.count) > this.total.amount){
let i = (parseFloat(this.count) - this.total.amount - parseFloat(this.total.bonus)).toFixed(2)
// this.Points = (this.total.amount - parseFloat(this.total.bonus)).toFixed(2)
this.Points = this.total.amount
//console.log(this.Points)
this.total.amount = 0
}
else if(parseFloat(this.count) < this.total.amount){
let i = (this.total.amount -parseFloat(this.count)).toFixed(2)
// this.total.amount = i
this.Points = this.count
this.total.amount = (this.total.amount - parseFloat(this.Points)).toFixed(2)
}
}
//使用红包
else if(!this.use&& this.current!=-1){
this.Points = 0
this.total = uni.getStorageSync('Total')
}
// 都不使用
else if(!this.use&& this.current==-1){
this.total = uni.getStorageSync('total')
}
//使用余额
else{
if(parseFloat(this.count) > this.total.amount){
let i = (parseFloat(this.count) - this.total.amount - parseFloat(this.total.bonus)).toFixed(2)
// this.Points = (this.total.amount - parseFloat(this.total.bonus)).toFixed(2)
this.Points = this.total.amount
//console.log(this.Points)
this.total.amount = 0
}
else if(parseFloat(this.count) < this.total.amount){
let i = (this.total.amount -parseFloat(this.count)).toFixed(2)
// this.total.amount = i
this.Points = this.count
this.total.amount = (this.total.amount - parseFloat(this.Points)).toFixed(2)
}
}
},
// 选择支付方式
selectPay(index){
this.pay_index=index
},
goAddress(){
uni.navigateTo({
url:'../account/address?type=1'
})
},
// 提交订单
submitorder(){
let data={
_action:'submitorder',
consignee:this.address,
postscript:'',
bonus:this.bouns_id,
surplus:this.Points,
// surplus:this.order.surplus,
// shipping_id:this.orderId,
shipping_id:this.order.shipping_id,
directshopping:0,
}
defaultRequest3(data,'consignee').then(res=>{
//console.info(res)
//console.log(data)
if(res.error==0){
this.getPayDate(res.data.order.order_id,res.data.will_get_integral)
}
})
},
// 变更配送方式
cartselectshipping(id){
let data={_action:'cartselectshipping',shipping_id:id,consignee:this.address}
defaultRequest3(data,'consignee').then(res=>{
////console.info(res)
if(res.error==0){
this.tag = 1
this.total=res.data.total
this.order=res.data.order
this.orderId=res.data.order.shipping_id
}
})
},
getList(){
defaultRequest3(this.query,'consignee').then(res=>{
////console.log(this.query)
////console.info(res)
if(res.error==0){
this.orderDate=res.data
this.address=res.data.consignee
this.goods_list=res.data.goods_list
this.shipping_list=res.data.shipping_list
// ////console.info(res.data.shipping_list,'1111')
if(res.data.bonus_list){
this.bonus_list=res.data.bonus_list
}
this.total=res.data.total
this.totalnum = this.total.amount
uni.setStorageSync('total',(res.data.total))
let ss = uni.getStorageSync('total')
////console.log(ss,'0000')
this.order=res.data.order
}
})
// 获取红包
let data={_action:'getuserbonus'}
defaultRequest2(data).then(res=>{
////console.info(res)
if(res.error==0){
this.list=res.data
}
})
//获取余额
defaultRequest2({
_action:'getusersummarydata'
}).then(res =>{
////console.log(res)
if(res.error ==0){
this.count = res.data.user_info.user_money
// this.count = 4.00
}
})
},
openMore(i){
this.popup_index=i
if(i==1){
this.isCoupons = true
if(!this.list){
uni.showToast({
icon:'none',
title:'No coupon available'
})
return
}
if(this.orderDate.allow_use_bonus==0){
uni.showToast({
icon:'none',
title:'Coupon cannot be used for this product'
})
return
}
}else if(i==3){
this.isPoints = true
if(this.orderDate.allow_use_integral==0){
uni.showToast({
icon:'none',
title:'Points cannot be used for this product'
})
return
}
}else{
if(!this.address){
uni.showToast({
icon:'none',
title:'please add address'
})
}
else if(!this.orderId||this.tag ==0){
uni.showToast({
icon:'none',
title:'please select shipping method'
})
}
else{
this.isShow=true
}
}
}
},
onLoad(e) {
this.query=JSON.parse(e.query)
this.orderId = e.orderId
this.order.shipping_id = e.orderId
if(this.orderId){
this.tag =1
}
////console.log(this.orderId,'///')
this.getList()
},
onShow(e) {
this.getList()
uni.$once('query' ,(query)=>{
////console.info(query)
if(query.type=='address'){
this.query.consignee=query.consignee
this.query.is_new=0
////console.log(this.query)
this.getList()
}
});
},
filters:{
goodsAttr(e){
return e.replace(/\s\n/g,';');
}
}
}
</script>
<style>
page{
border-top:14.67rpx #F6F5FA solid ;
padding-bottom: 140rpx;
}
</style>
<style lang="scss" scoped>
@import "@/common/scss/order.scss";
.order_info{
padding-left: 26.67rpx;
padding-right: 22.67rpx;
padding-top: 50.67rpx;
padding-bottom: 42.67rpx;
border-bottom:14.67rpx #F6F5FA solid ;
.info_title{
display: flex;
align-items: center;
justify-content: space-between;
font-weight: bold;
font-size: 26.67rpx;
.info_title_right{
display: flex;
align-items: center;
color: #666666;
font-size: 24rpx;
image{
margin-left: 33.33rpx;
}
}
}
.info_image{
display: flex;
margin-top: 26.67rpx;
.info_image_item{
width: 133.33rpx;
height: 133.33rpx;
margin-right: 12rpx;
background-color: #999999;
}
}
}
.method{
border-bottom:14.67rpx #F6F5FA solid ;
padding-top: 50rpx;
.method_title{
font-size: 26.67rpx;
font-weight: bold;
padding-left: 25.33rpx;
}
.method_item{
padding:41.33rpx 0 ;
border-bottom: 1px #E2E2E2 solid;
padding-left: 42.67rpx;
padding-right: 29.33rpx;
display: flex;
align-items: center;
&:last-child{
border-bottom: none;
}
.method_item_image{
width: 30rpx;
height: 30rpx;
image{
width: 100%;
height: 100%;
}
}
.method_item_right{
margin-left: 30.67rpx;
.item_price{
font-size: 28rpx;
margin-bottom: 14rpx;
.item_price_span{
color: #B22234;
}
}
.item_time{
font-size: 25.33rpx;
font-weight: 400;
.item_time_span{
color: #555555;
}
}
}
}
}
.discount{
border-bottom:14.67rpx #F6F5FA solid ;
padding-left: 26rpx;
padding-right: 22.67rpx;
padding-top: 42rpx;
padding-bottom: 45.33rpx;
.discount_item{
display: flex;
align-items: center;
justify-content: space-between;
font-size: 28rpx;
margin-bottom: 42rpx;
&:last-child{
margin-bottom: 0;
}
.discount_item_left{
.discount_item_left_span{
color: #666666;
}
}
.discount_item_right{
display: flex;
align-items: center;
color: #B22234;
font-weight: bold;
image{
margin-left: 14rpx;
}
}
}
}
.settlement{
border-bottom:14.67rpx #F6F5FA solid ;
padding: 44rpx 26rpx;
.settlement_item{
display: flex;
align-items: center;
justify-content: space-between;
font-size: 28rpx;
margin-bottom: 44rpx;
&:last-child{
margin-bottom: 0;
}
.settlement_item_right{
color: #3C3B6E;
font-weight: bold;
}
.settlement_item_right1{
color: #B22234;
font-weight: bold;
}
}
}
.total{
padding: 30.67rpx 0;
padding-left: 26rpx;
padding-right: 19.33rpx;
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
position: fixed;
bottom: 0;
left: 0;
background-color: white;
z-index: 99;
box-sizing: border-box;
font-size: 36rpx;
font-weight: 600;
button{
font-size: 26.67rpx;
color: white;
height: 73.33rpx;
line-height: 73.33rpx;
border-radius: 0;
border: none;
background-color: black;
margin: 0;
}
}
// 红包
.coupons{
z-index: 999;
position: fixed;
bottom: 0;
left: 0;
background-color: white;
padding-left: 29.33rpx;
padding-right: 29.33rpx;
box-sizing: border-box;
padding-top: 20.67rpx;
width: 100%;
font-size: 30.67rpx;
font-weight: 400;
padding-bottom: 17.67rpx;
.order_popup_title{
position: relative;
font-size: 32rpx;
font-weight: bold;
border-bottom: 1px solid #E2E2E2;
display: flex;
color:#000;
align-items: center;
justify-content: center;
// padding-top: 44.67rpx;
padding-bottom: 20.67rpx;
text-align: center;
image{
width: 21.33rpx;
height: 21.33rpx;
position: absolute;
right: 26rpx;
}
}
.select_cop{
height: 50rpx;
width: 50rpx;
margin: 0rpx 0rpx 15rpx 80rpx;
image{
height: 100%;
width: 100%;
}
}
.order_popup_points{
padding-bottom: 63.33rpx;
padding-left: 47.33rpx;
padding-top: 34.67rpx;
font-size: 28rpx;
.points_item{
display: flex;
align-items: center;
margin-bottom: 40rpx;
&:last-child{
margin-bottom: 0;
}
image{
width: 29.33rpx;
height: 29.33rpx;
margin-right: 26rpx;
}
}
}
}
</style>