App.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <script>
  2. import { User } from "@/config/api.js";
  3. export default {
  4. onLaunch: function () {
  5. !this.$db.get("access_token") && this.getOpenid();
  6. // #ifdef MP
  7. this.checkVersion();
  8. // #endif
  9. },
  10. onShow: function (optios) {
  11. uni.getSystemInfo({
  12. success: function (res) {
  13. if (res.windowWidth > 700) {
  14. uni.reLaunch({
  15. url: "/pages/pcWebViev/pcWebViev?path=" + optios.path + "&query=" + JSON.stringify(optios.query),
  16. });
  17. }
  18. },
  19. });
  20. },
  21. onHide: function () {},
  22. globalData: {
  23. isLogin: false,
  24. isAuth: null, //是否需要授权 uniid
  25. isBind: null, // 是否需要绑定手机号/邮箱
  26. userInfo: null, //用户信息
  27. access_token: "",
  28. loadOver: "",
  29. bgAudioManager: uni.getBackgroundAudioManager(),
  30. },
  31. methods: {
  32. /* 微信code换临时token */
  33. getOpenid() {
  34. uni.login({
  35. success: (result) => {
  36. User.wechatLog({
  37. Code: result.code,
  38. }).then((res) => {
  39. try {
  40. let token = res.Data.Authorization;
  41. this.$db.set("access_token", token);
  42. // this.$isResolve()
  43. } catch (e) {}
  44. });
  45. },
  46. });
  47. },
  48. checkVersion() {
  49. const updateManager = uni.getUpdateManager();
  50. updateManager.onCheckForUpdate(function (res) {
  51. // 请求完新版本信息的回调
  52. // console.log(res.hasUpdate);
  53. });
  54. updateManager.onUpdateReady(function (res) {
  55. uni.showModal({
  56. title: "更新提示",
  57. content: "新版本已经准备好,是否重启应用?",
  58. success(res) {
  59. if (res.confirm) {
  60. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  61. updateManager.applyUpdate();
  62. }
  63. },
  64. });
  65. });
  66. updateManager.onUpdateFailed(function (res) {
  67. // 新的版本下载失败
  68. });
  69. },
  70. },
  71. };
  72. </script>
  73. <style lang="scss">
  74. @import "uview-ui/index.scss";
  75. /*每个页面公共css */
  76. * {
  77. margin: 0;
  78. padding: 0;
  79. box-sizing: border-box;
  80. }
  81. ::-webkit-scrollbar {
  82. display: none;
  83. width: 0;
  84. height: 0;
  85. color: transparent;
  86. }
  87. view,
  88. text {
  89. box-sizing: border-box;
  90. }
  91. input {
  92. box-sizing: border-box;
  93. }
  94. button {
  95. margin: 0;
  96. padding: 0;
  97. }
  98. button::after {
  99. border: none;
  100. }
  101. .container {
  102. width: 100%;
  103. min-height: 100vh;
  104. font-size: 28rpx;
  105. }
  106. text {
  107. display: block;
  108. }
  109. button {
  110. text-align: center;
  111. border-radius: 8rpx;
  112. }
  113. /* border 1px样式 */
  114. .border_bottom,
  115. .border_top,
  116. .border_all {
  117. position: relative;
  118. }
  119. .border_top::after {
  120. position: absolute;
  121. content: "";
  122. width: 100%;
  123. left: 0;
  124. top: 0;
  125. height: 1px;
  126. padding: 0 32rpx;
  127. box-sizing: border-box;
  128. background-color: #e5e5e5;
  129. -webkit-transform: scale(1, 0.5);
  130. transform: scale(1, 0.5);
  131. -webkit-transform-origin: center bottom;
  132. transform-origin: center bottom;
  133. }
  134. .border_bottom::after {
  135. position: absolute;
  136. content: "";
  137. width: 100%;
  138. left: 0;
  139. bottom: 0;
  140. height: 1px;
  141. padding: 0 32rpx;
  142. box-sizing: border-box;
  143. background-color: #e5e5e5;
  144. -webkit-transform: scale(1, 0.5);
  145. transform: scale(1, 0.5);
  146. -webkit-transform-origin: center bottom;
  147. transform-origin: center bottom;
  148. }
  149. .border_all::before {
  150. content: "";
  151. display: block;
  152. position: absolute;
  153. width: 200%;
  154. height: 200%;
  155. border: 1px solid #d9d9d9;
  156. border-radius: 10rpx;
  157. transform-origin: 0 0;
  158. transform: scale(0.5, 0.5);
  159. -webkit-transform: scale(0.5, 0.5);
  160. box-sizing: border-box;
  161. }
  162. //全屏蒙版
  163. .mask-diaog {
  164. position: fixed;
  165. left: 0;
  166. top: 0;
  167. bottom: 0;
  168. right: 0;
  169. overflow: hidden;
  170. background-color: rgba(0, 0, 0, 0.5);
  171. z-index: 1000;
  172. color: #fff;
  173. }
  174. // 底部确认按钮
  175. .bot-btn-cont {
  176. width: 100%;
  177. position: fixed;
  178. left: 0;
  179. bottom: 122rpx;
  180. z-index: 9;
  181. .bot-btn {
  182. margin: 0 auto;
  183. width: 694rpx;
  184. height: 88rpx;
  185. line-height: 88rpx;
  186. text-align: center;
  187. font-size: 36rpx;
  188. color: #fff;
  189. background-color: #3385ff;
  190. }
  191. }
  192. // 无数据
  193. .nodata {
  194. text-align: center;
  195. display: block;
  196. color: #666666;
  197. padding: 200rpx 0;
  198. margin: 0 auto;
  199. .nodata_ico {
  200. width: 374rpx;
  201. height: 288rpx;
  202. margin-bottom: 30rpx;
  203. }
  204. .nodata_img {
  205. width: 374rpx;
  206. height: 288rpx;
  207. margin-bottom: 50rpx;
  208. }
  209. }
  210. .nodata2 {
  211. margin-top: 300rpx;
  212. }
  213. // 单行省略
  214. .text_oneLine {
  215. overflow: hidden;
  216. text-overflow: ellipsis;
  217. white-space: nowrap;
  218. }
  219. /* 2行省略 */
  220. .text_twoLine {
  221. text-overflow: -o-ellipsis-lastline;
  222. overflow: hidden;
  223. text-overflow: ellipsis;
  224. display: -webkit-box;
  225. -webkit-line-clamp: 2;
  226. line-clamp: 2;
  227. -webkit-box-orient: vertical;
  228. }
  229. /* 按钮空心样式 */
  230. .plain-style {
  231. background-color: #f2f2f2 !important;
  232. color: #07c160 !important;
  233. }
  234. .select-box {
  235. width: 100%;
  236. .box {
  237. height: 95prx;
  238. line-height: 95rpx;
  239. text-align: center;
  240. font-size: 32rpx;
  241. border-bottom: 1rpx solid #ebebeb;
  242. }
  243. .box-bottom {
  244. border-bottom: none !important;
  245. }
  246. }
  247. .slot-content {
  248. width: 100%;
  249. padding: 50rpx;
  250. text-align: center;
  251. font-size: 32rpx;
  252. color: #0f1826;
  253. line-height: 48rpx;
  254. }
  255. .forbid-copy {
  256. -webkit-user-select: none;
  257. -khtml-user-select: none;
  258. -moz-user-select: none;
  259. -ms-user-select: none;
  260. user-select: none;
  261. }
  262. .cancel-attention {
  263. flex-shrink: 0;
  264. padding: 5rpx 28rpx;
  265. border-radius: 37rpx 37rpx 37rpx 37rpx;
  266. font-weight: 400;
  267. font-size: 24rpx;
  268. background-color: #f0f0f0;
  269. color: #999999;
  270. }
  271. .free-charge {
  272. position: fixed;
  273. display: flex;
  274. align-items: center;
  275. bottom: 320rpx;
  276. right: 41rpx;
  277. height: 156rpx;
  278. z-index: 888;
  279. }
  280. .footer-free-charge {
  281. z-index: 99999;
  282. }
  283. </style>