修改立即购买按钮一直加载bug

master
mabo 2021-06-23 10:45:05 +08:00
parent 9586eedb56
commit a1fd5be5c4
7 changed files with 397 additions and 264 deletions

View File

@ -199,13 +199,18 @@ export default {
skuId: this.skuDetail.id skuId: this.skuDetail.id
}; };
this.loading = true; this.loading = true;
console.log(11111111);
addCartGoods(params).then(res => { addCartGoods(params).then(res => {
debugger;
this.loading = false; this.loading = false;
if (res.success) { if (res.success) {
this.$router.push({path: '/shoppingCart', query: {detail: this.skuDetail, count: this.count}}); this.$router.push({path: '/shoppingCart', query: {detail: this.skuDetail, count: this.count}});
} else { } else {
this.$Message.warning(res.message); this.$Message.warning(res.message);
} }
}).catch(() => {
console.log('catch');
this.loading = false;
}); });
}, },
buyNow () { // buyNow () { //
@ -222,6 +227,8 @@ export default {
} else { } else {
this.$Message.warning(res.message); this.$Message.warning(res.message);
} }
}).catch(() => {
this.loading1 = false;
}); });
}, },
pointPay () { // pointPay () { //

View File

@ -11,42 +11,37 @@
</div> --> </div> -->
<!-- 普通发票 --> <!-- 普通发票 -->
<div class="nav-content"> <div class="nav-content">
<Form <Form :model="invoiceForm" ref="form" label-position="left" :rules="ruleInline" :label-width="110">
:model="invoiceForm"
ref="form"
label-position="left"
:rules="ruleInline"
:label-width="110"
>
<FormItem label="发票类型"> <FormItem label="发票类型">
<RadioGroup v-model="invoiceForm.type" type="button" button-style="solid"> <RadioGroup v-model="invoice" type="button" button-style="solid">
<Radio @on-change="changeInvoice" :label="1">电子普通发票</Radio>
<Radio :label="2" :disabled="true">增值税专用发票</Radio>
</RadioGroup>
</FormItem>
<FormItem label="发票抬头">
<RadioGroup v-model="type" @on-change="changeInvoice" type="button" button-style="solid">
<Radio :label="1">个人</Radio> <Radio :label="1">个人</Radio>
<Radio :label="2">单位</Radio> <Radio :label="2">单位</Radio>
</RadioGroup> </RadioGroup>
</FormItem> </FormItem>
<FormItem <FormItem label="个人名称" v-if="type === 1" prop="receiptTitle">
label="发票抬头"
v-if="invoiceForm.type == 2"
prop="receiptTitle"
>
<i-input v-model="invoiceForm.receiptTitle"></i-input> <i-input v-model="invoiceForm.receiptTitle"></i-input>
</FormItem> </FormItem>
<FormItem <FormItem label="单位名称" v-if="type === 2" prop="receiptTitle">
label="纳税人识别号" <i-input v-model="invoiceForm.receiptTitle"></i-input>
v-if="invoiceForm.type == 2" </FormItem>
prop="taxpayerId" <FormItem label="纳税人识别号" v-if="type === 2" prop="taxpayerId">
>
<i-input v-model="invoiceForm.taxpayerId"></i-input> <i-input v-model="invoiceForm.taxpayerId"></i-input>
</FormItem> </FormItem>
<FormItem label="发票内容"> <FormItem label="发票内容">
<RadioGroup v-model="invoiceForm.receiptContent" type="button" button-style="solid"> <RadioGroup v-model="invoiceForm.receiptContent" type="button" button-style="solid">
<Radio label="不开发票">不开发票</Radio>
<Radio label="商品明细">商品明细</Radio> <Radio label="商品明细">商品明细</Radio>
<Radio label="商品类别">商品类别</Radio>
</RadioGroup> </RadioGroup>
</FormItem> </FormItem>
</Form> </Form>
<div style="text-align: center"> <div style="text-align: center">
<Button type="primary" :loading="loading" @click="save"></Button> <Button type="primary" :loading="loading" @click="submit"></Button>
<Button type="default" @click="invoiceAvailable = false">取消</Button> <Button type="default" @click="invoiceAvailable = false">取消</Button>
</div> </div>
</div> </div>
@ -54,20 +49,21 @@
</div> </div>
</template> </template>
<script> <script>
import { saveReceipt } from '@/api/member.js'; import { receiptSelect } from '@/api/cart.js';
import { TINumber } from '@/plugins/RegExp.js'; import { TINumber } from '@/plugins/RegExp.js';
export default { export default {
name: 'invoiceModal', name: 'invoiceModal',
data () { data () {
return { return {
invoice: 1,
invoiceAvailable: false, // invoiceAvailable: false, //
loading: false, // loading: false, //
invoiceForm: { // invoiceForm: {
//
// //
receiptTitle: '', // receiptTitle: '', //
taxpayerId: '', // taxpayerId: '', //
receiptContent: '不开发票', // receiptContent: '商品明细', //
type: 1 // 1 2
}, },
type: 1, // 1 2 type: 1, // 1 2
ruleInline: { ruleInline: {
@ -78,63 +74,76 @@ export default {
} }
}; };
}, },
props: ["invoiceData"], props: ['invoiceData'],
watch: { watch: {
invoiceData: { invoiceData: {
handler(val) { handler (val) {
this.invoiceForm = { ...val }; this.invoiceForm = { ...val };
if (flag) { if (val.taxpayerId) {
let params = { this.type = 2;
receiptTitle: '个人', } else {
receiptContent: this.invoiceForm.receiptContent this.type = 1;
};
this.loading = true;
saveReceipt(params)
.then((res) => {
this.loading = false;
if (res.success) {
this.$emit('change', res.result);
this.invoiceAvailable = false;
}
})
.catch(() => {
this.loading = false;
});
} }
} else { },
// deep: true,
immeadite: true
}
},
methods: {
/**
* 选择发票抬头
*/
changeInvoice (val) {
this.$nextTick(() => {
this.type = val;
});
},
/**
* 保存判断
*/
save () {
let flage = true;
//
const { type, receiptTitle, receiptContent } = JSON.parse(
JSON.stringify(this.invoiceForm)
);
//
if (!receiptTitle) {
this.$Message.error('请填写发票抬头!');
flage = false;
return false;
}
if (type === 2) {
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if (valid) { if (!valid) {
this.loading = true; flage = false;
let params = {
receiptTitle: this.invoiceForm.receiptTitle,
taxpayerId: this.invoiceForm.taxpayerId,
receiptContent: this.invoiceForm.receiptContent
};
let flag = true;
this.receiptItems.forEach((e) => {
if (e.taxpayerId === params.taxpayerId) {
flag = false;
}
});
if (!flag) {
this.$Message.error('已有当前税号的发票信息,请直接选择已有发票');
} else {
saveReceipt(params)
.then((res) => {
this.loading = false;
if (res.success) {
this.$emit('change', res.result);
this.invoiceAvailable = false;
}
})
.catch(() => {
this.loading = false;
});
}
} }
}); });
} else {
delete this.invoiceForm.taxpayerId;
}
return flage;
},
async submit () {
if (this.save()) {
this.loading = true;
let submit = {
way: this.$route.query.way,
...this.invoiceForm
};
let receipt = await receiptSelect(submit);
if (receipt.success) {
this.$emit('change', true);
}
this.loading = false;
} }
} }
} }

