| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- import Vue from 'vue'
- import App from './App'
- Vue.config.productionTip = false
- // import uView from "uview-ui";
- // Vue.use(uView);
- import md5 from 'js-md5';
- Vue.prototype.$md5 = md5;
- import dayjs from 'dayjs';
- Vue.prototype.$day = dayjs;
- import cof from '@/static/config/in';
- Vue.prototype.$cof = cof;
- // 微信全局分享
- import share from '@/utils/share.js'
- Vue.mixin(share)
- // js高精度计算
- import highPrecision from "@/utils/highPrecision";
- Vue.prototype.$h = highPrecision;
- Vue.prototype.tidyTpye = (da) => {
- switch(da) {
- case '1': return "零售专区";
- case '2': return "批发专区";
- case '3': return "精品专区";
- case '4': return "今日值得买";
- case '5': return "茶宝兑换";
- case '6': return "天天捡漏";
- default: return ""
- }
- }
- Number.prototype.toFixed = function (n) {
-
- if (n > 20 || n < 0) {
- throw new RangeError('toFixed() digits argument must be between 0 and 20');
- }
- const number = this;
- if (isNaN(number) || number >= Math.pow(10, 21)) {
- return number.toString();
- }
-
- if (typeof (n) == 'undefined' || n == 0) {
- return (Math.round(number)).toString();
- }
- let result = number.toString();
- const arr = result.split('.');
- // 整数的情况
- if (arr.length < 2) {
- result += '.';
- for (let i = 0; i < n; i += 1) {
- result += '0';
- }
- return result;
- }
- const integer = arr[0];
- const decimal = arr[1];
- if (decimal.length == n) {
- return result;
- }
-
- if (decimal.length < n) {
- for (let i = 0; i < n - decimal.length; i += 1) {
- result += '0';
- }
- return result;
- }
- result = integer + '.' + decimal.substr(0, n);
- const last = decimal.substr(n, 1);
- // 四舍五入,转换为整数再处理,避免浮点数精度的损失
- if (parseInt(last, 10) >= 5) {
- const x = Math.pow(10, n);
- result = (Math.round((parseFloat(result) * x)) + 1) / x;
- result = result.toFixed(n);
- }
- return result;
- }
- // 自动适配接口域名
- import hosts from "@/request/config";
- Vue.prototype.$hosts = hosts;
- // 上传
- import { up } from "@/utils/up";
- Vue.prototype.$up = up;
- // 页面跳转
- import { goto } from '@/utils/myfun.js';
- Vue.prototype.goto = goto;
- App.mpType = 'app'
- const app = new Vue({
- ...App
- })
- app.$mount()
- Array.prototype.indexOf = function (val) {
- for (var i = 0; i < this.length; i++) {
- if (this[i] == val) return i;
- }
- return -1;
- };
- Array.prototype.remove = function (val) {
- var index = this.indexOf(val);
- if (index > -1) {
- this.splice(index, 1);
- }
- };
- Vue.directive('focus', {
- inserted: (el, binding) => {
- if (binding.value == true || binding.value == undefined) {
- el.focus()
- }
- }
- });
|