hengmei-two/pagesA/getReadyDan/getReadyDan.vue

699 lines
26 KiB
Vue
Raw Normal View History

2021-10-11 10:21:06 +00:00
<template>
<view>
<!-- 状态栏 -->
<status-nav :titleVal="'购物车'" :statusTitle="true"></status-nav>
2021-10-22 03:07:32 +00:00
<view v-if="loading" :style="{paddingTop: statusHNH+'px'}" class="pad-zy30" style="padding-bottom: 150rpx;">
<view class="bacf radius20 mar-s20 disjbac pad-sx27-zy20">
2021-10-11 10:21:06 +00:00
<view class="bold">配送方式</view>
<view class="fon26 col3 disac">
2021-10-22 03:07:32 +00:00
<view @tap="expressEv(0)" :class="isExpress?'activeT':'expressT'" :style="{background:isExpress?publicColor:''}">快递</view>
<view @tap="expressEv(1)" :class="!isExpress?'activeT':'expressT'" :style="{background:isExpress?'':publicColor}">自提</view>
2021-10-11 10:21:06 +00:00
</view>
</view>
<!-- 地址信息 -->
2021-10-22 03:07:32 +00:00
<view v-if="isExpress" class="bacf radius20 mar-s20 pad-sx27-zy20">
2021-10-11 10:21:06 +00:00
<view class="bold">收件人信息</view>
2021-10-22 03:07:32 +00:00
<navigator url="/pagesA/myAddress/myAddress?isWhere=0" hover-class="none">
<view class="fon26 col3 disjbac pad-s50">
2021-11-02 10:23:53 +00:00
<view v-if="addressInfo!=''">
2021-10-22 03:07:32 +00:00
<view class="fon28 col3 bold mar-x20">{{addressInfo.name}} <span class="mar-z20">{{userPphone}}</span></view>
<view class="fon24 col9">{{addressInfo.province_str}}{{addressInfo.city_str}}{{addressInfo.county_str || ''}}{{addressInfo.address || ''}}</view>
</view>
2021-11-02 10:23:53 +00:00
<view v-else class="fon24 col9">请完善收件人信息</view>
2021-10-22 03:07:32 +00:00
<image src="/static/public/nextM.png" class="xiaDan-next" mode="aspectFill"></image>
2021-10-11 10:21:06 +00:00
</view>
2021-10-22 03:07:32 +00:00
</navigator>
2021-10-11 10:21:06 +00:00
</view>
<!-- 自提地址 -->
2021-10-22 03:07:32 +00:00
<view v-else class="bacf radius20 mar-s20 pad-sx27-zy20">
2021-10-11 10:21:06 +00:00
<view class="bold">自提地址</view>
2021-10-22 03:07:32 +00:00
<input type="number" maxlength="11" :focus="isFocus" @blur="blurEv" v-model="zPhone" class="mar-s50 mar-x20" style="border: 2rpx solid #E0E0E0;padding: 20rpx;border-radius: 10rpx;font-size: 24rpx;" placeholder="请输入收货人手机号" />
<view class="fon26 col3 disjbac">
2021-10-11 10:21:06 +00:00
<view>
2021-10-22 03:07:32 +00:00
<view class="fon28 col3 bold mar-x20">恒美植发</view>
<view class="fon24 col9">{{goAddress}}</view>
2021-10-11 10:21:06 +00:00
</view>
2021-10-22 03:07:32 +00:00
<!-- 立即导航 -->
<image @tap="goThere(goAddress)" src="/static/public/daoh.png" class="there" mode="aspectFill"></image>
2021-10-11 10:21:06 +00:00
</view>
</view>
<!-- 订单信息 -->
2021-10-22 03:07:32 +00:00
<view class="bacf radius20 mar-s20 pad-sx27-zy20">
2021-10-11 10:21:06 +00:00
<view class="bold">订单信息</view>
2021-10-22 03:07:32 +00:00
<view v-for="(item,index) in orderList" :key="index" class="fon26 col3 disjbac pad-sx50 disjbac bbot">
2021-11-02 10:23:53 +00:00
<image @tap="goShopDetail(item.id)" :src="item.imgSrc" class="flexs order-image" mode="aspectFill"></image>
2021-10-22 03:07:32 +00:00
<view class="width100 disjb fw" style="height: 166rpx;">
<view>
2021-11-02 10:23:53 +00:00
<view @tap="goShopDetail(item.id)" class="fon28 col3 bold clips2">{{item.title}}</view>
<view class="order-sy">{{item.sku_name}}</view>
2021-10-22 03:07:32 +00:00
</view>
<view class="disjbac mar-s10 width100">
<view class="order-item-price" v-if="isNei!=3">{{item.price}}</view>
<view class="order-item-price" v-else>{{item.price}}</view>
<view class="fon28 col6">x{{item.num}}</view>
2021-10-11 10:21:06 +00:00
</view>
</view>
</view>
2021-11-02 10:23:53 +00:00
<view class="fon28 disjbac mar-s20 pad-s10">
<view class="col6">{{allNum}}</view>
<view class="bold colf8" v-if="isNei!=3">{{zanAllPrice}}</view>
<view class="bold colf8" v-else>{{allPrice}}</view>
</view>
</view>
<!-- 选择支付方式 -->
<view class="bacf radius20 mar-s20 fon28 col3 pad-sx30 pad-zy20">
<view class="bold fon28">选择支付方式</view>
<view @tap="chooseFS(index)" v-for="(item,index) in payFS" :key="index" v-if="isCurrent!=index" class="disjbac mar-s30">
<view class="disac">
<image v-if="item.isActive" src="/static/public/chooseFS.png" class="chooseDX" mode=""></image>
<image v-else src="/static/public/cancle-FS.png" class="chooseDX" mode=""></image>
<view class="mar-z25">{{item.title}}</view>
</view>
<view v-if="item.num!=0">{{item.num}}</view>
</view>
2021-10-11 10:21:06 +00:00
</view>
<!-- 优惠 -->
2021-10-22 03:07:32 +00:00
<view v-if="isNei!=3" class="bacf radius20 mar-s20 pad-sx27-zy20">
2021-10-11 10:21:06 +00:00
<view class="bold">优惠</view>
2021-10-22 03:07:32 +00:00
<view @tap="quanEv(1)" class="fon28 col3 disjbac mar-sx40">
2021-10-11 10:21:06 +00:00
<view>优惠券</view>
<view class="disac">
2021-11-02 10:23:53 +00:00
<view class="colf8 bold">-{{youQuan.youPrice}}</view>
2021-10-22 03:07:32 +00:00
<image src="/static/public/nextM.png" class="xiaDan-next" mode="aspectFill"></image>
2021-10-11 10:21:06 +00:00
</view>
</view>
2021-10-22 03:07:32 +00:00
<!-- <view class="fon28 col3 disjbac">
2021-10-11 10:21:06 +00:00
<view>立减优惠</view>
2021-10-22 03:07:32 +00:00
<view class="colf8 bold">-{{delPrice}}.00</view>
</view> -->
2021-10-11 10:21:06 +00:00
</view>
<!-- 快递费用 -->
2021-10-22 03:07:32 +00:00
<view v-if="isExpress" class="bacf radius20 mar-s20 disjbac pad-sx27-zy20">
2021-10-11 10:21:06 +00:00
<view class="bold">快递费用</view>
2021-10-22 03:07:32 +00:00
<view class="fon28 colf8 bold">{{expressInfo.default_price}}.00</view>
2021-10-11 10:21:06 +00:00
</view>
2021-10-22 03:07:32 +00:00
<view class="disjbac posixzy bacf pad-zy32" style="height: 124rpx;line-height: 124rpx;">
2021-10-11 10:21:06 +00:00
<!-- 去支付 -->
2021-11-02 10:23:53 +00:00
<view class="fon36 colf8 bold" v-if="isNei!=3">{{allPrice}}<span v-if="isKq">+{{zf_kqPrice}}</span></view>
<view class="fon40 colf8 bold dis" v-else><span class="col3 fon28">合计积分</span>{{allPrice}}<span v-if="isExpress && expressInfo.default_price!=0">+ {{expressInfo.default_price}}</span></view>
2021-10-22 03:07:32 +00:00
<view @tap="goPayment" v-if="isNei!=3" class="goPayment"></view>
2021-11-02 10:23:53 +00:00
<view @tap="isDui=true" v-else class="goPayment">去兑换</view>
2021-10-11 10:21:06 +00:00
</view>
</view>
<view v-if="showQuan" @tap.stop="showQuan=false" class="posAll">
<view class="bacf posixzy" style="border-radius: 40rpx 40rpx 0rpx 0rpx;" @tap.stop="showQuan=true">
2021-10-22 03:07:32 +00:00
<view class="pad-sx20 pad-zy50">
2021-10-11 10:21:06 +00:00
<view class="disjbac">
2021-10-22 03:07:32 +00:00
<view class="fon28 bold col3">可用优惠券({{quanList.length}})</view>
2021-10-11 10:21:06 +00:00
<image @tap.stop="showQuan=false" src="/static/public/cha-close.png" style="width: 30rpx;height: 30rpx;" mode="aspectFill"></image>
</view>
2021-10-22 03:07:32 +00:00
<!-- <view class="fon28 bold col3 disja pad-s50" style="padding-bottom: 16rpx;">
2021-10-11 10:21:06 +00:00
<view class="posir" :class="switchQuan?'activeQuan':''" @tap="switchQuan=true">(1)</view>
<view class="posir" :class="!switchQuan?'activeQuan':''" @tap="switchQuan=false">(0)</view>
2021-10-22 03:07:32 +00:00
</view> -->
<scroll-view scroll-y class="mar-s40 quan-list-box">
<view @tap.stop="chooseQuan(index)" v-for="(item,index) in quanList" :key="index" class="mar-x40">
<view class="disjbac quan-item-box">
<view class="posir">
<image class="posia" src="/static/public/quan-left.png" mode=""></image>
<view class="posir" style="z-index: 1;">
<view class="pad-s40 pad-x30 fon28"><span class="bold fon56">{{item.youPrice}}</span></view>
<view class="fon24" style="padding-left: 12rpx;">{{item.manPrice}}元可使用</view>
</view>
2021-10-11 10:21:06 +00:00
</view>
<view>
2021-10-22 03:07:32 +00:00
<!-- <view class="fon28 col3 mar-s20">{{['黄金','白银'][item.isGrade]}}会员专属优惠券</view> -->
<view class="fon28 col3 mar-s20">{{item.name}}</view>
<view>
<image v-if="item.isStatus" src="/static/public/chooseQuan.png"></image>
<image v-else src="/static/public/cancleQuan.png"></image>
</view>
<view class="fon20 col3 mar-x20">有效期{{item.startTime.slice(0,10)}}{{item.endTime.slice(0,10)}}</view>
2021-10-11 10:21:06 +00:00
</view>
</view>
</view>
2021-10-22 03:07:32 +00:00
</scroll-view>
2021-10-11 10:21:06 +00:00
<!-- 领取优惠券按钮 -->
2021-10-22 03:07:32 +00:00
<view @tap.stop="goCoupon" class="ling-btn">领取优惠券</view>
2021-10-11 10:21:06 +00:00
</view>
</view>
</view>
<!-- 确认兑换弹框 -->
2021-11-02 10:23:53 +00:00
<view v-if="isDui" @tap.stop="isDui=false" class="posAll zhun-dui-box">
2021-10-11 10:21:06 +00:00
<view class="bacf radius20 width100 tc fon28 col3 pad20" @tap.stop="isDui=true">
<view class="bold" style="margin: 0rpx 0 56rpx 0;">兑换商品</view>
2021-11-02 10:23:53 +00:00
<view style="margin: 0rpx 0 66rpx 0;">您确定使用{{allPrice}}积分兑换吗</view>
<view class="disjbac mar-x20 pad-zy20 zhun-dui-btn">
<view @tap.stop="isDui=false">暂不兑换</view>
<view @tap.stop="goPayment">立即兑换</view>
</view>
</view>
</view>
<!-- 支付成功 -->
<view v-if="isSuccess" class="posAll" :style="{top:statusHNH+'px'}" style="z-index: 3;background-color: #F5F5F5;">
<view class="bacf radius20 mar-s20 mar-zy20 success-box">
<image src="/static/public/pay-success.png" mode=""></image>
<view class="fon28 col3 pad-s20 pad-x40">支付成功</view>
<view class="success-hj"><span v-if="isNei!=3">{{jsPrice}}</span><span v-else>{{jsPrice}}</span></view>
<view class="disja success-btn">
<view @tap="goDetail"></view>
<view @tap="goShop" class="colf" :style="{background:publicColor}">再逛一逛</view>
2021-10-11 10:21:06 +00:00
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
statusHNH:uni.getStorageSync('statusHNH'),
publicColor:uni.getStorageSync('publicColor'),//主题颜色
isExpress:true,
switchQuan:true,
2021-10-22 03:07:32 +00:00
showQuan:false,//是否显示优惠券弹框
isDui:false,
orderList:uni.getStorageSync('orderList'),
quanList:[],
goAddress:'四川省成都市青羊区青羊大道213号',
youQuan:{
id:0,
youPrice:0
},//优惠券
delPrice:0,//立减优惠(限时活动的)
allPrice:0,//合计
allNum:0,//总数量
zanAllPrice:0,//暂存合计
isNei:0,
expressInfo:{},//快递信息
2021-11-02 10:23:53 +00:00
addressInfo:'',//地址信息
userPphone:'请完善信息',
2021-10-22 03:07:32 +00:00
zPhone:'',//自提时的手机号
page:1,
size:10,
isFocus:false,
2021-11-02 10:23:53 +00:00
loading:false,
zf_allPrice:0,//实际付款
zf_kqPrice:0,//孔雀币
payFS:[
{title:'微信支付',isActive:true,num:0},
{title:'孔雀币',isActive:false,num:100},
{title:'积分',isActive:false,num:100},
],
isKq:false,
jsPrice:0,//结算时的金额,
zc_allPrice:0,//暂存实际总金额
coin_price:0,//孔雀币转换后的元
isSuccess:false,//支付成功
ntype:'money',//默认money孔雀币转钱 coin钱转孔雀币
times:0,//点击次数
2021-11-04 07:41:53 +00:00
isCurrent:2,
2021-10-11 10:21:06 +00:00
}
},
onShow() {
2021-10-22 03:07:32 +00:00
this.$toolAll.tools.isLogin();
2021-11-02 10:23:53 +00:00
this.checkChoose();//检测地址
2021-10-22 03:07:32 +00:00
uni.removeStorageSync('orderInfo');
2021-11-02 10:23:53 +00:00
setTimeout(()=>{
if(this.addressInfo==''){this.$toolAll.tools.showToast('请完善收件人信息','none',1500);}
},2000)
2021-10-11 10:21:06 +00:00
},
2021-10-22 03:07:32 +00:00
onLoad(options) {
2021-11-10 11:23:11 +00:00
this.checkexpress();//查询快递
2021-10-22 03:07:32 +00:00
this.checkeList();//查询订单列表
this.checkOrderDetail();//查询订单信息
this.isNei = options.isNei;
2021-11-02 10:23:53 +00:00
if(this.isNei==3) {
this.payFS[0].isActive = false;
this.payFS[2].isActive = true;
this.isCurrent = 1;
}
2021-10-11 10:21:06 +00:00
},
methods: {
2021-11-02 10:23:53 +00:00
checkChoose(){
if(uni.getStorageSync('chooseAddress')==''){
this.checkAddress();//查询地址
} else {
let naddress = uni.getStorageSync('chooseAddress');
this.addressInfo = {
id:naddress.id,
name:naddress.userName,
phone:naddress.userPhone,
province_str:naddress.province,
city_str:naddress.city,
county_str:naddress.county,
address:naddress.address
}
this.userPphone = this.$toolAll.tools.hideMPhone(naddress.userPhone);
}
},
obtainCoin(coinNum){//获取当前账户孔雀币
this.$requst.post('user/get-coin-price',{amount:coinNum,get_type:this.ntype}).then(res=>{
if(res.code==0){
if(this.ntype=='money'){
this.coin_price = res.data.amount/100;
} else {
this.zf_kqPrice = res.data.amount;
this.isKq = true;
}
}
})
},
goShopDetail(id){
uni.navigateTo({
url:`/pagesB/shopDetail/shopDetail?id=${id}`
})
},
chooseFS(index){
this.payFS[index].isActive = !this.payFS[index].isActive;
if(this.isNei==3){//积分
if(!this.payFS[0].isActive && !this.payFS[2].isActive){
this.$toolAll.tools.showToast('请选择支付方式')
this.allPrice = this.zanAllPrice;
this.isKq = false;
return;
}
} else {//孔雀币
if(!this.payFS[0].isActive && !this.payFS[1].isActive){
this.$toolAll.tools.showToast('请选择支付方式')
this.allPrice = this.zanAllPrice;
this.isKq = false;
this.zf_kqPrice = this.payFS[1].num;
return;
}
}
if(this.payFS[index].title=='微信支付'){
if(this.isNei!=3){
//选择了微信支付+选择了孔雀币
if(this.payFS[0].isActive && this.payFS[1].isActive){
if(this.zanAllPrice - this.coin_price >=0){//孔雀币不足以抵扣
this.allPrice = this.$toolAll.tools.addXiaoShu(this.zanAllPrice - this.coin_price);
this.zf_kqPrice = this.payFS[1].num;
} else {//孔雀币足以抵扣
this.allPrice = 0;
this.ntype = 'coin';
this.obtainCoin(this.zanAllPrice*100);
}
return;
}
//取消了微信支付+选择了孔雀币
if(!this.payFS[0].isActive && this.payFS[1].isActive){
if(this.zanAllPrice - this.coin_price>0){
this.$toolAll.tools.showToast('孔雀币不足');
}
return;
}
//选择了微信支付+取消了孔雀币
if(this.payFS[0].isActive && !this.payFS[1].isActive){
this.isKq = false;
this.zf_kqPrice = 0;
return;
}
}
}
if(this.payFS[index].title=='孔雀币') {
if(this.youQuan.youPrice!=0){
this.payFS[1].isActive = false;
this.$toolAll.tools.showToast('无法使用孔雀币支付');
} else {
if(this.coin_price!=0){
//选择了微信支付+选择了孔雀币
if(this.payFS[0].isActive && this.payFS[1].isActive) {
if(this.zanAllPrice - this.coin_price<=0){//孔雀币足以抵扣
this.ntype = 'coin';
this.obtainCoin(this.zanAllPrice*100);
this.allPrice = 0;
} else {//孔雀币不足以抵扣
this.allPrice = this.$toolAll.tools.addXiaoShu(this.zanAllPrice - this.coin_price).toFixed(2);
this.zf_kqPrice = this.payFS[1].num;
}
return;
}
//选择了微信支付+取消了孔雀币
if(this.payFS[0].isActive && !this.payFS[1].isActive) {
this.isKq = false;
if(this.youQuan.youPrice==0){
this.allPrice = this.$toolAll.tools.addXiaoShu(this.zanAllPrice).toFixed(2);
} else {
this.allPrice = this.$toolAll.tools.addXiaoShu(this.zanAllPrice-this.youQuan.youPrice).toFixed(2);
}
return;
}
//取消了微信支付+选择了孔雀币
if(!this.payFS[0].isActive && this.payFS[1].isActive){
if(this.zanAllPrice - this.coin_price<=0){//孔雀币足以抵扣应付款
this.ntype = 'coin'
this.obtainCoin(this.allPrice*100);
this.allPrice = 0;
} else {//孔雀币不足以抵扣应付款
this.$toolAll.tools.showToast('孔雀币不足')
this.allPrice = this.$toolAll.tools.addXiaoShu(this.zanAllPrice - this.coin_price).toFixed(2);
this.zf_kqPrice = this.payFS[1].num;
}
return;
}
//取消了微信支付+取消了孔雀币
if(!this.payFS[0].isActive && !this.payFS[1].isActive){
this.isKq = false;
this.allPrice = this.$toolAll.tools.addXiaoShu(this.zanAllPrice).toFixed(2);
return;
}
} else {
this.$toolAll.tools.showToast('暂无可用孔雀币');
this.payFS[index].isActive = false;
}
}
}
if(this.payFS[index].title=='积分') {
}
},
2021-10-22 03:07:32 +00:00
goPayment(){//去付款
this.isFocus = false;
2021-11-02 10:23:53 +00:00
this.isDui = false;
2021-10-22 03:07:32 +00:00
let nphone = '';
if(this.isExpress) {
nphone = this.addressInfo.phone;//默认地址的手机号
} else nphone = this.zPhone;//自提时的手机号
let self = 0;//快递的配送方式
if(!this.isExpress) self = 1;//自提的方式
let nsku_list = [];
2021-11-02 10:23:53 +00:00
let is_only = 0;
2021-10-22 03:07:32 +00:00
this.orderList.forEach(item=>{
let obj = {
sku_coding:item.coding,
2021-11-02 10:23:53 +00:00
num:item.num,
2021-11-08 07:50:30 +00:00
group_id:item.pin_user_id
2021-10-22 03:07:32 +00:00
}
nsku_list.push(obj);
2021-11-02 10:23:53 +00:00
is_only = item.is_only;
2021-10-22 03:07:32 +00:00
})
2021-11-02 10:23:53 +00:00
let is_score = 0;
if(this.isNei == 3) {is_score = 1}
if(this.zf_kqPrice!=0) {
this.jsPrice = `${this.allPrice} +${this.zf_kqPrice}孔雀币`;
} else {
this.jsPrice = this.allPrice;
}
2021-10-22 03:07:32 +00:00
let parmas = {
sku_list: nsku_list,//商品单号和数量数组
2021-11-02 10:23:53 +00:00
total: this.allPrice*100,//总金额
2021-10-22 03:07:32 +00:00
address_id: this.addressInfo.id,//地址ID
express_code: this.expressInfo.code,//快递编码
coupon_id: this.youQuan.id,//优惠券ID
2021-11-02 10:23:53 +00:00
coupon_price: this.youQuan.youPrice*100,//优惠券可用
2021-10-22 03:07:32 +00:00
pick_self: self,//是否自提0 快递, 1自提
pick_self_phone: nphone,//联系电话
2021-11-02 10:23:53 +00:00
original_total: this.zanAllPrice*100,//原价总金额
freight: this.expressInfo.default_price,//快递费
remarks: "",//备注
2021-11-11 04:04:41 +00:00
is_only:is_only,//是否是单独购买0 不是单独购买12是单独购买
2021-11-02 10:23:53 +00:00
is_score:is_score,//是否是积分商品0 不是积分商品1是积分商品
coin:this.zf_kqPrice//孔雀币
}
2021-11-08 07:50:30 +00:00
if(this.addressInfo=='' && self!=1){
this.$toolAll.tools.showToast('请完善收件人信息');
} else if(nphone=='') {
this.$toolAll.tools.showToast('请填写收货人手机号');
this.focusEv();
} else if(this.$toolAll.tools.isPhone(nphone)) {
this.$toolAll.tools.showToast('请正确填写收货人手机号');
this.focusEv();
} else if(this.isNei == 3 && !this.payFS[2].isActive){//积分判断条件
this.$toolAll.tools.showToast('请选择积分付款方式');
} else if(this.isNei == 3 && this.expressInfo.default_price!=0){//积分判断条件
this.$toolAll.tools.showToast('请添加微信支付方式');
} else if(this.isNei != 3 && !this.payFS[0].isActive && !this.payFS[1].isActive){
this.$toolAll.tools.showToast('请选择支付方式')
} else if(this.isNei != 3 && !this.payFS[0].isActive && this.allPrice*1 > this.coin_price*1){
this.$toolAll.tools.showToast('孔雀币不足');
} else {
if(this.times==0){
this.times++;
if(this.allPrice==0){
this.$toolAll.tools.showToast('正在支付','loading',1500);
} else {
this.$toolAll.tools.showToast('正在调起支付','loading',1500);
}
uni.request({
url:'https://hengmei.scdxtc.cn/api/order/create',
data:parmas,
method:'post',
header:{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Bearer '+uni.getStorageSync('token') || ''
},
success: (res) => {
if(res.data.code==0){
this.times = 0;
this.payment(res.data.data);
// uni.setStorageSync('orderList',this.orderList);
// uni.setStorageSync('orderInfo',res.data.data);
// uni.navigateTo({
// url:`/pagesA/immediatePayment/immediatePayment?allPrice=${this.allPrice}&allNum=${this.allNum}&startTime=${new Date(res.header.Date).getTime()}`
// })
} else {
2021-11-11 02:50:50 +00:00
this.$toolAll.tools.showToast(res.data.msg,'none',3000);
2021-11-08 07:50:30 +00:00
this.times = 0;
}
}
})
}
}
2021-11-02 10:23:53 +00:00
},
payment(info){
if(info.needPay){
uni.requestPayment({
provider: 'wxpay',
appId:info.payment_params.appId,//appId
timeStamp: info.payment_params.timeStamp,//时间戳
nonceStr: info.payment_params.nonceStr,//随机字符串
package: info.payment_params.package,//package
signType: info.payment_params.signType,//MD5
paySign: info.payment_params.sign,//签名
success:(res)=> {
this.$requst.post('order/paid',{order_coding:info.coding}).then(res=>{
if(res.code==0){
uni.removeStorageSync('chooseAddress')
this.isSuccess = true;
} else this.$toolAll.tools.showToast(res.msg);
})
},
fail() {
this.times = 0;
2021-11-11 07:33:17 +00:00
uni.navigateTo({
url:'/pagesA/myOrder/myOrder'
})
2021-10-22 03:07:32 +00:00
}
2021-11-02 10:23:53 +00:00
});
} else {
this.$requst.post('order/paid',{order_coding:info.coding}).then(res=>{
if(res.code==0){
uni.removeStorageSync('chooseAddress')
this.isSuccess = true;
} else this.$toolAll.tools.showToast(res.msg);
2021-10-22 03:07:32 +00:00
})
}
},
goThere(val){//去这里
2021-10-11 10:21:06 +00:00
wx.getLocation({//获取当前经纬度
type: 'wgs84', //返回可以用于wx.openLocation的经纬度官方提示bug: iOS 6.3.30 type 参数不生效,只会返回 wgs84 类型的坐标信息
success: function (res) {
wx.openLocation({//​使用微信内置地图查看位置。
2021-11-02 10:23:53 +00:00
latitude: 30.67554,//要去的纬度-地址
longitude: 104.010642,//要去的经度-地址
2021-10-22 03:07:32 +00:00
name: val,
address: val
2021-10-11 10:21:06 +00:00
})
}
})
},
2021-10-22 03:07:32 +00:00
checkAddress(){//默认地址查询
this.$requst.post('user/address').then(res=>{
if(res.code==0){
if(res.data.length!=0){
res.data.forEach(item=>{
if(item.is_default==1) {
this.addressInfo = item;
}
})
this.userPphone = this.$toolAll.tools.hideMPhone(this.addressInfo.phone);
}
}
})
},
checkexpress(){//查询快递费
if(this.isExpress) {
this.$requst.post('common/express-list').then(res=>{
if(res.code==0){
if(res.data.length!=0){
res.data.forEach(item=>{
if(item.is_default==1){
this.expressInfo = item;
this.expressInfo.default_price = this.expressInfo.default_price/100;
}
})
this.totalEv();
}
}
})
} else {
this.totalEv();
}
},
expressEv(index){//快递自取切换事件
if(index==0) {
this.isExpress = true;
2021-11-10 11:23:11 +00:00
// this.checkexpress();
2021-10-22 03:07:32 +00:00
}
if(index==1) {
this.isExpress = false;
}
},
totalEv(){//合计运算
2021-11-02 10:23:53 +00:00
if(this.isNei!=3 && this.isExpress){//普通商品,有运费
2021-10-22 03:07:32 +00:00
this.allPrice = this.zanAllPrice - this.youQuan.youPrice - this.delPrice + this.expressInfo.default_price;//合计 = 总价 - 优惠券 - 立减券 + 快递费
}
2021-11-02 10:23:53 +00:00
if(this.isNei!=3 && !this.isExpress){//普通商品无运费
2021-10-22 03:07:32 +00:00
this.allPrice = this.zanAllPrice - this.youQuan.youPrice - this.delPrice;//合计 = 总价 - 优惠券 - 立减券
}
this.allPrice = this.$toolAll.tools.addXiaoShu(this.allPrice);
2021-11-02 10:23:53 +00:00
if(this.isNei ==3 && this.isExpress){//积分商品,有运费
this.allPrice = this.zanAllPrice - this.youQuan.youPrice - this.delPrice + this.expressInfo.default_price;//合计 = 总价 - 优惠券 - 立减券 + 快递费
}
if(this.isNei ==3 && !this.isExpress){//积分商品,有运费
this.allPrice = this.zanAllPrice - this.youQuan.youPrice - this.delPrice;//合计 = 总价 - 优惠券 - 立减券
}
2021-10-22 03:07:32 +00:00
this.loading = true;
},
checkOrderDetail(){//查询订单准备信息
let nsku_list = [];
this.orderList.forEach(item=>{
let obj = {
sku_coding:item.coding,
num:item.num
}
nsku_list.push(obj)
})
let parmas = {
sku_list: nsku_list,
pick_self: 0
}
this.$requst.post('order/prepare-info',parmas).then(res=>{
if(res.code==0){
2021-11-02 10:23:53 +00:00
this.payFS[1].num = res.data.account.coin;
this.obtainCoin(res.data.account.coin);
this.payFS[2].num = res.data.account.score;
2021-10-22 03:07:32 +00:00
} else this.$toolAll.tools.showToast(res.msg);
})
},
checkeList(){
this.orderList.forEach(item=>{
this.allPrice += item.price*item.num;
this.allNum += item.num;
})
2021-11-02 10:23:53 +00:00
this.zanAllPrice = this.$toolAll.tools.addXiaoShu(this.allPrice);
2021-11-10 11:23:11 +00:00
this.quanEv(0);//查询优惠券列表
2021-10-22 03:07:32 +00:00
},
quanEv(index){//调起优惠券弹框事件
2021-11-02 10:23:53 +00:00
if(this.payFS[1].isActive){
this.$toolAll.tools.showToast('无法使用优惠券减免');
// this.allPrice = this.$toolAll.tools.addXiaoShu(this.zanAllPrice*1 + this.expressInfo.default_price*1);
} else {
if(index==1){
this.showQuan = true
}
this.youQuan.id = 0;
this.youQuan.youPrice = 0;
this.allPrice = (this.zanAllPrice*1 - this.expressInfo.default_price*1).toFixed(2);
this.checkQuan();//查询可用优惠券事件
2021-10-22 03:07:32 +00:00
}
},
checkQuan(){//查询可用优惠券事件
this.$requst.post('user/get-coupon-list',{status:'normal',page:this.page,size:this.size}).then(res=>{
if(res.code==0){
this.quanList = [];
if(res.data.length!=0){
res.data.forEach(item=>{
if(item.type!='taste'){//如果不等于体验券
let obj = {
id:item.id,
youPrice:item.amount/100,
manPrice:item.condition/100,
isGrade:0,
name:item.name,
startTime:item.begin_at,
endTime:item.end_at,
isStatus:false
}
this.quanList.push(obj);
}
})
}
}
})
},
chooseQuan(index){//选择可用优惠券事件
if(this.zanAllPrice <= this.quanList[index].manPrice){//如果满减大于合计
this.$toolAll.tools.showToast('未达到使用条件')
} else {
2021-11-02 10:23:53 +00:00
if(this.allPrice==0){
this.$toolAll.tools.showToast('此订单费用为 0');
// this.$requst.post('user/get-coin-price',{amount:this.quanList[index].youPrice,get_type:'coin'}).then(res=>{
// if(res.code==0){
// this.zf_kqPrice = this.zf_kqPrice - res.data.amount;
// this.showQuan = false;
// }
// })
} else {
this.quanList.forEach(item=>{
item.isStatus = false;
});
this.quanList[index].isStatus = true;
this.showQuan = false;
this.quanList[index].youPrice = this.$toolAll.tools.addXiaoShu(this.quanList[index].youPrice);
this.youQuan = this.quanList[index];
this.allPrice = this.zanAllPrice*1 - this.quanList[index].youPrice*1 + this.expressInfo.default_price*1;//合计 = 暂存合计 - 选中的优惠券
this.allPrice = this.allPrice.toFixed(2)*1;
}
2021-10-22 03:07:32 +00:00
}
},
goCoupon(){//去领取优惠券
this.showQuan = false;
2021-10-11 10:21:06 +00:00
uni.navigateTo({
2021-10-22 03:07:32 +00:00
url:'/pagesA/coupon/coupon'
2021-10-11 10:21:06 +00:00
})
2021-10-22 03:07:32 +00:00
},
focusEv(){//获取焦点
this.isFocus = true;
},
blurEv(){//失去焦点
this.isFocus = false;
2021-11-02 10:23:53 +00:00
},
goDetail(){//去订单列表
uni.navigateTo({
url:'/pagesA/myOrder/myOrder'
})
},
goShop(){//逛一逛
let nurl = '';
if(this.isNei==3) nurl = '/pagesA/pointsMall/pointsMall';
else nurl = '/pages/tabbar/shop/shop';
uni.reLaunch({
url:nurl
})
2021-10-11 10:21:06 +00:00
}
}
}
</script>
<style>
page {
background-color: #F5F5F5;
}
</style>