index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <app-layout class="app-math">
  3. <view class="container">
  4. <view class="cover-image">
  5. <u-image width="100%" height="400rpx" src="https://xiansin.oss-cn-shenzhen.aliyuncs.com/sange-bridge/images/formula/formula-cover.png"></u-image>
  6. </view>
  7. <view class="input">
  8. <u-input
  9. type="number"
  10. :custom-style="{backgroundColor: '#ffffff',borderRadius:'10rpx',padding:'8rpx 16rpx'}"
  11. placeholder-style="color:#aaa"
  12. placeholder="请输入角度(0-90°)"
  13. v-model="angle"
  14. ></u-input>
  15. </view>
  16. <view class="button">
  17. <u-button :ripple="true" @click="handleCalc" shape="circle" :custom-style="{backgroundColor:$u.color['mainBgColor'],color:'#ffffff'}">计算</u-button>
  18. </view>
  19. <view class="table">
  20. <view class="row">{{angle1}}°公示表</view>
  21. <view class="row stripe">
  22. <text class="txt">高</text>
  23. <text class="txt">*</text>
  24. <text class="txt">{{value1.toFixed(3)}}</text>
  25. <text class="txt">=</text>
  26. <text class="txt">底边</text>
  27. </view>
  28. <view class="row">
  29. <text class="txt">高</text>
  30. <text class="txt">*</text>
  31. <text class="txt">{{value2.toFixed(3)}}</text>
  32. <text class="txt">=</text>
  33. <text class="txt">斜边</text></view>
  34. <view class="row stripe">
  35. <text class="txt">边高</text>
  36. <text class="txt">*</text>
  37. <text class="txt">{{value3.toFixed(3)}}</text>
  38. <text class="txt">=</text>
  39. <text class="txt">切口</text></view>
  40. <view class="row">
  41. <text class="txt">底边</text>
  42. <text class="txt">*</text>
  43. <text class="txt">{{value4.toFixed(3)}}</text>
  44. <text class="txt">=</text>
  45. <text class="txt">高</text></view>
  46. <view class="row stripe">
  47. <text class="txt">底边</text>
  48. <text class="txt">*</text>
  49. <text class="txt">{{value5.toFixed(3)}}</text>
  50. <text class="txt">=</text>
  51. <text class="txt">斜边</text></view>
  52. <view class="row">
  53. <text class="txt">斜边</text>
  54. <text class="txt">*</text>
  55. <text class="txt">{{value6.toFixed(3)}}</text>
  56. <text class="txt">=</text>
  57. <text class="txt">高</text></view>
  58. <view class="row stripe">
  59. <text class="txt">斜边</text>
  60. <text class="txt">*</text>
  61. <text class="txt">{{value7.toFixed(3)}}</text>
  62. <text class="txt">=</text>
  63. <text class="txt">底边</text></view>
  64. </view>
  65. </view>
  66. </app-layout>
  67. </template>
  68. <script>
  69. import appLayout from "@/components/app-layout"
  70. export default {
  71. components:{
  72. appLayout,
  73. },
  74. data() {
  75. return {
  76. angle: '',
  77. angle1: 45,
  78. value1: 1.0,
  79. value2: 1.414,
  80. value3: 0.828,
  81. value4: 1.0,
  82. value5: 1.414,
  83. value6: 0.707,
  84. value7: 0.707,
  85. }
  86. },
  87. methods: {
  88. handleCalc(){
  89. if(!this.angle){
  90. this.$u.toast('角度不能为0');
  91. return;
  92. }
  93. if(!this.angle > 90){
  94. this.$u.toast('角度不能大于90');
  95. return;
  96. }
  97. this.angle1 = this.angle
  98. this.value1 = this.$util.cot(this.angle);
  99. this.value2 = this.$util.csc(this.angle);
  100. this.value3 = this.$util.tan(this.angle/2)*2;
  101. this.value4 = this.$util.tan(this.angle);
  102. this.value5 = this.$util.sec(this.angle);
  103. this.value6 = this.$util.sin(this.angle);
  104. this.value7 = this.$util.cos(this.angle);
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .app-math{
  111. .input{
  112. margin-top: 32rpx;
  113. }
  114. .button{
  115. margin-top: 32rpx;
  116. }
  117. .table{
  118. border-radius: 16rpx;
  119. overflow: hidden;
  120. text-align: center;
  121. margin-top: 32rpx;
  122. .row{
  123. padding: 16rpx 0;
  124. font-size: 36rpx;
  125. font-weight: 600;
  126. background: #EAEAEA;
  127. &.stripe{
  128. background: #D8D8D8;
  129. }
  130. >.txt{
  131. font-size: 28rpx;
  132. display: inline-block;
  133. font-weight: normal;
  134. &:nth-child(1){
  135. width: 15%;
  136. }
  137. &:nth-child(2){
  138. width: 15%;
  139. }
  140. &:nth-child(3){
  141. width: 15%;
  142. }
  143. &:nth-child(4){
  144. width: 15%;
  145. }
  146. &:nth-child(5){
  147. width: 15%;
  148. }
  149. }
  150. }
  151. }
  152. .version{
  153. font-size: 24rpx;
  154. margin-top: 32rpx;
  155. color: #c6c6c6;
  156. }
  157. .copyright{
  158. padding: 8rpx 0;
  159. color: #C6C6C6;
  160. font-size: 24rpx;
  161. .agreement{
  162. color: $main-color;
  163. }
  164. }
  165. }
  166. </style>