App.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <script>
  2. export default {
  3. data() {
  4. return {
  5. isFirstLaunch: true
  6. }
  7. },
  8. onLaunch: function(options) {
  9. this.handleLaunchOrShow(options);
  10. },
  11. onShow: function(options) {
  12. this.autoUpdate();
  13. if (this.isFirstLaunch) {
  14. this.handleLaunchOrShow(options);
  15. this.isFirstLaunch = false;
  16. }
  17. //通过 URL Scheme 唤醒小程序,传递的参数 query
  18. if (options.scene === 1065 && options.query) {
  19. const shareTQId = options.query.shareTQId;
  20. const shareUserId = options.query.shareUserId;
  21. if(shareTQId&&shareUserId) {
  22. uni.reLaunch({
  23. url: `/pages/home?shareTQId=${shareTQId}&shareUserId=${shareUserId}&from=urlScheme`
  24. });
  25. this.isFirstLaunch = false;
  26. }
  27. }
  28. },
  29. onHide: function() {
  30. if(uni.getStorageSync('channelType')) uni.removeStorageSync('channelType')
  31. if(uni.getStorageSync('shareTQId')) uni.removeStorageSync('shareTQId')
  32. if(uni.getStorageSync('shareUserId')) uni.removeStorageSync('shareUserId')
  33. },
  34. methods: {
  35. autoUpdate() {
  36. if (wx.canIUse('getUpdateManager')) {
  37. const updateManager = wx.getUpdateManager();
  38. updateManager.onCheckForUpdate(res => {
  39. if (res.hasUpdate) {
  40. updateManager.onUpdateReady(() => {
  41. wx.showModal({
  42. title: '更新提示',
  43. content: '发现新版本,是否更新?',
  44. success: function(res) {
  45. if (res.confirm) {
  46. updateManager.applyUpdate();
  47. }
  48. }
  49. })
  50. });
  51. updateManager.onUpdateFailed(function() {
  52. wx.showModal({
  53. title: '最新版提示',
  54. content: '新版本已上线,请您删除当前小程序,重新搜索打开',
  55. showCancel: false
  56. })
  57. });
  58. }
  59. })
  60. } else {
  61. wx.showModal({
  62. title: '提示',
  63. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。',
  64. showCancel: false
  65. })
  66. }
  67. },
  68. async handleLaunchOrShow(options) {
  69. // 获取扫码参数(scene是场景值,query是扫码携带的参数)
  70. const { scene, query } = options;
  71. // 判断是否是扫码打开(微信扫码场景值:1011 小程序码扫码,1012 长按识别小程序码)
  72. const isScanScene = [1011, 1012].includes(scene);
  73. const isScanType = query.q && query.q.indexOf('scan')>-1;
  74. if (isScanScene && isScanType) {
  75. // 关闭首页的加载/渲染,避免闪烁
  76. uni.hideHomeButton();
  77. uni.reLaunch({
  78. url: '/pages/scan',
  79. fail: (err) => {
  80. uni.reLaunch({ url: '/pages/home' });
  81. }
  82. });
  83. return;
  84. }
  85. uni.reLaunch({ url: '/pages/home' });
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="scss">
  91. /*每个页面公共css */
  92. @import "@/uni_modules/uview-ui/index.scss";
  93. @font-face {
  94. font-family: 'D-DINCondensed';
  95. src: url("@/static/Bebas.TTF");
  96. }
  97. *:not(.u-icon__icon):not([class*="iconfont"]) {
  98. box-sizing: border-box;
  99. font-family: Calibri, "Microsoft JhengHei UI", sans-serif !important;
  100. }
  101. uni-page-body,
  102. html,
  103. body {
  104. height: 100%;
  105. width: 750rpx;
  106. background: #F6F6F6;
  107. }
  108. .u-button--primary {
  109. background-color: #5776E6;
  110. }
  111. .uni-input-placeholder {
  112. text-align: right;
  113. }
  114. .ml5 {
  115. margin-left: 10rpx;
  116. }
  117. .contain {
  118. height: 100%;
  119. padding-bottom: 120rpx;
  120. padding-top: 24rpx;
  121. overflow-y: auto;
  122. .main {
  123. padding: 0 32rpx;
  124. background-color: #fff;
  125. }
  126. .tijiao {
  127. position: fixed;
  128. width: 100%;
  129. bottom: 0;
  130. left: 0;
  131. background-color: #fff;
  132. padding: 16rpx 32rpx;
  133. box-sizing: border-box;
  134. box-shadow: 0 -6px 12px 0 rgba(153, 153, 153, 0.10);
  135. }
  136. .u-cell__value {
  137. color: #333 !important;
  138. }
  139. }
  140. .tabPage{
  141. background: #F7F7F7;
  142. padding: 0 24rpx 194rpx;
  143. box-sizing: border-box;
  144. }
  145. .adf{
  146. display: flex;
  147. }
  148. .adfac{
  149. display: flex;
  150. align-items: center;
  151. }
  152. .adffc{
  153. display: flex;
  154. flex-direction: column;
  155. }
  156. .adfacjc{
  157. display: flex;
  158. align-items: center;
  159. justify-content: center;
  160. }
  161. .adfacjb{
  162. display: flex;
  163. align-items: center;
  164. justify-content: space-between;
  165. }
  166. .adffcac{
  167. display: flex;
  168. flex-direction: column;
  169. align-items: center;
  170. }
  171. .adffcacjc{
  172. display: flex;
  173. flex-direction: column;
  174. align-items: center;
  175. justify-content: center;
  176. }
  177. .adffcacjb{
  178. display: flex;
  179. flex-direction: column;
  180. align-items: center;
  181. justify-content: space-between;
  182. }
  183. .zt_btn{
  184. width: 100%;
  185. height: 88rpx;
  186. background: linear-gradient( 90deg, #33A7A7 0%, #64BBBB 100%);;
  187. border-radius: 44rpx;
  188. font-family: PingFangSC, PingFang SC;
  189. font-weight: bold;
  190. font-size: 32rpx;
  191. color: #FFFFFF;
  192. line-height: 88rpx;
  193. text-align: center;
  194. letter-spacing: 2rpx;
  195. }
  196. .qx_btn{
  197. width: 100%;
  198. height: 88rpx;
  199. border-radius: 44rpx;
  200. background: rgba(25, 156, 156, 0.06);
  201. font-family: PingFang-SC, PingFang-SC;
  202. font-weight: bold;
  203. font-size: 32rpx;
  204. color: #009191;
  205. line-height: 88rpx;
  206. text-align: center;
  207. letter-spacing: 2rpx;
  208. }
  209. </style>