| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214 |
- import {
- checkpaypassword,
- balanceConfig
- } from "@/api/order/payment"
- import {
- addressList,
- saveAddress,
- setDefault,
- deleteAddress,
- addressInfo
- } from "@/api/member/member"
- import {
- payment,
- calculate,
- orderCreate
- } from "@/api/combo"
- import {
- getArea
- } from "@/api/address"
- import {
- mapGetters
- } from "vuex"
- export default {
- name: "combo_payment",
- components: {},
- data: () => {
- var checkMobile = (rule, value, callback) => {
- if (value === "") {
- callback(new Error("请输入手机号"))
- } else if (!/^\d{11}$/.test(value)) {
- callback(new Error("手机号格式错误"))
- } else {
- callback()
- }
- }
- return {
- dialogVisible: false,
- memberAddress: {}, //收货地址列表
- addressId: 0, //收货地址
- addressForm: {
- id: 0,
- name: "",
- mobile: "",
- telephone: "",
- province_id: "",
- city_id: "",
- district_id: "",
- community_id: "",
- address: "",
- full_address: "",
- is_default: "",
- longitude: "",
- latitude: ""
- },
- pickerValueArray: {},
- cityArr: {},
- districtArr: {},
- addressRules: {
- name: [{
- required: true,
- message: "请输入收货人",
- trigger: "blur"
- },
- {
- min: 1,
- max: 20,
- message: "长度在 1 到 20 个字符",
- trigger: "blur"
- }
- ],
- mobile: [{
- required: true,
- validator: checkMobile,
- trigger: "change"
- }],
- province: [{
- required: true,
- message: "请选择省",
- trigger: "change"
- }],
- city: [{
- required: true,
- message: "请选择市",
- trigger: "change"
- }],
- district: [{
- required: true,
- message: "请选择区/县",
- trigger: "change"
- }],
- address: [{
- required: true,
- message: "请输入详细地址",
- trigger: "change"
- }]
- },
- isSend: false,
- orderCreateData: {
- is_balance: 0,
- pay_password: ""
- },
- orderPaymentData: {
- goods_money: 0,
- pay_money: 0,
- shop_goods_list: {
- site_name: "",
- express_type: [],
- coupon_list: []
- },
- bunding_info: {
- bl_name: ""
- },
- member_account: {
- balance: 0,
- is_pay_password: 0
- },
- platform_coupon_list: []
- },
- dialogCoupon: false,
- siteCoupon: {
- site_id: 0,
- data: []
- },
- siteDelivery: {
- site_id: 0,
- data: []
- },
- dialogStore: false,
- promotionInfo: false,
- storeList: {},
- sitePromotion: [],
- isSub: false,
- dialogpay: false,
- password: "",
- fullscreenLoading: true,
- deliveryTime: false,
- timeTip: "选择配送时间",
- time: null,
- selectCouponId: 0,
- addressShow: false,
- storeRadio: false,
- couponRadio: false,
- dialogPlatcoupon: false,
- platformCouponRadio: 0,
- platCouponList: [],
- balance_show : 1
- }
- },
- computed: {
- ...mapGetters(["comboOrderCreateData", "defaultGoodsImage", "city"]),
- promotionMoney() {
- return this.orderPaymentData.bunding_info.goods_money - this.orderPaymentData.bunding_info.bl_price
- },
- themeStyle() {
- return "theme-" + this.$store.state.themeStyle
- }
- },
- middleware: 'auth',
- mounted() {},
- created() {
- this.getMemberAddress()
- this.getOrderPaymentData()
- this.getBalanceConfig()
- },
- filters: {
- /**
- * 金额格式化输出
- * @param {Object} money
- */
- moneyFormat(money) {
- if (!money) money = 0
- return parseFloat(money).toFixed(2)
- },
- /**
- * 店铺优惠摘取
- */
- promotion(data) {
- let promotion = ""
- if (data) {
- Object.keys(data).forEach(key => {
- promotion += data[key].content + " "
- })
- }
- return promotion
- }
- },
- methods: {
- //获取余额支付配置
- getBalanceConfig() {
- balanceConfig()
- .then(res => {
- const {
- code,
- message,
- data
- } = res
- if (code >= 0) {
- this.balance_show = data.balance_show;
- }
- })
- .catch(err => {
- const {
- code,
- message,
- data
- } = err
- // this.$message.error(message)
- })
- },
- //获取收货地址
- getMemberAddress() {
- addressList({
- page_size: 0
- })
- .then(res => {
- const {
- code,
- message,
- data
- } = res
- if (data && data.list) {
- let that = this
- this.memberAddress = data.list
- data.list.forEach(function(e) {
- if (e.is_default == 1) {
- that.addressId = e.id
- }
- })
- }
- })
- .catch(err => {
- const {
- code,
- message,
- data
- } = err
- this.$message.error(message)
- })
- },
- //设置会员收货地址
- setMemberAddress(params) {
- this.addressId = params
- setDefault({
- id: params
- })
- .then(res => {
- const {
- code,
- message,
- data
- } = res
- this.orderCalculate()
- })
- .catch(err => {
- const {
- code,
- message,
- data
- } = err
- this.$message.error(message)
- })
- },
- //删除会员收货地址
- deleteMemberAddress(params) {
- deleteAddress({
- id: params
- })
- .then(res => {
- const {
- code,
- message,
- data
- } = res
- if (data) {
- this.$message({
- message: message,
- type: "success"
- })
- this.getMemberAddress()
- } else {
- this.$message({
- message: message,
- type: "warning"
- })
- }
- })
- .catch(err => {
- this.$message.error(err.message)
- })
- },
- //打开添加收货地址弹出层
- addAddressShow() {
- this.dialogVisible = true
- this.addressForm.id = 0
- this.addressForm.name = ""
- this.addressForm.mobile = ""
- this.addressForm.telephone = ""
- this.addressForm.province_id = ""
- this.addressForm.city_id = ""
- this.addressForm.district_id = ""
- this.addressForm.community_id = ""
- this.addressForm.address = ""
- this.addressForm.full_address = ""
- this.addressForm.is_default = ""
- this.addressForm.longitude = ""
- this.addressForm.latitude = ""
- // this.$nextTick(() => {
- // this.$refs.form.resetFields();
- // });
- this.cityArr = {}
- this.districtArr = {}
- this.getAddress(0)
- },
- //获取地址
- getAddress(type) {
- let pid = 0
- let that = this
- switch (type) {
- case 0:
- //加载省
- pid = 0
- break
- case 1:
- //加载市
- pid = this.addressForm.province_id
- that.cityArr = {}
- that.districtArr = {}
- this.addressForm.city_id = ""
- this.addressForm.district_id = ""
- break
- case 2:
- //加载区县
- pid = this.addressForm.city_id
- that.districtArr = {}
- this.addressForm.district_id = ""
- break
- }
- getArea({
- pid: pid
- })
- .then(res => {
- const {
- code,
- message,
- data
- } = res
- if (data) {
- switch (type) {
- case 0:
- that.pickerValueArray = data
- break
- case 1:
- //加载市
- that.cityArr = data
- break
- case 2:
- //加载区县
- that.districtArr = data
- break
- }
- }
- })
- .catch(err => {
- const {
- code,
- message,
- data
- } = err
- this.$message.error(message)
- })
- },
- //编辑地址 初始化
- initAddress(type) {
- let pid = 0
- let that = this
- switch (type) {
- case 0:
- //加载省
- pid = 0
- break
- case 1:
- //加载市
- pid = this.addressForm.province_id
- that.cityArr = {}
- that.districtArr = {}
- break
- case 2:
- //加载区县
- pid = this.addressForm.city_id
- that.districtArr = {}
- break
- }
- getArea({
- pid: pid
- })
- .then(res => {
- const {
- code,
- message,
- data
- } = res
- if (data) {
- switch (type) {
- case 0:
- that.pickerValueArray = data
- break
- case 1:
- //加载市
- that.cityArr = data
- break
- case 2:
- //加载区县
- that.districtArr = data
- break
- }
- }
- })
- .catch(err => {
- const {
- code,
- message,
- data
- } = err
- this.$message.error(message)
- })
- },
- //新增/编辑收货地址
- addmemberAddress(formName) {
- this.$refs[formName].validate(valid => {
- if (valid) {
- if (this.isSend) {
- return false
- }
- if (!this.addressForm.id) {
- this.addressForm.full_address = this.$refs.province.selectedLabel + "-" + this.$refs.city.selectedLabel + "-" +
- this.$refs.district.selectedLabel
- let data = {
- name: this.addressForm.name,
- mobile: this.addressForm.mobile,
- telephone: this.addressForm.telephone,
- province_id: this.addressForm.province_id,
- city_id: this.addressForm.city_id,
- district_id: this.addressForm.district_id,
- community_id: "",
- address: this.addressForm.address,
- full_address: this.addressForm.full_address,
- longitude: this.addressForm.longitude,
- latitude: this.addressForm.latitude,
- is_default: this.addressForm.is_default,
- url: 'add'
- }
- if (!data.province_id) {
- this.$message({
- message: "请选择省",
- type: "warning"
- })
- return false
- }
- if (!data.city_id) {
- this.$message({
- message: "请选择市",
- type: "warning"
- })
- return false
- }
- if (!data.district_id) {
- this.$message({
- message: "请选择区/县",
- type: "warning"
- })
- return false
- }
- this.isSend = true
- saveAddress(data)
- .then(res => {
- const {
- code,
- message,
- data
- } = res
- if (data) {
- this.setMemberAddress(data)
- this.$message({
- message: message,
- type: "success"
- })
- this.dialogVisible = false
- this.getMemberAddress()
- this.getOrderPaymentData()
- } else {
- this.$message({
- message: message,
- type: "warning"
- })
- }
- this.isSend = false
- })
- .catch(err => {
- const {
- code,
- message,
- data
- } = err
- this.$message.error(message)
- })
- } else {
- this.addressForm.full_address = this.$refs.province.selectedLabel + "-" + this.$refs.city.selectedLabel + "-" +
- this.$refs.district.selectedLabel
- let data = this.addressForm
- if (!data.province_id) {
- this.$message({
- message: "请选择省",
- type: "warning"
- })
- return false
- }
- if (!data.city_id) {
- this.$message({
- message: "请选择市",
- type: "warning"
- })
- return false
- }
- if (!data.district_id) {
- this.$message({
- message: "请选择区/县",
- type: "warning"
- })
- return false
- }
- this.isSend = true
- this.setMemberAddress(data.id);
- data.url = "edit";
- saveAddress(data)
- .then(res => {
- const {
- code,
- message,
- data
- } = res
- if (data) {
- this.$message({
- message: message,
- type: "success"
- })
- this.dialogVisible = false
- this.getMemberAddress()
- this.getOrderPaymentData()
- } else {
- this.$message({
- message: message,
- type: "warning"
- })
- }
- this.isSend = false
- })
- .catch(err => {
- const {
- code,
- message,
- data
- } = err
- this.$message.error(message)
- })
- }
- } else {
- return false
- }
- })
- },
- //编辑收货地址
- editAddress(id) {
- addressInfo({
- id: id
- })
- .then(res => {
- const {
- code,
- message,
- data
- } = res
- this.addressForm = {
- id: data.id,
- name: data.name,
- mobile: data.mobile,
- telephone: data.telephone,
- province_id: data.province_id,
- city_id: "",
- district_id: "",
- community_id: "",
- address: data.address,
- full_address: data.full_address,
- is_default: data.is_default,
- longitude: data.longitude,
- latitude: data.latitude
- }
- this.initAddress(0)
- this.initAddress(1)
- this.addressForm.city_id = data.city_id
- this.initAddress(2)
- this.addressForm.district_id = data.district_id
- this.dialogVisible = true
- })
- .catch(err => {
- const {
- code,
- message,
- data
- } = err
- this.$message.error(message)
- })
- },
- /**
- * 获取订单初始化数据
- */
- getOrderPaymentData() {
- this.orderCreateData = this.comboOrderCreateData
- if (!this.orderCreateData) {
- this.$message({
- message: "未获取到创建订单所需数据!", //提示的信息
- type: "warning",
- offset: 225,
- duration: 3000,
- onClose: () => {
- this.$router.go(-1)
- return false
- }
- })
- return
- }
- this.orderCreateData.web_city = this.city ? this.city.id : 0
- payment(this.orderCreateData)
- .then(res => {
- const {
- code,
- message,
- data
- } = res
- if (code >= 0) {
- this.orderPaymentData = res.data
- this.handlePaymentData()
- } else {
- this.$message({
- message: "未获取到创建订单所需数据!", //提示的信息
- type: "warning",
- offset: 225,
- duration: 3000,
- onClose: () => {
- this.$router.go(-1)
- return false
- }
- })
- return
- }
- })
- .catch(err => {
- const {
- code,
- message,
- data
- } = err
- this.$message.error(message)
- })
- },
- /**
- * 处理结算订单数据
- */
- handlePaymentData() {
- this.orderCreateData.delivery = {}
- this.orderCreateData.coupon = {}
- this.orderCreateData.is_balance = 0
- this.orderCreateData.pay_password = ""
- var data = this.orderPaymentData
- console.log(this.orderPaymentData)
- // this.platCouponList = data.platform_coupon_list
- // console.log(this.platCouponList, 'platCouponList')
- // if (this.platCouponList.length > 0) {
- // this.orderCreateData.platform_coupon_id = this.platCouponList[0].platformcoupon_id
- // this.selectPlatCouponId = this.platCouponList[0].platformcoupon_id
- // this.selectPlatCouponMoney = this.platCouponList[0].money
- // }
- // if (data.shop_goods_list.express_type != undefined && data.shop_goods_list.express_type[0] != undefined) {
- // var express_type = data.shop_goods_list.express_type
- // this.orderCreateData.delivery.delivery_type = express_type[0].name
- // this.orderCreateData.delivery.delivery_type_name = express_type[0].title
- // this.orderCreateData.delivery.store_id = 0
- // // 如果默认配送方式是门店配送
- // if (express_type[0].name == "store") {
- // if (express_type[0].store_list[0] != undefined) {
- // this.orderCreateData.delivery.store_id = express_type[0].store_list[0].store_id
- // }
- // }
- // }
- if (this.orderPaymentData.shop_goods_list.express_type.length > 1) {
- console.log(this.orderPaymentData.shop_goods_list.express_type, '配送方式')
- this.orderCreateData.delivery.delivery_type = 'express'
- this.orderCreateData.delivery.delivery_type_name = '物流配送'
- }
- let h = new Date().getHours().toString()
- let m = new Date().getMinutes().toString()
- if (h.length == 1) {
- h = "0" + h
- }
- if (m.length == 1) {
- m = "0" + m
- }
- let nowTime = h + ":" + m
- if (data.shop_goods_list.local_config) {
- if (data.shop_goods_list.local_config.info && data.shop_goods_list.local_config.info.time_is_open == 1) {
- this.orderCreateData.delivery.showTimeBar = true
- this.orderCreateData.delivery.buyer_ask_delivery_time = nowTime
- } else {
- this.orderCreateData.delivery.showTimeBar = false
- }
- }
- // if (data.shop_goods_list.coupon_list != undefined && data.shop_goods_list.coupon_list[0] != undefined) {
- // var coupon_list = data.shop_goods_list.coupon_list
- // this.orderCreateData.coupon.coupon_id = coupon_list[0].coupon_id
- // this.orderCreateData.coupon.coupon_money = coupon_list[0].money
- // this.selectCouponId = coupon_list[0].coupon_id
- // }
- Object.assign(this.orderPaymentData, this.orderCreateData)
- this.orderCalculate()
- },
- /**
- * 订单计算
- */
- orderCalculate() {
- this.fullscreenLoading = true
- let siteId = this.orderPaymentData.shop_goods_list.site_id
- var deliveryObj = this.orderCreateData.delivery
- var couponObj = this.orderCreateData.coupon
- var messageObj = this.orderCreateData.buyer_message
- var data = this.$util.deepClone(this.orderCreateData)
- data.delivery = JSON.stringify(deliveryObj)
- data.coupon = JSON.stringify(couponObj)
- data.buyer_message = messageObj
- data.member_address = JSON.stringify(data.member_address)
- calculate(data)
- .then(res => {
- const {
- code,
- message,
- data
- } = res
- if (code >= 0) {
- this.orderPaymentData.delivery_money = res.data.delivery_money
- this.orderPaymentData.coupon_money = res.data.coupon_money
- this.orderPaymentData.invoice_money = res.data.invoice_money
- this.orderPaymentData.promotion_money = res.data.promotion_money
- this.orderPaymentData.order_money = res.data.order_money
- this.orderPaymentData.balance_money = res.data.balance_money
- this.orderPaymentData.pay_money = res.data.pay_money
- this.orderPaymentData.goods_money = res.data.goods_money
- this.orderPaymentData.platform_coupon_money = res.data.platform_coupon_money
- } else {
- this.$message({
- message: message, //提示的信息
- type: "warning",
- offset: 225,
- duration: 3000,
- onClose: () => {
- this.$router.go(-1)
- return false
- }
- })
- return
- }
- this.fullscreenLoading = false
- })
- .catch(err => {
- const {
- code,
- message,
- data
- } = err
- this.$message.error(message)
- this.fullscreenLoading = false
- })
- },
- /**
- * 选择配送方式
- */
- selectDeliveryType(data) {
- this.orderCreateData.delivery.delivery_type = data.name
- this.orderCreateData.delivery.delivery_type_name = data.title
- // 如果是门店配送
- if (data.name == "store") {
- data.store_list.forEach(function(e, i) {
- data.store_list[i]["store_address"] = e.full_address + e.address
- })
- if (data.store_list[0] != undefined) {
- this.orderCreateData.delivery.store_id = data.store_list[0].store_id
- }
- this.dialogStore = true
- this.storeList = data.store_list
- } else if (data.name == "local") {
- this.deliveryTime = true
- }
- Object.assign(this.orderPaymentData, this.orderCreateData)
- this.orderCalculate()
- this.$forceUpdate()
- },
- /**
- * 选择自提点
- * @param {Object} item
- */
- selectStore(item) {
- if (!item) return;
- let store_id = item.store_id
- this.dialogStore = false
- this.orderCreateData.delivery.store_id = store_id
- this.orderCreateData.delivery.store_name = item.store_name
- Object.assign(this.orderPaymentData, this.orderCreateData)
- this.storeRadio = item
- this.orderCalculate()
- this.$forceUpdate()
- },
- /**
- * 显示平台优惠券信息
- * @param {Object} siteId
- * @param {Object} couponData
- */
- openPlatformCoupon() {
- let row = 0
- let that = this;
- this.dialogPlatcoupon = true
- // this.orderPaymentData.platform_coupon_list.forEach(function(e, i) {
- // if (e.platformcoupon_id == that.orderCreateData.platform_coupon_id) {
- // row = e
- // }
- // })
- // setTimeout(function() {
- // that.setPlatformCurrent(row)
- // that.platformCouponRadio = row;
- // }, 50)
- },
- /**
- * 取消选择优惠券
- * @param {Object} item
- */
- setPlatformCurrent(row) {
- this.$refs.platformCouponTable.setCurrentRow(row)
- if (row == undefined) {
- this.orderCalculate()
- }
- },
- /**
- * 确认选择优惠券
- * @param {Object} item
- */
- savePlatformCoupon() {
- this.dialogPlatcoupon = false
- this.orderCalculate()
- },
- /**
- * 选择优惠券
- * @param {Object} item
- */
- selectPlatformCoupon(item) {
- if (!item) {
- this.orderPaymentData.platform_coupon_id = 0;
- this.orderCreateData.platform_coupon_id = 0;
- this.orderPaymentData.platform_coupon_money = "0.00";
- this.orderCreateData.platform_coupon_money = "0.00";
- this.platformCouponRadio = '';
- } else {
- if (this.orderCreateData.platform_coupon_id != item.platformcoupon_id) {
- this.orderPaymentData.platform_coupon_id = item.platformcoupon_id;
- this.orderCreateData.platform_coupon_id = item.platformcoupon_id;
- this.orderPaymentData.platform_coupon_money = item.money;
- this.orderCreateData.platform_coupon_money = item.money;
- this.platformCouponRadio = item;
- } else {
- this.platformCouponRadio = '';
- this.orderPaymentData.platform_coupon_id = 0;
- this.orderCreateData.platform_coupon_id = 0;
- this.orderPaymentData.platform_coupon_money = "0.00";
- this.orderCreateData.platform_coupon_money = "0.00";
- }
- }
- Object.assign(this.orderPaymentData, this.orderCreateData);
- this.$forceUpdate()
- },
- /**
- * 显示店铺优惠券信息
- * @param {Object} siteId
- * @param {Object} couponData
- */
- openSiteCoupon(couponData) {
- this.tempData = {
- coupon: this.$util.deepClone(this.orderPaymentData.coupon)
- }
- this.selectCouponId = this.orderCreateData.coupon.coupon_id
- let row = 0
- let that = this
- couponData.forEach(function(e, i) {
- if (e.at_least > 0) {
- couponData[i]["use"] = "满" + e.at_least + "可用"
- } else {
- couponData[i]["use"] = "任意金额可用"
- }
- couponData[i]["time"] = timeStampTurnTime(e.end_time)
- if (e.coupon_id == that.selectCouponId) {
- row = e
- }
- })
- this.siteCoupon.data = couponData
- this.dialogCoupon = true
- setTimeout(function() {
- that.setCurrent(row)
- that.couponRadio = row;
- }, 50)
- },
- /**
- * 选择优惠券
- * @param {Object} item
- */
- selectCoupon(item) {
- if (!item) {
- this.orderCreateData.coupon.coupon_id = 0
- this.orderCreateData.coupon.coupon_money = "0.00"
- this.couponRadio = '';
- } else {
- if (this.orderCreateData.coupon.coupon_id != item.coupon_id) {
- this.orderCreateData.coupon.coupon_id = item.coupon_id
- this.orderCreateData.coupon.coupon_money = item.money
- this.couponRadio = item;
- } else {
- this.orderCreateData.coupon.coupon_id = 0
- this.orderCreateData.coupon.coupon_money = "0.00"
- this.couponRadio = '';
- }
- }
- Object.assign(this.orderPaymentData, this.orderCreateData)
- this.$forceUpdate()
- },
- /**
- * 取消选择优惠券
- * @param {Object} item
- */
- setCurrent(row) {
- this.$refs.couponTable.setCurrentRow(row)
- if (row == undefined) {
- this.orderCreateData.coupon.coupon_id = 0
- this.orderCreateData.coupon.coupon_money = "0.00"
- this.couponRadio = '';
- this.orderCalculate()
- }
- },
- /**
- * 确认选择优惠券
- * @param {Object} item
- */
- saveCoupon(row) {
- this.dialogCoupon = false
- this.orderCalculate()
- },
- /**
- * 显示店铺优惠信息
- * @param {Object} data
- */
- openSitePromotion(data) {
- this.sitePromotion = data
- if (this.promotionInfo) {
- this.promotionInfo = false
- } else {
- this.promotionInfo = true
- }
- },
- /**
- * 是否使用余额
- */
- useBalance(type) {
- if (this.orderCreateData.is_balance) this.orderCreateData.is_balance = 0
- else this.orderCreateData.is_balance = 1
- this.orderCalculate()
- this.$forceUpdate()
- },
- orderCreate() {
- if (this.verify()) {
- if (this.isSub) return
- this.isSub = true
- var loading = this.$loading({
- lock: true,
- text: "订单提交中...",
- spinner: "el-icon-loading",
- background: "rgba(0, 0, 0, 0.7)"
- })
- let siteId = this.orderPaymentData.shop_goods_list.site_id
- var deliveryObj = this.orderCreateData.delivery
- var couponObj = this.orderCreateData.coupon
- var messageObj = this.orderCreateData.buyer_message
- var data = this.$util.deepClone(this.orderCreateData)
- data.delivery = JSON.stringify(deliveryObj)
- data.coupon = JSON.stringify(couponObj)
- data.buyer_message = messageObj
- data.member_address = JSON.stringify(data.member_address)
- orderCreate(data)
- .then(res => {
- const {
- code,
- message,
- data
- } = res
- loading.close()
- if (code >= 0) {
- this.$store.dispatch("order/removeComboOrderCreateData", "")
- if (this.orderPaymentData.pay_money == 0) {
- this.$router.push({
- path: "/result",
- query: {
- code: data
- }
- })
- } else {
- this.$router.push({
- path: "/pay",
- query: {
- code: data
- }
- })
- }
- } else {
- this.$message({
- message: message,
- type: "warning"
- })
- }
- })
- .catch(err => {
- loading.close()
- this.isSub = false
- const {
- code,
- message,
- data
- } = err
- this.$message.error(message)
- })
- }
- },
- /**
- * 订单验证
- */
- verify() {
- if (!this.orderPaymentData.member_address) {
- this.$message({
- message: "请先选择您的收货地址",
- type: "warning"
- })
- return false
- }
- if (JSON.stringify(this.orderCreateData.delivery) == "{}") {
- this.$message({
- message: "店铺未设置配送方式",
- type: "warning"
- })
- return false
- }
- if (this.orderCreateData.delivery.delivery_type == "store" && this.orderCreateData.delivery.store_id == 0) {
- this.$message({
- message: "店铺没有可提货的门店,请选择其他配送方式",
- type: "warning"
- })
- return false
- }
- // if (this.orderCreateData.is_balance == 1 && this.orderCreateData.pay_password == "") {
- // this.dialogpay = true
- // return false
- // }
- return true
- },
- /**
- * 支付密码输入
- */
- input() {
- if (this.password.length == 6) {
- var loading = this.$loading({
- lock: true,
- text: "支付中",
- spinner: "el-icon-loading",
- background: "rgba(0, 0, 0, 0.7)"
- })
- checkpaypassword({
- pay_password: this.password
- })
- .then(res => {
- const {
- code,
- message,
- data
- } = res
- loading.close()
- if (code >= 0) {
- this.orderCreateData.pay_password = this.password
- this.orderCreate()
- this.dialogpay = false
- } else {
- this.$message({
- message: message,
- type: "warning"
- })
- }
- })
- .catch(err => {
- loading.close()
- const {
- code,
- message,
- data
- } = err
- this.$message.error(message)
- })
- }
- },
- textarea() {
- this.$forceUpdate()
- },
- bindTimeChange(time) {
- this.time = time
- this.orderCreateData.delivery.buyer_ask_delivery_time = this.time
- },
- setDeliveryTime() {
- this.deliveryTime = false
- this.orderCreateData.delivery.buyer_ask_delivery_time = this.time
- },
- imageError(index) {
- this.orderPaymentData.shop_goods_list.goods_list[index].sku_image = this.defaultGoodsImage
- },
- setPayPassword() {
- this.$util.pushToTab("/member/security");
- }
- }
- }
|