App.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. * {
  98. box-sizing: border-box;
  99. }
  100. uni-page-body,
  101. html,
  102. body {
  103. height: 100%;
  104. width: 750rpx;
  105. background: #F6F6F6;
  106. }
  107. .u-button--primary {
  108. background-color: #5776E6;
  109. }
  110. .uni-input-placeholder {
  111. text-align: right;
  112. }
  113. .ml5 {
  114. margin-left: 10rpx;
  115. }
  116. .contain {
  117. height: 100%;
  118. padding-bottom: 120rpx;
  119. padding-top: 24rpx;
  120. overflow-y: auto;
  121. .main {
  122. padding: 0 32rpx;
  123. background-color: #fff;
  124. }
  125. .tijiao {
  126. position: fixed;
  127. width: 100%;
  128. bottom: 0;
  129. left: 0;
  130. background-color: #fff;
  131. padding: 16rpx 32rpx;
  132. box-sizing: border-box;
  133. box-shadow: 0 -6px 12px 0 rgba(153, 153, 153, 0.10);
  134. }
  135. .u-cell__value {
  136. color: #333 !important;
  137. }
  138. }
  139. .tabPage{
  140. background: #F7F7F7;
  141. padding: 0 24rpx 194rpx;
  142. box-sizing: border-box;
  143. }
  144. .adf{
  145. display: flex;
  146. }
  147. .adfac{
  148. display: flex;
  149. align-items: center;
  150. }
  151. .adffc{
  152. display: flex;
  153. flex-direction: column;
  154. }
  155. .adfacjc{
  156. display: flex;
  157. align-items: center;
  158. justify-content: center;
  159. }
  160. .adfacjb{
  161. display: flex;
  162. align-items: center;
  163. justify-content: space-between;
  164. }
  165. .adffcac{
  166. display: flex;
  167. flex-direction: column;
  168. align-items: center;
  169. }
  170. .adffcacjc{
  171. display: flex;
  172. flex-direction: column;
  173. align-items: center;
  174. justify-content: center;
  175. }
  176. .adffcacjb{
  177. display: flex;
  178. flex-direction: column;
  179. align-items: center;
  180. justify-content: space-between;
  181. }
  182. .zt_btn{
  183. width: 100%;
  184. height: 88rpx;
  185. background: linear-gradient( 90deg, #33A7A7 0%, #64BBBB 100%);;
  186. border-radius: 44rpx;
  187. font-family: PingFangSC, PingFang SC;
  188. font-weight: bold;
  189. font-size: 32rpx;
  190. color: #FFFFFF;
  191. line-height: 88rpx;
  192. text-align: center;
  193. letter-spacing: 2rpx;
  194. }
  195. .qx_btn{
  196. width: 100%;
  197. height: 88rpx;
  198. border-radius: 44rpx;
  199. background: rgba(25, 156, 156, 0.06);
  200. font-family: PingFang-SC, PingFang-SC;
  201. font-weight: bold;
  202. font-size: 32rpx;
  203. color: #009191;
  204. line-height: 88rpx;
  205. text-align: center;
  206. letter-spacing: 2rpx;
  207. }
  208. </style>