142 lines
3.7 KiB
JavaScript
142 lines
3.7 KiB
JavaScript
|
|
import Vue from 'vue'
|
|||
|
|
import store from './store'
|
|||
|
|
import App from './App'
|
|||
|
|
import apis from '@/common/vmeitime-http/'
|
|||
|
|
|
|||
|
|
import Json from './Json' //测试用数据
|
|||
|
|
import common from './common/common.js'
|
|||
|
|
import cuCustom from './components/cu-custom.vue'
|
|||
|
|
import Vant from 'vant';
|
|||
|
|
import 'vant/lib/index.less';
|
|||
|
|
Vue.component('cu-custom', cuCustom);
|
|||
|
|
import foodCustom from './components/food-custom.vue'
|
|||
|
|
Vue.component('food-custom', foodCustom);
|
|||
|
|
Vue.prototype.$noMultipleClicks = common.noMultipleClicks;
|
|||
|
|
|
|||
|
|
|
|||
|
|
Vue.use(Vant);
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 因工具函数属于公司资产, 所以直接在Vue实例挂载几个常用的函数
|
|||
|
|
* 所有测试用数据均存放于根目录json.js
|
|||
|
|
*
|
|||
|
|
* css部分使用了App.vue下的全局样式和iconfont图标,有需要图标库的可以留言。
|
|||
|
|
* 示例使用了uni.scss下的变量, 除变量外已尽量移除特有语法,可直接替换为其它预处理器使用
|
|||
|
|
*/
|
|||
|
|
// #ifdef H5
|
|||
|
|
// 提交前需要注释 本地调试使用
|
|||
|
|
let vconShow = uni.getStorageSync('1001093_vconShow') == null ? '0' : uni.getStorageSync('1001093_vconShow');
|
|||
|
|
if (vconShow != 0) {
|
|||
|
|
const vconsole = require('vconsole')
|
|||
|
|
Vue.prototype.$vconsole = new vconsole() // 使用vconsole
|
|||
|
|
}
|
|||
|
|
// #endif
|
|||
|
|
|
|||
|
|
|
|||
|
|
// if (/(Android)/i.test(navigator.userAgent)) {
|
|||
|
|
// Vue.prototype.wxSdk=jWeixin;
|
|||
|
|
// }
|
|||
|
|
// if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
|
|||
|
|
// Vue.prototype.wxSdk=wx;
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
|
|||
|
|
const msg = (title, duration = 2500, mask = false, icon = 'none') => {
|
|||
|
|
//统一提示方便全局修改
|
|||
|
|
if (Boolean(title) === false) {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
uni.showToast({
|
|||
|
|
title,
|
|||
|
|
duration,
|
|||
|
|
mask,
|
|||
|
|
icon
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
const json = type => {
|
|||
|
|
//模拟异步请求数据
|
|||
|
|
return new Promise(resolve => {
|
|||
|
|
setTimeout(() => {
|
|||
|
|
resolve(Json[type]);
|
|||
|
|
}, 500)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const prePage = () => {
|
|||
|
|
let pages = getCurrentPages();
|
|||
|
|
let prePage = pages[pages.length - 2];
|
|||
|
|
// #ifdef H5
|
|||
|
|
return prePage;
|
|||
|
|
// #endif
|
|||
|
|
return prePage.$vm;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const formatter = (value) => {
|
|||
|
|
if (/\D/.test(value)) return `${value}`;
|
|||
|
|
if (value >= 10000) return `${(value / 10000).toFixed(2)}万`;
|
|||
|
|
return `${value}`;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const serviceUrl = "http://localhost:8080/";
|
|||
|
|
|
|||
|
|
Vue.config.productionTip = false
|
|||
|
|
Vue.prototype.$fire = new Vue();
|
|||
|
|
Vue.prototype.$store = store;
|
|||
|
|
Vue.prototype.$api = {
|
|||
|
|
msg,
|
|||
|
|
json,
|
|||
|
|
prePage,
|
|||
|
|
formatter,
|
|||
|
|
serviceUrl
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
App.mpType = 'app'
|
|||
|
|
|
|||
|
|
Vue.prototype.$apis = apis
|
|||
|
|
|
|||
|
|
// 开发模式
|
|||
|
|
Vue.prototype.ISDEV = true
|
|||
|
|
|
|||
|
|
/* let jweixin = require('ts-jwsdk') ;
|
|||
|
|
Vue.prototype.$wx = jweixin; */
|
|||
|
|
|
|||
|
|
const app = new Vue({
|
|||
|
|
...App
|
|||
|
|
})
|
|||
|
|
app.$mount()
|
|||
|
|
|
|||
|
|
//记录选择图片备份
|
|||
|
|
// wx.chooseImage({
|
|||
|
|
// count: 3, // 默认9
|
|||
|
|
// sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|||
|
|
// sourceType: ['camera'], // 可以指定来源是相册还是相机,默认二者都有
|
|||
|
|
// quality: 0.7, //压缩质量,范围0~1,数值越小,质量越低,压缩率越高(仅对jpg有效)
|
|||
|
|
// success: function (res) {
|
|||
|
|
// let localIds = res.localIds; // 返回选定照片的本地ID列表
|
|||
|
|
// if(typeof localIds=='string'){
|
|||
|
|
// wxSdk.getLocalImgData({
|
|||
|
|
// localId: localIds, // 图片的localID
|
|||
|
|
// success: function (res) {
|
|||
|
|
// var localData = res.localData; // localData是图片的base64数据,可以用img标签显示
|
|||
|
|
// if(_this.imgs.length<3){
|
|||
|
|
// _this.imgs.push(localData);
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// });
|
|||
|
|
// }else{
|
|||
|
|
// for(var i=0;i<localIds.length;i++){
|
|||
|
|
// wxSdk.getLocalImgData({
|
|||
|
|
// localId: localIds[i], // 图片的localID
|
|||
|
|
// success: function (res) {
|
|||
|
|
// var localData = res.localData; // localData是图片的base64数据,可以用img标签显示
|
|||
|
|
// if(_this.imgs.length<3){
|
|||
|
|
// _this.imgs.push(localData);
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// });
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
// }
|
|||
|
|
// });
|