| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <script>
- import initConfig from '@/initConfig.js';
- // #ifdef MP-WEIXIN
- import { SCAN_QR_CACHE } from '@/settings/enums.js';
- import { parseSceneToStoreTable, isScanEntryAllowed } from '@/utils/qrScene.js';
- import { syncM2GenericPricingStorage } from '@/utils/m2GenericApiPath.js';
- // #endif
- export default {
- onLaunch: function (e) {
- // 只有小程序执行
- // #ifdef MP-WEIXIN
- initConfig();
- // 通过二维码编译/扫码进入:将二维码携带的信息缓存(query.scene 为小程序码参数,query.q 为普通链接二维码)
- try {
- const sceneEnc = e?.query?.scene;
- const qEnc = e?.query?.q;
- const scene = sceneEnc != null && sceneEnc !== '' ? decodeURIComponent(String(sceneEnc)) : '';
- const q = qEnc != null && qEnc !== '' ? decodeURIComponent(String(qEnc)) : '';
- const rawFromQR = scene || q || '';
- if (rawFromQR) {
- const { storeId, tableId, m } = parseSceneToStoreTable(rawFromQR);
- const payload = { raw: rawFromQR, storeId, tableId, m };
- uni.setStorageSync(SCAN_QR_CACHE, JSON.stringify(payload));
- syncM2GenericPricingStorage(m);
- // 美食(m=1/无 m) 或 通用价目(m=2) 写入桌店;其它 m 不写
- if (isScanEntryAllowed(m)) {
- if (storeId) uni.setStorageSync('currentStoreId', storeId);
- if (tableId) uni.setStorageSync('currentTableId', tableId);
- }
- } else {
- syncM2GenericPricingStorage('');
- }
- } catch (err) {
- console.warn('缓存二维码启动参数失败', err);
- }
- // #endif
- },
- onShow: function (res) {
- console.log('App Show', res);
- // 是否是从被打开的小程序返回
- const { appId, extraData } = res.referrerInfo;
- if (appId && extraData) {
- uni.$emit('listener:ArBack', res.referrerInfo);
- }
- },
- onHide: function () {
- console.log('App Hide');
- }
- };
- </script>
- <style lang="scss">
- view,
- image,
- label {
- box-sizing: border-box;
- word-break: break-all;
- }
- image {
- height: auto;
- width: auto;
- }
- /* #ifndef APP-NVUE */
- // 设置整个项目的背景色
- page {
- background-color: #f7f9fa;
- }
- /* #endif */
- // 弹性盒子
- .flex {
- display: flex;
- &-none {
- flex: none;
- }
- &-1 {
- flex: 1;
- }
- &-y {
- flex-direction: column;
- }
- &-top {
- align-items: flex-start !important;
- }
- // 顶部对齐
- &-bottom {
- align-items: flex-end;
- }
- // 底部对齐
- &-content-end {
- justify-content: flex-end;
- }
- // 水平靠右 || 垂直靠下对齐
- &-center {
- align-items: center;
- }
- // 水平居中对齐
- &-center-center {
- align-items: center;
- justify-content: center;
- }
- // 水平垂直居中
- &-between {
- justify-content: space-between;
- }
- // 两端不留间隙对齐
- &-around {
- justify-content: space-around;
- }
- // 两端留间隙对齐
- &-wrap {
- flex-wrap: wrap;
- }
- // 允许换行
- }
- .w-0 {
- width: 0;
- }
- .h-0 {
- height: 0;
- }
- // 隐藏显示多少行
- .ellipsis {
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 1;
- word-break: break-all;
- @for $i from 2 through 10 {
- &.ellipsis-#{$i} {
- -webkit-line-clamp: $i;
- }
- }
- &-no {
- display: block;
- }
- }
- // 点击时的透明度
- .hover-active {
- opacity: 0.8 !important;
- }
- // 底部安全区
- .safe-area {
- padding-bottom: constant(safe-area-inset-bottom);
- /* 兼容 iOS < 11.2 */
- padding-bottom: env(safe-area-inset-bottom);
- /* 兼容 iOS >= 11.2 */
- }
- .ql-editor.ql-blank:before {
- color: #999999;
- font-size: 28rpx;
- font-style: normal;
- }
- </style>
|