hz-zhhq-app/main.js

142 lines
3.7 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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, //压缩质量范围01数值越小质量越低压缩率越高仅对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);
// }
// }
// });
// }
// }
// }
// });