• uni-app:实现页面效果3


    效果

    代码

    1. <template>
    2. <view>
    3. <view class="content_position">
    4. <view class="content">
    5. <view class="SN">
    6. <view class="SN_title">设备1view>
    7. <view class="SN_input">
    8. SN:
    9. <input type="text">
    10. view>
    11. view>
    12. <view class="line1">
    13. <view class="line1_item3">
    14. <view class="item3_top">
    15. <view class="item3_top_title_position">
    16. <view class="wind_img">
    17. <image :src="wind" mode="" class="rotate-image" :style="rotateStyle">image>
    18. view>
    19. view>
    20. <view class="item3_top_canvas_position">
    21. <canvas style="width:100%; height: 20px;" canvas-id="firstCanvas"
    22. id="firstCanvas">canvas>
    23. view>
    24. <view class="item3_top_text_position">
    25. <view class="top_text1">
    26. <view>
    27. <view class="text_center">风速view>
    28. <view class="circle">
    29. <view>
    30. <view class="text_center">
    31. <text>{{rotationSpeed}}text>M/S
    32. view>
    33. view>
    34. view>
    35. view>
    36. view>
    37. view>
    38. view>
    39. <view class="item3_bottom">
    40. <view class="line1_item3_block2">
    41. <view class="block2">
    42. <view class="title">
    43. 风速信号输入
    44. view>
    45. <view class="green_ring_select">
    46. <view>AI3view>
    47. <view>
    48. <image :src="down" mode="">image>
    49. view>
    50. view>
    51. <view class="block2_input">
    52. <view class="block2_input_title">
    53. 量程
    54. view>
    55. <view class="block2_input_data">
    56. <view class="input_data">
    57. <input type="text" value="0M/S">
    58. view>
    59. <view class="input_data">
    60. <input type="text" value="40M/S">
    61. view>
    62. view>
    63. view>
    64. view>
    65. view>
    66. <view class="line1_item3_block2">
    67. <view class="block2">
    68. <view class="title">
    69. CO信号输入
    70. view>
    71. <view class="green_ring_select">
    72. <view>AI4view>
    73. <view>
    74. <image :src="down" mode="">image>
    75. view>
    76. view>
    77. <view class="block2_input">
    78. <view class="block2_input_data1">
    79. <view class="input_data">
    80. <view class="input_data_title">view>
    81. <input type="text" value="4mA">
    82. view>
    83. <view class="input_data">
    84. <view class="input_data_title">180°view>
    85. <input type="text" value="12mA">
    86. view>
    87. view>
    88. view>
    89. view>
    90. view>
    91. view>
    92. view>
    93. view>
    94. view>
    95. view>
    96. view>
    97. template>
    98. <script>
    99. export default {
    100. data() {
    101. return {
    102. wind: getApp().globalData.icon + 'look/wind.png',
    103. down: getApp().globalData.icon + 'look/down.png',
    104. rotationSpeed: 1, // 自定义的旋转速度,数值越大转的越快
    105. }
    106. },
    107. onReady: function(e) {
    108. //创建一个画布上下文对象,用于进行绘图操作。'firstCanvas'是一个指定的画布标识符,表示在页面上的哪个 元素上进行绘制。
    109. var context = uni.createCanvasContext('firstCanvas')
    110. var width = '';
    111. const query = uni.createSelectorQuery();
    112. //获取宽度
    113. query.select('#firstCanvas').fields({
    114. size: true
    115. }, (res) => {
    116. width = res.width;
    117. //获取到宽度之后进行绘制
    118. //绘制路径中的线条。
    119. context.setStrokeStyle("#aaaaff")
    120. // 设置线条的宽度为2个像素。
    121. context.setLineWidth(2)
    122. // 绘制横线
    123. context.beginPath(); // 开始路径绘制
    124. context.moveTo(width / 2, 0); // 将起点移动到 (0, 100)
    125. context.lineTo(width / 2, 20);
    126. context.stroke(); // 绘制线条
    127. // 将之前的绘图操作渲染到画布上。
    128. context.draw()
    129. }).exec();
    130. },
    131. computed: {
    132. rotateStyle() {
    133. const duration = 1 / this.rotationSpeed + "s"; // 根据旋转速度计算动画持续时间
    134. return {
    135. animationDuration: duration
    136. };
    137. }
    138. },
    139. methods: {}
    140. }
    141. script>
    142. <style lang="scss">
    143. page {
    144. background-color: #f3f4f6;
    145. }
    146. /* 总体样式 */
    147. .content_position {
    148. width: 100%;
    149. display: flex;
    150. align-items: center;
    151. justify-content: center;
    152. }
    153. .content {
    154. width: 90%;
    155. padding: 2% 0;
    156. }
    157. /* SN 样式 */
    158. .SN {
    159. color: #6b6c6e;
    160. padding: 2%;
    161. display: flex;
    162. // border:1px solid black;
    163. justify-content: space-between;
    164. /* 将左右视图分散对齐 */
    165. .SN_input {
    166. display: flex;
    167. // border:1px solid black;
    168. input {
    169. border-bottom: 1px solid #a3a4a6;
    170. width: 200rpx;
    171. }
    172. image {
    173. width: 48rpx;
    174. height: 48rpx;
    175. }
    176. }
    177. }
    178. // 行1样式
    179. .line1 {
    180. // border: 1px solid black;
    181. background-color: #fff;
    182. border-radius: 15px;
    183. margin: 5% 0;
    184. padding: 3% 5%;
    185. }
    186. .line1_item3 {
    187. // border: 1px solid black;
    188. margin-top: 5%;
    189. }
    190. .wind_img {
    191. // border: 1px solid black;
    192. background-color: #edf1fc;
    193. width: 150rpx;
    194. height: 150rpx;
    195. display: flex;
    196. align-items: center;
    197. justify-content: center;
    198. border-radius: 50%;
    199. image {
    200. width: 90rpx;
    201. height: 90rpx;
    202. }
    203. }
    204. .text_center {
    205. display: flex;
    206. align-items: center;
    207. justify-content: center;
    208. }
    209. //圆环图标
    210. .item3_top_title_position {
    211. display: flex;
    212. align-items: center;
    213. justify-content: center;
    214. // border: 1px solid black;
    215. }
    216. //画布位置
    217. .item3_top_canvas_position {
    218. display: flex;
    219. align-items: center;
    220. justify-content: center;
    221. }
    222. //文本位置
    223. .item3_top_text_position {
    224. position: relative;
    225. height: 400rpx;
    226. }
    227. //圆环
    228. .circle {
    229. margin-top: 20%;
    230. width: 140rpx;
    231. height: 140rpx;
    232. border-radius: 50%;
    233. font-size: 95%;
    234. display: flex;
    235. align-items: center;
    236. justify-content: center;
    237. background-color: #e8e8e8;
    238. }
    239. .top_text1 {
    240. position: absolute;
    241. left: 50%;
    242. transform: translateX(-50%);
    243. // border: 1px solid black;
    244. width: 220rpx;
    245. height: 300rpx;
    246. background-color: #edf1fc;
    247. border-radius: 10px;
    248. display: flex;
    249. align-items: center;
    250. justify-content: center;
    251. }
    252. // 底部样式
    253. .item3_bottom {
    254. display: flex;
    255. justify-content: space-between; //分散排列
    256. // border: 1px solid black;
    257. }
    258. //两列
    259. .line1_item3_block2 {
    260. display: flex;
    261. text-align: center;
    262. margin: 0 5%; //增加底部两个模块之间的距离
    263. }
    264. //两个小块样式
    265. .block2_input {
    266. display: flex;
    267. width: 100%;
    268. }
    269. // 底部两小块标题
    270. .block2_input_title {
    271. // border: 1px solid black;
    272. display: flex;
    273. align-items: center; //竖直居中
    274. justify-content: center; //水平居中
    275. }
    276. // .input_data_title{
    277. // margin-right: 5%;
    278. // }
    279. .block2_input_data {
    280. width: 70%;
    281. }
    282. .block2_input_data1 {
    283. width: 100%;
    284. }
    285. .block2_input_data1 input {
    286. margin: 5rpx 0;
    287. border: 1px solid #808080;
    288. border-radius: 20px;
    289. padding: 2% 5%;
    290. color: #737373;
    291. text-align: right;
    292. }
    293. .input_data {
    294. display: flex;
    295. align-items: center;
    296. height: 80rpx;
    297. // border: 1px solid black;
    298. }
    299. .block2_input_data input {
    300. margin: 5rpx 0;
    301. border: 1px solid #808080;
    302. border-radius: 20px;
    303. padding: 2% 5%;
    304. color: #737373;
    305. text-align: right;
    306. }
    307. //绿环样式
    308. .green_ring_select {
    309. background-color: #6da54f;
    310. border-radius: 20px;
    311. color: #fff;
    312. font-size: 95%;
    313. display: flex;
    314. align-items: center;
    315. padding: 3% 0;
    316. margin: 5% 0;
    317. // width:200rpx;
    318. view:nth-child(1) {
    319. width: 60%;
    320. display: flex;
    321. justify-content: center;
    322. align-items: center;
    323. }
    324. view:nth-child(2) {
    325. width: 40%;
    326. display: flex;
    327. justify-content: center;
    328. align-items: center;
    329. image {
    330. width: 30rpx;
    331. height: 30rpx;
    332. }
    333. }
    334. }
    335. // 旋转风扇
    336. .rotate-image {
    337. animation: rotateAnimation linear infinite;
    338. transform-origin: center center;
    339. transform: translate3d(0, 0, 0);
    340. }
    341. @keyframes rotateAnimation {
    342. from {
    343. transform: rotate(0deg);
    344. }
    345. to {
    346. transform: rotate(360deg);
    347. }
    348. }
    349. style>

  • 相关阅读:
    PAT A1034 Head of a Gang
    Web前端开发技术课程大作业,期末考试HTML+CSS+JavaScript电竞游戏介绍网站
    软件测试: 测试用例
    Improved Baselines with Momentum Contrastive Learning 论文学习
    【MyBatis笔记10】Mybatis中几个动态SQL标签和内置参数
    day22每日一考
    VMware 虚拟机中 Linux 系统Centos7磁盘空间扩容
    YOLO目标检测——无人机航拍输电线路绝缘瓷瓶数据集下载分享【对应voc、coco和yolo三种格式标签】
    WeTab--颜值与实力并存的浏览器插件
    Linux学习6—文件的查找与压缩
  • 原文地址:https://blog.csdn.net/weixin_46001736/article/details/133359500