hengmei-two/pagesA/getReadyDan/getReadyDan-two.vue

831 lines
31 KiB
Vue
Raw Permalink Normal View History

<template>
<view>
<!-- 状态栏 -->
<status-nav :titleVal="'购物车'" :statusTitle="true"></status-nav>
<view v-if="loading" :style="{paddingTop: statusHeight+'px'}" class="pad-zy30" style="padding-bottom: 150rpx;">
<view class="bacf radius20 mar-s20 disjbac pad-sx27-zy20">
<view class="bold">配送方式</view>
<view class="fon26 col3 disac">
<view @tap="expressEv(1)" :class="!isExpress?'activeT':'expressT'" :style="{background:isExpress?'':publicColor}">自提</view>
<view v-if="!isVirtual" @tap="expressEv(0)" :class="isExpress?'activeT':'expressT'" :style="{background:isExpress?publicColor:''}"></view>
</view>
</view>
<!-- 地址信息 -->
<view v-if="isExpress" class="bacf radius20 mar-s20 pad-sx27-zy20">
<view class="bold">收件人信息</view>
<navigator url="/pagesA/myAddress/myAddress?isWhere=0" hover-class="none">
<view class="fon26 col3 disjbac pad-s50">
<view v-if="addressInfo!=''">
<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>
<view v-else class="fon24 col9">请完善收件人信息</view>
<image src="/static/public/nextM.png" class="xiaDan-next" mode="aspectFill"></image>
</view>
</navigator>
</view>
<!-- 自提地址 -->
<view v-else class="bacf radius20 mar-s20 pad-sx27-zy20">
<view class="bold">自提地址</view>
<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">
<view>
<view class="fon28 col3 bold mar-x20">恒美植发</view>
<view class="fon24 col9">{{goAddress}}</view>
</view>
<!-- 立即导航 -->
<image @tap="goThere(goAddress)" src="/static/public/daoh.png" class="there" mode="aspectFill"></image>
</view>
</view>
<!-- 订单信息 -->
<view class="bacf radius20 mar-s20 pad-sx27-zy20">
<view class="bold">订单信息</view>
<view v-for="(item,index) in orderList" :key="index" class="fon26 col3 disjbac pad-sx50 disjbac bbot">
<image lazy-load @tap="goShopDetail(item.id)" :src="item.imgSrc" class="flexs order-image" mode="aspectFill"></image>
<view class="width100 disjb fw" style="height: 166rpx;">
<view>
<view @tap="goShopDetail(item.id)" class="fon28 col3 bold clips2">{{item.title}}</view>
<view class="order-sy">{{item.sku_name}}</view>
</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>
</view>
</view>
</view>
<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>
</view>
<!-- 优惠 -->
<view v-if="isNei!=3" class="bacf radius20 mar-s20 pad-sx27-zy20">
<view class="bold">优惠</view>
<view @tap="quanEv(1)" class="fon28 col3 disjbac mar-sx40">
<view>优惠券</view>
<view class="disac">
<view class="colf8 bold">-{{youQuan.youPrice}}</view>
<image src="/static/public/nextM.png" class="xiaDan-next" mode="aspectFill"></image>
</view>
</view>
</view>
<!-- 快递费用 -->
<view v-if="isExpress && has_postage==1" class="bacf radius20 mar-s20 disjbac pad-sx27-zy20">
<view class="bold">快递费用</view>
<view class="fon28 colf8 bold">{{expressInfo.default_price}}</view>
</view>
<view class="disjbac posixzy bacf pad-zy32" style="height: 124rpx;line-height: 124rpx;">
<!-- 去支付 -->
<view class="fon36 colf8 bold" v-if="isNei!=3">{{allPrice<0?0:allPrice}}<span v-if="isKq">+{{zf_kqPrice}}</span><span v-if="isExpress && expressInfo.default_price!=0" style="font-size: 24rpx;color: #000;">+ {{expressInfo.default_price}}</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>
<view @tap="goPayment" v-if="isNei!=3" class="goPayment"></view>
<view @tap="isDui=true" v-else class="goPayment">去兑换</view>
</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">
<view class="pad-sx20 pad-zy50">
<view class="disjbac">
<view class="fon28 bold col3">可用优惠券({{quanList.length}})</view>
<image @tap.stop="showQuan=false" src="/static/public/cha-close.png" style="width: 30rpx;height: 30rpx;" mode="aspectFill"></image>
</view>
<!-- <view class="fon28 bold col3 disja pad-s50" style="padding-bottom: 16rpx;">
<view class="posir" :class="switchQuan?'activeQuan':''" @tap="switchQuan=true">(1)</view>
<view class="posir" :class="!switchQuan?'activeQuan':''" @tap="switchQuan=false">(0)</view>
</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>
</view>
<view>
<!-- <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>
</view>
</view>
</view>
</scroll-view>
<!-- 领取优惠券按钮 -->
<view @tap.stop="goCoupon" class="ling-btn">领取优惠券</view>
</view>
</view>
</view>
<!-- 确认兑换弹框 -->
<view v-if="isDui" @tap.stop="isDui=false" class="posAll zhun-dui-box">
<view class="bacf radius20 width100 tc fon28 col3 pad20" @tap.stop="isDui=true">
<view class="bold" style="margin: 0rpx 0 56rpx 0;">兑换商品</view>
<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:statusHeight+'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<0?0: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>
</view>
</view>
</view>
<!-- 分享弹框 -->
<view v-if="isfen" class="posAll disjcac" style="background-color: rgba(0,0,0,.25);z-index: 8;">
<view class="bacf width100 radius20 posir" style="padding: 60rpx 50rpx;margin: 0 70rpx;text-align: center;">
<image @tap="isfen=false" src="../../static/public/closequan.png" class="posia heyan-close" mode=""></image>
<view style="color: #f55255;font-size: 36rpx;">立即完成拼单?</view>
<view style="margin: 50rpx 0;font-size: 26rpx;">点击下方分享给朋友完成拼单</view>
<view class="posir radius15 disjcac pad-sx20" style="background-color: #22cc3e;color: #FFFFFF;font-size: 36rpx;">
2022-07-05 09:27:51 +00:00
邀请拼单
<button open-type="share" class="posia-op">邀请拼单</button>
</view>
</view>
</view>
<!-- 用户信息授权手机号授权 -->
<auth-userInfo-mobileInfo></auth-userInfo-mobileInfo>
</view>
</template>
<script>
export default {
data() {
return {
isExpress:false,
switchQuan:true,
showQuan:false,//是否显示优惠券弹框
isDui:false,
orderList:uni.getStorageSync('orderList'),
has_postage:uni.getStorageSync('has_postage'),
quanList:[],
goAddress:'四川省成都市青羊区青羊大道213号',
youQuan:{
id:0,
youPrice:0
},//优惠券
allPrice:0,//合计
allNum:0,//总数量
zanAllPrice:0,//暂存合计
isNei:0,
expressInfo:{},//快递信息
addressInfo:'',//地址信息
userPphone:'请完善信息',
zPhone:'',//自提时的手机号
page:1,
size:10,
isFocus:false,
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,//点击次数
isCurrent:2,
isfen:false,
checkGrounpId:0,
expressInfo:{
default_price:0
},
isVirtual:false,//是否是虚拟商品
2022-07-05 09:27:51 +00:00
payType:'',//支付方式 wechat=微信支付;coin=孔雀币;hybrid=混合支付
groupLast:'0', //是否拼团成功
}
},
computed: {
// 主题颜色
publicColor() {
return this.$store.state.publicColor
},
statusHeight() {
return this.$store.state.statusHeight
}
},
onShareAppMessage(res) {
var shareObj = {
     title: this.orderList[0].title, // 默认是小程序的名称(可以写slogan等)
     path: `/pagesB/shopDetail/shopDetail?id=${this.orderList[0].id}&category_id=0&is_activity=${this.orderList[0].is_activity}&share_id=${uni.getStorageSync('userId')}&invite_code=${uni.getStorageSync('invite_code')}`, // 默认是当前页面,必须是以‘/’开头的完整路径
     imageUrl: this.orderList[0].imgSrc//自定义图片路径可以是本地文件路径、代码包文件路径或者网络图片路径支持PNG及JPG不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
  };
  return shareObj;
//   return false;
},
onShow() {
// 禁止分享
this.$toolAll.tools.disableShareEv();
this.checkChoose();//检测地址
uni.removeStorageSync('orderInfo');
},
onLoad(options) {
// wechat=微信支付;coin=孔雀币;hybrid=混合支付
this.payType = uni.getStorageSync('payType');
// this.payType = 'coin';
if(this.payType=='wechat') {
this.payFS = [{title:'微信支付',isActive:true,num:0}]
} else if(this.payType=='coin'){
this.payFS = [{title:'孔雀币',isActive:true,num:0}]
} else if(this.payType=='hybrid'){
this.payFS = [
{title:'微信支付',isActive:true,num:0},
{title:'孔雀币',isActive:false,num:0}
]
}
// 自提手机号
this.zPhone = uni.getStorageSync('phone');
// 判断是不是虚拟商品
options.isVirtual == "virtual" ? this.isVirtual = true : this.isVirtual = false
this.checkexpress();//查询快递
this.checkeList(options.isNei);//查询订单列表
this.checkOrderDetail();//查询订单信息
this.isNei = options.isNei;
if(this.isNei==3) {
this.payFS[0].isActive = false;
this.payFS[2].isActive = true;
this.isCurrent = 1;
}
},
methods: {
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;
if(this.payType=='coin'){
// 只有孔雀币支付方式
if(this.zanAllPrice - this.coin_price<=0){//孔雀币足以抵扣
this.allPrice = 0;
this.zf_kqPrice = this.zanAllPrice*1;
} else {//孔雀币不足以抵扣
this.allPrice = (this.$toolAll.tools.addXiaoShu(this.zanAllPrice - this.coin_price)*1).toFixed(2);
this.zf_kqPrice = this.coin_price;
}
this.isKq = true;
}
} 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.payType!='coin'){
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;
}
} else {
if(this.expressInfo.default_price==0){
this.$toolAll.tools.showToast('暂不可微信支付');
this.payFS[index].isActive = false;
}
}
}
if(this.payFS[index].title=='孔雀币') {
if(this.payType!='coin'){
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)*1).toFixed(2);
this.zf_kqPrice = this.payFS[1].num;
}
this.isKq = true;
return;
}
//选择了微信支付+取消了孔雀币
if(this.payFS[0].isActive && !this.payFS[1].isActive) {
this.isKq = false;
this.zf_kqPrice = 0;
// 如果优惠券金额等0
if(this.youQuan.youPrice==0){
this.allPrice = (this.$toolAll.tools.addXiaoShu(this.zanAllPrice)*1).toFixed(2);
} else {
this.allPrice = (this.$toolAll.tools.addXiaoShu(this.zanAllPrice - this.youQuan.youPrice)*1).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;
}
if(this.zanAllPrice - this.coin_price>0){//孔雀币不足以抵扣应付款
this.$toolAll.tools.showToast('孔雀币不足')
this.allPrice = (this.$toolAll.tools.addXiaoShu(this.zanAllPrice - this.coin_price)*1).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)*1).toFixed(2);
return;
}
} else {
this.$toolAll.tools.showToast('暂无可用孔雀币');
this.payFS[index].isActive = false;
}
}
} else {
if(!this.payFS[index].isActive) {
this.isKq = false;
this.zf_kqPrice = 0;
this.allPrice = this.zanAllPrice;
} else {
// 只有孔雀币支付方式
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)*1).toFixed(2);
this.zf_kqPrice = this.payFS[0].num;
}
}
}
}
},
goPayment(){//去付款
this.isFocus = false;
this.isDui = false;
let nphone = '';
if(this.isExpress) {
nphone = this.addressInfo.phone;//默认地址的手机号
} else nphone = this.zPhone;//自提时的手机号
let self = 0;//快递的配送方式
if(!this.isExpress) self = 1;//自提的方式
let nsku_list = [];
let is_only = 0;
this.orderList.forEach(item=>{
let obj = {
sku_coding:item.coding,
num:item.num,
group_id:item.pin_user_id
}
nsku_list.push(obj);
is_only = item.is_only;
})
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;
}
let parmas = {
sku_list: nsku_list,//商品单号和数量数组
total: this.allPrice*100,//总金额
address_id: this.addressInfo.id || 0,//地址ID
express_code: this.expressInfo.code || 0,//快递编码
coupon_id: this.youQuan.id,//优惠券ID
coupon_price: this.youQuan.youPrice*100,//优惠券可用
pick_self: self,//是否自提0 快递, 1自提
pick_self_phone: nphone,//联系电话
original_total: this.zanAllPrice*100,//原价总金额
freight: this.expressInfo.default_price || 0,//快递费
remarks: "",//备注
is_only:is_only,//是否是单独购买0 不是单独购买12是单独购买
is_score:is_score,//是否是积分商品0 不是积分商品1是积分商品
coin:this.zf_kqPrice//孔雀币
}
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.expressInfo.default_price!=undefined && !this.payFS[0].isActive){//积分判断条件
this.$toolAll.tools.showToast('请添加微信支付方式');
} else if(this.isNei != 3 && !this.payFS[0].isActive && !this.payFS[1].isActive){
this.$toolAll.tools.showToast('请选择支付方式')
} else if(this.payType=='coin' && this.allPrice*1 > this.coin_price*1){
this.$toolAll.tools.showToast('孔雀币不足');
} else if(this.payType=='hybrid' && 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:`${uni.getStorageSync('hostapi')}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);
2022-07-05 09:27:51 +00:00
this.groupLast = res.data.data.group_last;
// 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 {
this.$toolAll.tools.showToast(res.data.msg,'none',3000);
this.times = 0;
}
}
})
}
}
},
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){
this.suseeceEv(info.coding);
} else this.$toolAll.tools.showToast(res.msg);
})
},
fail:()=> {
this.$toolAll.tools.showToast('取消支付');
setTimeout(()=>{
uni.navigateTo({
url:'/pagesA/myOrder/myOrder'
})
},2000)
}
});
} else {
this.$requst.post('order/paid',{order_coding:info.coding}).then(res=>{
if(res.code==0){
this.suseeceEv(info.coding);
} else this.$toolAll.tools.showToast(res.msg);
})
}
},
suseeceEv(coding){
uni.removeStorageSync('chooseAddress')
this.isSuccess = true;
if(this.orderList[0].cateNum==1 && this.orderList.pin_user_id!=0){
this.$requst.post('order/get-group-id',{order_coding:coding}).then(res=>{
if(res.code==0){
this.checkGrounpId = res.data.group_id;
2022-07-05 09:27:51 +00:00
if(this.groupLast !== 1){
this.isfen = true;
}
else{
this.$toolAll.tools.showToast('拼团成功');
}
}
})
}
},
goThere(val){//去这里
2022-05-30 08:51:00 +00:00
// wx.getLocation({//获取当前经纬度
// type: 'wgs84', //返回可以用于wx.openLocation的经纬度官方提示bug: iOS 6.3.30 type 参数不生效,只会返回 wgs84 类型的坐标信息
// success: function (res) {
// wx.openLocation({//​使用微信内置地图查看位置。
// latitude: 30.67554,//要去的纬度-地址
// longitude: 104.010642,//要去的经度-地址
// name: val,
// address: val
// })
// }
// })
},
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;
} else {
if(res.data.length==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;
if(this.has_postage==1){
this.expressInfo.default_price = this.expressInfo.default_price/100;
} else {
this.expressInfo.default_price = 0;
}
}
})
this.totalEv();
}
}
})
}
},
expressEv(index){//快递自取切换事件
if(index==0) {
this.isExpress = true;
this.checkexpress();
if(this.addressInfo==''){this.$toolAll.tools.showToast('请完善收件人信息','none',1500);}
}
if(index==1) {
this.isExpress = false;
this.expressInfo.default_price = 0;
}
},
totalEv(){//合计运算
if(this.isNei!=3) {
// 商品订单合计
// this.allPrice = this.zanAllPrice - this.youQuan.youPrice;
if(this.payType=='coin'){
this.obtainCoin(this.payFS[0].num);
}
} else {
// 积分订单合计
this.allPrice = this.zanAllPrice;
}
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){
this.obtainCoin(res.data.account.coin);
if(this.payType=='coin'){
this.payFS[0].num = res.data.account.coin;
} else if(this.payType=='wechat'){
} else if(this.payType=='hybrid'){
this.payFS[1].num = res.data.account.coin;
if(res.data.account.coin==0) {
this.payFS[1].isActive = false;
} else {
setTimeout(()=>{
this.chooseFS(1);
},500)
}
} else {
this.payFS[1].num = res.data.account.coin;
this.payFS[2].num = res.data.account.score;
}
} else this.$toolAll.tools.showToast(res.msg);
})
},
checkeList(isJfen){
this.allPrice = this.allPrice*1;
this.orderList.forEach(item=>{
this.allPrice += item.price*item.num;
this.allNum += item.num;
})
if(isJfen==3){// 是积分商品
this.zanAllPrice = this.allPrice;
} else {
this.zanAllPrice = this.$toolAll.tools.addXiaoShu(this.allPrice);
}
this.quanEv(0);//查询优惠券列表
this.totalEv();
},
quanEv(index){//调起优惠券弹框事件
if(this.payType!='coin' && this.payType!='wechat'){
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();//查询可用优惠券事件
}
}
},
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 {
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;
}
}
},
goCoupon(){//去领取优惠券
this.showQuan = false;
uni.navigateTo({
url:'/pagesA/coupon/coupon'
})
},
focusEv(){//获取焦点
this.isFocus = true;
},
blurEv(){//失去焦点
this.isFocus = false;
},
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
})
}
}
}
</script>
<style>
page {
background-color: #F5F5F5;
}
</style>