index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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="src"></u-image>
  6. </view>
  7. <view class="input">
  8. <u-input
  9. type="digit"
  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. src: this.$site.root+"assets/images/formula/formula-cover.png"
  86. }
  87. },
  88. methods: {
  89. handleCalc(){
  90. if(!this.angle){
  91. this.$u.toast('角度不能为0');
  92. return;
  93. }
  94. if(!this.angle > 90){
  95. this.$u.toast('角度不能大于90');
  96. return;
  97. }
  98. this.angle1 = this.angle
  99. this.value1 = this.$util.cot(this.angle);
  100. this.value2 = this.$util.csc(this.angle);
  101. this.value3 = this.$util.tan(this.angle/2)*2;
  102. this.value4 = this.$util.tan(this.angle);
  103. this.value5 = this.$util.sec(this.angle);
  104. this.value6 = this.$util.sin(this.angle);
  105. this.value7 = this.$util.cos(this.angle);
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. .app-math{
  112. .input{
  113. margin-top: 32rpx;
  114. }
  115. .button{
  116. margin-top: 32rpx;
  117. }
  118. .table{
  119. border-radius: 16rpx;
  120. overflow: hidden;
  121. text-align: center;
  122. margin-top: 32rpx;
  123. .row{
  124. padding: 16rpx 0;
  125. font-size: 36rpx;
  126. font-weight: 600;
  127. background: #EAEAEA;
  128. &.stripe{
  129. background: #D8D8D8;
  130. }
  131. >.txt{
  132. font-size: 28rpx;
  133. display: inline-block;
  134. font-weight: normal;
  135. &:nth-child(1){
  136. width: 15%;
  137. }
  138. &:nth-child(2){
  139. width: 15%;
  140. }
  141. &:nth-child(3){
  142. width: 15%;
  143. }
  144. &:nth-child(4){
  145. width: 15%;
  146. }
  147. &:nth-child(5){
  148. width: 15%;
  149. }
  150. }
  151. }
  152. }
  153. .version{
  154. font-size: 24rpx;
  155. margin-top: 32rpx;
  156. color: #c6c6c6;
  157. }
  158. .copyright{
  159. padding: 8rpx 0;
  160. color: #C6C6C6;
  161. font-size: 24rpx;
  162. .agreement{
  163. color: $main-color;
  164. }
  165. }
  166. }
  167. </style>