日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

屏幕亮度

my.setKeepScreenOn(OBJECT)

說明:基礎庫 1.3.0 及以上版本支持該接口,低版本需要做兼容處理,操作參見 小程序基礎庫說明。mPaaS 10.1.32 及以上版本支持該接口。


此接口用于設置是否保持屏幕長亮狀態。僅在當前小程序生效,離開小程序后失效。

入參

參數 類型 必填 說明
keepScreenOn Boolean 是否保持屏幕長亮狀態
success Function 接口調用成功的回調函數
fail Function 接口調用失敗的回調函數
complete Function 接口調用結束的回調函數(調用成功、失敗都會執行)

代碼示例

  1. <!-- API-DEMO page/API/screen/screen.axml-->
  2. <view class="page">
  3. <view class="page-description">屏幕亮度 API</view>
  4. <view class="page-section">
  5. <view class="page-section-title">設置是否保持屏幕長亮狀態</view>
  6. <view class="page-section-demo">
  7. <switch checked="{{status}}" onChange="switchKeepScreenOn"/>
  8. </view>
  9. </view>
  10. <view class="page-section">
  11. <view class="page-section-title">設置屏幕亮度</view>
  12. <view class="page-section-demo">
  13. <slider value="{{brightness}}" max="1" min="0" onChange="sliderChange" step="0.02"/>
  14. </view>
  15. </view>
  16. <view class="page-section">
  17. <view class="page-section-title">獲取屏幕亮度</view>
  18. <view class="page-section-demo">
  19. <button type="primary" onTap="getBrightness">獲取屏幕亮度</button>
  20. </view>
  21. </view>
  22. </view>
  1. // API-DEMO page/API/screen/screen.js
  2. Page({
  3. data: {
  4. status: false,
  5. brightness: 1,
  6. },
  7. onLoad() {
  8. my.getScreenBrightness({
  9. success: res => {
  10. this.setData({
  11. brightness: res.brightness
  12. })
  13. },
  14. })
  15. },
  16. sliderChange(e) {
  17. my.setScreenBrightness({
  18. brightness: e.detail.value,
  19. success: (res) => {
  20. this.setData({
  21. brightness: e.detail.value,
  22. })
  23. }
  24. })
  25. },
  26. switchKeepScreenOn(e) {
  27. my.setKeepScreenOn({
  28. keepScreenOn: e.detail.value,
  29. success: (res) => {
  30. this.setData({
  31. status: e.detail.value,
  32. })
  33. }
  34. })
  35. },
  36. getBrightness() {
  37. my.getScreenBrightness({
  38. success: res => {
  39. my.alert({
  40. content: `當前屏幕亮度:${res.brightness}`
  41. });
  42. }
  43. })
  44. }
  45. });

my.getScreenBrightness(OBJECT)

說明:基礎庫 1.4.0 及以上版本支持該接口,低版本需要做兼容處理,操作參見 小程序基礎庫說明。mPaaS 10.1.32 及以上版本支持該接口。


此接口用于獲取屏幕亮度。

入參

參數 類型 必填 說明
success Function 接口調用成功的回調函數
fail Function 接口調用失敗的回調函數
complete Function 接口調用結束的回調函數(調用成功、失敗都會執行)

