| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- 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
- })
- } else {
- setTimeout(() => {
- this.setNavigationBarTitleText();
- }, 800)
- }
- }
- },
- 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
- }
- }
- }
|