邓雄飞 4 years ago
parent
commit
86c5c9264b
9 changed files with 547 additions and 401 deletions
  1. 2
      components/scroll-list/scroll-list.vue
  2. 762
      pages.json
  3. 2
      pages/login/index.vue
  4. 18
      pages/mall/index.vue
  5. 2
      pages/mine/index.vue
  6. 2
      pages/setting/index.vue
  7. 40
      pages/submit-quotation/index.vue
  8. 4
      utils/hook.js
  9. 116
      utils/index.js

2
components/scroll-list/scroll-list.vue

@ -624,7 +624,7 @@ export default {
align-items: center; align-items: center;
flex-direction: column; flex-direction: column;
.empty-view { .empty-view {
margin: auto;
// margin: auto;
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 400rpx; margin-bottom: 400rpx;

762
pages.json

@ -1,381 +1,385 @@
{ {
"pages": [{
"path": "pages/start-page/index",
"style": {
"navigationBarTitleText": "启动页",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
}, {
"path": "pages/client/index",
"style": {
"navigationBarTitleText": "客户",
"navigationStyle": "custom"
}
},
{
"path": "pages/client-list/index",
"style": {
"navigationBarTitleText": "客户列表",
"navigationStyle": "custom"
}
},
{
"path": "pages/search/index",
"style": {
"navigationBarTitleText": "客户搜索",
"navigationStyle": "custom"
}
},
{
"path": "pages/add-user/index",
"style": {
"navigationBarTitleText": "添加客户",
"navigationStyle": "custom"
}
},
{
"path": "pages/trade/index",
"style": {
"navigationBarTitleText": "交易",
"navigationStyle": "custom"
}
},
{
"path": "pages/mall/index",
"style": {
"navigationBarTitleText": "商城",
"navigationStyle": "custom"
}
},
{
"path": "pages/mine/index",
"style": {
"navigationBarTitleText": "我的",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/login/index",
"style": {
"navigationBarTitleText": "登录",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/enterprise-info/index",
"style": {
"navigationBarTitleText": "完善企业信息",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/toggle-supplier/index",
"style": {
"navigationBarTitleText": "切换供应商",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/message/index",
"style": {
"navigationBarTitleText": "消息中心",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/order-detail/index",
"style": {
"navigationBarTitleText": "订单详情",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/setting/index",
"style": {
"navigationBarTitleText": "系统设置",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/agreement/index",
"style": {
"navigationBarTitleText": "用户与隐私协议",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/client-detail/index",
"style": {
"navigationBarTitleText": "客户详情",
"navigationStyle": "custom"
}
},
{
"path": "pages/client-credit/index",
"style": {
"navigationBarTitleText": "客户授信",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/month-credit/index",
"style": {
"navigationBarTitleText": "月结授信",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/fs-credit/index",
"style": {
"navigationBarTitleText": "飞算授信",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/guarantee-agreement/index",
"style": {
"navigationBarTitleText": "担保协议",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/client-credit-limit/index",
"style": {
"navigationBarTitleText": "授信额度",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/client-credit-list/index",
"style": {
"navigationBarTitleText": "客户授信列表",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/client-credit-detail/index",
"style": {
"navigationBarTitleText": "授信信息",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/my-offer/index",
"style": {
"navigationBarTitleText": "我的报价",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/submit-quotation/index",
"style": {
"navigationBarTitleText": "提交报价",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/quotation-details/index",
"style": {
"navigationBarTitleText": "报价详情",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/switching-mall/index",
"style": {
"navigationBarTitleText": "切换商城",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/add-paper/index",
"style": {
"navigationBarTitleText": "添加纸品",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/page-view/index",
"style": {
"navigationBarTitleText": "统一第三方页面",
"enablePullDownRefresh": false
}
},
{
"path": "pages/credit-management/index",
"style": {
"navigationBarTitleText": "征信管理",
"navigationStyle": "custom"
}
},
{
"path": "pages/credit-order-list/index",
"style": {
"navigationBarTitleText": "账期订单融资",
"navigationStyle": "custom"
}
},
{
"path": "pages/contract-manage/index",
"style": {
"navigationBarTitleText": "合同管理",
"navigationStyle": "custom"
}
},
{
"path": "pages/store-settings/index",
"style": {
"navigationBarTitleText": "店铺设置",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/follow-up-records/index",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "跟进记录"
}
},
{
"path": "pages/add-record/index",
"style": {
"navigationBarTitleText": "新增跟进记录",
"navigationStyle": "custom"
}
},
{
"path": "pages/paper-detail/index",
"style": {
"navigationBarTitleText": "纸商城详情",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/platform-message-info/index",
"style": {
"navigationBarTitleText": "平台公告详情",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/user-info/index",
"style": {
"navigationBarTitleText": "用户名",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/about/index",
"style": {
"navigationBarTitleText": "关于",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/user-info/index",
"style": {
"navigationBarTitleText": "用户名",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/about/index",
"style": {
"navigationBarTitleText": "关于",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/account-management/index",
"style": {
"navigationBarTitleText": "账号管理",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/add-account/index",
"style": {
"navigationBarTitleText": "新增企业账号",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8",
"backgroundColorTop": "#FFFFFF"
},
"tabBar": {
"color": "#888",
"selectedColor": "#007AFF",
"borderStyle": "white",
"backgroundColor": "#f9f9f9",
"list": [{
"pagePath": "pages/client/index",
"iconPath": "static/imgs/tabbar/client-gray.png",
"selectedIconPath": "static/imgs/tabbar/client-blue.png",
"text": "客户"
},
{
"pagePath": "pages/trade/index",
"iconPath": "static/imgs/tabbar/trade-gray.png",
"selectedIconPath": "static/imgs/tabbar/trade-blue.png",
"text": "交易"
},
{
"pagePath": "pages/mall/index",
"iconPath": "static/imgs/tabbar/mall-gray.png",
"selectedIconPath": "static/imgs/tabbar/mall-blue.png",
"text": "纸商城"
},
{
"pagePath": "pages/mine/index",
"iconPath": "static/imgs/tabbar/mine-gray.png",
"selectedIconPath": "static/imgs/tabbar/mine-blue.png",
"text": "我的"
}
]
},
"condition": {
//
"current": 0, //(list )
"list": [{
"name": "", //
"path": "", //
"query": "" //onLoad
}]
}
"pages": [
{
"path": "pages/start-page/index",
"style": {
"navigationBarTitleText": "启动页",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/client/index",
"style": {
"navigationBarTitleText": "客户",
"navigationStyle": "custom"
}
},
{
"path": "pages/client-list/index",
"style": {
"navigationBarTitleText": "客户列表",
"navigationStyle": "custom"
}
},
{
"path": "pages/search/index",
"style": {
"navigationBarTitleText": "客户搜索",
"navigationStyle": "custom"
}
},
{
"path": "pages/add-user/index",
"style": {
"navigationBarTitleText": "添加客户",
"navigationStyle": "custom"
}
},
{
"path": "pages/trade/index",
"style": {
"navigationBarTitleText": "交易",
"navigationStyle": "custom"
}
},
{
"path": "pages/mall/index",
"style": {
"navigationBarTitleText": "商城",
"navigationStyle": "custom"
}
},
{
"path": "pages/mine/index",
"style": {
"navigationBarTitleText": "我的",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/login/index",
"style": {
"navigationBarTitleText": "登录",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/enterprise-info/index",
"style": {
"navigationBarTitleText": "完善企业信息",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/toggle-supplier/index",
"style": {
"navigationBarTitleText": "切换供应商",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/message/index",
"style": {
"navigationBarTitleText": "消息中心",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/order-detail/index",
"style": {
"navigationBarTitleText": "订单详情",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/setting/index",
"style": {
"navigationBarTitleText": "系统设置",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/agreement/index",
"style": {
"navigationBarTitleText": "用户与隐私协议",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/client-detail/index",
"style": {
"navigationBarTitleText": "客户详情",
"navigationStyle": "custom"
}
},
{
"path": "pages/client-credit/index",
"style": {
"navigationBarTitleText": "客户授信",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/month-credit/index",
"style": {
"navigationBarTitleText": "月结授信",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/fs-credit/index",
"style": {
"navigationBarTitleText": "飞算授信",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/guarantee-agreement/index",
"style": {
"navigationBarTitleText": "担保协议",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/client-credit-limit/index",
"style": {
"navigationBarTitleText": "授信额度",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/client-credit-list/index",
"style": {
"navigationBarTitleText": "客户授信列表",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/client-credit-detail/index",
"style": {
"navigationBarTitleText": "授信信息",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/my-offer/index",
"style": {
"navigationBarTitleText": "我的报价",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/submit-quotation/index",
"style": {
"navigationBarTitleText": "提交报价",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/quotation-details/index",
"style": {
"navigationBarTitleText": "报价详情",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/switching-mall/index",
"style": {
"navigationBarTitleText": "切换商城",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/add-paper/index",
"style": {
"navigationBarTitleText": "添加纸品",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/page-view/index",
"style": {
"navigationBarTitleText": "统一第三方页面",
"enablePullDownRefresh": false
}
},
{
"path": "pages/credit-management/index",
"style": {
"navigationBarTitleText": "征信管理",
"navigationStyle": "custom"
}
},
{
"path": "pages/credit-order-list/index",
"style": {
"navigationBarTitleText": "账期订单融资",
"navigationStyle": "custom"
}
},
{
"path": "pages/contract-manage/index",
"style": {
"navigationBarTitleText": "合同管理",
"navigationStyle": "custom"
}
},
{
"path": "pages/store-settings/index",
"style": {
"navigationBarTitleText": "店铺设置",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/follow-up-records/index",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "跟进记录"
}
},
{
"path": "pages/add-record/index",
"style": {
"navigationBarTitleText": "新增跟进记录",
"navigationStyle": "custom"
}
},
{
"path": "pages/paper-detail/index",
"style": {
"navigationBarTitleText": "纸商城详情",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/platform-message-info/index",
"style": {
"navigationBarTitleText": "平台公告详情",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/user-info/index",
"style": {
"navigationBarTitleText": "用户名",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/about/index",
"style": {
"navigationBarTitleText": "关于",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/user-info/index",
"style": {
"navigationBarTitleText": "用户名",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/about/index",
"style": {
"navigationBarTitleText": "关于",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/account-management/index",
"style": {
"navigationBarTitleText": "账号管理",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/add-account/index",
"style": {
"navigationBarTitleText": "新增企业账号",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8",
"backgroundColorTop": "#FFFFFF"
},
"tabBar": {
"color": "#888",
"selectedColor": "#007AFF",
"borderStyle": "white",
"backgroundColor": "#f9f9f9",
"list": [
{
"pagePath": "pages/client/index",
"iconPath": "static/imgs/tabbar/client-gray.png",
"selectedIconPath": "static/imgs/tabbar/client-blue.png",
"text": "客户"
},
{
"pagePath": "pages/trade/index",
"iconPath": "static/imgs/tabbar/trade-gray.png",
"selectedIconPath": "static/imgs/tabbar/trade-blue.png",
"text": "交易"
},
{
"pagePath": "pages/mall/index",
"iconPath": "static/imgs/tabbar/mall-gray.png",
"selectedIconPath": "static/imgs/tabbar/mall-blue.png",
"text": "纸商城"
},
{
"pagePath": "pages/mine/index",
"iconPath": "static/imgs/tabbar/mine-gray.png",
"selectedIconPath": "static/imgs/tabbar/mine-blue.png",
"text": "我的"
}
]
},
"condition": {
//
"current": 0, //(list )
"list": [
{
"name": "", //
"path": "", //
"query": "" //onLoad
}
]
}
} }

2
pages/login/index.vue

@ -1,5 +1,5 @@
<template> <template>
<view style="background-color: white">
<view style="background-color: white; height: 100vh">
<uni-nav-bar :fixed="true" color="#ffffff" background-color="#ffffff" :status-bar="true" :border="false" left-icon="closeempty" @clickLeft="close" /> <uni-nav-bar :fixed="true" color="#ffffff" background-color="#ffffff" :status-bar="true" :border="false" left-icon="closeempty" @clickLeft="close" />
<view class="logo_area"> <view class="logo_area">
<image class="logo" src="/static/logo.png"></image> <image class="logo" src="/static/logo.png"></image>

18
pages/mall/index.vue

@ -68,10 +68,10 @@
<uni-nav-bar :fixed="true" :status-bar="true"> <uni-nav-bar :fixed="true" :status-bar="true">
<view slot="left" style="font-size: 40rpx; color: #000000">纸商城</view> <view slot="left" style="font-size: 40rpx; color: #000000">纸商城</view>
</uni-nav-bar> </uni-nav-bar>
<view v-if="!hasCompany" class="flex-col-center-center" style="margin-top: 100rpx">
<view v-if="hasLogin && !hasCompany" class="flex-col-center-center" style="margin-top: 100rpx">
<text style="font-size: 30rpx; text-align: center; font-weight: 600">请先完善企业基本信息</text> <text style="font-size: 30rpx; text-align: center; font-weight: 600">请先完善企业基本信息</text>
</view> </view>
<view class="" v-if="!hasLogin"><not-logged @loginChange="loginChange()"></not-logged></view>
<view class="" v-if="!hasLogin"><not-logged @loginChange="loginChange()"></not-logged></view>
</view> </view>
<view class="share-area" v-if="visible" @click="closeShare"> <view class="share-area" v-if="visible" @click="closeShare">
<view class="share-content"> <view class="share-content">
@ -92,7 +92,7 @@
</template> </template>
<script> <script>
import notLogged from '@/components/not-logged/not-logged.vue'
import notLogged from '@/components/not-logged/not-logged.vue'
import uGap from '@/components/u-gap/u-gap.vue' import uGap from '@/components/u-gap/u-gap.vue'
import { back, go2, loginGo2, screenShot } from '@/utils/hook.js' import { back, go2, loginGo2, screenShot } from '@/utils/hook.js'
import { SupplierList, productStatus, storeDetail, getSupplierQrCode } from '@/apis/add-paper.js' import { SupplierList, productStatus, storeDetail, getSupplierQrCode } from '@/apis/add-paper.js'
@ -153,9 +153,9 @@ export default {
hasCompany() { hasCompany() {
return this.$store.state.supplierInfo.id != null return this.$store.state.supplierInfo.id != null
}, },
hasLogin() {
return this.$store.state.qnToken != ''
}
hasLogin() {
return this.$store.state.qnToken != ''
}
}, },
onShow() { onShow() {
if (this.hasCompany) { if (this.hasCompany) {
@ -168,9 +168,9 @@ export default {
}, },
methods: { methods: {
back, back,
loginChange() {
go2('login')
},
loginChange() {
go2('login')
},
// //
makeScreenShot() { makeScreenShot() {
screenShot() screenShot()

2
pages/mine/index.vue

@ -31,7 +31,7 @@
</view> </view>
</view> </view>
<view class="operation"> <view class="operation">
<view class="box">
<view class="box" v-if="hasLogin">
<view class="container" @click="go2('message')"> <view class="container" @click="go2('message')">
<image class="icon" src="/static/imgs/mine/msg-icon.png"></image> <image class="icon" src="/static/imgs/mine/msg-icon.png"></image>
<view v-if="messageNum > 0" class="number"> <view v-if="messageNum > 0" class="number">

2
pages/setting/index.vue

@ -19,7 +19,7 @@
</view> </view>
<qn-footer fixed height="120"> <qn-footer fixed height="120">
<view class="flex-row-center-center"> <view class="flex-row-center-center">
<view class="button flex-row-center-center" @click="exit">
<view class="button flex-row-center-center" @click="exit(true)">
<text class="text">退出登录</text> <text class="text">退出登录</text>
</view> </view>
</view> </view>

40
pages/submit-quotation/index.vue

@ -154,7 +154,7 @@
<view class="submit-popup-close submit-number-box"> <view class="submit-popup-close submit-number-box">
<view class=""><view class="submit-popup-title">购买数量()</view></view> <view class=""><view class="submit-popup-title">购买数量()</view></view>
<view class="submit-number-line"> <view class="submit-number-line">
<uni-number-box v-model="addObj.quantity"></uni-number-box>
<uni-number-box :max="100000000" v-model="addObj.quantity"></uni-number-box>
<text class="submit-number-text">预估重量{{ round(addObj.gramWeight * addObj.width * addObj.length * addObj.quantity * 1e-12, 4) }}</text> <text class="submit-number-text">预估重量{{ round(addObj.gramWeight * addObj.width * addObj.length * addObj.quantity * 1e-12, 4) }}</text>
</view> </view>
</view> </view>
@ -446,9 +446,37 @@ export default {
}, },
// //
sureModifyPaper() { sureModifyPaper() {
this.$refs.popup.close()
//
if (!this.addObj.unitFee) {
this.addObj.unitFee = 0
}
let fields = [
{ name: '克重', value: 'gramWeight' },
{ name: '宽度', value: 'width' },
{ name: '长度', value: 'length' },
{ name: '纸品数量', value: 'quantity' }
]
for (let i = 0; i < fields.length; i++) {
if (!this.addObj[fields[i].value]) {
uni.showToast({
title: fields[i].name + '不能为空',
icon: 'none'
})
return
}
}
// //
this.addObj.weight = round(this.addObj.gramWeight * this.addObj.width * this.addObj.length * this.addObj.quantity * 1e-12, 4) this.addObj.weight = round(this.addObj.gramWeight * this.addObj.width * this.addObj.length * this.addObj.quantity * 1e-12, 4)
if (!this.addObj.weight || this.addObj.weight == 0) {
uni.showToast({
title: '纸品重量不能为0',
icon: 'none'
})
return
}
this.$refs.popup.close()
//
this.addObj.totalPrice = round(this.addObj.unitFee * this.addObj.weight, 2)
this.upDataObj.itemList[this.modifyIndex] = JSON.parse(JSON.stringify(this.addObj)) this.upDataObj.itemList[this.modifyIndex] = JSON.parse(JSON.stringify(this.addObj))
this.upDataObj = JSON.parse(JSON.stringify(this.upDataObj)) this.upDataObj = JSON.parse(JSON.stringify(this.upDataObj))
@ -461,9 +489,12 @@ export default {
}, },
// //
pricesSure() { pricesSure() {
if (!this.prices.otherFee) {
this.prices.otherFee = 0
}
this.$set(this.upDataObj.itemList[this.pricesIndex], 'otherFee', this.prices.otherFee) this.$set(this.upDataObj.itemList[this.pricesIndex], 'otherFee', this.prices.otherFee)
this.$set(this.upDataObj.itemList[this.pricesIndex], 'unitFee', this.prices.unitFee) this.$set(this.upDataObj.itemList[this.pricesIndex], 'unitFee', this.prices.unitFee)
var abs = round(this.prices.unitFee * this.prices.weight + (this.prices.otherFee - 0), 2)
var abs = round(this.prices.unitFee * this.prices.weight, 2)
this.$set(this.upDataObj.itemList[this.pricesIndex], 'totalPrice', round(abs, 2)) this.$set(this.upDataObj.itemList[this.pricesIndex], 'totalPrice', round(abs, 2))
this.upDataObj = JSON.parse(JSON.stringify(this.upDataObj)) this.upDataObj = JSON.parse(JSON.stringify(this.upDataObj))
this.$refs.popupPrice.close() this.$refs.popupPrice.close()
@ -479,6 +510,7 @@ export default {
var otherFee = parseFloat(this.upDataObj.otherFee) + parseFloat(this.upDataObj.itemList[i].otherFee) var otherFee = parseFloat(this.upDataObj.otherFee) + parseFloat(this.upDataObj.itemList[i].otherFee)
this.upDataObj.otherFee = round(otherFee, 2) this.upDataObj.otherFee = round(otherFee, 2)
} }
this.upDataObj.totalAllPrice = round(this.upDataObj.totalAllPrice + this.upDataObj.otherFee, 2)
}, },
// //
updateQuery() { updateQuery() {
@ -754,7 +786,7 @@ export default {
.submit-btn { .submit-btn {
width: 686rpx; width: 686rpx;
height: 96rpx; height: 96rpx;
line-height: 96rpx;
line-height: 96rpx;
background: #007aff; background: #007aff;
border-radius: 10rpx; border-radius: 10rpx;
.text { .text {

4
utils/hook.js

@ -87,9 +87,9 @@ export function loginGo2(url, data = {}, isRedirect) {
* 退出登录并跳转到登录页面 * 退出登录并跳转到登录页面
* @return {null} * @return {null}
*/ */
export function exit() {
export function exit(redirect = false) {
store.dispatch('logout') store.dispatch('logout')
go2('login')
go2('login', {}, redirect)
} }
/** /**

116
utils/index.js

@ -157,9 +157,14 @@ export const makeSocket = async ({ pageInfo = '', retry = false }) => {
* @value {number} num 需要四舍五入的数字 * @value {number} num 需要四舍五入的数字
* @value {number} precision 小数点后保留的位数 * @value {number} precision 小数点后保留的位数
*/ */
export function round(number, precision) {
return Math.round(+number + 'e' + precision) / Math.pow(10, precision)
}
// export function round(number, precision) {
// let number = number + ''
// if(number.includes('e')) {
// number = number.split('e')[0]
// }
// return Math.round(+number + 'e' + precision) / Math.pow(10, precision)
// }
/** /**
* {beyond:是否超出目标时间,day:,hours:小时,minutes:分钟,seconds:秒钟} * {beyond:是否超出目标时间,day:,hours:小时,minutes:分钟,seconds:秒钟}
@ -197,3 +202,108 @@ export const difTime = (time, target) => {
seconds seconds
} }
} }
/**
* 迭代操作
*/
function iteratorOperation(arr, operation) {
const [num1, num2, ...others] = arr
let res = operation(num1, num2)
others.forEach((num) => {
res = operation(res, num)
})
return res
}
/**
* Return digits length of a number
* @param {*number} num Input number
*/
function digitLength(num) {
// Get digit length of e
const eSplit = num.toString().split(/[eE]/)
const len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0)
return len > 0 ? len : 0
}
/**
* 把错误的数据转正
* strip(0.09999999999999998)=0.1
*/
function strip(num, precision = 15) {
return +parseFloat(Number(num).toPrecision(precision))
}
/**
* 把小数转成整数支持科学计数法如果是小数则放大成整数
* @param {*number} num 输入数
*/
function float2Fixed(num) {
if (num.toString().indexOf('e') === -1) {
return Number(num.toString().replace('.', ''))
}
const dLen = digitLength(num)
return dLen > 0 ? strip(Number(num) * Math.pow(10, dLen)) : Number(num)
}
/**
* 检测数字是否越界如果越界给出提示
* @param {*number} num 输入数
*/
function checkBoundary(num) {
if (_boundaryCheckingState) {
if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) {
console.warn(`${num} is beyond boundary when transfer to integer, the results may not be accurate`)
}
}
}
/**
* 精确乘法
*/
function times(...nums) {
if (nums.length > 2) {
return iteratorOperation(nums, times)
}
const [num1, num2] = nums
const num1Changed = float2Fixed(num1)
const num2Changed = float2Fixed(num2)
const baseNum = digitLength(num1) + digitLength(num2)
const leftValue = num1Changed * num2Changed
checkBoundary(leftValue)
return leftValue / Math.pow(10, baseNum)
}
/**
* 精确除法
*/
function divide(...nums) {
if (nums.length > 2) {
return iteratorOperation(nums, divide)
}
const [num1, num2] = nums
const num1Changed = float2Fixed(num1)
const num2Changed = float2Fixed(num2)
checkBoundary(num1Changed)
checkBoundary(num2Changed)
// fix: 类似 10 ** -4 为 0.00009999999999999999,strip 修正
return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1))))
}
/**
* 精确四舍五入
*/
export const round = (num, ratio) => {
const base = Math.pow(10, ratio)
let result = divide(Math.round(Math.abs(times(num, base))), base)
if (num < 0 && result !== 0) {
result = times(result, -1)
}
return result
}
Loading…
Cancel
Save