|
@@ -20,6 +20,7 @@ var shoppingConfirm = new Vue({
|
|
|
productCount:'',//提交订单的商品数量
|
|
|
addressList:[],//收货地址
|
|
|
addressData:{},//初始化地址信息
|
|
|
+ hanldAddressData:{},//选择确定的地址信息
|
|
|
isAddType:'',
|
|
|
addAddressData:{
|
|
|
addressID:'',
|
|
@@ -50,8 +51,8 @@ var shoppingConfirm = new Vue({
|
|
|
isSubDisabled:false,
|
|
|
isCheckedBalabce:false,
|
|
|
isDefaultChecked:false,
|
|
|
- isAddressListLength:false,
|
|
|
balanceDeductionFlag:2,
|
|
|
+ isAddressListLength:false,
|
|
|
invoiceType:'1',
|
|
|
invoiceTitle:0,
|
|
|
goodRemark:[],
|
|
@@ -62,16 +63,6 @@ var shoppingConfirm = new Vue({
|
|
|
currentTab:0,
|
|
|
choseAddressText:'',//选取的地址信息
|
|
|
freightData:'',//运费信息
|
|
|
- invoiceData:{
|
|
|
- id:'',
|
|
|
- invoiceTitle:'', //单位名称
|
|
|
- corporationTaxNum:'',//纳税人识别号
|
|
|
- registeredAddress: '',//单位地址
|
|
|
- registeredPhone:'', //注册电话
|
|
|
- openBank:'', //开户银行
|
|
|
- bankAccountNo: '' ,//银行账号
|
|
|
- type:0
|
|
|
- }, //初始化发票信息
|
|
|
orderInfo:[],//提交的商品信息
|
|
|
payInfo:{}, //订单信息
|
|
|
addTabList:[
|
|
@@ -85,6 +76,16 @@ var shoppingConfirm = new Vue({
|
|
|
city: '',
|
|
|
town: ''
|
|
|
},
|
|
|
+ invoiceData:{//初始化发票信息
|
|
|
+ id:'',
|
|
|
+ invoiceTitle:'', //单位名称
|
|
|
+ corporationTaxNum:'',//纳税人识别号
|
|
|
+ registeredAddress: '',//单位地址
|
|
|
+ registeredPhone:'', //注册电话
|
|
|
+ openBank:'', //开户银行
|
|
|
+ bankAccountNo: '' ,//银行账号
|
|
|
+ type:0
|
|
|
+ },
|
|
|
invoiceTypeList:[
|
|
|
{value:'1',name:'不开发票'},
|
|
|
{value:'2',name:'普通发票'},
|
|
@@ -102,13 +103,18 @@ var shoppingConfirm = new Vue({
|
|
|
},
|
|
|
checkedAddressItemIndex:0,
|
|
|
},
|
|
|
+ filters: {
|
|
|
+ NumFormat:function(text) {
|
|
|
+ return Number(text).toFixed(2);
|
|
|
+ }
|
|
|
+ },
|
|
|
computed: {
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
- getAddressList:function(userID,pageSize){//获取收货地址
|
|
|
+ getAddressList:function(userId,pageSize){//获取收货地址
|
|
|
var _self = this;
|
|
|
- OrderApi.GetAddressList({userID:userID,pageNum:1,pageSize:pageSize},function (response) {
|
|
|
+ OrderApi.GetAddressList({userID:userId,pageNum:1,pageSize:pageSize},function (response) {
|
|
|
if(response.code == 0){
|
|
|
var data = response.data;
|
|
|
if(data.results != ''){
|
|
@@ -117,10 +123,9 @@ var shoppingConfirm = new Vue({
|
|
|
_self.addressData = data.results[0];
|
|
|
_self.addressID = data.results[0].addressID;
|
|
|
_self.townID = data.results[0].townID;
|
|
|
- // _self.getFreightData();
|
|
|
+ _self.getFreightData();
|
|
|
_self.isAddressListLength = false;
|
|
|
}else{
|
|
|
- _self.isAddType == 'add';
|
|
|
_self.isAddressListLength = true;
|
|
|
_self.addressData = _self.addressData;
|
|
|
_self.GetProvinceFn()
|
|
@@ -130,19 +135,19 @@ var shoppingConfirm = new Vue({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- getConfirmInfo: function (productIds, productCount) {
|
|
|
+ getConfirmInfo: function (productIds, productCount) {//订单初始化
|
|
|
var _self = this;
|
|
|
if(_self.userId ===0){return;}
|
|
|
OrderApi.GetOrderConfirmInfo({userId: _self.userId,count: productCount,productIds: productIds},function(response){
|
|
|
if (response.code === 0 && response.data) {
|
|
|
var data = response.data;
|
|
|
_self.isRequest = true;
|
|
|
- // _self.goodsList = data.shopList;
|
|
|
- // _self.allPrice = data.productTotalFee;
|
|
|
- // _self.allCount = data.productCount;
|
|
|
- // _self.payAllPrice = data.productTotalFee;
|
|
|
- // _self.productKind = data.productKind;
|
|
|
- // _self.userMoney = data.userMoney;
|
|
|
+ _self.goodsList = data.list;
|
|
|
+ _self.allPrice = data.totalPrice;
|
|
|
+ _self.allCount = data.totalCount;
|
|
|
+ _self.payAllPrice = data.totalPrice;
|
|
|
+ _self.productKind = data.productKind;
|
|
|
+ _self.userMoney = data.userMoney;
|
|
|
_self.getAddressList(_self.userId,20);
|
|
|
}else{
|
|
|
CAIMEI.Alert(response.msg, '确定', false);
|
|
@@ -151,7 +156,7 @@ var shoppingConfirm = new Vue({
|
|
|
},
|
|
|
getFreightData :function(){//获取邮费信息
|
|
|
var _self = this;
|
|
|
- var params ={userId:_self.userID,productIds:_self.productIds,totalPrice:_self.allPrice,townId:_self.addressData.townID};
|
|
|
+ var params ={userId:_self.userId,productIds:_self.productIds,totalPrice:_self.allPrice,townId:_self.addressData.townID};
|
|
|
OrderApi.GetOrderPostage(params,function (response) {
|
|
|
if(response.code == 0){
|
|
|
_self.freightData = response.data;
|
|
@@ -299,9 +304,37 @@ var shoppingConfirm = new Vue({
|
|
|
_self.addAddressData = item;
|
|
|
_self.addAddressData.allAddress=item.province+''+item.city+''+item.town;
|
|
|
},
|
|
|
+ defaultAddressFn :function(addressID){//列表直接设为默认地址
|
|
|
+ var _self = this;
|
|
|
+ OrderApi.DefaultAddress({addressId:addressID,userId:_self.userId},function (response) {
|
|
|
+ if(response.code == 0 ){ //成功
|
|
|
+ _self.addressList = [];
|
|
|
+ _self.getAddressList(_self.userId,20);
|
|
|
+ }else{
|
|
|
+ CAIMEI.Alert(response.msg,'确定',false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ deleteAddress :function(addressID){//列表删除单个地址
|
|
|
+ var _self = this;
|
|
|
+ CAIMEI.Modal('确定要删除该地址?','取消','确定',function () {
|
|
|
+ OrderApi.DeleteAddress({addressID:addressID,userID:_self.userId},function (response) {
|
|
|
+ if(response.code == 0 ){ //删除成功
|
|
|
+ CAIMEI.dialog('删除成功');
|
|
|
+ _self.addressList = [];
|
|
|
+ _self.getAddressList(_self.userId,20);
|
|
|
+ }else{
|
|
|
+ CAIMEI.Alert(response.msg,'确定',false);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
+ },
|
|
|
+ changeHandle :function(index) {//商品备注的值被改变后
|
|
|
+ this.goodsList[index].note = this.goodRemark[index];
|
|
|
+ // console.log(this.goodsList)
|
|
|
+ },
|
|
|
ConfirmAddressFn :function(){//保存地址
|
|
|
var _self = this;
|
|
|
- console.log( _self.isAddType);
|
|
|
if(_self.addAddressData.townID == ""){
|
|
|
CAIMEI.dialog('请选择所在地区');
|
|
|
return;
|
|
@@ -327,7 +360,6 @@ var shoppingConfirm = new Vue({
|
|
|
mobile:_self.addAddressData.mobile, //手机
|
|
|
defaultFlag:_self.addAddressData.defaultFlag//是否默认收货地址(0 不是默认,1 默认)
|
|
|
};
|
|
|
- // console.log('ADD',params);
|
|
|
}else{
|
|
|
var params = {
|
|
|
addressID:_self.addAddressData.addressID,//编辑保存地址ID
|
|
@@ -343,7 +375,7 @@ var shoppingConfirm = new Vue({
|
|
|
OrderApi.AddSaveAddress(params,function(response){
|
|
|
if(response.code == 0){
|
|
|
CAIMEI.dialog('保存成功');
|
|
|
- _self.getAddressList(_self.userID,20);
|
|
|
+ _self.getAddressList(_self.userId,20);
|
|
|
_self.isShwoAddModel = false;
|
|
|
_self.isConDisabled = false;
|
|
|
}else{
|
|
@@ -351,36 +383,248 @@ var shoppingConfirm = new Vue({
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ ConfirmOrderFn :function(){//提交订单
|
|
|
+ var _self = this;
|
|
|
+ if (_self.isSubDisabled) { return false; }
|
|
|
+ if(_self.addressID == ''){
|
|
|
+ CAIMEI.dialog('请先添加收货地址~');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //选择开发票处理
|
|
|
+ if(_self.invoiceType == '1'){
|
|
|
+ CAIMEI.returnedTarget();
|
|
|
+ _self.invoiceData = Object.assign(_self.invoiceData,'',{type:0});
|
|
|
+ }else if(_self.invoiceType == '2'){
|
|
|
+ switch(_self.peopleInvoiceData.invoiceTitleType){
|
|
|
+ case '0':
|
|
|
+ if(_self.peopleInvoiceData.invoiceTitle == ""){
|
|
|
+ CAIMEI.dialog('请输入个人抬头');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case '1':
|
|
|
+ if(_self.peopleInvoiceData.invoiceTitle == ""){
|
|
|
+ CAIMEI.dialog('请输入公司抬头');
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(_self.peopleInvoiceData.corporationTaxNum == ""){
|
|
|
+ CAIMEI.dialog('请输入纳税人识别号');
|
|
|
+ return
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }else if(_self.invoiceType == '3'){
|
|
|
+ if(_self.invoiceData.invoiceTitle == ""){
|
|
|
+ CAIMEI.dialog('请输入单位名称');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(_self.invoiceData.corporationTaxNum == ""){
|
|
|
+ CAIMEI.dialog('请输入纳税人识别号');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(_self.invoiceData.registeredAddress == ""){
|
|
|
+ CAIMEI.dialog('请输入单位地址');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(_self.invoiceData.registeredPhone == ""){
|
|
|
+ CAIMEI.dialog('请输入注册电话');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(_self.invoiceData.openBank == ""){
|
|
|
+ CAIMEI.dialog('请输入开户银行');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(_self.invoiceData.bankAccountNo == ""){
|
|
|
+ CAIMEI.dialog('请输入银行账号');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ CAIMEI.returnedTarget();
|
|
|
+ _self.invoiceData = Object.assign(_self.invoiceData,'',{type:2});
|
|
|
+ }
|
|
|
+ //商品信息
|
|
|
+ _self.orderInfo = _self.goodsList.map(function(el){
|
|
|
+ var productInfo = [];
|
|
|
+ el.cartList.forEach(function(item){
|
|
|
+ productInfo.push({
|
|
|
+ productId:item.productId,
|
|
|
+ productNum:item.number,
|
|
|
+ presentNum:0
|
|
|
+ })
|
|
|
+ });
|
|
|
+ return {shopId:el.id,note:el.note?el.note:'',productInfo:productInfo}
|
|
|
+ });
|
|
|
+ //订单信息
|
|
|
+ _self.payInfo = {
|
|
|
+ clauseId:0,//条款(暂时保留)
|
|
|
+ orderShouldPayFee:_self.payAllPrice.toFixed(2),//提交的总价
|
|
|
+ balancePayFlag:_self.balanceDeductionFlag,//余额抵扣的状态
|
|
|
+ freight:parseInt(_self.hanldFreight).toFixed(2),//邮费
|
|
|
+ freePostFlag:parseInt(_self.hanldFreePostFlag)//运费形式
|
|
|
+ };
|
|
|
+ var params = {
|
|
|
+ orderSource:1,
|
|
|
+ clubUserId:_self.userId,
|
|
|
+ cartType:_self.cartType,
|
|
|
+ addressId:_self.addressID,
|
|
|
+ orderInfo:_self.orderInfo,
|
|
|
+ payInfo:_self.payInfo, //订单信息
|
|
|
+ orderInvoice:_self.invoiceData
|
|
|
+ };
|
|
|
+ // console.log('最后参数',params);
|
|
|
+ //提交
|
|
|
+ _self.isSubDisabled = true;
|
|
|
+ OrderApi.ConfirmOrder({'params':JSON.stringify(params)},function (response) {
|
|
|
+ // console.log(response);
|
|
|
+ if(response.code === 1){
|
|
|
+ var data = { payableAmount: _self.deductMoney };
|
|
|
+ CAIMEI.Storage.removeItem('confirmOrderInfo');
|
|
|
+ CAIMEI.Storage.setItem('confirmOrderInfo',JSON.stringify({data:data}));
|
|
|
+ window.location.href = '/order/paySuccess.jsp';
|
|
|
+ }else if(response.code === 2){
|
|
|
+ var data = {
|
|
|
+ orderID:response.data.orderID,
|
|
|
+ orderNo:response.data.orderNo,
|
|
|
+ orderMark:response.data.orderMark,
|
|
|
+ payableAmount:response.data.payableAmount
|
|
|
+ };
|
|
|
+ CAIMEI.Storage.removeItem('confirmOrderInfo');
|
|
|
+ CAIMEI.Storage.setItem('confirmOrderInfo',JSON.stringify({data:data}));
|
|
|
+ window.location.href = '/web/order/view/pay/caimei-paycash.jsp?type=confirm&orderID='+response.data.orderID;
|
|
|
+ }else{
|
|
|
+ CAIMEI.Alert(response.msg,'确定',false);
|
|
|
+ _self.isSubDisabled = false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ checkedAddressItemFn:function(index,item){//选择地址处理
|
|
|
+ var _self = this;
|
|
|
+ _self.checkedAddressItemIndex = index;
|
|
|
+ _self.hanldAddressData = item;
|
|
|
+ },
|
|
|
+ ConfirmCheckedAddressFn:function(){//确定使用选择的地址
|
|
|
+ var _self = this;
|
|
|
+ _self.addressData = _self.hanldAddressData;
|
|
|
+ _self.isShowAddress = false;
|
|
|
+ },
|
|
|
+ HideCheckedAddressFn :function(){//隐藏选择地址列表
|
|
|
+ var _self = this;
|
|
|
+ _self.isShowAddress = false;
|
|
|
+ },
|
|
|
CancelAddressFn:function(){
|
|
|
- this.isAddressListLength = false;
|
|
|
+ var _self = this;
|
|
|
+ _self.isShwoAddModel = false;
|
|
|
+ },
|
|
|
+ ShowCheckedAddressFn :function(){//显示地址列表选择地址
|
|
|
+ var _self = this;
|
|
|
+ _self.isShowAddress = true;
|
|
|
+ },
|
|
|
+ ShowAddAddressFn :function(){//显示新增地址
|
|
|
+ var _self = this;
|
|
|
+ _self.isAddType = 'add';
|
|
|
+ _self.isShwoAddModel = true;
|
|
|
+ _self.addressData = this.addressData;
|
|
|
+ _self.GetProvinceFn();
|
|
|
+ },
|
|
|
+ radioChange :function(value){//发票信息选择
|
|
|
+ var _self=this;
|
|
|
+ _self.invoiceType = event.target.value;
|
|
|
+ for (var i = 0; i < _self.invoiceTypeList.length; i++) {
|
|
|
+ if (_self.invoiceTypeList[i].value === _self.invoiceType) {
|
|
|
+ _self.current = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch(_self.invoiceType){
|
|
|
+ case '1':
|
|
|
+ CAIMEI.returnedTarget();
|
|
|
+ _self.invoiceData = Object.assign(_self.invoiceData,'',{type:0});
|
|
|
+ break;
|
|
|
+ case '2':
|
|
|
+ _self.invoiceTitle = "0";
|
|
|
+ _self.peopleInvoiceData.invoiceTitleType = "0";
|
|
|
+ CAIMEI.returnedTarget();
|
|
|
+ _self.invoiceData = Object.assign(_self.peopleInvoiceData,'',{type:1});
|
|
|
+ break;
|
|
|
+ case '3':
|
|
|
+ _self.getUseFindInvoice();
|
|
|
+ break;
|
|
|
+ }
|
|
|
},
|
|
|
- ShowCheckedAddressFn :function(){//显示地址列表
|
|
|
- this.isShowAddress = true;
|
|
|
+ radioChangeTitle :function(event) {//发票抬头选择
|
|
|
+ this.peopleInvoiceData.invoiceTitleType = event.target.value;
|
|
|
+ for (var i = 0; i < this.invoiceTitleList.length; i++) {
|
|
|
+ if (this.invoiceTitleList[i].value === this.peopleInvoiceData.invoiceTitleType) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch(this.peopleInvoiceData.invoiceTitleType){
|
|
|
+ case '1':
|
|
|
+ this.peopleInvoiceData.invoiceTitle = "";
|
|
|
+ this.peopleInvoiceData.invoiceContent = "明细";
|
|
|
+ break;
|
|
|
+ }
|
|
|
},
|
|
|
- HideCheckedAddressFn :function(){//显示地址列表
|
|
|
- this.isShowAddress = false;
|
|
|
+ getUseFindInvoice :function(){//获取发票信息
|
|
|
+ var _self = this;
|
|
|
+ OrderApi.GetFindInvoice({userId:_self.userId},function(response){
|
|
|
+ if(response.code == 0){
|
|
|
+ if(response.data == null){
|
|
|
+ CAIMEI.returnedTarget();
|
|
|
+ _self.invoiceData = Object.assign(_self.invoiceData,'',{type:0,userId:_self.userId})
|
|
|
+ }else{
|
|
|
+ _self.invoiceData = response.data
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ CAIMEI.Alert(response.msg,'确定',false);
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
- ShowAddAddressFn :function(){//显示地址列表
|
|
|
- this.isAddressListLength = true;
|
|
|
+ checkedBalabce :function(){//勾选使用余额
|
|
|
+ if(this.userMoney > 0){
|
|
|
+ this.isCheckedBalabce = !this.isCheckedBalabce;
|
|
|
+ if(this.isCheckedBalabce){
|
|
|
+ this.balanceDeductionFlag =1;
|
|
|
+ this.attributePallPrice()
|
|
|
+ }else{
|
|
|
+ if(this.hanldFreePostFlag == 1 || this.hanldFreePostFlag == '1'){
|
|
|
+ this.payAllPrice = this.allPrice+ parseInt(this.freightData.freight);
|
|
|
+ }else{
|
|
|
+ this.payAllPrice = this.allPrice;
|
|
|
+ }
|
|
|
+ this.deductMoney = 0.00;
|
|
|
+ this.balanceDeductionFlag = 2;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return
|
|
|
+ }
|
|
|
+ },
|
|
|
+ gernerateId :function(index){
|
|
|
+ return "male_" +index
|
|
|
+ },
|
|
|
+ gernerateTitleId :function(index){
|
|
|
+ return "title_" +index
|
|
|
},
|
|
|
},
|
|
|
created: function () {
|
|
|
- this.subType = getUrlParam("type") ? getUrlParam("type")*1 : "";
|
|
|
+ var _self = this;
|
|
|
+ _self.subType = getUrlParam("type") ? getUrlParam("type")*1 : "";
|
|
|
if(globalUserData){
|
|
|
- this.userId = globalUserData.userId;
|
|
|
- this.userIdentity = globalUserData.identity;
|
|
|
- this.userToken = globalUserData.token;
|
|
|
+ _self.userId = globalUserData.userId;
|
|
|
+ _self.userIdentity = globalUserData.identity;
|
|
|
+ _self.userToken = globalUserData.token;
|
|
|
// subType:(1购物车提交[对应表cm_cart],2直接购买提交)
|
|
|
- if(this.subType === 1) {
|
|
|
- var productIds = window.localStorage.getItem("shoppingProductIds");
|
|
|
+ if(_self.subType === 1) {
|
|
|
+ _self.cartType= 1;
|
|
|
+ _self.productIds = window.localStorage.getItem("shoppingProductIds");
|
|
|
// 获取列表数据
|
|
|
- this.getConfirmInfo(productIds, null);
|
|
|
- }else if(this.subType === 2){
|
|
|
- var productId = getUrlParam("id");
|
|
|
- var count = getUrlParam("count");
|
|
|
- if(productId && count) {
|
|
|
+ _self.getConfirmInfo( _self.productIds, null);
|
|
|
+ }else if(_self.subType === 2){
|
|
|
+ _self.cartType= 2;
|
|
|
+ _self.productIds = getUrlParam("id");
|
|
|
+ _self.productKind = getUrlParam("count");
|
|
|
+ if(_self.productIds && _self.productKind) {
|
|
|
// 获取列表数据
|
|
|
- this.getConfirmInfo(productId, count);
|
|
|
+ _self.getConfirmInfo(_self.productIds,_self.productKind);
|
|
|
}else{
|
|
|
CAIMEI.Alert('参数错误,请重新提交订单!', '确定', false);
|
|
|
}
|