代碼示例

  1. <!-- API-DEMO page/API/screen/screen.axml-->
  2. <view class="page">
  3. <view class="page-description">屏幕亮度 API</view>
  4. <view class="page-section">
  5. <view class="page-section-title">設置是否保持屏幕長亮狀態</view>
  6. <view class="page-section-demo">
  7. <switch checked="{{status}}" onChange="switchKeepScreenOn"/>
  8. </view>
  9. </view>
  10. <view class="page-section">
  11. <view class="page-section-title">設置屏幕亮度</view>
  12. <view class="page-section-demo">
  13. <slider value="{{brightness}}" max="1" min="0" onChange="sliderChange" step="0.02"/>
  14. </view>
  15. </view>
  16. <view class="page-section">
  17. <view class="page-section-title">獲取屏幕亮度</view>
  18. <view class="page-section-demo">
  19. <button type="primary" onTap="getBrightness">獲取屏幕亮度</button>
  20. </view>
  21. </view>
  22. </view>
  1. // API-DEMO page/API/screen/screen.js
  2. Page({
  3. data: {
  4. status: false,
  5. brightness: 1,
  6. },
  7. onLoad() {
  8. my.getScreenBrightness({
  9. success: res => {
  10. this.setData({
  11. brightness: res.brightness
  12. })
  13. },
  14. })
  15. },
  16. sliderChange(e) {
  17. my.setScreenBrightness({
  18. brightness: e.detail.value,
  19. success: (res) => {
  20. this.setData({
  21. brightness: e.detail.value,
  22. })
  23. }
  24. })
  25. },
  26. switchKeepScreenOn(e) {
  27. my.setKeepScreenOn({
  28. keepScreenOn: e.detail.value,
  29. success: (res) => {
  30. this.setData({
  31. status: e.detail.value,
  32. })
  33. }
  34. })
  35. },
  36. getBrightness() {
  37. my.getScreenBrightness({
  38. success: res => {
  39. my.alert({
  40. content: `當前屏幕亮度:${res.brightness}`
  41. });
  42. }
  43. })
  44. }
  45. });

my.setScreenBrightness(OBJECT)

說明:基礎庫 1.4.0 及以上版本支持該接口,低版本需要做兼容處理,操作參見 小程序基礎庫說明。mPaaS 10.1.32 及以上版本支持該接口。


此接口用于設置屏幕亮度。

入參

參數 類型 必填 說明
brightness Number 需要設置的屏幕亮度,取值范圍為 0-1
success Function 接口調用成功的回調函數
fail Function 接口調用失敗的回調函數
complete Function 接口調用結束的回調函數(調用成功、失敗都會執行)

代碼示例

  1. <!-- API-DEMO page/API/screen/screen.axml-->
  2. <view class="page">
  3. <view class="page-description">屏幕亮度 API</view>
  4. <view class="page-section">
  5. <view class="page-section-title">設置是否保持屏幕長亮狀態</view>
  6. <view class="page-section-demo">
  7. <switch checked="{{status}}" onChange="switchKeepScreenOn"/>
  8. </view>
  9. </view>
  10. <view class="page-section">
  11. <view class="page-section-title">設置屏幕亮度</view>
  12. <view class="page-section-demo">
  13. <slider value="{{brightness}}" max="1" min="0" onChange="sliderChange" step="0.02"/>
  14. </view>
  15. </view>
  16. <view class="page-section">
  17. <view class="page-section-title">獲取屏幕亮度</view>
  18. <view class="page-section-demo">
  19. <button type="primary" onTap="getBrightness">獲取屏幕亮度</button>
  20. </view>
  21. </view>
  22. </view>
  1. // API-DEMO page/API/screen/screen.js
  2. Page({
  3. data: {
  4. status: false,
  5. brightness: 1,
  6. },
  7. onLoad() {
  8. my.getScreenBrightness({
  9. success: res => {
  10. this.setData({
  11. brightness: res.brightness
  12. })
  13. },
  14. })
  15. },
  16. sliderChange(e) {
  17. my.setScreenBrightness({
  18. brightness: e.detail.value,
  19. success: (res) => {
  20. this.setData({
  21. brightness: e.detail.value,
  22. })
  23. }
  24. })
  25. },
  26. switchKeepScreenOn(e) {
  27. my.setKeepScreenOn({
  28. keepScreenOn: e.detail.value,
  29. success: (res) => {
  30. this.setData({
  31. status: e.detail.value,
  32. })
  33. }
  34. })
  35. },
  36. getBrightness() {
  37. my.getScreenBrightness({
  38. success: res => {
  39. my.alert({
  40. content: `當前屏幕亮度:${res.brightness}`
  41. });
  42. }
  43. })
  44. }
  45. });