Просмотр исходного кода

Merge branch 'master' of ssh://git.9026.com:2212/xiansin/sange-bridge into master

xiansin 3 лет назад
Родитель
Сommit
d01173f09c

+ 1 - 1
core/math-lists.js

xqd
@@ -22,7 +22,7 @@ module.exports = [
         url: "/pages/formula/anytriangle"
     },
     {
-        title: "任意角度计算",
+        title: "任意角度计算",
         coverImage: mathImg.anyangle.cover,
         url: "/pages/formula/anyangle"
     },

+ 2 - 1
core/util.js

xqd xqd
@@ -71,6 +71,7 @@ const checkTriangle = (a,b,c) => {
 }
 
 const round = (number,percent) => {
+    console.log('-->data',number)
     if(!number) return  number
     let flag = number < 0 ? '-' : '';
     let arr = number.toString().split(".");
@@ -79,7 +80,7 @@ const round = (number,percent) => {
     number = Math.floor(Math.abs(Number(number)) * i) / i
     if(arr.length > 1 ){
         let str = arr[1]
-        if(str.length > 2 && str[2] >= 5){
+        if((str.length > 2 && str[2] >= 6) || (str.length > 2 && str[3] >= 6)){
             number = Math.ceil(number * i)
             number += 1;
             number = number / i;

+ 1 - 1
pages.json

xqd
@@ -123,7 +123,7 @@
         {
           "path": "anyangle",
           "style": {
-            "navigationBarTitleText": "任意角度计算",
+            "navigationBarTitleText": "任意角度计算",
             "enablePullDownRefresh": false
           }
         },

+ 4 - 4
pages/formula/angle.vue

xqd xqd
@@ -23,15 +23,15 @@
         <div class="footer">
             <view class="result dir-top-wrap cross-center" v-if="showResult">
                 <view v-for="item in rules" v-if="item.value && item.show">
-                    <text>{{item.name}}=</text>{{item.value}}{{item.unit}}
+                    <text>{{item.name}}=</text>{{$util.round(item.value,2)}}{{item.unit}}
                     <text v-if="item.isHalf">{{$util.round(item.value/2,2)}}{{item.unit}}</text>
                 </view>
             </view>
             <view class="title">计算图</view>
             <view class="calc-img">
                 <text class="height">{{formData.height?parseFloat(formData.height):'**'}}cm</text>
-                <text class="xiebian">{{rules.xiebian.value?rules.xiebian.value:'**'}}{{rules.xiebian.unit}}</text>
-                <text class="angle">{{rules.angle.value?rules.angle.value:'**'}}{{rules.angle.unit}}</text>
+                <text class="xiebian">{{rules.xiebian.value?$util.round(rules.xiebian.value,2):'**'}}{{rules.xiebian.unit}}</text>
+                <text class="angle">{{rules.angle.value?$util.round(rules.angle.value,2):'**'}}{{rules.angle.unit}}</text>
                 <text class="dibian">{{formData.dibian?parseFloat(formData.dibian):'**'}}cm</text>
                 <u-image width="100%" height="300rpx" :src="mathImgs[name].calc" mode="aspectFit"></u-image>
             </view>
@@ -86,7 +86,7 @@
             },
             roundRules(){
                 for (const itemKey in this.rules) {
-                    this.rules[itemKey].value = this.$util.round(this.rules[itemKey].value,2);
+                    //this.rules[itemKey].value = this.$util.round(this.rules[itemKey].value,2);
                 }
             },
             initRules(){

+ 21 - 8
pages/formula/anyangle.vue

xqd xqd xqd
@@ -30,7 +30,7 @@
         <div class="footer">
             <view class="result dir-top-wrap cross-center" v-if="showResult">
                 <view v-for="item in rules" v-if="item.value && item.show">
-                    <text>{{item.name}}=</text>{{item.value}}{{item.unit}}
+                    <text>{{item.name}}=</text>{{$util.round(item.value,2)}}{{item.unit}}
                     <text v-if="item.isHalf">{{$util.round(item.value/2,2)}}{{item.unit}}</text>
                 </view>
             </view>
@@ -111,19 +111,32 @@
                     this.$u.toast('两边之后要大于第三边');
                     return;
                 }
-                left = (Math.pow(a,2) + Math.pow(c,2) - Math.pow(b,2)) / (2 * a * c)
-                right = (Math.pow(b,2) + Math.pow(c,2) - Math.pow(a,2)) / (2 * b * c)
+                left = (Math.pow(b,2) + Math.pow(c,2) - Math.pow(a,2)) / (2 * b * c)
+                right = (Math.pow(a,2) + Math.pow(c,2) - Math.pow(b,2)) / (2 * a * c)
+                top = (Math.pow(a,2) + Math.pow(b,2) - Math.pow(c,2)) / (2 * a * b)
+
                 this.rules.left.value = this.$util.acos(left)
                 this.rules.right.value = this.$util.acos(right)
-                this.rules.top.value = top = 180 - this.rules.left.value - this.rules.right.value
+                this.rules.top.value = this.$util.acos(top)
+
+               /* if(this.rules.left.value > 90){
+                    this.rules.left.value = Math.abs(180 - this.rules.left.value)
+                }else if(this.rules.right.value > 90){
+                    this.rules.left.value = Math.abs(180 - this.rules.right.value)
+                }else if(this.rules.top.value > 90){
+                    this.rules.left.value = Math.abs(180 - this.rules.top.value)
+                }*/
+                this.rules.left.value = this.rules.left.value > 90 ? Math.abs(180 - this.rules.left.value) : this.rules.left.value;
+                this.rules.right.value = this.rules.right.value > 90 ? Math.abs(180 - this.rules.right.value) : this.rules.right.value;
+                this.rules.top.value = this.rules.top.value > 90 ? Math.abs(180 - this.rules.top.value) : this.rules.top.value;
 
                 if(biangao){
                     if(this.formData.angle === '1'){ // 顶角
-                        slice = biangao * this.$util.csc(this.rules.top.value)
+                        slice = biangao * this.$util.tan(this.rules.top.value/2)*2
                     }else if(this.formData.angle === '2'){ // 左底角
-                        slice = biangao * this.$util.csc(this.rules.left.value)
+                        slice = biangao * this.$util.tan(this.rules.left.value/2)*2
                     }else{
-                        slice = biangao * this.$util.csc(this.rules.right.value)
+                        slice = biangao * this.$util.tan(this.rules.right.value/2)*2
                     }
                 }
 
@@ -132,7 +145,7 @@
             },
             roundRules(){
                 for (const itemKey in this.rules) {
-                    this.rules[itemKey].value = this.$util.round(this.rules[itemKey].value,2);
+                    //this.rules[itemKey].value = this.$util.round(this.rules[itemKey].value,2);
                 }
             },
             initRules(){

+ 35 - 10
pages/formula/anytriangle.vue

xqd xqd
@@ -78,10 +78,7 @@
                 for (const itemKey in this.formData) {
                     validate.push(this.formData[itemKey]);
                 }
-                if(!this.$util.checkArrayNotNullNumber(validate,3)){
-                    this.$u.toast('至少输入三个参数');
-                    return;
-                }
+
                 let lengtha = 0;
                 let lengthb = 0;
                 let lengthc = 0;
@@ -89,17 +86,45 @@
                 let angleb = 0;
                 let anglec = 0;
 
+                lengtha = parseFloat( this.formData.lengtha)?parseFloat(this.formData.lengtha):0;
+                lengthb = parseFloat(this.formData.lengthb)?parseFloat(this.formData.lengthb):0;
+                lengthc = parseFloat(this.formData.lengthc)?parseFloat(this.formData.lengthc):0;
+                anglea = parseFloat(this.formData.anglea)?parseFloat(this.formData.anglea):0;
+                angleb = parseFloat(this.formData.angleb)?parseFloat(this.formData.angleb):0;
+                anglec = parseFloat(this.formData.anglec)?parseFloat(this.formData.anglec):0;
+
+                if(anglea && anglea > 180){
+                    this.$u.toast('角度A不能大于180');
+                    return;
+                }
+
+                if(angleb && angleb > 180){
+                    this.$u.toast('角度B不能大于180');
+                    return;
+                }
+
+                if(anglec && anglec > 180){
+                    this.$u.toast('角度C不能大于180');
+                    return;
+                }
+
+                if((anglea + angleb + anglec) > 180){
+                    this.$u.toast('内角之和不能大于180');
+                    return;
+                }
+
+                if(!this.$util.checkArrayNotNullNumber(validate,3)){
+                    this.$u.toast('至少输入三个参数');
+                    return;
+                }
+
+
                 /**1、 已知a、b、c
                  * cosA=(b²+c²-a²)÷(2bc)
                  * cosB=(a²+c²-b²)÷(2ac)
                  * cosC =(a²+b²-c²)÷(2ab)
                  */
-                lengtha = parseFloat( this.formData.lengtha);
-                lengthb = parseFloat(this.formData.lengthb);
-                lengthc = parseFloat(this.formData.lengthc);
-                anglea = parseFloat(this.formData.anglea);
-                angleb = parseFloat(this.formData.angleb);
-                anglec = parseFloat(this.formData.anglec);
+
                 if(lengtha && lengthb && lengthc){
                     if(!this.$util.checkTriangle(lengtha, lengthb, lengthc)){
                         this.$u.toast('两边之后要大于第三边');

+ 2 - 2
pages/formula/duochengzhijiao.vue

xqd
@@ -108,8 +108,8 @@
                     this.$u.toast('请输入角度');
                     return
                 }
-                if( this.formData.angle &&  this.formData.angle > 90){
-                    this.$u.toast('角度不能大于90');
+                if( this.formData.angle &&  this.formData.angle >= 90){
+                    this.$u.toast('角度不能大于和等于90');
                     return
                 }
                 if(!this.formData.cengjianju){

+ 2 - 2
pages/formula/rightAngleVertical.vue

xqd xqd
@@ -32,7 +32,7 @@
                 <u-image width="100%" height="300rpx" :src="mathImgs[name].calc" mode="aspectFit"></u-image>
             </view>
             <view class="title">切割图</view>
-            <u-image width="100%" height="300rpx" :src="mathImgs[name].slice" mode="aspectFit"></u-image>
+            <u-image width="100%" height="600rpx" :src="mathImgs[name].slice" mode="aspectFit"></u-image>
 
         </div>
     </view>
@@ -82,7 +82,7 @@
             },
             roundRules(){
                 for (const itemKey in this.rules) {
-                    this.rules[itemKey].value = this.$util.round(this.rules[itemKey].value,2);
+                    this.rules[itemKey].value = this.$util.round(this.$util.round(this.rules[itemKey].value,3),2);
                 }
             },
             initRules(){

+ 4 - 4
pages/formula/slice.vue

xqd xqd
@@ -23,14 +23,14 @@
         <div class="footer">
             <view class="result dir-top-wrap cross-center" v-if="showResult">
                 <view v-for="item in rules" v-if="item.value && item.show">
-                    <text>{{item.name}}=</text>{{item.value}}{{item.unit}}
+                    <text>{{item.name}}=</text>{{$util.round(item.value,2)}}{{item.unit}}
                     <text v-if="item.isHalf">{{$util.round(item.value/2,2)}}{{item.unit}}</text>
                 </view>
             </view>
             <view class="title">计算图</view>
             <view class="calc-img">
-                <text class="slice1">{{rules.slice.value?(rules.slice.value/2):'**'}}{{rules.slice.unit}}</text>
-                <text class="slice2">{{rules.slice.value?(rules.slice.value/2):'**'}}{{rules.slice.unit}}</text>
+                <text class="slice1">{{rules.slice.value?$util.round(rules.slice.value/2,2):'**'}}{{rules.slice.unit}}</text>
+                <text class="slice2">{{rules.slice.value?$util.round(rules.slice.value/2,2):'**'}}{{rules.slice.unit}}</text>
                 <text class="slice3 bottom">{{rules.slice.value?rules.slice.value:'**'}}{{rules.slice.unit}}</text>
                 <u-image width="100%" height="300rpx" :src="mathImgs[name].calc" mode="aspectFit"></u-image>
             </view>
@@ -91,7 +91,7 @@
             },
             roundRules(){
                 for (const itemKey in this.rules) {
-                    this.rules[itemKey].value = this.$util.round(this.rules[itemKey].value,2);
+                    //this.rules[itemKey].value = this.$util.round(this.rules[itemKey].value,2);
                 }
             },
             initRules(){

+ 1 - 1
static/css/math.scss

xqd
@@ -32,7 +32,7 @@
                 font-size: 24rpx;
                 font-weight: normal;
                 &:last-child{
-                    margin-left: 10rpx;
+                    margin-left: 20rpx;
                 }
             }
         }