diff --git a/.env.development b/.env.development index a8fceaf..6be1052 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,5 @@ VITE_NOW_TYPE = 'dist' -# VITE_BASE_URL = 'http://192.168.1.10:8546' -VITE_BASE_URL = 'https://erp.lihaink.cn' \ No newline at end of file +VITE_PUSH_URL = 'ws://192.168.1.22:8787' +VITE_BASE_URL = 'http://192.168.1.22:8546' +# VITE_BASE_URL = 'https://erp.lihaink.cn' \ No newline at end of file diff --git a/.env.production b/.env.production index 55d7d1a..370d4f4 100644 --- a/.env.production +++ b/.env.production @@ -1,3 +1,4 @@ VITE_NOW_TYPE = 'build' +VITE_PUSH_URL = 'ws://192.168.1.22:3133' VITE_BASE_URL = 'https://shop.lihaink.cn' \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 627a394..b94553f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "mitt": "^3.0.1", "moment": "^2.30.1", "pinia": "^2.1.7", + "print-js": "^1.6.0", "sass": "^1.72.0", "vue": "^3.4.21", "vue-router": "^4.3.0" @@ -1469,6 +1470,11 @@ "postcss": "^8.0.0" } }, + "node_modules/print-js": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/print-js/-/print-js-1.6.0.tgz", + "integrity": "sha512-BfnOIzSKbqGRtO4o0rnj/K3681BSd2QUrsIZy/+WdCIugjIswjmx3lDEZpXB2ruGf9d4b3YNINri81+J0FsBWg==" + }, "node_modules/proxy-from-env": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", diff --git a/package.json b/package.json index 704a939..53b709d 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "mitt": "^3.0.1", "moment": "^2.30.1", "pinia": "^2.1.7", + "print-js": "^1.6.0", "sass": "^1.72.0", "vue": "^3.4.21", "vue-router": "^4.3.0" diff --git a/src/App.vue b/src/App.vue index 00a2bb3..e2555ed 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,13 +1,14 @@ diff --git a/src/api/shop.js b/src/api/shop.js index 4c36840..b6292b8 100644 --- a/src/api/shop.js +++ b/src/api/shop.js @@ -73,6 +73,6 @@ export function saleStoreListApi(data) { /** * @description 店铺商品分类 */ -export function merchantCategoryListApi(id, data) { - return request.get(`store/merchant/category/lst/${id}`, { params: data }) +export function merchantCategoryListApi(data) { + return request.get(`goods/goodsclass/lists`, { params: data }) } \ No newline at end of file diff --git a/src/api/store.js b/src/api/store.js index 4a70d45..9985644 100644 --- a/src/api/store.js +++ b/src/api/store.js @@ -26,21 +26,21 @@ export function cartChangeApi(id, data) { * @description 结算 */ export function orderCheckApi(data) { - return request.post(`v2/order/check`, data) + return request.post(`/order/RetailOrder/checkOrder`, data) } /** * @description 删除商品 */ export function cartDeleteApi(data) { - return request.post(`user/cart/delete`, data) + return request.post(`/order/cart/delete`, data) } /** * @description 支付 */ export function orderCreateApi(data) { - return request.post(`v2/order/create`, data) + return request.post(`/order/RetailOrder/createOrder`, data) } /** @@ -60,8 +60,8 @@ export function orderStatusApi(data) { /** * @description 订单列表 */ -export function orderListApi(id, data) { - return request.get(`admin/${id}/order_list`, { params: data }) +export function orderListApi(data) { + return request.get(`/order/retailOrder/merchant_order_list`, { params: data }) } /** @@ -108,8 +108,22 @@ export function orderPriceApi(mer_id, data) { /** - * @description 批发订单列表 + * @description 收银订单列表 */ -export function saleOrderListApi(mer_id, data) { - return request.get(`order/list`, { params: data }) +export function saleOrderListApi(data) { + return request.get(`/order/retailOrder/order_list`, { params: data }) +} + +/** + * @description 采购订单提交 + */ +export function createOrderApi(data) { + return request.get(`/order/OpurchaseOrder/createOrder`, { params: data }) +} + +/** + * @description 订单商品列表 + */ +export function cashierinfoListApi(data) { + return request.get(`/order/cashierinfo/lists`, { params: data }) } \ No newline at end of file diff --git a/src/common/push.js b/src/common/push.js new file mode 100644 index 0000000..78271ad --- /dev/null +++ b/src/common/push.js @@ -0,0 +1,751 @@ + + +export const Push = function Push(options) { + this.doNotConnect = 0; + options = options || {}; + options.heartbeat = options.heartbeat || 25000; + options.pingTimeout = options.pingTimeout || 10000; + this.config = options; + this.uid = 0; + this.channels = {}; + this.connection = null; + this.pingTimeoutTimer = 0; + Push.instances.push(this); + this.createConnection(); +} + +Push.prototype.checkoutPing = function() { + var _this = this; + _this.checkoutPingTimer && clearTimeout(_this.checkoutPingTimer); + _this.checkoutPingTimer = setTimeout(function () { + _this.checkoutPingTimer = 0; + if (_this.connection.state === 'connected') { + _this.connection.send('{"event":"pusher:ping","data":{}}'); + if (_this.pingTimeoutTimer) { + clearTimeout(_this.pingTimeoutTimer); + _this.pingTimeoutTimer = 0; + } + _this.pingTimeoutTimer = setTimeout(function () { + _this.connection.closeAndClean(); + if (!_this.connection.doNotConnect) { + _this.connection.waitReconnect(); + } + }, _this.config.pingTimeout); + } + }, this.config.heartbeat); +}; + +Push.prototype.channel = function (name) { + return this.channels.find(name); +}; +Push.prototype.allChannels = function () { + return this.channels.all(); +}; +Push.prototype.createConnection = function () { + if (this.connection) { + throw Error('Connection already exist'); + } + var _this = this; + var url = this.config.url; + function updateSubscribed () { + for (var i in _this.channels) { + _this.channels[i].subscribed = false; + } + } + this.connection = new Connection({ + url: url, + app_key: this.config.app_key, + onOpen: function () { + _this.connection.state ='connecting'; + _this.checkoutPing(); + }, + onMessage: function(params) { + if(_this.pingTimeoutTimer) { + clearTimeout(_this.pingTimeoutTimer); + _this.pingTimeoutTimer = 0; + } + + params = JSON.parse(params.data); + var event = params.event; + var channel_name = params.channel; + + if (event === 'pusher:pong') { + _this.checkoutPing(); + return; + } + if (event === 'pusher:error') { + throw Error(params.data.message); + } + var data = JSON.parse(params.data), channel; + if (event === 'pusher_internal:subscription_succeeded') { + channel = _this.channels[channel_name]; + channel.subscribed = true; + channel.processQueue(); + channel.emit('pusher:subscription_succeeded'); + return; + } + if (event === 'pusher:connection_established') { + _this.connection.socket_id = data.socket_id; + _this.connection.updateNetworkState('connected'); + _this.subscribeAll(); + } + if (event.indexOf('pusher_internal') !== -1) { + console.log("Event '"+event+"' not implement"); + return; + } + channel = _this.channels[channel_name]; + if (channel) { + channel.emit(event, data); + } + }, + onClose: function () { + updateSubscribed(); + }, + onError: function () { + updateSubscribed(); + } + }); +}; +Push.prototype.disconnect = function () { + this.connection.doNotConnect = 1; + this.connection.close(); +}; + +Push.prototype.subscribeAll = function () { + if (this.connection.state !== 'connected') { + return; + } + for (var channel_name in this.channels) { + //this.connection.send(JSON.stringify({event:"pusher:subscribe", data:{channel:channel_name}})); + this.channels[channel_name].processSubscribe(); + } +}; + +Push.prototype.unsubscribe = function (channel_name) { + if (this.channels[channel_name]) { + delete this.channels[channel_name]; + if (this.connection.state === 'connected') { + this.connection.send(JSON.stringify({event:"pusher:unsubscribe", data:{channel:channel_name}})); + } + } +}; +Push.prototype.unsubscribeAll = function () { + var channels = Object.keys(this.channels); + if (channels.length) { + if (this.connection.state === 'connected') { + for (var channel_name in this.channels) { + this.unsubscribe(channel_name); + } + } + } + this.channels = {}; +}; +Push.prototype.subscribe = function (channel_name) { + if (this.channels[channel_name]) { + return this.channels[channel_name]; + } + if (channel_name.indexOf('private-') === 0) { + return createPrivateChannel(channel_name, this); + } + if (channel_name.indexOf('presence-') === 0) { + return createPresenceChannel(channel_name, this); + } + return createChannel(channel_name, this); +}; +Push.instances = []; + +function createChannel(channel_name, push) +{ + var channel = new Channel(push.connection, channel_name); + push.channels[channel_name] = channel; + channel.subscribeCb = function () { + push.connection.send(JSON.stringify({event:"pusher:subscribe", data:{channel:channel_name}})); + } + channel.processSubscribe(); + return channel; +} + +function createPrivateChannel(channel_name, push) +{ + var channel = new Channel(push.connection, channel_name); + push.channels[channel_name] = channel; + channel.subscribeCb = function () { + __ajax({ + url: push.config.auth, + type: 'POST', + data: {channel_name: channel_name, socket_id: push.connection.socket_id}, + success: function (data) { + data = JSON.parse(data); + data.channel = channel_name; + push.connection.send(JSON.stringify({event:"pusher:subscribe", data:data})); + }, + error: function (e) { + throw Error(e); + } + }); + }; + channel.processSubscribe(); + return channel; +} + +function createPresenceChannel(channel_name, push) +{ + return createPrivateChannel(channel_name, push); +} + +/*window.addEventListener('online', function(){ + var con; + for (var i in Push.instances) { + con = Push.instances[i].connection; + con.reconnectInterval = 1; + if (con.state === 'connecting') { + con.connect(); + } + } +});*/ + + +function Connection(options) { + this.dispatcher = new Dispatcher(); + __extends(this, this.dispatcher); + var properies = ['on', 'off', 'emit']; + for (var i in properies) { + this[properies[i]] = this.dispatcher[properies[i]]; + } + this.options = options; + this.state = 'initialized'; //initialized connecting connected disconnected + this.doNotConnect = 0; + this.reconnectInterval = 1; + this.connection = null; + this.reconnectTimer = 0; + this.connect(); +} + +Connection.prototype.updateNetworkState = function(state){ + var old_state = this.state; + this.state = state; + if (old_state !== state) { + this.emit('state_change', { previous: old_state, current: state }); + } +}; + +Connection.prototype.connect = function () { + this.doNotConnect = 0; + if (this.state === 'connected') { + console.log('networkState is "' + this.state + '" and do not need connect'); + return; + } + if (this.reconnectTimer) { + clearTimeout(this.reconnectTimer); + this.reconnectTimer = 0; + } + + this.closeAndClean(); + + var options = this.options; + var websocket = new WebSocket(options.url+'/app/'+options.app_key); + + this.updateNetworkState('connecting'); + + var _this = this; + websocket.onopen = function (res) { + _this.reconnectInterval = 1; + if (_this.doNotConnect) { + _this.updateNetworkState('disconnected'); + websocket.close(); + return; + } + if (options.onOpen) { + options.onOpen(res); + } + }; + + if (options.onMessage) { + websocket.onmessage = options.onMessage; + } + + websocket.onclose = function (res) { + websocket.onmessage = websocket.onopen = websocket.onclose = websocket.onerror = null; + _this.updateNetworkState('disconnected'); + if (!_this.doNotConnect) { + _this.waitReconnect(); + } + if (options.onClose) { + options.onClose(res); + } + }; + + websocket.onerror = function (res) { + _this.close(); + if (!_this.doNotConnect) { + _this.waitReconnect(); + } + if (options.onError) { + options.onError(res); + } + }; + this.connection = websocket; +} + +Connection.prototype.closeAndClean = function () { + if(this.connection) { + var websocket = this.connection; + websocket.onmessage = websocket.onopen = websocket.onclose = websocket.onerror = null; + try { + websocket.close(); + } catch (e) {} + this.updateNetworkState('disconnected'); + } +}; + +Connection.prototype.waitReconnect = function () { + if (this.state === 'connected' || this.state === 'connecting') { + return; + } + if (!this.doNotConnect) { + this.updateNetworkState('connecting'); + var _this = this; + if (this.reconnectTimer) { + clearTimeout(this.reconnectTimer); + } + this.reconnectTimer = setTimeout(function(){ + _this.connect(); + }, this.reconnectInterval); + if (this.reconnectInterval < 1000) { + this.reconnectInterval = 1000; + } else { + // 每次重连间隔增大一倍 + this.reconnectInterval = this.reconnectInterval * 2; + } + // 有网络的状态下,重连间隔最大2秒 + if (this.reconnectInterval > 2000 && navigator.onLine) { + _this.reconnectInterval = 2000; + } + } +} + +Connection.prototype.send = function(data) { + if (this.state !== 'connected') { + console.trace('networkState is "' + this.state + '", can not send ' + data); + return; + } + this.connection.send(data); +} + +Connection.prototype.close = function(){ + this.updateNetworkState('disconnected'); + this.connection.close(); +} + +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) {d[p] = b[p];} + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; + +function Channel(connection, channel_name) { + this.subscribed = false; + this.dispatcher = new Dispatcher(); + this.connection = connection; + this.channelName = channel_name; + this.subscribeCb = null; + this.queue = []; + __extends(this, this.dispatcher); + var properies = ['on', 'off', 'emit']; + for (var i in properies) { + this[properies[i]] = this.dispatcher[properies[i]]; + } +} + +Channel.prototype.processSubscribe = function () { + if (this.connection.state !== 'connected') { + return; + } + this.subscribeCb(); +}; + +Channel.prototype.processQueue = function () { + if (this.connection.state !== 'connected' || !this.subscribed) { + return; + } + for (var i in this.queue) { + this.queue[i](); + } + this.queue = []; +}; + +Channel.prototype.trigger = function (event, data) { + if (event.indexOf('client-') !== 0) { + throw new Error("Event '" + event + "' should start with 'client-'"); + } + var _this = this; + this.queue.push(function () { + _this.connection.send(JSON.stringify({ event: event, data: data, channel: _this.channelName })); + }); + this.processQueue(); +}; + +//////////////// +var Collections = (function () { + var exports = {}; + function extend(target) { + var sources = []; + for (var _i = 1; _i < arguments.length; _i++) { + sources[_i - 1] = arguments[_i]; + } + for (var i = 0; i < sources.length; i++) { + var extensions = sources[i]; + for (var property in extensions) { + if (extensions[property] && extensions[property].constructor && + extensions[property].constructor === Object) { + target[property] = extend(target[property] || {}, extensions[property]); + } + else { + target[property] = extensions[property]; + } + } + } + return target; + } + + exports.extend = extend; + function stringify() { + var m = ["Push"]; + for (var i = 0; i < arguments.length; i++) { + if (typeof arguments[i] === "string") { + m.push(arguments[i]); + } + else { + m.push(safeJSONStringify(arguments[i])); + } + } + return m.join(" : "); + } + + exports.stringify = stringify; + function arrayIndexOf(array, item) { + var nativeIndexOf = Array.prototype.indexOf; + if (array === null) { + return -1; + } + if (nativeIndexOf && array.indexOf === nativeIndexOf) { + return array.indexOf(item); + } + for (var i = 0, l = array.length; i < l; i++) { + if (array[i] === item) { + return i; + } + } + return -1; + } + + exports.arrayIndexOf = arrayIndexOf; + function objectApply(object, f) { + for (var key in object) { + if (Object.prototype.hasOwnProperty.call(object, key)) { + f(object[key], key, object); + } + } + } + + exports.objectApply = objectApply; + function keys(object) { + var keys = []; + objectApply(object, function (_, key) { + keys.push(key); + }); + return keys; + } + + exports.keys = keys; + function values(object) { + var values = []; + objectApply(object, function (value) { + values.push(value); + }); + return values; + } + + exports.values = values; + function apply(array, f, context) { + for (var i = 0; i < array.length; i++) { + f.call(context || (window), array[i], i, array); + } + } + + exports.apply = apply; + function map(array, f) { + var result = []; + for (var i = 0; i < array.length; i++) { + result.push(f(array[i], i, array, result)); + } + return result; + } + + exports.map = map; + function mapObject(object, f) { + var result = {}; + objectApply(object, function (value, key) { + result[key] = f(value); + }); + return result; + } + + exports.mapObject = mapObject; + function filter(array, test) { + test = test || function (value) { + return !!value; + }; + var result = []; + for (var i = 0; i < array.length; i++) { + if (test(array[i], i, array, result)) { + result.push(array[i]); + } + } + return result; + } + + exports.filter = filter; + function filterObject(object, test) { + var result = {}; + objectApply(object, function (value, key) { + if ((test && test(value, key, object, result)) || Boolean(value)) { + result[key] = value; + } + }); + return result; + } + + exports.filterObject = filterObject; + function flatten(object) { + var result = []; + objectApply(object, function (value, key) { + result.push([key, value]); + }); + return result; + } + + exports.flatten = flatten; + function any(array, test) { + for (var i = 0; i < array.length; i++) { + if (test(array[i], i, array)) { + return true; + } + } + return false; + } + + exports.any = any; + function all(array, test) { + for (var i = 0; i < array.length; i++) { + if (!test(array[i], i, array)) { + return false; + } + } + return true; + } + + exports.all = all; + function encodeParamsObject(data) { + return mapObject(data, function (value) { + if (typeof value === "object") { + value = safeJSONStringify(value); + } + return encodeURIComponent(base64_1["default"](value.toString())); + }); + } + + exports.encodeParamsObject = encodeParamsObject; + function buildQueryString(data) { + var params = filterObject(data, function (value) { + return value !== undefined; + }); + return map(flatten(encodeParamsObject(params)), util_1["default"].method("join", "=")).join("&"); + } + + exports.buildQueryString = buildQueryString; + function decycleObject(object) { + var objects = [], paths = []; + return (function derez(value, path) { + var i, name, nu; + switch (typeof value) { + case 'object': + if (!value) { + return null; + } + for (i = 0; i < objects.length; i += 1) { + if (objects[i] === value) { + return {$ref: paths[i]}; + } + } + objects.push(value); + paths.push(path); + if (Object.prototype.toString.apply(value) === '[object Array]') { + nu = []; + for (i = 0; i < value.length; i += 1) { + nu[i] = derez(value[i], path + '[' + i + ']'); + } + } + else { + nu = {}; + for (name in value) { + if (Object.prototype.hasOwnProperty.call(value, name)) { + nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']'); + } + } + } + return nu; + case 'number': + case 'string': + case 'boolean': + return value; + } + }(object, '$')); + } + + exports.decycleObject = decycleObject; + function safeJSONStringify(source) { + try { + return JSON.stringify(source); + } + catch (e) { + return JSON.stringify(decycleObject(source)); + } + } + + exports.safeJSONStringify = safeJSONStringify; + return exports; +})(); + +var Dispatcher = (function () { + function Dispatcher(failThrough) { + this.callbacks = new CallbackRegistry(); + this.global_callbacks = []; + this.failThrough = failThrough; + } + Dispatcher.prototype.on = function (eventName, callback, context) { + this.callbacks.add(eventName, callback, context); + return this; + }; + Dispatcher.prototype.on_global = function (callback) { + this.global_callbacks.push(callback); + return this; + }; + Dispatcher.prototype.off = function (eventName, callback, context) { + this.callbacks.remove(eventName, callback, context); + return this; + }; + Dispatcher.prototype.emit = function (eventName, data) { + var i; + for (i = 0; i < this.global_callbacks.length; i++) { + this.global_callbacks[i](eventName, data); + } + var callbacks = this.callbacks.get(eventName); + if (callbacks && callbacks.length > 0) { + for (i = 0; i < callbacks.length; i++) { + callbacks[i].fn.call(callbacks[i].context || (window), data); + } + } + else if (this.failThrough) { + this.failThrough(eventName, data); + } + return this; + }; + return Dispatcher; +}()); + +var CallbackRegistry = (function () { + function CallbackRegistry() { + this._callbacks = {}; + } + CallbackRegistry.prototype.get = function (name) { + return this._callbacks[prefix(name)]; + }; + CallbackRegistry.prototype.add = function (name, callback, context) { + var prefixedEventName = prefix(name); + this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || []; + this._callbacks[prefixedEventName].push({ + fn: callback, + context: context + }); + }; + CallbackRegistry.prototype.remove = function (name, callback, context) { + if (!name && !callback && !context) { + this._callbacks = {}; + return; + } + var names = name ? [prefix(name)] : Collections.keys(this._callbacks); + if (callback || context) { + this.removeCallback(names, callback, context); + } + else { + this.removeAllCallbacks(names); + } + }; + CallbackRegistry.prototype.removeCallback = function (names, callback, context) { + Collections.apply(names, function (name) { + this._callbacks[name] = Collections.filter(this._callbacks[name] || [], function (oning) { + return (callback && callback !== oning.fn) || + (context && context !== oning.context); + }); + if (this._callbacks[name].length === 0) { + delete this._callbacks[name]; + } + }, this); + }; + CallbackRegistry.prototype.removeAllCallbacks = function (names) { + Collections.apply(names, function (name) { + delete this._callbacks[name]; + }, this); + }; + return CallbackRegistry; +}()); +function prefix(name) { + return "_" + name; +} + +function __ajax(options){ + options=options||{}; + options.type=(options.type||'GET').toUpperCase(); + options.dataType=options.dataType||'json'; + params=formatParams(options.data); + + var xhr; + if(window.XMLHttpRequest){ + xhr=new XMLHttpRequest(); + }else{ + xhr=ActiveXObject('Microsoft.XMLHTTP'); + } + + xhr.onreadystatechange=function(){ + if(xhr.readyState === 4){ + var status=xhr.status; + if(status>=200 && status<300){ + options.success&&options.success(xhr.responseText,xhr.responseXML); + }else{ + options.error&&options.error(status); + } + } + } + + if(options.type==='GET'){ + xhr.open('GET',options.url+'?'+params,true); + xhr.send(null); + }else if(options.type==='POST'){ + xhr.open('POST',options.url,true); + xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + xhr.send(params); + } +} + +function formatParams(data){ + var arr=[]; + for(var name in data){ + arr.push(encodeURIComponent(name)+'='+encodeURIComponent(data[name])); + } + return arr.join('&'); +} + +// export const push = { +// a:6 +// } \ No newline at end of file diff --git a/src/components/pay.vue b/src/components/pay.vue index 83dc49f..eb5736c 100644 --- a/src/components/pay.vue +++ b/src/components/pay.vue @@ -51,7 +51,7 @@ const setForm = (e) => { }; const setRePay = (e) => { - form.value.order_price = e.price; + form.value.total = e.price; order_id.value = e.order_id; }; @@ -88,7 +88,7 @@ const handleEnter = () => { if (order_id.value) orderPay(order_id.value); else { let pay_type; - if (regexWechat.test(input.value)) pay_type = "micropay"; + if (regexWechat.test(input.value)) pay_type = "9"; else if (regexPay.test(input.value)) pay_type = "alipayBar"; else { loading.value = false; @@ -102,16 +102,15 @@ const handleEnter = () => { cart_id: cart_id.value, pay_type: pay_type, auth_code: input.value, - staff_id: userStore.userInfo.service.service_id, }) .then((res) => { - if (res.status == 200 && (res.message == "支付成功" || res.message == "success")) { + if (res.data.trade_state == 'SUCCESS') { drawer.value = false; ElMessage({ - message: res.message=='success'?'支付成功':res.message, + message: res.data.trade_state_desc || '支付成功', type: "success", }); - audioplay(res.data.message||res.data.result.message); + if(res.data.message) audioplay(res.data.message); beforeClose(); } else { if (!res.data.group_order_sn) { @@ -160,13 +159,13 @@ const orderPay = (id) => { }; orderPayApi(id, query) .then((res) => { - if (res.status == 200 && (res.message == "支付成功" || res.message == "success")) { + if (res.data.trade_state == 'SUCCESS') { drawer.value = false; ElMessage({ message: res.message=='success'?'支付成功':res.message, type: "success", }); - audioplay(res.data.message||res.data.result.message); + if(res.data.message) audioplay(res.data.message); beforeClose(); } else { order_id.value = res.data.group_order_id; @@ -193,16 +192,16 @@ const getOrderStatus = (id) => { order_sn: id, }) .then((res) => { - if (res.data.paid == 1 || res.message == "支付成功") { + if (res.data.trade_state == 'SUCCESS') { ElMessage({ message: res.message, type: "success", }); - audioplay(res.data.message); + if(res.data.message) audioplay(res.data.message); beforeClose(); } else { ElMessage({ - message: res.message, + message: res.data.trade_state=='USERPAYING' ? '用户正在支付中' : res.message, type: "error", }); input.value = ""; @@ -256,7 +255,7 @@ const collection = ref(""); //输入的金额 const changePrice = computed(() => { // 找零 if (+collection.value > 0) { - return (collection.value - form.value.order_price).toFixed(2); + return (collection.value - form.value.total).toFixed(2); } return -1; }); @@ -298,26 +297,24 @@ const cashBnt = () => { changePrice.value === "" || changePrice.value === null || changePrice.value === undefined || - +collection.value < +form.value.order_price + +collection.value < +form.value.total ) return ElMessage.error("收款金额应该大于等于应收金额"); if (order_id.value) orderPay(order_id.value); else orderCreateApi({ address_id: "", - key: form.value.key, cart_id: cart_id.value, pay_type: "cash_payment", - staff_id: userStore.userInfo.service.service_id, }) .then((res) => { - if (res.status == 200 && res.message == "支付成功") { + if (res.data.trade_state == 'SUCCESS') { drawer.value = false; ElMessage({ message: res.message, type: "success", }); changeActive(1); - audioplay(res.data.message); + if(res.data.message) audioplay(res.data.message); beforeClose(); } else { if (!res.data.group_order_sn) { @@ -462,7 +459,7 @@ onUnmounted(() => {
应收金额(元):
- ¥{{ form.order_price }} + ¥{{ form.total }}
{ > C - + 确认
diff --git a/src/layout/index.vue b/src/layout/index.vue index 55231bc..cc0af41 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -3,9 +3,28 @@ import myHeader from "./myHeader.vue"; import myAside from "./myAside.vue"; import { ref, nextTick, onMounted, onUnmounted } from "vue"; import mitt from "@/utils/mitt.js"; +import { useUserStore } from "@/store/user.js"; +import { Push } from "@/common/push.js"; + +const userStore = useUserStore(); +const connection = new Push({ + url: import.meta.env.VITE_PUSH_URL, // websocket地址 + app_key: '2ce3ce22329517213caa7dad261f5695', +}); +// 浏览器监听user-1 +const user_channel = connection.subscribe(`user-${userStore.userInfo.id}`); +// const user_channel = connection.subscribe(`user-${1}`); +// 当user-2频道有message事件的消息时 +user_channel.on('message', function (data) { + console.log("收到消息--",data, JSON.parse(data.content)); +}); +// 断线事件 +user_channel.on('close', function () { + +}); const KeyboardEvent = (e)=>{ console.log('按下', e.keyCode); diff --git a/src/layout/myAside.vue b/src/layout/myAside.vue index 79f3961..58e7f43 100644 --- a/src/layout/myAside.vue +++ b/src/layout/myAside.vue @@ -10,14 +10,10 @@ const navTo = (name) => { router.push({ name }); }; const list = ref([ - { name: "home", title: "收银", ico: "Sell", count: 0 }, - { name: "order", title: "收银订单", ico: "DataLine", count: 0 }, - { name: "orderSystem", title: "平台订单", ico: "DataAnalysis", count: 0 }, - { name: "saleHome", title: "批发", ico: "Van", count: 0 }, - { name: "saleOrder", title: "批发订单", ico: "Tickets", count: 0 }, - { name: "convert", title: "核销", ico: "FullScreen", count: 0 }, - { name: "shop", title: "商品", ico: "ShoppingBag", count: 0 }, - { name: "orderCount", title: "订单统计", ico: "PieChart", count: 0 }, + { name: "saleHome", title: "收银", ico: "Sell", count: 0 }, + { name: "saleOrder", title: "收银订单", ico: "DataLine", count: 0 }, + { name: "order", title: "待提采购", ico: "DataAnalysis", count: 0 }, + { name: "orderSystem", title: "采购订单", ico: "Tickets", count: 0 }, ]); const aup = () => { let index = list.value.findIndex((item) => item.name == route.name); diff --git a/src/layout/myHeader.vue b/src/layout/myHeader.vue index 54680c0..d10b500 100644 --- a/src/layout/myHeader.vue +++ b/src/layout/myHeader.vue @@ -3,7 +3,7 @@ import { useUserStore } from "@/store/user.js"; import { ref } from "vue"; import { info, logout } from "@/api/user.js"; import { ElMessage } from "element-plus"; -import { useRouter } from 'vue-router' +import { useRouter } from "vue-router"; const userStore = useUserStore(); @@ -12,25 +12,18 @@ merInfo.value = userStore.userInfo; const router = useRouter(); const onLogout = () => { - logout().then(() => { - userStore.setUserInfo({}); - userStore.setToken(""); - router.push("/login"); - }).catch(() => { - ElMessage({ - message: "退出失败", - type: "error", - }) - }); -} - + userStore.setUserInfo({}); + userStore.setToken(""); + router.push("/login"); +};
-
{{ item.cate_name }}
+
{{ item.name }}
{ :key="indexc" @click="changeActive(index, indexc)" > - {{ chil.cate_name }} + {{ chil.name }}
diff --git a/src/views/saleHome/component/order.vue b/src/views/saleHome/component/order.vue index 5929b5c..6a83afc 100644 --- a/src/views/saleHome/component/order.vue +++ b/src/views/saleHome/component/order.vue @@ -1,6 +1,6 @@ @@ -267,36 +209,6 @@ const getOrderStatus = (id) => { position: relative; overflow: hidden; - .header-nav { - display: flex; - background: linear-gradient( - to bottom, - #f5f5f5 50%, - #fff 50% - ); /* 创建渐变背景 */ - .nav-item { - height: 4rem; - width: 8rem; - cursor: pointer; - display: flex; - justify-content: center; - align-items: center; - font-size: 1.2rem; - background-color: #f5f5f5; - border-radius: 1rem 1rem 0 0; - } - .nav-item-active { - background-color: #fff; - position: relative; - transition: 300ms; - } - .nav-item-radius1 { - border-radius: 0 0 1rem 0; - } - .nav-item-radius2 { - border-radius: 0 0 0 1rem; - } - } .detail { height: calc(100vh - 100px - 4rem); box-sizing: border-box; @@ -305,17 +217,19 @@ const getOrderStatus = (id) => { .table { padding: 1rem; padding-bottom: 6rem; + overflow-y: auto; + height: 100%; .table-title { font-weight: bold; - padding-top: 1rem; } .table-info { display: flex; flex-wrap: wrap; color: #777; font-size: 0.9rem; - padding-bottom: 2rem; + padding-bottom: 1rem; + margin-bottom: 1rem; border-bottom: 1px solid #eee; &:last-child { @@ -333,43 +247,6 @@ const getOrderStatus = (id) => { } } } - - .footer { - height: 6rem; - box-sizing: border-box; - padding: 0 1.5rem; - position: absolute; - bottom: 0; - left: 0; - width: 100%; - box-shadow: 0 -1px 0.625rem #eee; - display: flex; - justify-content: space-between; - align-items: center; - background-color: #fff; - .info { - display: flex; - align-items: flex-end; - .ser { - font-weight: bold; - margin-right: 1rem; - } - .price { - margin-right: 1rem; - span { - color: #ff4a00; - font-size: 1.2rem; - font-weight: bold; - } - } - } - .handle { - .btn { - border-radius: 4rem; - padding: 1.2rem; - } - } - } } } diff --git a/src/views/saleOrder/component/order.vue b/src/views/saleOrder/component/order.vue index 5215730..7d9594c 100644 --- a/src/views/saleOrder/component/order.vue +++ b/src/views/saleOrder/component/order.vue @@ -1,11 +1,11 @@ @@ -95,7 +100,7 @@ onMounted(()=>{
{
{ @click="setForm(item, index)" >
-
- 单号: {{ item.order_sn }} -
+
单号: {{ item.number }}
{{ item.create_time }}
-
+
-
- {{ item.orderProduct[0].cart_info.product.store_name }} +
+ {{ item.goods_list[0].class_name }}
-
¥{{ item.pay_price }}
-
共{{ item.total_num }}件商品
+
¥{{ item.total }}
+
共{{ item.goods_count }}款商品
已支付 - (支付宝收款) - (现金支付) - (微信收款) - (余额支付) - (微信支付) - (商户余额支付) - (对公转账) + (微信收款) + (余额支付) + (微信支付)
未支付
-
+
没有更多了
@@ -235,7 +223,7 @@ onMounted(()=>{ span { color: #ff4a00; } - .nav-item{ + .nav-item { font-weight: bold; } .nav-item-btn { @@ -250,7 +238,7 @@ onMounted(()=>{ height: 2.5rem; border-bottom: 1px solid #eee; } - .order-list { + .order-lists { height: calc(100vh - 100px - 10.2rem); overflow-y: auto; .item { @@ -336,7 +324,7 @@ onMounted(()=>{ justify-content: space-between; font-size: 0.9rem; color: #777; - .manage-btn{ + .manage-btn { color: #fff; background-color: #e6a23c; border-radius: 0.2rem; diff --git a/src/views/saleOrder/indexSystem.vue b/src/views/saleOrder/indexSystem.vue index 66ced1d..2c6a3f8 100644 --- a/src/views/saleOrder/indexSystem.vue +++ b/src/views/saleOrder/indexSystem.vue @@ -9,9 +9,9 @@ import { ref, nextTick } from "vue"; diff --git a/src/views/test/test.vue b/src/views/test/test.vue new file mode 100644 index 0000000..6e77172 --- /dev/null +++ b/src/views/test/test.vue @@ -0,0 +1,39 @@ + + + + + \ No newline at end of file