index.ux 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <import name="center-modal" src="../../../components/center-modal"></import>
  2. <import name="add-desktop" src="/src/components/addDesktop"></import>
  3. <template>
  4. <div class="wrapper" style="position: relative;">
  5. <add-desktop></add-desktop>
  6. <image class="w h-350" style="width: 100%;" src="https://ytnovels.oss-cn-shanghai.aliyuncs.com/appStatic/images/source/yundongjibu.jpg"></image>
  7. <div class="num">
  8. <text class="curNum" id="popup" @click="setNum">{{ curNum }}</text>
  9. <text class="totalNum">/100000步</text>
  10. </div>
  11. <center-modal
  12. show="{{showModal}}"
  13. title="设置步数"
  14. @close="closeModal"
  15. if="{{showModal}}"
  16. >
  17. <div class="popup_box">
  18. <input
  19. type="text"
  20. id="search-input"
  21. class="search-input"
  22. placeholder="请输入书名或作者"
  23. value="{{curNum}}"
  24. onchange="change"
  25. />
  26. <!-- <div class="flex">
  27. <div class="btn btn_cancel">
  28. <text>取消</text>
  29. </div>
  30. <div class="btn btn_sure" @click="closePopup">
  31. <text>确定</text>
  32. </div>
  33. </div> -->
  34. </div>
  35. </center-modal>
  36. </div>
  37. </template>
  38. <script>
  39. import health from '@service.health'
  40. export default {
  41. private: {
  42. title: '欢迎体验快应用开发',
  43. curNum:0,
  44. inputNum:1000,
  45. showPopup:false,
  46. showModal: false,
  47. support:false,
  48. },
  49. onInit() {
  50. var that = this
  51. health.hasStepsOfDay({
  52. success: function(data) {
  53. if(!data.support){
  54. $utils.showToast(`当前设备获取不到步数`)
  55. }else{
  56. that.support = true
  57. health.getTodaySteps({
  58. success: function(data) {
  59. that.curNum = data.steps
  60. // $utils.showToast(`获取成功${data.steps}步数`)
  61. },
  62. fail: function(data, code) {
  63. if(code == '1001'){
  64. $utils.showToast(`还不支持获取步数`)
  65. }else if (code == '201'){
  66. $utils.showToast(`用户拒绝授权`)
  67. }else if (code == '207'){
  68. $utils.showToast(`用户拒绝并勾选不再询问复选框`)
  69. }
  70. console.log(`handling fail, code = ${code}, errorMsg=${data}`)
  71. }
  72. })
  73. }
  74. },
  75. fail: function(data, code) {
  76. console.log(`handling fail!, code = ${code}`)
  77. }
  78. })
  79. },
  80. // 设置步数
  81. setNum(){
  82. if(!this.support){
  83. this.showModal = true
  84. }
  85. },
  86. closeModal() {
  87. this.showModal = false
  88. },
  89. change(e){
  90. console.log('e',e)
  91. this.curNum = e.text
  92. },
  93. // 打开Popup
  94. openPopup() {
  95. this.showPopup = true;
  96. console.log('弹窗已打开');
  97. },
  98. // 关闭Popup
  99. closePopup() {
  100. this.showPopup = false;
  101. console.log('弹窗已关闭');
  102. },
  103. // Popup状态变化回调
  104. popupStateChange(e) {
  105. console.log('弹窗状态变化:', e.state);
  106. if (e.state === 'hide') {
  107. // 确保状态同步
  108. this.showPopup = false;
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="less">
  114. .wrapper {
  115. flex-direction: column;
  116. justify-content: center;
  117. align-items: center;
  118. }
  119. .title {
  120. text-align: center;
  121. color: #212121;
  122. }
  123. .num{
  124. position: absolute;
  125. top: 490px;
  126. left: 300px;
  127. flex-direction: column;
  128. .curNum{
  129. font-size: 50px;
  130. color: #000;
  131. font-weight: bold;
  132. }
  133. .totalNum{
  134. font-size: 26px;
  135. color: #999;
  136. }
  137. }
  138. .popup_box{
  139. flex-direction: column;
  140. align-items: center;
  141. justify-content: center;
  142. .search-input{
  143. border: 1px solid #000000;
  144. padding: 20px;
  145. width: 550px;
  146. }
  147. .btn{
  148. width: 150px;
  149. height: 40px;
  150. border: 1px solid #000000;
  151. border-radius: 20px;
  152. align-items: center;
  153. justify-content: center;
  154. }
  155. .btn_sure{
  156. color: #ffffff;
  157. background: linear-gradient(90deg, #03fedf, #2ed9fb);
  158. }
  159. }
  160. </style>