|
@@ -2,10 +2,8 @@ import store from '@/store'
|
|
|
import { mapGetters,mapActions } from 'vuex'
|
|
import { mapGetters,mapActions } from 'vuex'
|
|
|
import { pageTo, isLogin } from '@/utils/util.js'
|
|
import { pageTo, isLogin } from '@/utils/util.js'
|
|
|
import { getUser, wxMiniLogin } from '@/utils/auth'
|
|
import { getUser, wxMiniLogin } from '@/utils/auth'
|
|
|
-import { postWxCode, getDictionaries } from '@/api/mini'
|
|
|
|
|
-import { getStaffApi,hasTokenAutoLogin } from '@/api/common'
|
|
|
|
|
-import { allProduct } from '@/api/product'
|
|
|
|
|
-import { codePay} from "@/api/order/index";
|
|
|
|
|
|
|
+import { getDictionaries } from '@/api/mini'
|
|
|
|
|
+import { hasTokenAutoLogin } from '@/api/common'
|
|
|
|
|
|
|
|
// #ifdef APP-PLUS
|
|
// #ifdef APP-PLUS
|
|
|
const shangMiPrint = uni.requireNativePlugin('G5KJ-ShangMiPrint')
|
|
const shangMiPrint = uni.requireNativePlugin('G5KJ-ShangMiPrint')
|
|
@@ -59,14 +57,12 @@ export default {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(this.$util.isEmpty(this.getLoginInfo)){
|
|
if(this.$util.isEmpty(this.getLoginInfo)){
|
|
|
-
|
|
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
|
|
- //微信小程序第一次打开小程序时尝试登录一次
|
|
|
|
|
var pages = getCurrentPages()
|
|
var pages = getCurrentPages()
|
|
|
let currentRoute = pages[pages.length-1].route;
|
|
let currentRoute = pages[pages.length-1].route;
|
|
|
let token = uni.getStorageSync('token')
|
|
let token = uni.getStorageSync('token')
|
|
|
if(this.$util.isEmpty(token)){
|
|
if(this.$util.isEmpty(token)){
|
|
|
if(currentRoute == 'pages/home/cash'){
|
|
if(currentRoute == 'pages/home/cash'){
|
|
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
wxMiniLogin(true).then(res => {
|
|
wxMiniLogin(true).then(res => {
|
|
|
//用于开启小程序自动登录
|
|
//用于开启小程序自动登录
|
|
|
let currentMiniOpenId = res.data.currentMiniOpenId || ''
|
|
let currentMiniOpenId = res.data.currentMiniOpenId || ''
|
|
@@ -80,6 +76,7 @@ export default {
|
|
|
this.init()
|
|
this.init()
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
+ // #endif
|
|
|
}
|
|
}
|
|
|
}else{
|
|
}else{
|
|
|
let that = this
|
|
let that = this
|
|
@@ -96,35 +93,7 @@ export default {
|
|
|
store.commit('setLoginInfo', { ...subRes.data.admin, ...subRes.data })
|
|
store.commit('setLoginInfo', { ...subRes.data.admin, ...subRes.data })
|
|
|
this.skCustomId = subRes.data.skCustomId
|
|
this.skCustomId = subRes.data.skCustomId
|
|
|
// #ifdef APP-PLUS
|
|
// #ifdef APP-PLUS
|
|
|
- this.listenPDAkd()
|
|
|
|
|
- // #endif
|
|
|
|
|
- this.setUserShopAll()
|
|
|
|
|
- if (this.init) {
|
|
|
|
|
- this.init()
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- // #endif
|
|
|
|
|
-
|
|
|
|
|
- //#ifdef APP-PLUS
|
|
|
|
|
- //有token重新获取登陆信息!!!
|
|
|
|
|
- const appToken = uni.getStorageSync('token')
|
|
|
|
|
- if(!this.$util.isEmpty(appToken)){
|
|
|
|
|
- let that = this
|
|
|
|
|
- hasTokenAutoLogin().then(subRes=>{
|
|
|
|
|
- if(subRes.code != 1){
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- getDictionaries({ token: subRes.data.token }).then(res => {
|
|
|
|
|
- if (!that.$util.isEmpty(res)) {
|
|
|
|
|
- store.commit('setDictionariesInfo', { ...res.data.dict, ...res.data })
|
|
|
|
|
- store.commit('setMyShopInfo', { ...res.data.shop, ...res.data })
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- store.commit('setLoginInfo', { ...subRes.data.admin, ...subRes.data })
|
|
|
|
|
- this.skCustomId = subRes.data.skCustomId
|
|
|
|
|
- // #ifdef APP-PLUS
|
|
|
|
|
- this.listenPDAkd()
|
|
|
|
|
|
|
+ this.listenScan()
|
|
|
// #endif
|
|
// #endif
|
|
|
this.setUserShopAll()
|
|
this.setUserShopAll()
|
|
|
if (this.init) {
|
|
if (this.init) {
|
|
@@ -132,8 +101,6 @@ export default {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
- // #endif
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
},
|
|
},
|
|
@@ -146,119 +113,26 @@ export default {
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
...mapActions(['setUserShopAll']),
|
|
...mapActions(['setUserShopAll']),
|
|
|
-
|
|
|
|
|
// #ifdef APP-PLUS
|
|
// #ifdef APP-PLUS
|
|
|
- //监听pda扫码开单
|
|
|
|
|
- listenPDAkd(){
|
|
|
|
|
-
|
|
|
|
|
- //PDA扫码开单前准备好所有花材,首页已经有加载不再需要
|
|
|
|
|
- allProduct().then(res=>{
|
|
|
|
|
- this.allProduct = res.data.list
|
|
|
|
|
- console.log('................载入最新花材................')
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- this.checkStock = true
|
|
|
|
|
-
|
|
|
|
|
- let that = this
|
|
|
|
|
-
|
|
|
|
|
- //商米D1s收银台
|
|
|
|
|
- if(plus.device.vendor == 'SUNMI'){
|
|
|
|
|
- //https://ext.dcloud.net.cn/plugin?id=3514
|
|
|
|
|
- //初始化
|
|
|
|
|
- shangMiPrint.init()
|
|
|
|
|
- //扫码返回
|
|
|
|
|
- globalEvent.addEventListener('scancode',function(e){
|
|
|
|
|
- if(e.code == 'ok'){
|
|
|
|
|
- let productIdCode = e.data
|
|
|
|
|
- console.log(productIdCode)
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- console.log('!!!!!!!!!!!!!!!!!!!!!!!!商米收银台发起监听!!!!!!!!!!!!!!!!!!!!!!!!')
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- // #endif
|
|
|
|
|
- //付款码付款
|
|
|
|
|
- requestCodePay(authCode){
|
|
|
|
|
- let that = this
|
|
|
|
|
- uni.showLoading({title: '正在付款',mask:true})
|
|
|
|
|
- let orderId = uni.getStorageSync('globalCodePayId');
|
|
|
|
|
- codePay({id:orderId,authCode:authCode}).then(res=>{
|
|
|
|
|
- uni.hideLoading()
|
|
|
|
|
- if(res.code == 1){
|
|
|
|
|
- if(res.data.returnStatus == 'SUCCESS'){
|
|
|
|
|
- that.$util.pageTo({ url: '/admin/billing/result',type:2,query: {orderId:orderId,title:'支付成功'}})
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- toFreeApply_HOME () {
|
|
|
|
|
- let status = ''
|
|
|
|
|
- if (uni.getStorageSync('HOME_STATUS_STROAGE_SHOW') == '0') {
|
|
|
|
|
- this.$util.pageTo({
|
|
|
|
|
- url: "/pagesClient/official/index",
|
|
|
|
|
- query: {
|
|
|
|
|
- ...this.option
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- } else {
|
|
|
|
|
- getStaffApi().then(res => {
|
|
|
|
|
- if (res.data.openShop == '2') {
|
|
|
|
|
- status = '2'
|
|
|
|
|
- } else if (res.data.openShop == '3') {
|
|
|
|
|
- status = '3'
|
|
|
|
|
|
|
+ //监听扫码
|
|
|
|
|
+ listenScan(){
|
|
|
|
|
+ let that = this
|
|
|
|
|
+ //商米收银台
|
|
|
|
|
+ if(plus.device.vendor == 'SUNMI'){
|
|
|
|
|
+ //https://ext.dcloud.net.cn/plugin?id=3514
|
|
|
|
|
+ //初始化
|
|
|
|
|
+ shangMiPrint.init()
|
|
|
|
|
+ //扫码返回
|
|
|
|
|
+ globalEvent.addEventListener('scancode',function(e){
|
|
|
|
|
+ if(e.code == 'ok'){
|
|
|
|
|
+ let productIdCode = e.data
|
|
|
|
|
+ console.log(productIdCode)
|
|
|
|
|
+ that.$msg(productIdCode)
|
|
|
}
|
|
}
|
|
|
- uni.navigateTo({url:'/pages/home/result?status=' + status})
|
|
|
|
|
- }).catch(err => {})
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- //有几个地方涉及登陆,需要统一方法,请搜索关键词 uni_login
|
|
|
|
|
- experienceFun(experienceCode){
|
|
|
|
|
- if (this.$util.isEmpty(experienceCode)) {
|
|
|
|
|
- this.$msg('请输入体验码')
|
|
|
|
|
- return false
|
|
|
|
|
- }
|
|
|
|
|
- /**姜枫 2021.04.30 小程序审核体验帐号**/
|
|
|
|
|
- postWxCode({experienceCode: experienceCode}).then(subRes => {
|
|
|
|
|
- if (this.$util.isEmpty(subRes)) {
|
|
|
|
|
- return false
|
|
|
|
|
- }
|
|
|
|
|
- uni.setStorageSync('token', subRes.data.token)
|
|
|
|
|
- uni.setStorageSync('shopId', subRes.data.admin.currentShopId)
|
|
|
|
|
- getDictionaries({ token: subRes.data.token }).then(res => {
|
|
|
|
|
- if (this.$util.isEmpty(res)) {
|
|
|
|
|
- return false
|
|
|
|
|
- }
|
|
|
|
|
- this.$store.commit('setDictionariesInfo', {
|
|
|
|
|
- ...res.data.dict,
|
|
|
|
|
- ...res.data
|
|
|
|
|
})
|
|
})
|
|
|
- this.$store.commit('setMyShopInfo', {
|
|
|
|
|
- ...res.data.shop,
|
|
|
|
|
- ...res.data
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- this.$store.commit('setLoginInfo', {
|
|
|
|
|
- ...subRes.data.admin,
|
|
|
|
|
- ...subRes.data
|
|
|
|
|
- })
|
|
|
|
|
- uni.removeStorageSync('HOME_STATUS_STROAGE_SHOW')
|
|
|
|
|
- uni.removeStorageSync('OPEN_SHOP_ID')
|
|
|
|
|
-
|
|
|
|
|
- //shish 20210615
|
|
|
|
|
- uni.removeStorageSync('HOME_REFRESH')
|
|
|
|
|
-
|
|
|
|
|
- this.no_shop_show_model = false
|
|
|
|
|
-
|
|
|
|
|
- getUser(true)
|
|
|
|
|
- //获取门店信息
|
|
|
|
|
- this.setUserShopAll();
|
|
|
|
|
- uni.reLaunch({url:'/pages/home/cash'})
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- mounted() {
|
|
|
|
|
- if (this.mInit) {
|
|
|
|
|
- this.mInit()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ console.log('!!!!!!!!!!!!!!!!!!!!!!!!商米收银台发起监听!!!!!!!!!!!!!!!!!!!!!!!!')
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // #endif
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|