App.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <script>
  2. import {
  3. useStore
  4. } from 'vuex'
  5. import storage from '@/utils/storage'
  6. export default {
  7. onLaunch: function(options) {
  8. // 暂时隐藏uni.hideTabBar()
  9. // uni.hideTabBar()
  10. // 分销
  11. const store = useStore()
  12. let parent_id
  13. if (options.query && options.query.scene) {
  14. parent_id = decodeURIComponent(options.query.scene).split('=')[1]
  15. } else if (options.query && options.query.parent_id) {
  16. parent_id = options.query.parent_id
  17. }
  18. storage.set('PARENT_ID', parent_id, 30 * 86400 * 3)
  19. store.commit('M_PARENT_ID', parent_id);
  20. // #ifdef MP
  21. this.updateManager()
  22. // #endif
  23. },
  24. onShow: function() {
  25. console.log('App Show');
  26. },
  27. onLoad() {
  28. console.log('App Load');
  29. },
  30. onHide: function() {
  31. console.log('App Hide');
  32. },
  33. methods: {
  34. /**
  35. * 小程序主动更新
  36. */
  37. updateManager() {
  38. const updateManager = uni.getUpdateManager();
  39. updateManager.onCheckForUpdate(res => {
  40. // 请求完新版本信息的回调
  41. // console.log(res.hasUpdate)
  42. })
  43. updateManager.onUpdateReady(() => {
  44. uni.showModal({
  45. title: '更新提示',
  46. content: '新版本已经准备好,即将重启应用',
  47. showCancel: false,
  48. success(res) {
  49. if (res.confirm) {
  50. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  51. updateManager.applyUpdate()
  52. }
  53. }
  54. })
  55. })
  56. updateManager.onUpdateFailed(() => {
  57. // 新的版本下载失败
  58. uni.showModal({
  59. title: '更新提示',
  60. content: '新版本下载失败',
  61. showCancel: false
  62. })
  63. })
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss">
  69. /*uview-plus */
  70. @import "@/uni_modules/uview-plus/index.scss";
  71. /* 自定义样式 */
  72. @import "@/common/scss/common.scss";
  73. @import "@/common/scss/animation.scss";
  74. @import "@/utils/utils.scss";
  75. page {
  76. background-color: $--base-cont-bg;
  77. font-family: PingFang SC-Bold, PingFang SC;
  78. /* #ifndef MP-ALIPAY */
  79. height: 100%;
  80. /* #endif */
  81. /* #ifdef MP-ALIPAY */
  82. height: 100vh;
  83. /* #endif */
  84. font-size: 28rpx;
  85. word-break: break-all;
  86. }
  87. .w-calc-30 {
  88. padding: 0 30rpx;
  89. width: calc(100% - 60rpx);
  90. }
  91. .hb {
  92. height: 100%;
  93. box-sizing: border-box;
  94. }
  95. .hidden {
  96. overflow: hidden;
  97. }
  98. .base-color {
  99. color: $--base-color;
  100. }
  101. .base-color-2 {
  102. color: $--base-color2;
  103. }
  104. .base-color-3 {
  105. color: $--base-color3;
  106. }
  107. .base-color-red {
  108. color: $--base-color-red;
  109. }
  110. .base-color-gray {
  111. color: $--base-color-gray;
  112. }
  113. .base-color-dark {
  114. color: $--base-color-dark;
  115. }
  116. .base-color-dark2 {
  117. color: $--base-color-dark2;
  118. }
  119. .base-price {
  120. color: $--base-color-price;
  121. }
  122. .base-success {
  123. color: $--base-color-success;
  124. }
  125. .base-bg {
  126. background: $--base-bg;
  127. }
  128. .base-bg-2 {
  129. background: $--base-bg2;
  130. }
  131. .colorf {
  132. color: #fff;
  133. }
  134. .color0 {
  135. color: #000;
  136. }
  137. .color3 {
  138. color: #333;
  139. }
  140. .color6 {
  141. color: #666;
  142. }
  143. .color9 {
  144. color: #999;
  145. }
  146. .bgf {
  147. background: #fff;
  148. }
  149. .fixed {
  150. position: fixed;
  151. }
  152. .absolute {
  153. position: absolute;
  154. }
  155. .relative {
  156. position: relative;
  157. }
  158. .w100 {
  159. width: 100%;
  160. }
  161. .h100 {
  162. height: 100%;
  163. }
  164. .card {
  165. background: #fff;
  166. border-radius: 15rpx;
  167. }
  168. .cover-height {
  169. height: 100%;
  170. display: flex;
  171. flex-direction: column;
  172. box-sizing: border-box;
  173. }
  174. .row {
  175. display: flex;
  176. flex-direction: row;
  177. }
  178. .column {
  179. display: flex;
  180. flex-direction: column;
  181. }
  182. .justify-start {
  183. display: flex;
  184. justify-content: flex-start;
  185. }
  186. .justify-center {
  187. display: flex;
  188. justify-content: center;
  189. }
  190. .justify-end {
  191. display: flex;
  192. justify-content: flex-end;
  193. }
  194. .justify-around {
  195. display: flex;
  196. justify-content: space-around;
  197. }
  198. .justify-evenly {
  199. display: flex;
  200. justify-content: space-evenly;
  201. }
  202. .justify-between {
  203. display: flex;
  204. justify-content: space-between;
  205. }
  206. .align-start {
  207. display: flex;
  208. align-items: flex-start;
  209. }
  210. .align-center {
  211. display: flex;
  212. align-items: center;
  213. }
  214. .align-end {
  215. display: flex;
  216. align-items: flex-end;
  217. }
  218. .center {
  219. display: flex;
  220. justify-content: center;
  221. align-items: center;
  222. }
  223. .centerV {
  224. display: flex;
  225. justify-content: center;
  226. align-items: center;
  227. flex-direction: column;
  228. }
  229. .wrap {
  230. flex-wrap: wrap;
  231. }
  232. .flex-1 {
  233. flex: 1;
  234. }
  235. .ellipsis {
  236. overflow: hidden;
  237. text-overflow: ellipsis;
  238. display: -webkit-box;
  239. -webkit-box-orient: vertical;
  240. box-sizing: border-box;
  241. width: 100%;
  242. -webkit-line-clamp: 1;
  243. }
  244. .lines-2 {
  245. -webkit-line-clamp: 2 !important;
  246. }
  247. .bold {
  248. font-weight: bold;
  249. }
  250. .line-through {
  251. text-decoration: line-through;
  252. }
  253. .scrollx {
  254. overflow-x: scroll;
  255. }
  256. .scrolly {
  257. overflow-y: scroll;
  258. }
  259. </style>