|
|
@@ -1,102 +1,145 @@
|
|
|
<script>
|
|
|
-import store from '@/store'
|
|
|
-import { mapMutations, mapActions, mapGetters } from 'vuex'
|
|
|
-import { setTimeout } from 'timers'
|
|
|
-import { getDictionaries } from '@/api/mini'
|
|
|
-import util from "./utils/util"
|
|
|
-import priceSocket from "./mixins/priceSocket";
|
|
|
+import store from '@/store';
|
|
|
+import { mapActions } from 'vuex';
|
|
|
+import { getDictionaries } from '@/api/mini';
|
|
|
+import util from './utils/util';
|
|
|
+import priceSocket from './mixins/priceSocket';
|
|
|
export default {
|
|
|
- mixins:[priceSocket],
|
|
|
+ mixins: [priceSocket],
|
|
|
// 全端,数据共享,还可以解决页面初始化模板访问不到值得
|
|
|
// 有坑 分包里的页面访问不到
|
|
|
globalData: {},
|
|
|
- onLaunch () {
|
|
|
- uni.removeStorageSync('suitInfoList');
|
|
|
- uni.removeStorageSync('productInfoList');
|
|
|
- uni.removeStorageSync('pxClassInfoList');
|
|
|
+ onLaunch() {
|
|
|
+ uni.removeStorageSync('suitInfoList');
|
|
|
+ uni.removeStorageSync('productInfoList');
|
|
|
+ uni.removeStorageSync('pxClassInfoList');
|
|
|
+
|
|
|
+ uni.onPushMessage((res) => {
|
|
|
+ console.log("收到推送消息:",res) //监听推送消息
|
|
|
+ let message = res.data;
|
|
|
+ // 提取页面路径(支持 pagesOrder/detail 这样的格式)
|
|
|
+ let pagePath = message.payload && message.payload.page;
|
|
|
+ // 用户点击查看详情,跳转到指定页面
|
|
|
+ // 检查是否需要添加 / 前缀
|
|
|
+ let url = pagePath.startsWith('/') ? pagePath : `/${pagePath}`;
|
|
|
+
|
|
|
+ // 如果有额外参数,拼接到URL
|
|
|
+ if (message.params || (message.payload && message.payload.params)) {
|
|
|
+ let params = message.params || message.payload.params;
|
|
|
+ let queryString = Object.keys(params).map(key => `${key}=${params[key]}`).join('&');
|
|
|
+ url = `${url}?${queryString}`;
|
|
|
+ }
|
|
|
+ console.log('推送消息跳转页面:', url);
|
|
|
+
|
|
|
+ // 使用 navigateTo 跳转
|
|
|
+ uni.navigateTo({
|
|
|
+ url: url,
|
|
|
+ fail: (err) => {
|
|
|
+ console.error('页面跳转失败:', err);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 设置角标
|
|
|
+ let badgeNumber = message.aps && message.aps.badge ? message.aps.badge - 1 : false;
|
|
|
+ if (badgeNumber !== false) {
|
|
|
+ plus.runtime.setBadgeNumber(badgeNumber);
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
// #ifdef H5
|
|
|
// H5开发环境无法微信授权,使用固定的用户 shish 2020.4.30
|
|
|
- if (process.env.NODE_ENV == "development") {
|
|
|
- uni.setStorageSync("token","eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjBfNTIifQ.eyJpc3MiOiJodHRwczpcL1wvYXBpLnNob3AuaHpnaGQuY29tIiwiYXVkIjoiaHR0cHM6XC9cL2FwaS5zaG9wLmh6Z2hkLmNvbSIsImp0aSI6IjBfNTIiLCJpYXQiOjE2MTYxNTc2NjQsIm5iZiI6MTYxNjE1NzY2NCwiZXhwIjoxNjI0Nzk3NjY0LCJ1bmlxdWVJZCI6IjUyIiwic291cmNlSWQiOjB9.VzSekbSwSczMWsfdPVdrm3gZ-v9o3p01NbMVNT4nGZ4")
|
|
|
- uni.setStorageSync("account", "0")
|
|
|
- getDictionaries({ token: uni.getStorageSync('token') }).then(res => {
|
|
|
+ if (process.env.NODE_ENV == 'development') {
|
|
|
+ uni.setStorageSync(
|
|
|
+ 'token',
|
|
|
+ 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjBfNTIifQ.eyJpc3MiOiJodHRwczpcL1wvYXBpLnNob3AuaHpnaGQuY29tIiwiYXVkIjoiaHR0cHM6XC9cL2FwaS5zaG9wLmh6Z2hkLmNvbSIsImp0aSI6IjBfNTIiLCJpYXQiOjE2MTYxNTc2NjQsIm5iZiI6MTYxNjE1NzY2NCwiZXhwIjoxNjI0Nzk3NjY0LCJ1bmlxdWVJZCI6IjUyIiwic291cmNlSWQiOjB9.VzSekbSwSczMWsfdPVdrm3gZ-v9o3p01NbMVNT4nGZ4'
|
|
|
+ );
|
|
|
+ uni.setStorageSync('account', '0');
|
|
|
+ getDictionaries({ token: uni.getStorageSync('token') }).then((res) => {
|
|
|
if (util.isEmpty(res)) {
|
|
|
- return false
|
|
|
+ return false;
|
|
|
}
|
|
|
store.commit('setDictionariesInfo', {
|
|
|
...res.data.dict,
|
|
|
...res.data
|
|
|
- })
|
|
|
- store.commit('setMyShopInfo', {
|
|
|
- ...res.data.shop,
|
|
|
- ...res.data
|
|
|
- })
|
|
|
- })
|
|
|
+ });
|
|
|
+ store.commit('setMyShopInfo', {
|
|
|
+ ...res.data.shop,
|
|
|
+ ...res.data
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
// #endif
|
|
|
|
|
|
// 删除缓存
|
|
|
if (process.env.NODE_ENV == 'production') {
|
|
|
- uni.removeStorageSync('shopUser')
|
|
|
+ uni.removeStorageSync('shopUser');
|
|
|
}
|
|
|
// #ifdef MP-WEIXIN
|
|
|
// wxLoginFn()
|
|
|
// uni.clearStorage()
|
|
|
- const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
|
|
|
- uni.setStorageSync('account', extConfig.account)
|
|
|
-
|
|
|
+ const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {};
|
|
|
+ uni.setStorageSync('account', extConfig.account);
|
|
|
// #endif
|
|
|
-
|
|
|
},
|
|
|
- onLoad () {
|
|
|
+ onLoad() {
|
|
|
// const pages = getCurrentPages();
|
|
|
// const currentPage = pages[pages.length - 1];
|
|
|
// const url = `/${currentPage.route}`;
|
|
|
// console.log(1111,url)
|
|
|
},
|
|
|
- onShow (extraData) {
|
|
|
- if(extraData){
|
|
|
- uni.setStorageSync('extraData',extraData)
|
|
|
- }
|
|
|
+ onShow(extraData) {
|
|
|
+ if (extraData) {
|
|
|
+ uni.setStorageSync('extraData', extraData);
|
|
|
+ }
|
|
|
},
|
|
|
- onHide () { },
|
|
|
- onError (err) {
|
|
|
- console.error(err, '错误捕获')
|
|
|
+ onHide() {},
|
|
|
+ onError(err) {
|
|
|
+ console.error(err, '错误捕获');
|
|
|
},
|
|
|
methods: {
|
|
|
...mapActions(['setUserShopAll'])
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
|
//没有scss变量方法的,主要引入 这样打包的时候就不会所有的组件都打包进去
|
|
|
-@import "./static/iconfont/iconfont.css";
|
|
|
-@import "./static/css/uni2.css";
|
|
|
-@import "./static/css/base.scss";
|
|
|
-@import "./static/css/common.scss";
|
|
|
-@import "./static/css/reset.scss";
|
|
|
+@import './static/iconfont/iconfont.css';
|
|
|
+@import './static/css/uni2.css';
|
|
|
+@import './static/css/base.scss';
|
|
|
+@import './static/css/common.scss';
|
|
|
+@import './static/css/reset.scss';
|
|
|
page {
|
|
|
height: 100%;
|
|
|
}
|
|
|
/**开单-扎和支切换样式**/
|
|
|
-.switchover-unit{
|
|
|
- position: fixed;
|
|
|
- left: calc(170upx / 2 - 50upx);
|
|
|
- bottom: 140upx;
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- justify-content: center;
|
|
|
- width: 100upx;
|
|
|
- height: 100upx;
|
|
|
- color: #FFFFFF;
|
|
|
- background: #4b8cf4;
|
|
|
- border-radius: 50%;
|
|
|
- font-size: 42upx;
|
|
|
- font-weight: 700;
|
|
|
- z-index: 2;
|
|
|
+.switchover-unit {
|
|
|
+ position: fixed;
|
|
|
+ left: calc(170upx / 2 - 50upx);
|
|
|
+ bottom: 140upx;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ width: 100upx;
|
|
|
+ height: 100upx;
|
|
|
+ color: #ffffff;
|
|
|
+ background: #4b8cf4;
|
|
|
+ border-radius: 50%;
|
|
|
+ font-size: 42upx;
|
|
|
+ font-weight: 700;
|
|
|
+ z-index: 2;
|
|
|
}
|
|
|
/**开单-增加减少动画**/
|
|
|
-.animation{animation:imgmove 0.3s 1;animation-iteration-count:1}
|
|
|
-@-webkit-keyframes imgmove{0%{transform: scale(0.7);}100%{transform: scale(1);}}
|
|
|
+.animation {
|
|
|
+ animation: imgmove 0.3s 1;
|
|
|
+ animation-iteration-count: 1;
|
|
|
+}
|
|
|
+@-webkit-keyframes imgmove {
|
|
|
+ 0% {
|
|
|
+ transform: scale(0.7);
|
|
|
+ }
|
|
|
+ 100% {
|
|
|
+ transform: scale(1);
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|