App.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <style lang="scss">
  2. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  3. @import "uview-ui/index.scss";
  4. </style>
  5. <script>
  6. import Vue from 'vue'
  7. // import app from './utils/api.js'
  8. export default {
  9. onLaunch() {
  10. // 获取未读信息
  11. // this.getAllMessage()
  12. // 微信登录
  13. wx.login({
  14. success({
  15. code
  16. }) {
  17. // console.log('code', code);
  18. uni.request({
  19. url:'https://teacherapi.cocorobo.cn/api/pbl/weChatCode',
  20. // url: 'http://localhost:7333/api/pbl/weChatCode', //接口地址:前缀+方法中传入的地址
  21. method: 'GET',
  22. data: {
  23. codes: code
  24. }
  25. }).then(res => {
  26. // console.log('微信登录',res);
  27. uni.setStorageSync('oId', res.data)
  28. // uni.getStorageSync('oId')
  29. })
  30. }
  31. })
  32. // 获取设备信息
  33. uni.getSystemInfo({
  34. success: function(res) {
  35. Vue.prototype.screenHeight = res.screenHeight
  36. Vue.prototype.screenWidth = res.screenWidth
  37. // console.log(res);
  38. const tabBarHeight = res.screenHeight - res.windowHeight;
  39. Vue.prototype.tabBarHeight = tabBarHeight
  40. if (uni.getMenuButtonBoundingClientRect()) {
  41. console.log('小程序');
  42. // 小程序状态栏是指显示电量的那一小部分
  43. thisWechat(res.statusBarHeight)
  44. } else {
  45. console.log('app');
  46. thisApp(res.statusBarHeight)
  47. }
  48. }
  49. });
  50. // 微信
  51. function thisWechat(statusBarHeight) {
  52. // 获取胶囊位置
  53. let meunButtonInfo = uni.getMenuButtonBoundingClientRect()
  54. // console.log(meunButtonInfo);
  55. Vue.prototype.meunButtonInfo = meunButtonInfo.height
  56. // 计算出导航栏高度+动态栏
  57. let allHeight = meunButtonInfo.bottom + (meunButtonInfo.top - statusBarHeight) * 2;
  58. // console.log(allHeight);
  59. let navheight;
  60. Vue.prototype.navheight = allHeight
  61. // 按钮离顶
  62. let alltop = meunButtonInfo.top
  63. Vue.prototype.navTop = alltop
  64. // 动态栏高度
  65. let statusHeight
  66. Vue.prototype.statusHeight = statusBarHeight
  67. };
  68. // 这个app的
  69. function thisApp(statusBarHeight) {
  70. // console.log(uni.getSystemInfoSync());
  71. // 导航栏高度
  72. let customBarHeight;
  73. if (uni.getSystemInfoSync().platform === 'android') {
  74. customBarHeight = statusBarHeight + 50;
  75. } else if (uni.getSystemInfoSync().platform === 'ios') {
  76. // iOS 平台
  77. // 在这里根据 iOS 平台的特性计算自定义状态栏高度
  78. // ...
  79. customBarHeight = statusBarHeight + 45;
  80. } else {
  81. // 其他平台
  82. // ...
  83. customBarHeight = statusBarHeight;
  84. }
  85. // console.log(customBarHeight);
  86. Vue.prototype.customBar = customBarHeight;
  87. }
  88. },
  89. onShow() {
  90. },
  91. methods: {
  92. // 获取未读信息
  93. getAllMessage() {
  94. this.$request('/selectAllMessage', "POST", {
  95. oid: this.$store.state.user.openid
  96. }).then(res => {
  97. console.log('获取未读信息',res[0][0].msg);
  98. let num = res[0][0].msg
  99. if (num == 0) {
  100. uni.hideTabBarRedDot({
  101. index: 3
  102. })
  103. } else {
  104. Vue.prototype.msgnum = num
  105. uni.setTabBarBadge({
  106. index: 3,
  107. text: num.toString()
  108. })
  109. }
  110. })
  111. }
  112. },
  113. onLoad() {
  114. }
  115. }
  116. </script>
  117. <style lang="scss">
  118. /*每个页面公共css */
  119. body,
  120. html {
  121. background-color: #f0f2f5;
  122. /* font-family: PingFang SC; */
  123. height: 100vh;
  124. width: 750rpx;
  125. }
  126. view {
  127. box-sizing: border-box;
  128. padding: 0;
  129. }
  130. /* 确认弹窗 */
  131. .mask { //弹窗背景色
  132. position: fixed;
  133. top: 0;
  134. left: 0;
  135. width: 100%;
  136. height: 100%;
  137. background-color: rgba(0, 0, 0, 0.3);
  138. z-index: 999;
  139. overflow: hidden;
  140. // display: none;
  141. }
  142. .popup-container {
  143. position: fixed;
  144. top: 50%;
  145. left: 50%;
  146. transform: translate(-50%, -50%);
  147. width: 520rpx;
  148. height: 260rpx;
  149. z-index: 1000;
  150. border-radius: 16rpx;
  151. overflow: hidden;
  152. .popup {
  153. width: 100%;
  154. height: 100%;
  155. display: flex;
  156. flex-direction: column;
  157. background-color: #fff;
  158. border-radius: 16rpx;
  159. overflow: hidden;
  160. .header {
  161. flex: 1;
  162. display: flex;
  163. justify-content: center;
  164. align-items: center;
  165. flex-direction: column;
  166. margin-top: 24px;
  167. font-size: 34rpx;
  168. font-weight: 600;
  169. image {
  170. width: 150rpx;
  171. height: 150rpx;
  172. margin-top: 15px;
  173. margin-bottom: 15px;
  174. }
  175. }
  176. .footer {
  177. width: 100%;
  178. display: flex;
  179. overflow: hidden;
  180. .cancel-btn {
  181. width: 50%;
  182. height: 100rpx;
  183. background-color: #F7F7F7;
  184. color: #000;
  185. font-size: 34rpx;
  186. text-align: center;
  187. border-bottom-left-radius: 16rpx;
  188. line-height: 50px;
  189. }
  190. .confirm-btn {
  191. width: 50%;
  192. height: 100rpx;
  193. background-color: #0081FE;
  194. color: #fff;
  195. font-size: 34rpx;
  196. text-align: center;
  197. line-height: 50px;
  198. }
  199. }
  200. }
  201. }
  202. /* 触底加载更多 */
  203. .loading {
  204. height: 30rpx;
  205. text-align: center;
  206. padding-top: 20rpx;
  207. padding-bottom: 100rpx;
  208. font-size: 26rpx;
  209. color: #888;
  210. line-height: 2em;
  211. }
  212. /* 公共字体大小类 */
  213. .one-font {
  214. font-size: 48rpx;
  215. line-height: 72rpx;
  216. font-weight: 600;
  217. }
  218. .two-font {
  219. font-size: 40rpx;
  220. line-height: 56rpx;
  221. }
  222. .twoZ-font {
  223. font-size: 40rpx;
  224. line-height: 56rpx;
  225. font-weight: 500;
  226. }
  227. .three-font {
  228. font-size: 34rpx;
  229. line-height: 48rpx;
  230. font-weight: 500;
  231. }
  232. .num-font {
  233. font-size: 36rpx;
  234. line-height: 56rpx;
  235. font-weight: 700;
  236. }
  237. .bmTit-font {
  238. font-size: 36rpx;
  239. line-height: 44rpx;
  240. font-weight: 500;
  241. }
  242. .fNum-font {
  243. font-size: 44rpx;
  244. line-height: 56rpx;
  245. font-weight: 700;
  246. }
  247. .zw-font {
  248. font-size: 34rpx;
  249. line-height: 48rpx;
  250. }
  251. .btn-font {
  252. font-size: 28rpx;
  253. line-height: 40rpx;
  254. font-weight: 600;
  255. }
  256. .fwb-font {
  257. font-size: 28rpx;
  258. line-height: 40rpx;
  259. font-size: 400;
  260. }
  261. .sZw-font {
  262. font-size: 26rpx;
  263. line-height: 42rpx;
  264. font-size: 400;
  265. }
  266. .sBtn-font {
  267. font-size: 24rpx;
  268. line-height: 32rpx;
  269. font-weight: 600;
  270. }
  271. .fz-font {
  272. font-size: 24rpx;
  273. line-height: 32rpx;
  274. font-weight: 400;
  275. }
  276. .bq-font {
  277. font-size: 20rpx;
  278. line-height: 24rpx;
  279. }
  280. .bqZ-font {
  281. font-size: 20rpx;
  282. line-height: 24rpx;
  283. font-weight: 600;
  284. }
  285. </style>