Commit eda22a72 by lichao

收银台修改logo提示和监听外卖自提单小票打印

parent 1285c7f2
......@@ -146,6 +146,9 @@ export default {
*getStore(action, {call}) {
return yield call(api.getStore, action);
},
*findModuleSetting(action, {call}) {
return yield call(api.findModuleSetting, action);
},
},
};
......
......@@ -10,7 +10,6 @@ import CounterMixins from './CounterMixins';
import NP from '../utils/np';
import AutoClick from '../utils/AutoClick';
import Touch from '../components/Touch';
import logo from '../assets/Vertical/logo.png';
import counterText from '../assets/Vertical/counterText.png';
import img24h from '../assets/Vertical/24h.png';
import phone from '../assets/Vertical/phone.png';
......@@ -20,9 +19,11 @@ import WxFacepay from '../utils/WxFacepay';
import {width, setSpText, scaleSize, scaleHeight} from '../utils/screen';
import Speech from '../utils/Speech';
import delay from '../utils/delay';
import Printer from '../utils/Printer';
import Smilepay from '../utils/Smilepay';
import {leaveTalkCall, onTalkCall} from '../utils/agora';
import Toast from '../components/Toast';
import {ossLink} from '../utils/config';
let pageSize = 8; // 分页大小
window.pageSize = pageSize;
......@@ -40,6 +41,7 @@ class VerticalPage extends Component {
hintVisible: false,
setting: false,
logoVisible: true,
logo: '',
};
async componentWillMount() {
......@@ -64,6 +66,7 @@ class VerticalPage extends Component {
await this.wxFacepay(); // 点击开通重新调用
this.faceBusy = false;
});
await this.refreshLogo();
}
initSetting = () => {
......@@ -96,11 +99,52 @@ class VerticalPage extends Component {
// 语音通话中
window.socket.on('talkLeave', this.leaveC);
}
// logo改变
if (!window.socket.hasListeners('storeSetting')) {
window.socket.on('storeSetting', async data => {
// 重新获取logo
await this.refreshLogo();
});
}
// 外卖自提订单小票打印
if (!window.socket.hasListeners('orderReceipt')) {
window.socket.on('orderReceipt', async data => {
await this.print(data.goods, data.receipt);
});
}
} catch (e) {
console.log(e);
}
};
refreshLogo = async () => {
let group = await AsyncStorage.getItem('KEY');
let {data} = await this.props.dispatch({
type: 'store/findModuleSetting',
group,
});
if (data.code === 1 && data.data) {
await this.setState({logo: `${ossLink}/${data.data}`});
}
};
print = async (arr, receipt) => {
let total = 0;
let goods = [];
arr.map(v => {
total += (v.price > 0 ? v.price : v.prePrice) * v.num;
goods.push(
`${v.name},${v.num},${v.price > 0 ? v.price : v.prePrice},${(v.price > 0
? v.price
: v.prePrice) * v.num}`,
);
});
goods.push(`总计, , ,${total.toFixed(2)}`);
await Printer.printNote(goods, receipt);
};
handleTalkCall = async () => {
try {
// 加入语音通话
......@@ -481,7 +525,7 @@ class VerticalPage extends Component {
imgArr,
adType,
} = this.props;
let {contact, hintVisible, logoVisible} = this.state;
let {contact, hintVisible, logoVisible, logo} = this.state;
pageSize =
goods && goods.bags.length > 0
? goods && goods.bags.length > 3
......@@ -528,7 +572,12 @@ class VerticalPage extends Component {
/>
<View style={styles.header}>
<View style={styles.left}>
{logoVisible && <Image source={logo} />}
{logoVisible &&
(logo ? (
<Image style={{width: 100, height: 100}} source={{uri: logo}} />
) : (
<Image source={require('../assets/Vertical/logo.png')} />
))}
<Image style={styles.counterText} source={counterText} />
<Image source={img24h} />
</View>
......
......@@ -86,3 +86,7 @@ export function getAdvertising(action) {
export function getStore({group}) {
return axios.get(`/store/setting/${group}`);
}
export function findModuleSetting({group}) {
return axios.get(`/store/module/setting/${group}`);
}
......@@ -8,6 +8,10 @@ export const qrHost = login;
export const imgUrl = 'http://barcod.oss-cn-shenzhen.aliyuncs.com/images/';
export const watermark = '.jpg?x-oss-process=style/zmgo_thumb_watermark';
export const appName = '仲马购人工智能';
export const bucket =
process.env.NODE_ENV === 'production' ? 'zhongma' : 'self-shop-test';
export const region = 'oss-cn-shenzhen';
export const ossLink = `https://${bucket}.${region}.aliyuncs.com`;
window.defaultCount = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment