import { GetOrderPush } from '../../api/order'; import GtPush from '@/utils/gtpush-min.js'; const defaultState = () => { return { pushOrderInfo: {}, }; }; const state = defaultState(); const getters = {}; const mutations = {}; const getClient = () => { // #ifdef APP-PLUS let clientInfo = plus.push.getClientInfo(); //获取 clientID uni.setStorageSync('clientid', clientInfo.clientid); return clientInfo.clientid; console.log(clientInfo); // #endif }; const actions = { async intOrderPush({ dispatch }) { GtPush.init({ appid: 'KXgzOaKSzd5HG3p9IPaVa8', onClientId: (res) => { let params = { cid: res.cid, message: '测试', }; dispatch('getOrderPush', params); console.log('onClientId = ' + res.cid); }, onlineState: (res) => { console.log('onlineState = ' + res.online); }, onPushMsg: (res) => { console.log('onPushMsg = ' + res.message); }, onError: (res) => { console.log('error', +res.message); }, }); }, async getOrderPush({ dispatch }, params) { // #ifdef APP-PLUS let clientid = getClient(); // #endif let res = await GetOrderPush(params); if (res && res.second) { console.log('OrderPush', res); } }, }; export default { namespaced: true, state, getters, mutations, actions, };