App.vue 5.0 KB

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