123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460 |
- $('.navLayout').find('.navList').removeClass("on").find('.con').hide().find('a').removeClass("on");
- $('.navLayout').find('.navList').eq(0).addClass("on").find('.con').show().find('a').eq(2).addClass("on");
- const seeDetail = new Vue({
- el: '#seeDetail',
- mixins: [cmSysVitaMixins],
- data() {
- const defaultConfirmParam = {
- cartType:3, // 购买类型:(1自主下单, 3协销下单)
- orderSource:1, // 订单来源 1WWW 6小程序[采美,星范]
- addressId:0, // 收货地址Id
- cityId:0, // 收货地址Id
- orderInfo:[], // 订单商品数据 // 订单发票信息
- addressInfo:{
- receiver:'',
- mobile:'',
- provinceId:'',
- cityId:'',
- townId:'',
- address:''
- }, // 订单地址信息
- orderInvoice:{ type: 0 }, // 订单发票信息
- payInfo:{ // 订单金额数据
- orderShouldPayFee: 0, // 订单最终支付金额
- clauseId:0 // 条款Id
- }
- };
- return {
- isFiexd:false,
- shopId:'',
- addressForm:{
- receiver:'',
- mobile:'',
- provinceId:'',
- cityId:'',
- townId:'',
- address:''
- },
- invoiceForm:{
- type:0, // 0 不开发票 1 普通发票 2 增值税发票
- headingType:0, // 0 个人 1 单位
- invoiceTitle:'', // 发票抬头
- corporationTaxNum:'',//单位税号
- registeredAddress:'',// 注册地址
- registeredPhone:'',// 注册电话
- openBank:'',// 开户银行
- bankAccountNo:''// 银行账号
- },
- hanldShouldPayFee:0,
- prosParams:{
- productInfo:[],
- shopId:'',
- cityId:''
- },
- confirmParam: defaultConfirmParam, // 提交订单参数
- supplier:{},
- orderInfoArray:[],
- provinceList:[],
- cityList:[],
- townList:[],
- productsArr:[],
- isLoading:true,
- abnormalProductList:[],// 成本异常商品
- goodsDialogVisible:false,
- abnormalDialogVisible:false,
- productRadio:null,
- checkedProductList:[],
- total:0,
- productsList:[],
- listQuery:{
- name:'',//商品名称
- shopId:'',
- pageNum:1,
- pageSize:10
- },
- rules: {
- receiver: [{required: true,message: '请填写收货人',trigger: 'blur'}],
- mobile: [{required: true,message: '请填写联系方式',trigger: 'blur'}],
- provinceId: [{required: true,message: '请选择省份',trigger: 'change'}],
- cityId: [{required: true,message: '请选择市',trigger: 'change'}],
- townId: [{required: true,message: '请选择区县',trigger: 'change'}],
- address: [{required: true,message: '请填写详细地址信息',trigger: 'blur'}],
- invoiceTitle: [{required: true,message: '请填写发票抬头',trigger: 'blur'}],
- corporationTaxNum: [{required: true,message: '请填写单位税号',trigger: 'blur'}],
- registeredAddress: [{required: true,message: '请填写详细地址信息',trigger: 'blur'}],
- registeredPhone: [{required: true,message: '请填写注册电话',trigger: 'blur'}],
- openBank: [{required: true,message: '请填写开户银行',trigger: 'blur'}],
- bankAccountNo: [{required: true,message: '请填写银行账号',trigger: 'blur'}]
- },
- submitLoading:false,
- }
- },
- filters: {
- amountfilters(value) {
- if (value) {
- return Number(value).toFixed(2)
- } else {
- return '0.00'
- }
- },
- },
- computed: {
- disabled() {
- return this.productRadio === null
- },
- checkedConfirmFlag(){
- if(this.confirmParam.cityId && this.checkedProductList.length > 0 ){
- return true
- }
- },
- },
- methods: {
- // 计算总运费
- handleTotalPostage(supplier){
- if(supplier.isColdChina){
- if(supplier.handlePostageFlag === 2){
- return (supplier.coldChain*100 + supplier.postage*100 - supplier.postage*100)/100
- }else{
- return (supplier.postage*100 + supplier.coldChain*100)/100
- }
- }else{
- return supplier.postage
- }
- },
- // 勾选冷链费
- handleChangeColdChina(flag,supplier){
- if(flag){
- supplier.totalPrice = Number((supplier.totalPrice*100 + supplier.coldChain*100)/100)
- this.attributePallPrice()
- console.log('totalPrice',supplier.totalPrice)
- }else{
- supplier.totalPrice = Number(this.repiceNumSub(supplier.totalPrice,supplier.coldChain))
- this.attributePallPrice()
- console.log('hanldShouldPayFee',this.hanldShouldPayFee)
- }
- },
- getProvinceOptions(){ // 获取全部省份
- const _this = this;
- OrderApi.GetAddressSelect({},function(res){
- if(res.code === 0 && res.data){
- _this.provinceList = res.data;
- }else{
- CAIMEI.Alert(res.msg,'确定',false);
- }
- });
- },
- getCityList(parentId){// 获取地区
- const _this = this;
- this.cityList = [];
- this.townList = [];
- this.addressForm.cityId = '';
- this.addressForm.townId = '';
- OrderApi.GetAddressSelect({ parentId: parentId,type:1 },function(res){
- if(res.code === 0 && res.data){
- _this.cityList = res.data;
- }else{
- CAIMEI.Alert(res.msg,'确定',false);
- }
- });
- },
- getTownList(cityId){
- const _this = this;
- this.townList = [];
- this.addressForm.townId = '';
- this.confirmParam.cityId = this.prosParams.cityId = this.addressForm.cityId
- console.log('cityId',cityId)
- OrderApi.GetAddressSelect({parentId: cityId,type:2},function(res){
- if(res.code === 0 && res.data){
- _this.townList = res.data;
- }else{
- CAIMEI.Alert(res.msg,'确定',false);
- }
- })
- // 切换市区时重新调用确认订单信息
- if(this.checkedProductList.length > 0){
- this.prosParams.productInfo = this.handleProStringify(this.checkedProductList)
- console.log('prosParams',this.prosParams)
- this.getSettlement(this.prosParams)
- }
- },
- handleConfirm(){
- // 校验收货信息
- this.$refs['dataForm'].validate(async valid => {
- if (valid) {
- if(this.productsArr.length === 0){
- this.$alert('请添加商品~', '提示', {
- type: 'warning',
- confirmButtonText: '确定',
- });
- }
- }
- })
- // 校验发票
- if(this.invoiceForm.type!==0){
- this.$refs['invoiceForm'].validate(async valid => {
- if (valid) {
- if(this.checkedConfirmFlag){
- this.initializationParams()
- }
- }
- })
- }else {
- if(this.checkedConfirmFlag){
- this.initializationParams()
- }
- }
- },
- //统一处理
- initializationParams(){
- // 发票信息
- if(this.invoiceForm.type!==0){
- this.invoiceForm.type = parseInt(this.invoiceForm.type)
- this.confirmParam.orderInvoice = this.invoiceForm;
- }
- //商品信息
- this.confirmParam.orderInfo = this.hanldeProcessing()
- console.log('orderInfo',this.confirmParam.orderInfo)
- this.confirmParam.payInfo.orderShouldPayFee = parseFloat(this.hanldShouldPayFee).toFixed(2);
- this.confirmParam.addressInfo = JSON.stringify(this.addressForm)
- console.log('addressInfo',this.confirmParam.addressInfo)
- this.confirmParam.payInfo = JSON.stringify(this.confirmParam.payInfo)
- this.confirmParam.orderInfo = JSON.stringify(this.confirmParam.orderInfo)
- this.confirmParam.orderInvoice = JSON.stringify(this.confirmParam.orderInvoice)
- console.log('confirmParam',this.confirmParam);
- this.handleConfirmOrder(this.confirmParam);
- },
- // 处理数据格式
- hanldeProcessing() {
- return this.orderInfoArray.map(el => {
- let productInfo = []
- el.cartList.forEach(pros => {
- productInfo.push({
- skuId: pros.skuId,
- productNum: pros.number,
- presentNum: 0,
- productType: pros.giftType,
- price: pros.price.toString()
- })
- })
- return {
- splitCode: el.splitCode,
- shopId: el.shopId,
- note: el.note ? el.note : '',
- postage: el.isColdChina
- ? parseInt(el.postage + el.coldChain).toFixed(2)
- : parseInt(el.postage).toFixed(2),
- postageFlag: parseInt(el.handlePostageFlag),
- isColdChina: el.isColdChina ? 1 : 0,
- productInfo: productInfo
- }
- })
- },
- handleConfirmOrder(params){
- const _this = this;
- this.submitLoading = true
- setTimeout(()=>{
- SupplierApi.shopGenerateOrder(params,function(response){
- if(response.code === 0){
- const data = response.data
- _this.submitLoading = false
- _this.$message({
- message: '恭喜你,订单提交成功~',
- type: 'success'
- });
- setTimeout(()=>{
- _this.submitLoading = false
- _this.formatConfirmParam()
- window.location.href = '/supplier/order/detail.html?shopOrderId='+data.shopOrderId
- },2000)
- }else{
- setTimeout(()=>{
- _this.$message.error(response.msg)
- _this.submitLoading = false
- _this.formatConfirmParam()
- },2000)
- }
- })
- },1000)
- },
- // 还原提交订单参数格式
- formatConfirmParam:function(){
- this.confirmParam.payInfo = JSON.parse(this.confirmParam.payInfo);
- this.confirmParam.orderInfo = JSON.parse(this.confirmParam.orderInfo);
- this.confirmParam.addressInfo = JSON.parse(this.confirmParam.addressInfo);
- this.confirmParam.orderInvoice = JSON.parse(this.confirmParam.orderInvoice);
- console.log('payInfo',this.confirmParam.payInfo)
- },
- // 添加商品弹窗显示
- handleShowVisible(){
- this.getProductList()
- this.goodsDialogVisible = true
- },
- //切换页码
- handleCurrentChange(val){
- this.listQuery.pageNum = val;
- this.getProductList();
- },
- // 已选择的禁用勾选框
- handleSelectable(row) {
- const skuIds = this.checkedProductList.map(pros => pros.skuId);
- console.log('skuIds',skuIds)
- return !skuIds.includes(row.skuId);
- },
- //取消选择
- handleCanle(){
- this.productRadio = null
- this.goodsDialogVisible = false
- },
- // 删除确认商品
- handleDelete(index){
- this.checkedProductList.splice(index, 1)
- if(this.checkedProductList.length === 0){
- this.productsArr = []
- }
- if(this.checkedProductList.length > 0){
- this.prosParams.productInfo = this.handleProStringify(this.checkedProductList)
- this.getSettlement(this.prosParams)
- }
- },
- //修改sku
- handleChangeSku(row){
- const _this = this
- let skus = row.skus
- console.log('skus',skus)
- skus.forEach((sku)=>{
- if(row.skuId === sku.skuId){
- if(sku.ladderPriceFlag === 1){
- row.price = _this.handeleToFixed(sku.ladderPriceList[0].buyPrice)
- row.count = sku.minBuyNumber
- row.minBuyNumber = sku.minBuyNumber
- row.ladderPriceFlag = sku.ladderPriceFlag
- row.ladderPriceList = sku.ladderPriceList
- }else{
- row.price = _this.handeleToFixed(sku.price)
- row.count = sku.minBuyNumber
- row.minBuyNumber = sku.minBuyNumber
- row.ladderPriceFlag = sku.ladderPriceFlag
- row.ladderPriceList = sku.ladderPriceList
- }
- }
- })
- },
- // 修改数量判断阶梯价
- handleChangeNumber(row){
- const _this = this
- if (row.count < row.minBuyNumber) {
- row.count = row.minBuyNumber
- if (row.ladderPriceFlag === 1) {
- row.ladderPriceList.forEach((item) => {
- if (row.count >= item.buyNum) {
- row.price = _this.handeleToFixed(item.buyPrice)
- }
- })
- } else {
- row.price = _this.handeleToFixed(row.price)
- }
- } else {
- if (row.ladderPriceFlag === 1) {
- row.ladderPriceList.forEach((item) => {
- if (row.count >= item.buyNum) {
- row.price = _this.handeleToFixed(item.buyPrice)
- }
- })
- } else {
- row.price = _this.handeleToFixed(row.price)
- }
- }
- },
- // 保留小数点后两位数
- handeleToFixed(value){
- return value.toFixed(2)
- },
- //确认选择商品
- handleAddProConfirm(){
- this.checkedProductList = [...this.checkedProductList,...this.productRadio]
- this.prosParams.productInfo = this.handleProStringify(this.checkedProductList)
- this.getSettlement(this.prosParams)
- },
- // 统一格式化确认订单商品信息参数
- handleProStringify(productInfo){
- return JSON.stringify(productInfo.map((pros)=>{
- return {
- productId:pros.productId,
- count:pros.count,
- skuId:pros.skuId,
- price:pros.price
- }
- }))
- },
- // 确认订单信息
- getSettlement(params){
- const _this = this;
- this.orderInfoArray =[]
- SupplierApi.getSettlement(params,function(response){
- if(response.code === 0){
- let data = response.data
- if(data.abnormalProductList.length > 0){
- _this.abnormalProductList = data.abnormalProductList
- _this.abnormalDialogVisible = true
- // 根据 checkedProductList 中的 skuId,删除 abnormalProductList 中的相同 skuId 的数据
- _this.checkedProductList = _this.checkedProductList.filter(check => !_this.abnormalProductList.map(abnormal => abnormal.skuId).includes(check.skuId));
- console.log('checkedProductList',_this.checkedProductList)
- }else{
- _this.supplier = data.shop
- _this.orderInfoArray.push(_this.supplier)
- _this.hanldShouldPayFee = data.shop.totalPrice;
- _this.supplier.handlePostageFlag = data.shop.postageFlag
- _this.productsArr = data.shop.cartList
- _this.handleCanle()
- }
- }else{
- _this.$message.error(response.msg)
- }
- })
- },
- // 选择商品
- handleSelectionChange(row) {
- this.productRadio = row
- console.log('productRadio', this.productRadio)
- },
- getProductList(){//我的商品数据初始化
- const _this = this;
- this.isLoading = true
- SupplierApi.getShopProduct(this.listQuery,function(response){
- if(response.code === 0){
- const data = response.data
- _this.productsList = data.results.map((pros)=>{
- pros.count = pros.minBuyNumber
- pros.price = _this.handeleToFixed(pros.price)
- return pros
- })
- _this.total = data.totalRecord
- _this.isLoading = false
- }else{
- CAIMEI.Alert(response.msg, '确定')
- _this.isLoading = false
- }
- })
- },
- },
- mounted () {
- const _this = this;
- this.getProvinceOptions();
- if(globalUserData){
- this.listQuery.shopId = this.confirmParam.shopId = globalUserData.shopId;
- this.shopId = this.prosParams.shopId = globalUserData.shopId;
- }
- if (isPC) {
- $(window).scroll(function (event) {
- var supportPageOffset = window.pageXOffset !== undefined; // 判断是否支持pageXOffset
- var isCSS1Compat = ((document.compatMode || "") === "CSS1Compat"); // 判断渲染模式是不是标准模式
- var scrollHeight = supportPageOffset ? window.pageYOffset : isCSS1Compat ? document.documentElement.scrollTop : document.body.scrollTop;
- if (scrollHeight < 100) {
- _this.isFiexd = true
- } else {
- _this.isFiexd = false
- }
- });
- }
- },
- });
|