103 lines
2.3 KiB
JavaScript
103 lines
2.3 KiB
JavaScript
export default {
|
|
onShow() {
|
|
this.setNavigationBarTitleText();
|
|
},
|
|
methods: {
|
|
/**
|
|
* 设置页面标题
|
|
*/
|
|
setNavigationBarTitleText() {
|
|
let pages = getCurrentPages();
|
|
let currentPage = pages[pages.length - 1];
|
|
if (currentPage && currentPage.$holder && currentPage.$holder.navigationBarTitleText) {
|
|
let title = currentPage.$holder.navigationBarTitleText;
|
|
if (this.storeInfo) title += '-' + this.storeInfo.store_name;
|
|
if (title != currentPage.$holder.navigationBarTitleText) uni.setNavigationBarTitle({
|
|
title: title
|
|
})
|
|
}
|
|
}
|
|
},
|
|
filters: {
|
|
/**
|
|
* 金额格式化
|
|
* @param {Object} money
|
|
*/
|
|
moneyFormat(money) {
|
|
if (isNaN(money)) return money;
|
|
return parseFloat(money).toFixed(2);
|
|
},
|
|
/**
|
|
* 时间格式化
|
|
* @param {Object} time 时间戳
|
|
* @param {Object} format 输出格式
|
|
*/
|
|
timeFormat(time, format = 'y-m-d h:i:s') {
|
|
var date = new Date();
|
|
date.setTime(time * 1000);
|
|
|
|
var y = date.getFullYear();
|
|
var m = date.getMonth() + 1;
|
|
var d = date.getDate();
|
|
var h = date.getHours();
|
|
var i = date.getMinutes();
|
|
var s = date.getSeconds();
|
|
|
|
format = format.replace('y', y);
|
|
format = format.replace('m', (m < 10 ? '0' + m : m));
|
|
format = format.replace('d', (d < 10 ? '0' + d : d));
|
|
format = format.replace('h', (h < 10 ? '0' + h : h));
|
|
format = format.replace('i', (i < 10 ? '0' + i : i));
|
|
format = format.replace('s', (s < 10 ? '0' + s : s));
|
|
|
|
return format;
|
|
},
|
|
/**
|
|
* 刷新会员信息
|
|
*/
|
|
refreshMemberInfo() {
|
|
if (this.memberInfo) {
|
|
this.$api.sendRequest({
|
|
url: '/cashier/storeapi/member/info',
|
|
data: {
|
|
member_id: this.memberInfo.member_id
|
|
},
|
|
success: res => {
|
|
if (res.code == 0 && res.data) {
|
|
this.$store.commit('setMemberInfo', res.data);
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
},
|
|
computed: {
|
|
getRootFontSize() {
|
|
return this.$store.state.rootSize;
|
|
},
|
|
siteInfo() {
|
|
return this.$store.state.siteInfo;
|
|
},
|
|
storeInfo() {
|
|
return this.$store.state.storeInfo;
|
|
},
|
|
memberInfo() {
|
|
return this.$store.state.memberInfo;
|
|
},
|
|
defaultImg() {
|
|
return this.$store.state.defaultImg;
|
|
}
|
|
},
|
|
watch: {
|
|
'storeInfo.store_id': {
|
|
handler(nval, oval) {
|
|
if (oval && typeof this.switchStoreAfter == 'function') {
|
|
this.switchStoreAfter();
|
|
this.setNavigationBarTitleText();
|
|
}
|
|
},
|
|
deep: true
|
|
}
|
|
}
|
|
}
|