123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- // import config from "./config"
- // import store from "@/store/index.js"
- import {
- Decimal
- } from 'decimal.js'
- import config from "./config.js"
- export const setToken = (tokenVal) => {
- try {
- uni.setStorageSync(config.tokenKey, tokenVal);
- } catch (e) {
- // error
- }
- }
- export const getToken = () => {
- try {
- const value = uni.getStorageSync(config.tokenKey);
- return value || ''
- } catch (e) {
- // error
- }
- }
- // 判断是否登录
- export const ifLogin_ = () => {
- return new Promise((resolve, reject) => {
- if (getToken()) {
- resolve()
- } else {
- uni.navigateTo({
- url: '/pages/login/index'
- });
- reject()
- };
- })
- };
- export const reverseBack = () => {
- const pages = getCurrentPages()
- if (pages.length <= 1) {
- uni.reLaunch({
- url: '/pages/index/index'
- });
- } else {
- uni.navigateBack({
- delta: 1,
- fail: err => {}
- })
- }
- }
- export const decimalNum = {
- // 加法
- add:(a , b) => {
- return new Decimal(a).add(new Decimal(b))
- },
- // 减法
- sub:(a , b) => {
- return new Decimal(a).sub(new Decimal(b))
- },
- // 乘法
- mul:(a , b) => {
- return new Decimal(a).mul(new Decimal(b))
- },
- // 除法
- div:(a , b) => {
- return new Decimal(a).div(new Decimal(b))
- },
-
- // // 加法
- // let c = new Decimal(a).add(new Decimal(b))
- // // 减法
- // let d = new Decimal(a).sub(new Decimal(b))
- // // 乘法
- // let e = new Decimal(a).mul(new Decimal(b))
- // // 除法
- // let f = new Decimal(a).div(new Decimal(b))
-
- }
|