App.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <script>
  2. import initConfig from '@/initConfig.js';
  3. // #ifdef MP-WEIXIN
  4. import { SCAN_QR_CACHE } from '@/settings/enums.js';
  5. import { parseSceneToStoreTable, isScanEntryAllowed } from '@/utils/qrScene.js';
  6. import { syncM2GenericPricingStorage } from '@/utils/m2GenericApiPath.js';
  7. // #endif
  8. export default {
  9. onLaunch: function (e) {
  10. // 只有小程序执行
  11. // #ifdef MP-WEIXIN
  12. initConfig();
  13. // 通过二维码编译/扫码进入:将二维码携带的信息缓存(query.scene 为小程序码参数,query.q 为普通链接二维码)
  14. try {
  15. const sceneEnc = e?.query?.scene;
  16. const qEnc = e?.query?.q;
  17. const scene = sceneEnc != null && sceneEnc !== '' ? decodeURIComponent(String(sceneEnc)) : '';
  18. const q = qEnc != null && qEnc !== '' ? decodeURIComponent(String(qEnc)) : '';
  19. const rawFromQR = scene || q || '';
  20. if (rawFromQR) {
  21. const { storeId, tableId, m } = parseSceneToStoreTable(rawFromQR);
  22. const payload = { raw: rawFromQR, storeId, tableId, m };
  23. uni.setStorageSync(SCAN_QR_CACHE, JSON.stringify(payload));
  24. syncM2GenericPricingStorage(m);
  25. // 美食(m=1/无 m) 或 通用价目(m=2) 写入桌店;其它 m 不写
  26. if (isScanEntryAllowed(m)) {
  27. if (storeId) uni.setStorageSync('currentStoreId', storeId);
  28. if (tableId) uni.setStorageSync('currentTableId', tableId);
  29. }
  30. } else {
  31. syncM2GenericPricingStorage('');
  32. }
  33. } catch (err) {
  34. console.warn('缓存二维码启动参数失败', err);
  35. }
  36. // #endif
  37. },
  38. onShow: function (res) {
  39. console.log('App Show', res);
  40. // 是否是从被打开的小程序返回
  41. const { appId, extraData } = res.referrerInfo;
  42. if (appId && extraData) {
  43. uni.$emit('listener:ArBack', res.referrerInfo);
  44. }
  45. },
  46. onHide: function () {
  47. console.log('App Hide');
  48. }
  49. };
  50. </script>
  51. <style lang="scss">
  52. view,
  53. image,
  54. label {
  55. box-sizing: border-box;
  56. word-break: break-all;
  57. }
  58. image {
  59. height: auto;
  60. width: auto;
  61. }
  62. /* #ifndef APP-NVUE */
  63. // 设置整个项目的背景色
  64. page {
  65. background-color: #f7f9fa;
  66. }
  67. /* #endif */
  68. // 弹性盒子
  69. .flex {
  70. display: flex;
  71. &-none {
  72. flex: none;
  73. }
  74. &-1 {
  75. flex: 1;
  76. }
  77. &-y {
  78. flex-direction: column;
  79. }
  80. &-top {
  81. align-items: flex-start !important;
  82. }
  83. // 顶部对齐
  84. &-bottom {
  85. align-items: flex-end;
  86. }
  87. // 底部对齐
  88. &-content-end {
  89. justify-content: flex-end;
  90. }
  91. // 水平靠右 || 垂直靠下对齐
  92. &-center {
  93. align-items: center;
  94. }
  95. // 水平居中对齐
  96. &-center-center {
  97. align-items: center;
  98. justify-content: center;
  99. }
  100. // 水平垂直居中
  101. &-between {
  102. justify-content: space-between;
  103. }
  104. // 两端不留间隙对齐
  105. &-around {
  106. justify-content: space-around;
  107. }
  108. // 两端留间隙对齐
  109. &-wrap {
  110. flex-wrap: wrap;
  111. }
  112. // 允许换行
  113. }
  114. .w-0 {
  115. width: 0;
  116. }
  117. .h-0 {
  118. height: 0;
  119. }
  120. // 隐藏显示多少行
  121. .ellipsis {
  122. overflow: hidden;
  123. text-overflow: ellipsis;
  124. display: -webkit-box;
  125. -webkit-box-orient: vertical;
  126. -webkit-line-clamp: 1;
  127. word-break: break-all;
  128. @for $i from 2 through 10 {
  129. &.ellipsis-#{$i} {
  130. -webkit-line-clamp: $i;
  131. }
  132. }
  133. &-no {
  134. display: block;
  135. }
  136. }
  137. // 点击时的透明度
  138. .hover-active {
  139. opacity: 0.8 !important;
  140. }
  141. // 底部安全区
  142. .safe-area {
  143. padding-bottom: constant(safe-area-inset-bottom);
  144. /* 兼容 iOS < 11.2 */
  145. padding-bottom: env(safe-area-inset-bottom);
  146. /* 兼容 iOS >= 11.2 */
  147. }
  148. .ql-editor.ql-blank:before {
  149. color: #999999;
  150. font-size: 28rpx;
  151. font-style: normal;
  152. }
  153. </style>