View File

@ -50,7 +50,6 @@ export default {
}, },
created () { created () {
this.getGoodsDetail(); this.getGoodsDetail();
}, },
data () { data () {
return { return {

View File

@ -108,7 +108,7 @@ export default {
this.pageNumber = 1; this.pageNumber = 1;
this.params.pageSize = val; this.params.pageSize = val;
this.getList() this.getList()
}, }
} }
} }
</script> </script>
@ -132,10 +132,10 @@ export default {
color: $theme_color; color: $theme_color;
} }
} }
.selected-cate{ .selected-cate{
color: $theme_color; color: $theme_color;
} }
} }
.page-size { .page-size {
width: 1200px; width: 1200px;

View File

@ -4,15 +4,23 @@
<!-- LOGO 步骤条 --> <!-- LOGO 步骤条 -->
<div class="width_1200 logo"> <div class="width_1200 logo">
<div> <div>
<router-link to="/"><img :src="logoImg" alt="lili shop" title="lilishop"></router-link> <router-link to="/"
><img :src="logoImg" alt="lili shop" title="lilishop"
/></router-link>
<div>结算页</div> <div>结算页</div>
</div> </div>
<div class="cart-steps"> <div class="cart-steps">
<span :class="stepIndex==1?'active':''">1.我的购物车</span> <span :class="stepIndex == 1 ? 'active' : ''">1.我的购物车</span>
<Icon :class="stepIndex==1?'active-arrow':''" custom="icomoon icon-next"></Icon> <Icon
<span :class="stepIndex==1?'active':''">2.填写订单信息</span> :class="stepIndex == 1 ? 'active-arrow' : ''"
<Icon :class="stepIndex==1?'active-arrow':''" custom="icomoon icon-next"></Icon> custom="icomoon icon-next"
<span :class="stepIndex==2?'active':''">3.成功提交订单</span> ></Icon>
<span :class="stepIndex == 1 ? 'active' : ''">2.填写订单信息</span>
<Icon
:class="stepIndex == 1 ? 'active-arrow' : ''"
custom="icomoon icon-next"
></Icon>
<span :class="stepIndex == 2 ? 'active' : ''">3.成功提交订单</span>
</div> </div>
</div> </div>
<Divider /> <Divider />
@ -24,18 +32,35 @@
<span @click="goAddressManage"></span> <span @click="goAddressManage"></span>
</div> </div>
<div class="address-manage"> <div class="address-manage">
<div class="address-item" v-show="moreAddr ? true : index < 3" :class="selectedAddress.id === item.id?'border-red':''" @mouseenter="showEditBtn = index" @mouseleave="showEditBtn = ''" <div
@click="selectAddress(item)" v-for="(item,index) in addressList" :key="index"> class="address-item"
v-show="moreAddr ? true : index < 3"
:class="selectedAddress.id === item.id ? 'border-red' : ''"
@mouseenter="showEditBtn = index"
@mouseleave="showEditBtn = ''"
@click="selectAddress(item)"
v-for="(item, index) in addressList"
:key="index"
>
<div> <div>
<span>{{item.name}}</span> <span>{{ item.name }}</span>
<Tag class="ml_10" v-if="item.isDefault" color="red"></Tag> <Tag class="ml_10" v-if="item.isDefault" color="red"></Tag>
<Tag class="ml_10" v-if="item.alias" color="warning">{{item.alias}}</Tag> <Tag class="ml_10" v-if="item.alias" color="warning">{{
item.alias
}}</Tag>
</div>
<div>{{ item.mobile }}</div>
<div>
{{ item.consigneeAddressPath | unitAddress }} {{ item.detail }}
</div> </div>
<div>{{item.mobile}}</div>
<div>{{ item.consigneeAddressPath | unitAddress }} {{item.detail}}</div>
<div class="edit-btn" v-show="showEditBtn === index"> <div class="edit-btn" v-show="showEditBtn === index">
<span @click.stop="editAddress(item.id)">修改</span> <span @click.stop="editAddress(item.id)">修改</span>
<span class="ml_10" v-if="!item.isDefault" @click.stop="delAddress(item)"></span> <span
class="ml_10"
v-if="!item.isDefault"
@click.stop="delAddress(item)"
>删除</span
>
</div> </div>
<div class="corner-icon" v-show="selectedAddress.id === item.id"> <div class="corner-icon" v-show="selectedAddress.id === item.id">
<div></div> <div></div>
@ -48,8 +73,12 @@
</div> </div>
</div> </div>
<div class="more-addr" @click="moreAddr = !moreAddr" v-if="addressList.length>3"> <div
{{moreAddr ? '收起地址' : '更多地址'}} class="more-addr"
@click="moreAddr = !moreAddr"
v-if="addressList.length > 3"
>
{{ moreAddr ? "收起地址" : "更多地址" }}
<Icon v-show="!moreAddr" type="md-arrow-dropdown" /> <Icon v-show="!moreAddr" type="md-arrow-dropdown" />
<Icon v-show="moreAddr" type="md-arrow-dropup" /> <Icon v-show="moreAddr" type="md-arrow-dropup" />
</div> </div>
@ -60,10 +89,17 @@
<span>商品信息</span> <span>商品信息</span>
<span @click="$router.push('/cart')"></span> <span @click="$router.push('/cart')"></span>
</div> </div>
<div class="goods-msg" v-for="(shop,shopIndex) in goodsList" :key="shopIndex"> <div
class="goods-msg"
v-for="(shop, shopIndex) in goodsList"
:key="shopIndex"
>
<div class="shop-name"> <div class="shop-name">
<span> <span>
<span class="hover-color" @click="goShopPage(shop.storeId)">{{shop.storeName}}</span>&nbsp;&nbsp; <span class="hover-color" @click="goShopPage(shop.storeId)">{{
shop.storeName
}}</span
>&nbsp;&nbsp;
</span> </span>
<!-- <span> <!-- <span>
<p style="width:120px">配送方式</p> <p style="width:120px">配送方式</p>
@ -73,33 +109,60 @@
</span> --> </span> -->
</div> </div>
<div class="goods-list"> <div class="goods-list">
<div class="goods-item" v-for="(goods,goodsIndex) in shop.skuList" :key="goodsIndex"> <div
<span class="hover-color" @click="goGoodsDetail(goods.goodsSku.id, goods.goodsSku.goodsId)"> class="goods-item"
<img :src="goods.goodsSku.thumbnail" alt=""> v-for="(goods, goodsIndex) in shop.skuList"
<span style="vertical-align:top;">{{goods.goodsSku.goodsName}}</span> :key="goodsIndex"
>
<span
class="hover-color"
@click="
goGoodsDetail(goods.goodsSku.id, goods.goodsSku.goodsId)
"
>
<img :src="goods.goodsSku.thumbnail" alt="" />
<span style="vertical-align: top">{{
goods.goodsSku.goodsName
}}</span>
</span> </span>
<span class="goods-price">{{goods.goodsSku.price | unitPrice('¥')}}</span> <span class="goods-price">{{
<span>x{{goods.num}}</span> goods.goodsSku.price | unitPrice("¥")
<span>{{goods.goodsSku.quantity > 0 ? '有货' : '无货'}}</span> }}</span>
<span class="goods-price">{{goods.goodsSku.price * goods.num | unitPrice('¥')}}</span> <span>x{{ goods.num }}</span>
<span>{{ goods.goodsSku.quantity > 0 ? "有货" : "无货" }}</span>
<span class="goods-price">{{
(goods.goodsSku.price * goods.num) | unitPrice("¥")
}}</span>
</div> </div>
</div> </div>
<div class="order-mark"> <div class="order-mark">
<Input type="textarea" maxlength="60" v-model="shop.remark" show-word-limit placeholder="订单备注" /> <Input
<span style="font-size:12px;color:#999;">提示请勿填写有关支付收货发票方面的信息</span> type="textarea"
maxlength="60"
v-model="shop.remark"
show-word-limit
placeholder="订单备注"
/>
<span style="font-size: 12px; color: #999"
>提示请勿填写有关支付收货发票方面的信息</span
>
</div> </div>
</div> </div>
</div> </div>
<!-- 发票信息 --> <!-- 发票信息 -->
<div class="invoice"> <div class="invoice">
<div class="card-head mt_20 mb_20"> <div class="card-head mt_20 mb_20">
<span class="relative">发票信息<span class="inv-tips"> <span class="relative"
<Icon type="ios-alert-outline" />开企业抬头发票须填写纳税人识别号以免影响报销 >发票信息<span class="inv-tips">
</span></span> <Icon
type="ios-alert-outline"
/>
</span></span
>
</div> </div>
<div class="inovice-content"> <div class="inovice-content">
<span>{{invoiceData.receiptTitle}}</span> <span>{{ invoiceData.receiptTitle }}</span>
<span>{{invoiceData.receiptContent}}</span> <span>{{ invoiceData.receiptContent }}</span>
<span @click="editInvoice"></span> <span @click="editInvoice"></span>
</div> </div>
</div> </div>
@ -108,24 +171,49 @@
<div class="card-head mt_20 mb_20"> <div class="card-head mt_20 mb_20">
<span class="relative">优惠券</span> <span class="relative">优惠券</span>
</div> </div>
<div v-if="couponList.length === 0"> <div v-if="couponList.length === 0"></div>
无可用优惠券
</div>
<ul v-else class="coupon-list"> <ul v-else class="coupon-list">
<li v-for="(item, index) in couponList" class="coupon-item" :key="index"> <li
v-for="(item, index) in couponList"
class="coupon-item"
:key="index"
>
<div class="c-left"> <div class="c-left">
<div> <div>
<span v-if="item.couponType === 'PRICE'" class="fontsize_12 global_color">¥<span class="price">{{item.price | unitPrice}}</span></span> <span
<span v-if="item.couponType === 'DISCOUNT'" class="fontsize_12 global_color"><span class="price">{{item.couponDiscount}}</span></span> v-if="item.couponType === 'PRICE'"
<span class="describe">{{item.consumeThreshold}}元可用</span> class="fontsize_12 global_color"
><span class="price">{{
item.price | unitPrice
}}</span></span
>
<span
v-if="item.couponType === 'DISCOUNT'"
class="fontsize_12 global_color"
><span class="price">{{ item.couponDiscount }}</span
></span
>
<span class="describe"
>{{ item.consumeThreshold }}元可用</span
>
</div> </div>
<p>使用范围{{useScope(item.scopeType)}}</p> <p>使用范围{{ useScope(item.scopeType) }}</p>
<p>有效期{{item.endTime}}</p> <p>有效期{{ item.endTime }}</p>
</div> </div>
<img class="used" v-if="usedCouponId.includes(item.id)" src="../../assets/images/geted.png" alt=""> <img
class="used"
v-if="usedCouponId.includes(item.id)"
src="../../assets/images/geted.png"
alt=""
/>
<b></b> <b></b>
<a class="c-right" @click="useCoupon(item.id, true)">立即使用</a> <a class="c-right" @click="useCoupon(item.id, true)">立即使用</a>
<a class="c-right" v-if="usedCouponId.includes(item.id)" @click="useCoupon(item.id, false)"></a> <a
class="c-right"
v-if="usedCouponId.includes(item.id)"
@click="useCoupon(item.id, false)"
>放弃优惠</a
>
<i class="circle-top"></i> <i class="circle-top"></i>
<i class="circle-bottom"></i> <i class="circle-bottom"></i>
</li> </li>
@ -138,81 +226,116 @@
</div> </div>
<div> <div>
<div> <div>
<span>使用积分</span><Input type="text" style="width:100px;" v-model.number="otherMsgForm.point" placeholder="请输入使用积分" /> <span style="color:#999;">您当前的可用积分为 {{otherMsgForm.totalPoint}} <span>使用积分</span
本订单最多可以使用{{otherMsgForm.availablePoint}}</span> ><Input
type="text"
style="width: 100px"
v-model.number="otherMsgForm.point"
placeholder="请输入使用积分"
/>
<span style="color: #999"
>您当前的可用积分为
{{ otherMsgForm.totalPoint }} 本订单最多可以使用{{
otherMsgForm.availablePoint
}}</span
>
</div> </div>
</div> </div>
</div> </div>
<!-- 订单价格 --> <!-- 订单价格 -->
<div class="order-price"> <div class="order-price">
<div> <div>
<span>{{totalNum}}件商品总商品金额</span><span>{{priceDetailDTO.goodsPrice | unitPrice('¥')}}</span> <span>{{ totalNum }}件商品总商品金额</span
><span>{{ priceDetailDTO.goodsPrice | unitPrice("¥") }}</span>
</div> </div>
<div> <div>
<span>运费</span><span>{{ priceDetailDTO.freightPrice | unitPrice('¥')}}</span> <span>运费</span
><span>{{ priceDetailDTO.freightPrice | unitPrice("¥") }}</span>
</div> </div>
<div> <div>
<span>优惠金额</span><span>-{{ priceDetailDTO.discountPrice + priceDetailDTO.couponPrice + priceDetailDTO.updatePrice | unitPrice('¥')}}</span> <span>优惠金额</span
><span
>-{{
(priceDetailDTO.discountPrice +
priceDetailDTO.couponPrice +
priceDetailDTO.updatePrice)
| unitPrice("¥")
}}</span
>
</div> </div>
<div> <div>
<span>应付金额</span><span class='actrual-price'>{{priceDetailDTO.billPrice | unitPrice('¥')}}</span> <span>应付金额</span
><span class="actrual-price">{{
priceDetailDTO.billPrice | unitPrice("¥")
}}</span>
</div> </div>
</div> </div>
</div> </div>
<!-- 底部支付栏 --> <!-- 底部支付栏 -->
<div class="order-footer width_1200"> <div class="order-footer width_1200">
<div class="pay ml_20" @click="pay"></div> <div class="pay ml_20" @click="pay"></div>
<div class="pay-address" v-if="addressList.length">{{ selectedAddress.consigneeAddressPath | unitAddress }} <div class="pay-address" v-if="addressList.length">
{{selectedAddress.detail}}&nbsp;&nbsp;收货人{{selectedAddress.name}}&nbsp;&nbsp;{{selectedAddress.mobile}}</div> 配送至{{ selectedAddress.consigneeAddressPath | unitAddress }}
{{ selectedAddress.detail }}&nbsp;&nbsp;收货人{{
selectedAddress.name
}}&nbsp;&nbsp;{{ selectedAddress.mobile }}
</div>
</div> </div>
<BaseFooter></BaseFooter> <BaseFooter></BaseFooter>
<!-- 添加发票模态框 --> <!-- 添加发票模态框 -->
<invoice-modal ref="invModal" :invoiceData="invoiceData" @change="getInvMsg" /> <invoice-modal
ref="invModal"
:invoiceData="invoiceData"
@change="getInvMsg"
/>
<!-- 选择地址模态框 --> <!-- 选择地址模态框 -->
<address-manage ref="address" :id="addrId" @change="addrChange"></address-manage> <address-manage
ref="address"
:id="addrId"
@change="addrChange"
></address-manage>
</div> </div>
</template> </template>
<script> <script>
import invoiceModal from "@/components/invoiceModal"; import invoiceModal from '@/components/invoiceModal';
import addressManage from "@/components/addressManage"; import addressManage from '@/components/addressManage';
import { memberAddress, delMemberAddress } from "@/api/address"; import { memberAddress, delMemberAddress } from '@/api/address';
import { import {
cartGoodsPay, cartGoodsPay,
createTrade, createTrade,
selectAddr, selectAddr,
shippingMethod, shippingMethod,
selectCoupon, selectCoupon,
couponNum, couponNum
} from "@/api/cart"; } from '@/api/cart';
import { canUseCouponList } from "@/api/member.js"; import { canUseCouponList } from '@/api/member.js';
import { getLogo } from "@/api/common.js"; import { getLogo } from '@/api/common.js';
export default { export default {
name: "Pay", name: 'Pay',
components: { invoiceModal, addressManage }, components: { invoiceModal, addressManage },
data() { data () {
return { return {
stepIndex: 1, // stepIndex: 1, //
invoiceAvailable: false, // invoiceAvailable: false, //
showEditBtn: "", // showEditBtn: '', //
orderMark: "", // orderMark: '', //
invoiceData: { invoiceData: {
// //
receiptTitle: "个人", receiptTitle: '个人',
receiptContent: "不开发票", receiptContent: '不开发票'
}, },
otherMsgForm: { otherMsgForm: {
// //
point: 0, point: 0,
availablePoint: 10, availablePoint: 10,
totalPoint: 100, totalPoint: 100,
noGoods: 0, noGoods: 0
}, },
deliveryList: [ deliveryList: [
// //
// {value: 'SELF_PICK_UP', label: ''}, // {value: 'SELF_PICK_UP', label: ''},
{ value: "LOGISTICS", label: "物流" }, { value: 'LOGISTICS', label: '物流' }
// {value: 'LOCAL_TOWN_DELIVERY', label: ''} // {value: 'LOCAL_TOWN_DELIVERY', label: ''}
], ],
addressList: [], // addressList: [], //
@ -220,37 +343,37 @@ export default {
goodsList: [], // goodsList: [], //
priceDetailDTO: {}, // priceDetailDTO: {}, //
totalNum: 0, // totalNum: 0, //
addrId: "", // id addrId: '', // id
moreAddr: false, // moreAddr: false, //
canUseCouponNum: 0, // canUseCouponNum: 0, //
couponList: [], // couponList: [], //
logoImg: "", // logo logoImg: '', // logo
usedCouponId: [], // 使id usedCouponId: [], // 使id
selectedCoupon: {}, // selectedCoupon: {} //
}; };
}, },
mounted() { mounted () {
this.init(); this.init();
if (!this.Cookies.getItem("logo")) { if (!this.Cookies.getItem('logo')) {
getLogo().then((res) => { getLogo().then((res) => {
if (res.success) { if (res.success) {
let logoObj = JSON.parse(res.result.settingValue); let logoObj = JSON.parse(res.result.settingValue);
this.Cookies.setItem("logo", logoObj.buyerSideLogo); this.Cookies.setItem('logo', logoObj.buyerSideLogo);
} }
}); });
} else { } else {
this.logoImg = this.Cookies.getItem("logo"); this.logoImg = this.Cookies.getItem('logo');
} }
}, },
methods: { methods: {
init() { init () {
this.getGoodsDetail(); this.getGoodsDetail();
}, },
goAddressManage() { goAddressManage () {
// //
this.$router.push("/home/MyAddress"); this.$router.push('/home/MyAddress');
}, },
getAddress() { getAddress () {
// //
memberAddress().then((res) => { memberAddress().then((res) => {
if (res.success) { if (res.success) {
@ -263,7 +386,7 @@ export default {
} }
}); });
}, },
getGoodsDetail() { getGoodsDetail () {
// //
this.$Spin.show(); this.$Spin.show();
cartGoodsPay({ way: this.$route.query.way }) cartGoodsPay({ way: this.$route.query.way })
@ -274,24 +397,21 @@ export default {
this.priceDetailDTO = res.result.priceDetailDTO; this.priceDetailDTO = res.result.priceDetailDTO;
this.skuList = res.result.skuList; this.skuList = res.result.skuList;
res.result.receiptVO res.result.receiptVO ? (this.invoiceData = res.result.receiptVO) : '';
? (this.invoiceData = res.result.receiptVO)
: "";
let notSupArea = res.result.notSupportFreight; let notSupArea = res.result.notSupportFreight;
this.selectedCoupon = {}; this.selectedCoupon = {};
if (res.result.platformCoupon) if (res.result.platformCoupon) this.selectedCoupon.platformCoupon = res.result.platformCoupon;
this.selectedCoupon.platformCoupon = res.result.platformCoupon;
Object.assign(this.selectedCoupon, res.result.storeCoupons); Object.assign(this.selectedCoupon, res.result.storeCoupons);
if (notSupArea) { if (notSupArea) {
let content = []; let content = [];
let title = ""; let title = '';
notSupArea.forEach((e) => { notSupArea.forEach((e) => {
title = e.errorMessage; title = e.errorMessage;
content.push(e.goodsSku.goodsName); content.push(e.goodsSku.goodsName);
}); });
this.$Modal.warning({ this.$Modal.warning({
title: "以下商品超出配送区域" || title, title: '以下商品超出配送区域' || title,
content: content.toString(), content: content.toString(),
}); });
} }
@ -310,7 +430,7 @@ export default {
this.$Spin.hide(); this.$Spin.hide();
}); });
}, },
getCouponNum() { getCouponNum () {
// //
couponNum({ way: this.$route.query.way }).then((res) => { couponNum({ way: this.$route.query.way }).then((res) => {
this.canUseCouponNum = res.result; this.canUseCouponNum = res.result;
@ -326,10 +446,10 @@ export default {
let params = { let params = {
pageNumber: 1, pageNumber: 1,
pageSize: 100, pageSize: 100,
memberCouponStatus: "NEW", memberCouponStatus: 'NEW',
scopeId: skuArr.toString(), scopeId: skuArr.toString(),
storeId: storeArr.toString(), storeId: storeArr.toString(),
totalPrice: this.priceDetailDTO.goodsPrice, totalPrice: this.priceDetailDTO.goodsPrice
}; };
canUseCouponList(params).then((res) => { canUseCouponList(params).then((res) => {
// //
@ -350,86 +470,85 @@ export default {
} }
}); });
}, },
selectAddress(item) { selectAddress (item) {
// //
let params = { let params = {
way: this.$route.query.way, way: this.$route.query.way,
shippingAddressId: item.id, shippingAddressId: item.id
}; };
selectAddr(params).then((res) => { selectAddr(params).then((res) => {
if (res.success) { if (res.success) {
this.$Message.success("选择收货地址成功"); this.$Message.success('选择收货地址成功');
this.selectedAddress = item; this.selectedAddress = item;
this.getGoodsDetail(); this.getGoodsDetail();
} }
}); });
}, },
editAddress(id) { editAddress (id) {
// //
this.addrId = id; this.addrId = id;
this.$refs.address.show(); this.$refs.address.show();
}, },
addrChange(item) { addrChange () {
// //
this.getAddress(); this.getAddress();
}, },
delAddress(item) { delAddress (item) {
// //
this.$Modal.confirm({ this.$Modal.confirm({
title: "提示", title: '提示',
content: "你确定删除这个收货地址", content: '你确定删除这个收货地址',
onOk: () => { onOk: () => {
delMemberAddress(item.id).then((res) => { delMemberAddress(item.id).then((res) => {
if (res.success) { if (res.success) {
this.$Message.success("删除成功"); this.$Message.success('删除成功');
this.getAddress(); this.getAddress();
} }
}); });
}, },
onCancel: () => {}, onCancel: () => {}
}); });
}, },
goGoodsDetail(skuId, goodsId) { goGoodsDetail (skuId, goodsId) {
// //
let routeUrl = this.$router.resolve({ let routeUrl = this.$router.resolve({
path: "/goodsDetail", path: '/goodsDetail',
query: { skuId, goodsId }, query: { skuId, goodsId }
}); });
window.open(routeUrl.href, "_blank"); window.open(routeUrl.href, '_blank');
}, },
// //
goShopPage(id) { goShopPage (id) {
let routeUrl = this.$router.resolve({ let routeUrl = this.$router.resolve({
path: "/Merchant", path: '/Merchant',
query: { id: id }, query: { id: id }
}); });
window.open(routeUrl.href, "_blank"); window.open(routeUrl.href, '_blank');
}, },
selectDelivery(delivery) { selectDelivery (delivery) {
// //
let params = { let params = {
way: this.$route.query.way, way: this.$route.query.way,
shippingMethod: delivery.value, shippingMethod: delivery.value
}; };
shippingMethod(params).then((res) => {}); shippingMethod(params).then((res) => {});
}, },
useCoupon(id, used) { useCoupon (id, used) {
// 使 // 使
let params = { let params = {
way: this.$route.query.way, way: this.$route.query.way,
memberCouponId: id, memberCouponId: id,
used: used, // true 使 false used: used // true 使 false
}; };
selectCoupon(params).then((res) => { selectCoupon(params).then((res) => {
if (res.success) this.init(); if (res.success) this.init();
}); });
}, },
editInvoice() { editInvoice () {
// //
this.$refs.invModal.invoiceAvailable = true; this.$refs.invModal.invoiceAvailable = true;
}, },
getInvMsg(item) { getInvMsg (item) {
// //
if (item) { if (item) {
this.init(); this.init();
@ -437,18 +556,18 @@ export default {
} }
}, },
pay() { pay () {
// //
const params = { const params = {
client: "PC", client: 'PC',
remark: [], remark: [],
way: this.$route.query.way, way: this.$route.query.way
}; };
this.goodsList.forEach((e) => { this.goodsList.forEach((e) => {
if (e.remark) { if (e.remark) {
params.remark.push({ params.remark.push({
remark: e.remark, remark: e.remark,
storeId: e.storeId, storeId: e.storeId
}); });
} }
}); });
@ -461,8 +580,8 @@ export default {
this.$Spin.hide(); this.$Spin.hide();
if (res.success) { if (res.success) {
this.$router.push({ this.$router.push({
path: "/payment", path: '/payment',
query: { orderType: "TRADE", sn: res.result.sn }, query: { orderType: 'TRADE', sn: res.result.sn }
}); });
} }
}) })
@ -470,22 +589,22 @@ export default {
this.$Spin.hide(); this.$Spin.hide();
}); });
}, },
useScope(type) { useScope (type) {
let goods = "全部商品"; let goods = '全部商品';
switch (type) { switch (type) {
case "ALL": case 'ALL':
goods = "全部商品"; goods = '全部商品';
break; break;
case "PORTION_GOODS": case 'PORTION_GOODS':
goods = "部分商品"; goods = '部分商品';
break; break;
case "PORTION_GOODS_CATEGORY": case 'PORTION_GOODS_CATEGORY':
goods = "部分分类商品"; goods = '部分分类商品';
break; break;
} }
return `${goods}可用`; return `${goods}可用`;
}, }
}, }
}; };
</script> </script>

View File

@ -1,27 +1,27 @@
// import Vue from 'vue'; // import Vue from 'vue';
import axios from "axios"; import axios from 'axios';
import https from "https"; import https from 'https';
import { Message, Spin, Modal } from "view-design"; import { Message, Spin, Modal } from 'view-design';
import Storage from "./storage"; import Storage from './storage';
import config from "@/config"; import config from '@/config';
import router from "../router/index.js"; import router from '../router/index.js';
import store from "../vuex/store"; import store from '../vuex/store';
import { handleRefreshToken } from "@/api/index"; import { handleRefreshToken } from '@/api/index';
const qs = require("qs"); const qs = require('qs');
export const buyerUrl = export const buyerUrl =
process.env.NODE_ENV === "development" process.env.NODE_ENV === 'development'
? config.api_dev.buyer ? config.api_dev.buyer
: config.api_prod.buyer; : config.api_prod.buyer;
export const commonUrl = export const commonUrl =
process.env.NODE_ENV === "development" process.env.NODE_ENV === 'development'
? config.api_dev.common ? config.api_dev.common
: config.api_prod.common; : config.api_prod.common;
export const managerUrl = export const managerUrl =
process.env.NODE_ENV === "development" process.env.NODE_ENV === 'development'
? config.api_dev.manager ? config.api_dev.manager
: config.api_prod.manager; : config.api_prod.manager;
export const sellerUrl = export const sellerUrl =
process.env.NODE_ENV === "development" process.env.NODE_ENV === 'development'
? config.api_dev.seller ? config.api_dev.seller
: config.api_prod.seller; : config.api_prod.seller;
// 创建axios实例 // 创建axios实例
@ -35,7 +35,7 @@ const service = axios.create({
}), }),
paramsSerializer: params => paramsSerializer: params =>
qs.stringify(params, { qs.stringify(params, {
arrayFormat: "repeat" arrayFormat: 'repeat'
}) })
}); });
@ -44,15 +44,15 @@ service.interceptors.request.use(
config => { config => {
const { loading } = config; const { loading } = config;
// 如果是put/post请求用qs.stringify序列化参数 // 如果是put/post请求用qs.stringify序列化参数
const isPutPost = config.method === "put" || config.method === "post"; const isPutPost = config.method === 'put' || config.method === 'post';
const isJson = config.headers["Content-Type"] === "application/json"; const isJson = config.headers['Content-Type'] === 'application/json';
const isFile = config.headers["Content-Type"] === "multipart/form-data"; const isFile = config.headers['Content-Type'] === 'multipart/form-data';
if (isPutPost && isJson) { if (isPutPost && isJson) {
config.data = JSON.stringify(config.data); config.data = JSON.stringify(config.data);
} }
if (isPutPost && !isFile && !isJson) { if (isPutPost && !isFile && !isJson) {
config.data = qs.stringify(config.data, { config.data = qs.stringify(config.data, {
arrayFormat: "repeat" arrayFormat: 'repeat'
}); });
} }
/** 配置全屏加载 */ /** 配置全屏加载 */
@ -60,16 +60,16 @@ service.interceptors.request.use(
config.loading = Spin.show(); config.loading = Spin.show();
} }
const uuid = Storage.getItem("uuid"); const uuid = Storage.getItem('uuid');
config.headers["uuid"] = uuid; config.headers['uuid'] = uuid;
// 获取访问Token // 获取访问Token
let accessToken = Storage.getItem("accessToken"); let accessToken = Storage.getItem('accessToken');
if (accessToken && config.needToken) { if (accessToken && config.needToken) {
config.headers["accessToken"] = accessToken; config.headers['accessToken'] = accessToken;
// 解析当前token时间 // 解析当前token时间
let jwtData = JSON.parse( let jwtData = JSON.parse(
decodeURIComponent(escape(window.atob(accessToken.split(".")[1]))) decodeURIComponent(escape(window.atob(accessToken.split('.')[1])))
); );
if (jwtData.exp < Math.round(new Date() / 1000)) { if (jwtData.exp < Math.round(new Date() / 1000)) {
refresh() refresh()
@ -83,33 +83,32 @@ service.interceptors.request.use(
} }
); );
async function refresh() { async function refresh (error) {
const getTokenRes = await refreshToken(); const getTokenRes = await refreshToken();
if (getTokenRes === "success") { if (getTokenRes === 'success') {
// 刷新token // 刷新token
if (isRefreshToken === 1) { if (isRefreshToken === 1) {
error.response.config.headers.accessToken = Storage.getItem( error.response.config.headers.accessToken = Storage.getItem(
"accessToken" 'accessToken'
); );
return service(error.response.config); return service(error.response.config);
} else { } else {
router.go(0); router.go(0);
} }
} else { } else {
Storage.removeItem("accessToken"); Storage.removeItem('accessToken');
Storage.removeItem("refreshToken"); Storage.removeItem('refreshToken');
Storage.removeItem("userInfo"); Storage.removeItem('userInfo');
Storage.setItem("cartNum", 0); Storage.setItem('cartNum', 0);
store.commit("SET_CARTNUM", 0); store.commit('SET_CARTNUM', 0);
console.log("1111");
Modal.confirm({ Modal.confirm({
title: "请登录", title: '请登录',
content: "<p>请登录后执行此操作</p>", content: '<p>请登录后执行此操作</p>',
okText: "立即登录", okText: '立即登录',
cancelText: "继续浏览", cancelText: '继续浏览',
onOk: () => { onOk: () => {
router.push({ router.push({
path: "/login", path: '/login',
query: { query: {
rePath: router.history.current.path, rePath: router.history.current.path,
query: JSON.stringify(router.history.current.query) query: JSON.stringify(router.history.current.query)
@ -140,15 +139,15 @@ service.interceptors.response.use(
isRefreshToken++; isRefreshToken++;
if (isRefreshToken === 1) { if (isRefreshToken === 1) {
refresh() refresh(error)
isRefreshToken = 0; isRefreshToken = 0;
} }
} else { } else {
if (error.message) { if (error.message) {
let _message = let _message =
error.code === "ECONNABORTED" error.code === 'ECONNABORTED'
? "连接超时,请稍候再试!" ? '连接超时,请稍候再试!'
: "网络错误,请稍后再试!"; : '网络错误,请稍后再试!';
Message.error(errorData.message || _message); Message.error(errorData.message || _message);
} }
} }
@ -171,13 +170,13 @@ const closeLoading = target => {
}; };
export const Method = { export const Method = {
GET: "get", GET: 'get',
POST: "post", POST: 'post',
PUT: "put", PUT: 'put',
DELETE: "delete" DELETE: 'delete'
}; };
export default function request(options) { export default function request (options) {
// 如果是服务端或者是请求的刷新token不需要检查token直接请求。 // 如果是服务端或者是请求的刷新token不需要检查token直接请求。
// if (process.server || options.url.indexOf('passport/token') !== -1) { // if (process.server || options.url.indexOf('passport/token') !== -1) {
return service(options); return service(options);
@ -186,19 +185,19 @@ export default function request(options) {
} }
// 防抖闭包来一波 // 防抖闭包来一波
function getTokenDebounce() { function getTokenDebounce () {
let lock = false; let lock = false;
let success = false; let success = false;
return function() { return function () {
if (!lock) { if (!lock) {
lock = true; lock = true;
let oldRefreshToken = Storage.getItem("refreshToken"); let oldRefreshToken = Storage.getItem('refreshToken');
handleRefreshToken(oldRefreshToken) handleRefreshToken(oldRefreshToken)
.then(res => { .then(res => {
if (res.success) { if (res.success) {
let { accessToken, refreshToken } = res.result; let { accessToken, refreshToken } = res.result;
Storage.setItem("accessToken", accessToken); Storage.setItem('accessToken', accessToken);
Storage.setItem("refreshToken", refreshToken); Storage.setItem('refreshToken', refreshToken);
success = true; success = true;
lock = false; lock = false;
@ -220,9 +219,9 @@ function getTokenDebounce() {
if (!lock) { if (!lock) {
clearInterval(timer); clearInterval(timer);
if (success) { if (success) {
resolve("success"); resolve('success');
} else { } else {
resolve("fail"); resolve('fail');
} }
} }
}, 500); // 轮询时间间隔 }, 500); // 轮询时间间隔

View File

@ -5,7 +5,7 @@ import ViewUI from "view-design";
import "./styles/theme.less"; import "./styles/theme.less";
import "core-js/stable"; import "core-js/stable";
import "regenerator-runtime/runtime"; // import "regenerator-runtime/runtime";
import vueQr from 'vue-qr' import vueQr from 'vue-qr'
import App from "./App"; import App from "./App";