loading_view_auth.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { _decorator, Component, sys } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('loading_view_auth')
  4. export class loading_view_auth extends Component {
  5. private m_cb = null
  6. start() {
  7. if(sys.platform != sys.Platform.WECHAT_GAME) {
  8. return
  9. }
  10. const windowInfo = wx.getWindowInfo()
  11. // console.log('windowInfo=',windowInfo)
  12. let bili = 1920 / windowInfo.screenHeight
  13. let width = 100
  14. let height = 35
  15. let left = windowInfo.screenWidth / 2 - width / 2
  16. let top = windowInfo.screenHeight / 2 + height / 2 + (90 / bili)
  17. let button = wx.createUserInfoButton({
  18. type: 'text',
  19. text: '允 许',
  20. style: {
  21. left: left,
  22. top: top,
  23. width: width,
  24. height: height,
  25. backgroundColor: '#3ADA62',
  26. color: '#ffffff',
  27. textAlign: 'center',
  28. borderRadius:4,
  29. fontSize: 17,
  30. lineHeight: height,
  31. }
  32. })
  33. button.onTap((res) => {
  34. // console.log('button_res=',res)
  35. button.destroy()
  36. if(this.m_cb) {
  37. this.m_cb()
  38. }
  39. })
  40. }
  41. initView(cb) {
  42. this.m_cb = cb
  43. }
  44. }