2025-03-11 09:45:29 +08:00
|
|
|
import Vue from 'vue';
|
|
|
|
import Vuex from 'vuex';
|
|
|
|
import App from './App';
|
|
|
|
import uView from 'uview-ui';
|
|
|
|
import 'uview-ui/theme.scss';
|
|
|
|
import store from './store'; // 引入 Vuex Store
|
|
|
|
import http from './common/api.js';
|
|
|
|
import MyRequest from 'common/MyRequest.js';
|
2025-03-10 13:49:13 +08:00
|
|
|
|
2025-03-11 09:45:29 +08:00
|
|
|
Vue.use(Vuex);
|
|
|
|
Vue.use(uView);
|
|
|
|
import uniDatetimePicker from '@dcloudio/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue';
|
|
|
|
|
|
|
|
Vue.component('uni-datetime-picker', uniDatetimePicker);
|
|
|
|
|
|
|
|
// 挂载到 Vue 实例上
|
|
|
|
Vue.prototype.$http = http;
|
|
|
|
Vue.prototype.$MyRequest = MyRequest;
|
2025-03-10 13:49:13 +08:00
|
|
|
|
2025-03-11 09:45:29 +08:00
|
|
|
/**
|
|
|
|
* 用户相关信息
|
|
|
|
*/
|
|
|
|
Vue.prototype.$login = {
|
|
|
|
appName: "ziWMS", // app名称
|
|
|
|
userid: store.state.userid, // 用户id
|
|
|
|
username: store.state.username, // 用户名称
|
|
|
|
sitename: store.state.sitename, // 账号
|
|
|
|
version: store.state, // app版本
|
|
|
|
tokenId: store.state.token, // 令牌id
|
|
|
|
};
|
2025-03-10 13:49:13 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取剩余高度
|
|
|
|
* @param {输入控件数量} count
|
|
|
|
* @param {微调值} fineTuning
|
|
|
|
* @param {单个控件标准高度} standardHeight
|
|
|
|
*/
|
2025-03-11 09:45:29 +08:00
|
|
|
Vue.prototype.$GetRemainingHeight = function(count, fineTuning, standardHeight) {
|
|
|
|
let h = 0;
|
|
|
|
// 设备硬件通讯
|
|
|
|
uni.getSystemInfo({
|
|
|
|
success: function(res) {
|
|
|
|
if (!standardHeight) {
|
|
|
|
standardHeight = 50;
|
|
|
|
}
|
|
|
|
h = res.windowHeight - (count * standardHeight + fineTuning);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return h;
|
|
|
|
};
|
2025-03-10 13:49:13 +08:00
|
|
|
|
2025-03-11 09:45:29 +08:00
|
|
|
/**
|
|
|
|
* 显示消息弹框
|
|
|
|
* @param {消息内容} msg
|
|
|
|
* @param {显示时间} interval
|
|
|
|
*/
|
|
|
|
Vue.prototype.$showMessage = function(msg, interval) {
|
|
|
|
if (!msg) {
|
|
|
|
console.log('弹框信息为空,不进行实际弹框操作');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!interval) {
|
|
|
|
interval = 1000; // 三秒
|
|
|
|
}
|
|
|
|
uni.showToast({
|
|
|
|
icon: 'none',
|
|
|
|
title: msg,
|
|
|
|
duration: interval,
|
|
|
|
});
|
|
|
|
};
|
2025-03-10 13:49:13 +08:00
|
|
|
|
2025-03-11 09:45:29 +08:00
|
|
|
Vue.prototype.$showMessage = function(message, type) {
|
|
|
|
// 实现弹框逻辑
|
|
|
|
console.log('Show message:', message, type);
|
|
|
|
// 使用 uView 或其他 UI 库显示消息
|
|
|
|
uni.showToast({
|
|
|
|
icon: type,
|
|
|
|
title: message,
|
|
|
|
duration: 1000,
|
2025-03-10 13:49:13 +08:00
|
|
|
});
|
2025-03-11 09:45:29 +08:00
|
|
|
};
|
2025-03-10 13:49:13 +08:00
|
|
|
|
|
|
|
|
2025-03-11 09:45:29 +08:00
|
|
|
/**
|
|
|
|
* 播放成功提示音
|
|
|
|
*/
|
|
|
|
Vue.prototype.$playSuccess = function() {
|
|
|
|
this.$play('success');
|
|
|
|
};
|
2025-03-10 13:49:13 +08:00
|
|
|
|
2025-03-11 09:45:29 +08:00
|
|
|
/**
|
|
|
|
* 播放失败提示音
|
|
|
|
*/
|
|
|
|
Vue.prototype.$playFail = function() {
|
|
|
|
this.$play('fail');
|
|
|
|
};
|
2025-03-10 13:49:13 +08:00
|
|
|
|
2025-03-11 09:45:29 +08:00
|
|
|
/**
|
|
|
|
* 提示音
|
|
|
|
* @param {标志} flag
|
|
|
|
*/
|
|
|
|
Vue.prototype.$play = function(flag) {
|
|
|
|
var playPath = '';
|
|
|
|
if (flag === 'success') {
|
|
|
|
playPath = 'static/voice/success.wav';
|
|
|
|
} else {
|
|
|
|
// 长震动(苹果只有长震动)
|
|
|
|
uni.vibrateLong({
|
|
|
|
success: function() {
|
|
|
|
console.log('success');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
playPath = 'static/voice/fail.wav';
|
|
|
|
}
|
|
|
|
const innerAudioContext = uni.createInnerAudioContext();
|
|
|
|
innerAudioContext.autoplay = true;
|
|
|
|
innerAudioContext.src = playPath;
|
|
|
|
innerAudioContext.onPlay(() => {
|
|
|
|
// console.log('开始播放');
|
|
|
|
});
|
|
|
|
innerAudioContext.onError((res) => {
|
|
|
|
console.log("声音播放失败:" + res);
|
|
|
|
});
|
|
|
|
};
|
2025-03-10 13:49:13 +08:00
|
|
|
|
2025-03-11 09:45:29 +08:00
|
|
|
Vue.config.productionTip = false;
|
2025-03-10 13:49:13 +08:00
|
|
|
|
2025-03-11 09:45:29 +08:00
|
|
|
App.mpType = 'app';
|
2025-03-10 13:49:13 +08:00
|
|
|
|
|
|
|
const app = new Vue({
|
2025-03-11 09:45:29 +08:00
|
|
|
...App,
|
|
|
|
store
|
|
|
|
});
|
|
|
|
app.$mount();
|