修复一些缺陷,更换tabbar素材

pull/1/MERGE
hejinfu1026 2021-11-15 10:16:11 +08:00
parent c42aab28a1
commit 955ea2fdee
19 changed files with 284 additions and 137 deletions

View File

@ -2,10 +2,19 @@
// launchtypelocalremote, localremote // launchtypelocalremote, localremote
"version": "0.0", "version": "0.0",
"configurations": [{ "configurations": [{
"type": "uniCloud", "default" :
"default": { {
"launchtype": "remote" "launchtype" : "remote"
} },
} "h5" :
{
"launchtype" : "remote"
},
"mp-weixin" :
{
"launchtype" : "remote"
},
"type" : "uniCloud"
}
] ]
} }

View File

@ -1,6 +1,5 @@
<template> <template>
<!-- v-if="reply.length>0" --> <view class="evaluateWtapper" v-if="reply.length > 0">
<view class="evaluateWtapper">
<view class="evaluateItem" v-for="(item, indexw) in reply" :key="indexw"> <view class="evaluateItem" v-for="(item, indexw) in reply" :key="indexw">
<view class="pic-text acea-row"> <view class="pic-text acea-row">
<view class="pictrue"> <view class="pictrue">
@ -39,7 +38,7 @@
props: { props: {
reply: { reply: {
type: Array, type: Array,
default: () => [] default: []
} }
}, },
data: function() { data: function() {

View File

@ -1,5 +1,5 @@
let domain = 'http://127.0.0.1:8080' let domain = 'https://api.dev.java.crmeb.net/'
module.exports = { module.exports = {
// 请求域名 格式: https://您的域名 // 请求域名 格式: https://您的域名

View File

@ -1,6 +1,6 @@
{ {
"name" : "crmeb", "name" : "crmeb",
"appid" : "__UNI__66E0853", "appid" : "__UNI__E8BDBA5",
"description" : "crmeb商城", "description" : "crmeb商城",
"versionName" : "1.0.0", "versionName" : "1.0.0",
"versionCode" : 1001, "versionCode" : 1001,
@ -99,11 +99,7 @@
}, },
"domain" : "", "domain" : "",
"sdkConfigs" : { "sdkConfigs" : {
"maps" : { "maps" : {}
"qqmap" : {
"key" : "map key"
}
}
}, },
"optimization" : { "optimization" : {
"treeShaking" : { "treeShaking" : {

View File

@ -276,6 +276,7 @@
import { import {
getProductCode getProductCode
} from '@/api/store.js' } from '@/api/store.js'
import { spread } from "@/api/user";
export default { export default {
components: { components: {
shareRedPackets, shareRedPackets,
@ -417,18 +418,27 @@
}, },
}); });
if (options.hasOwnProperty('id') || options.scene) { if (options.hasOwnProperty('id') || options.scene) {
options.scene ? this.id = app.globalData.id : this.id = options.id; if (options.scene) { //
// app.globalData.openPages = '/pages/activity/goods_combination_details/index?id=' + this.id + '&spid=' + this.userInfo.uid; let qrCodeValue = this.$util.getUrlParams(decodeURIComponent(options.scene));
let mapeMpQrCodeValue = this.$util.formatMpQrCodeData(qrCodeValue);
app.globalData.spread = mapeMpQrCodeValue.spread;
this.id = mapeMpQrCodeValue.id;
setTimeout(()=>{
spread(mapeMpQrCodeValue.spread).then(res => {}).catch(res => {})
},2000)
}else{
this.id = options.id;
}
if (this.isLogin) { if (this.isLogin) {
this.combinationDetail(); this.combinationDetail();
} else { } else {
// #ifdef H5 // #ifdef H5 || APP-PLUS
try { try {
uni.setStorageSync('comGoodsId', options.id); uni.setStorageSync('comGoodsId', options.id);
} catch (e) {} } catch (e) {}
// #endif // #endif
this.$Cache.set('login_back_url', this.$Cache.set('login_back_url',
`/pages/activity/goods_combination_details/index?id=${options.id}&spid=${options.spid?options.spid:0}` `/pages/activity/goods_combination_details/index?id=${options.id}&spread=${options.pid?options.pid:0}`
); );
toLogin(); toLogin();
} }
@ -448,7 +458,6 @@
}) })
} }
}; };
this.isLogin && silenceBindingSpread();
}, },
methods: { methods: {
getProductReplyCount: function() { getProductReplyCount: function() {

View File

@ -112,7 +112,6 @@
</view> </view>
</view> </view>
</view> </view>
<!-- <shareRedPackets :sharePacket="sharePacket" @listenerActionSheet="listenerActionSheet" @closeChange="closeChange"></shareRedPackets> -->
<product-window :attr='attribute' :limitNum='1' @myevent="onMyEvent" @ChangeAttr="ChangeAttr" @ChangeCartNum="ChangeCartNum" <product-window :attr='attribute' :limitNum='1' @myevent="onMyEvent" @ChangeAttr="ChangeAttr" @ChangeCartNum="ChangeCartNum"
@attrVal="attrVal" @iptCartNum="iptCartNum"></product-window> @attrVal="attrVal" @iptCartNum="iptCartNum"></product-window>
<!-- #ifdef MP --> <!-- #ifdef MP -->
@ -200,6 +199,7 @@
toLogin toLogin
} from '@/libs/login.js'; } from '@/libs/login.js';
import { silenceBindingSpread } from "@/utils"; import { silenceBindingSpread } from "@/utils";
import { spread } from "@/api/user";
export default { export default {
data() { data() {
return { return {
@ -311,7 +311,7 @@
} }
}, },
onLoad(options) { onLoad(options) {
let that = this let that = this;
that.$store.commit("PRODUCT_TYPE", 'normal'); that.$store.commit("PRODUCT_TYPE", 'normal');
let statusBarHeight = ''; let statusBarHeight = '';
var pages = getCurrentPages(); var pages = getCurrentPages();
@ -330,16 +330,38 @@
let menuButtonInfo = uni.getMenuButtonBoundingClientRect() let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
this.meunHeight = menuButtonInfo.height this.meunHeight = menuButtonInfo.height
this.backH = (that.navH / 2) + (this.meunHeight / 2) this.backH = (that.navH / 2) + (this.meunHeight / 2)
setTimeout(()=>{
if(options.spread){
app.globalData.spread = options.spread;
spread(options.spread).then(res => {})
}
},2000)
if (!options.scene && !options.id){
this.showSkeleton = false;
this.$util.Tips({
title: '缺少参数无法查看商品'
}, {
url: '/pages/index/index'
});
return;
}
if (options.hasOwnProperty('id') || options.scene){
if (options.scene) { //
let qrCodeValue = this.$util.getUrlParams(decodeURIComponent(options.scene));
let mapeMpQrCodeValue = this.$util.formatMpQrCodeData(qrCodeValue);
app.globalData.spread = mapeMpQrCodeValue.spread;
this.id = mapeMpQrCodeValue.id;
setTimeout(()=>{
spread(mapeMpQrCodeValue.spread).then(res => {}).catch(res => {})
},2000)
}else{
this.id = options.id;
}
}
// #endif // #endif
if (!options.scene && options.id == 'undefined') return this.$util.Tips({
title: '缺少参数无法查看商品'
}, {
tab: 3,
url: 1
});
options.scene ? this.id = app.globalData.id : this.id = options.id;
if (this.isLogin) { if (this.isLogin) {
this.id = options.id;
this.getSeckillDetail(); this.getSeckillDetail();
} else { } else {
this.$Cache.set('login_back_url', this.$Cache.set('login_back_url',
@ -372,7 +394,7 @@
limit: 3, limit: 3,
type: 0, type: 0,
}).then(res => { }).then(res => {
this.reply = res.data.list ? [res.data.list[0]] : []; this.reply = res.data.list;
}) })
}, },
getProductReplyCount: function() { getProductReplyCount: function() {

View File

@ -269,6 +269,7 @@
getProductGood, getProductGood,
getReplyProduct getReplyProduct
} from '@/api/store.js'; } from '@/api/store.js';
import { spread } from "@/api/user";
import { import {
getCoupons getCoupons
} from '@/api/api.js'; } from '@/api/api.js';
@ -425,38 +426,48 @@
if (pages.length <= 1) { if (pages.length <= 1) {
that.retunTop = false that.retunTop = false
} }
// #ifdef MP
that.navH = app.globalData.navHeight; that.navH = app.globalData.navHeight;
// #ifdef MP || APP-PLUS
// id
setTimeout(()=>{
if(options.spread){
app.globalData.spread = options.spread;
spread(options.spread).then(res => {})
}
},2000)
// #endif // #endif
// #ifndef MP uni.getSystemInfo({
that.navH = 96; success: function(res) {
// #endif that.height = res.windowHeight;
if (options.id == 'undefined') { },
that.id = 0 });
} else { if (!options.scene && !options.id) {
that.id = options.id; this.showSkeleton = false;
this.$util.Tips({
title: '缺少参数无法查看商品'
}, {
url: '/pages/index/index'
});
return;
}
if (options.hasOwnProperty('id') || options.scene) {
if (options.scene) { //
let qrCodeValue = that.$util.getUrlParams(decodeURIComponent(options.scene));
let mapeMpQrCodeValue = that.$util.formatMpQrCodeData(qrCodeValue);
app.globalData.spread = mapeMpQrCodeValue.spread;
this.id = mapeMpQrCodeValue.id;
setTimeout(()=>{
spread(mapeMpQrCodeValue.spread).then(res => {}).catch(res => {})
},2000)
} else {
this.id = options.id;
}
options.type == undefined || options.type == null ? that.type = 'normal' : that.type = options.type; options.type == undefined || options.type == null ? that.type = 'normal' : that.type = options.type;
that.$store.commit("PRODUCT_TYPE", that.type); that.$store.commit("PRODUCT_TYPE", that.type);
} }
uni.getSystemInfo({
success: function(res) {
that.height = res.windowHeight
//res.windowHeight:px*2rpx98
},
});
//
// #ifdef MP
if (!options.scene && options.id == 'undefined') return this.$util.Tips({
title: '缺少参数无法查看商品'
}, {
tab: 3,
url: 1
});
options.scene ? this.id = app.globalData.id : this.id = options.id;
// #endif
this.getGoodsDetails(); this.getGoodsDetails();
this.getCouponList(); this.getCouponList();
this.isLogin && silenceBindingSpread();
this.getProductReplyList(); this.getProductReplyList();
this.getProductReplyCount(); this.getProductReplyCount();
this.getGoods(); this.getGoods();

View File

@ -6,29 +6,30 @@
<view class='item acea-row row-between-wrapper' style="border: none;"> <view class='item acea-row row-between-wrapper' style="border: none;">
<view class='name'>姓名</view> <view class='name'>姓名</view>
<input type='text' placeholder='请输入姓名' placeholder-style="color:#ccc;" name='realName' :value="userAddress.realName" <input type='text' placeholder='请输入姓名' placeholder-style="color:#ccc;" name='realName' :value="userAddress.realName"
placeholder-class='placeholder'></input> placeholder-class='placeholder' maxlength="4"></input>
</view> </view>
<view class='item acea-row row-between-wrapper'> <view class='item acea-row row-between-wrapper'>
<view class='name'>联系电话</view> <view class='name'>联系电话</view>
<input type='text' placeholder='请输入联系电话' placeholder-style="color:#ccc;" name="phone" :value='userAddress.phone' <input type='number' placeholder='请输入联系电话' placeholder-style="color:#ccc;" name="phone" :value='userAddress.phone'
placeholder-class='placeholder'></input> placeholder-class='placeholder' maxlength="11"></input>
</view> </view>
<view class='item acea-row row-between-wrapper'> <view class='item acea-row row-between-wrapper relative'>
<view class='name'>所在地区</view> <view class='name'>所在地区</view>
<view class="address"> <view class="address">
<picker mode="multiSelector" @change="bindRegionChange" <picker mode="multiSelector" @change="bindRegionChange"
@columnchange="bindMultiPickerColumnChange" :value="valueRegion" :range="multiArray"> @columnchange="bindMultiPickerColumnChange" :value="valueRegion" :range="multiArray">
<view class='acea-row'> <view class='acea-row'>
<view class="picker line1">{{region[0]}}{{region[1]}}{{region[2]}}</view> <view class="picker line1">{{region[0]}}{{region[1]}}{{region[2]}}</view>
<view class='iconfont icon-dizhi font-color'></view> <view class='iconfont icon-xiangyou abs_right'></view>
</view> </view>
</picker> </picker>
</view> </view>
</view> </view>
<view class='item acea-row row-between-wrapper'> <view class='item acea-row row-between-wrapper relative'>
<view class='name'>详细地址</view> <view class='name'>详细地址</view>
<input type='text' placeholder='请填写具体地址' placeholder-style="color:#ccc;" name='detail' placeholder-class='placeholder' <input type='text' placeholder='请填写具体地址' placeholder-style="color:#ccc;" name='detail' placeholder-class='placeholder'
:value='userAddress.detail'></input> v-model='userAddress.detail' maxlength="18"></input>
<view class='iconfont icon-dizhi font-color abs_right' @tap="chooseLocation"></view>
</view> </view>
</view> </view>
<view class='default acea-row row-middle borRadius14'> <view class='default acea-row row-middle borRadius14'>
@ -49,7 +50,7 @@
<!-- #ifdef MP --> <!-- #ifdef MP -->
<!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> --> <!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
<!-- #endif --> <!-- #endif -->
<home></home> <!-- <home></home> -->
</view> </view>
</template> </template>
@ -67,12 +68,12 @@
import { import {
mapGetters mapGetters
} from "vuex"; } from "vuex";
import wPicker from "@/components/wPicker/w-picker.vue";
// #ifdef MP // #ifdef MP
import authorize from '@/components/Authorize'; import authorize from '@/components/Authorize';
// #endif // #endif
import home from '@/components/home'; import home from '@/components/home';
// import city from '@/utils/cityData'; // import city from '@/utils/cityData';
let app = getApp();
export default { export default {
components: { components: {
// #ifdef MP // #ifdef MP
@ -102,7 +103,7 @@
defaultRegionCode: '440113', defaultRegionCode: '440113',
bargain: false, // bargain: false, //
combination: false, // combination: false, //
secKill: false // secKill: false, //
}; };
}, },
computed: mapGetters(['isLogin']), computed: mapGetters(['isLogin']),
@ -120,39 +121,42 @@
onLoad(options) { onLoad(options) {
if (this.isLogin) { if (this.isLogin) {
this.preOrderNo = options.preOrderNo || 0; this.preOrderNo = options.preOrderNo || 0;
// this.cartId = options.cartId || '';
// this.pinkId = options.pinkId || 0;
// this.couponId = options.couponId || 0;
this.id = options.id || 0; this.id = options.id || 0;
// this.secKill = options.secKill || false;
// this.combination = options.combination || false;
// this.bargain = options.bargain || false;
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: options.id ? '修改地址' : '添加地址' title: options.id ? '修改地址' : '添加地址'
}) })
this.getUserAddress(); this.getUserAddress();
this.getCityList(); if(this.$Cache.has('cityList')){
// if(this.district && this.district.length){ //
// this.initialize(); this.district = this.$Cache.getItem('cityList')
// } this.initialize();
}else{
this.getCityList();
}
} else { } else {
toLogin(); toLogin();
} }
}, },
methods: { methods: {
// // #ifdef APP-PLUS
//
handleGetRegion(region) {
this.region = region
},
// #endif
//
getCityList: function() { getCityList: function() {
let that = this; let that = this;
getCity().then(res => { getCity().then(res => {
this.district = res.data this.district = res.data;
let oneDay = 24 * 3600 * 1000;
// this.$Cache.set('cityList', JSON.stringify(res.data)); //
this.$Cache.setItem({name:'cityList',value:res.data,expires:oneDay * 7}); //
that.initialize(); that.initialize();
}) })
}, },
initialize: function() { initialize: function() {
let that = this, let that = this,province = [],city = [],area = [];
province = [],
city = [],
area = [];
if (that.district.length) { if (that.district.length) {
let cityChildren = that.district[0].child || []; let cityChildren = that.district[0].child || [];
let areaChildren = cityChildren.length ? (cityChildren[0].child || []) : []; let areaChildren = cityChildren.length ? (cityChildren[0].child || []) : [];
@ -216,7 +220,7 @@
break; break;
} }
// #ifdef MP // #ifdef MP || APP-PLUS
this.$set(this.multiArray, 0, multiArray[0]); this.$set(this.multiArray, 0, multiArray[0]);
this.$set(this.multiArray, 1, multiArray[1]); this.$set(this.multiArray, 1, multiArray[1]);
this.$set(this.multiArray, 2, multiArray[2]); this.$set(this.multiArray, 2, multiArray[2]);
@ -224,9 +228,6 @@
// #ifdef H5 // #ifdef H5
this.multiArray = multiArray; this.multiArray = multiArray;
// #endif // #endif
this.multiIndex = multiIndex this.multiIndex = multiIndex
// this.setData({ multiArray: multiArray, multiIndex: multiIndex}); // this.setData({ multiArray: multiArray, multiIndex: multiIndex});
}, },
@ -254,6 +255,13 @@
that.city_id = res.data.cityId that.city_id = res.data.cityId
}); });
}, },
chooseLocation: function () {
uni.chooseLocation({
success: (res) => {
this.$set(this.userAddress,'detail',res.address.replace(/.+?(省|市|自治区|自治州|县|区)/g,''));
}
})
},
// //
getWxAddress: function() { getWxAddress: function() {
let that = this; let that = this;
@ -456,9 +464,7 @@
setTimeout(function() { setTimeout(function() {
if (that.preOrderNo>0) { if (that.preOrderNo>0) {
uni.redirectTo({ uni.redirectTo({
url: '/pages/users/order_confirm/index?preOrderNo=' + that url: '/pages/users/order_confirm/index?preOrderNo=' + that.preOrderNo + '&addressId=' + (that.id ? that.id : res.data.id)
.preOrderNo + '&addressId=' + (that.id ? that.id : res.data
.id)
}) })
} else { } else {
// #ifdef H5 // #ifdef H5
@ -469,29 +475,7 @@
delta: 1, delta: 1,
}) })
// #endif // #endif
} }
// if (that.cartId) {
// let cartId = that.cartId;
// let pinkId = that.pinkId;
// let couponId = that.couponId;
// that.cartId = '';
// that.pinkId = '';
// that.couponId = '';
// uni.navigateTo({
// url: '/pages/users/order_confirm/index?cartId=' + cartId + '&addressId=' + (that.id ? that.id : res.data.id) +'&pinkId=' + pinkId + '&couponId=' + couponId + '&secKill=' + that.secKill + '&combination=' + that.combination + '&bargain=' + that.bargain
// });
// } else {
// // #ifdef H5
// return history.back();
// // #endif
// // #ifndef H5
// return uni.navigateBack({
// delta: 1,
// })
// // #endif
// }
}, 1000); }, 1000);
}).catch(err => { }).catch(err => {
return that.$util.Tips({ return that.$util.Tips({
@ -510,7 +494,6 @@
.addAddress { .addAddress {
padding-top: 20rpx; padding-top: 20rpx;
} }
.addAddress .list { .addAddress .list {
background-color: #fff; background-color: #fff;
padding: 0 24rpx; padding: 0 24rpx;
@ -548,10 +531,6 @@
font-size: 30rpx; font-size: 30rpx;
} }
.addAddress .list .item picker .iconfont {
font-size: 43rpx;
}
.addAddress .default { .addAddress .default {
padding: 0 30rpx; padding: 0 30rpx;
height: 90rpx; height: 90rpx;
@ -585,4 +564,15 @@
color: #E93323 ; color: #E93323 ;
border: 1px solid #E93323; border: 1px solid #E93323;
} }
.relative{
position: relative;
}
.icon-dizhi{
font-size: 44rpx;
z-index: 100;
}
.abs_right{
position: absolute;
right:0;
}
</style> </style>

View File

@ -18,7 +18,8 @@
width: 375px; width: 375px;
height: 667px; height: 667px;
background-color: #fff; background-color: #fff;
box-sizing: content-box; /* box-sizing: content-box; */
box-sizing: border-box;
border: none; border: none;
} }
@ -39,20 +40,15 @@
window.isPC = true; window.isPC = true;
window.onload = function(){ window.onload = function(){
/* 监听电脑浏览器窗口尺寸改变 */ /* 监听电脑浏览器窗口尺寸改变 */
window.onresize = function(){ if(window.innerWidth <= 420){
/* 窗口宽度 小于或等于420px 时跳转回H5页面 */ window.location.pathname = '/';
if(window.innerWidth <= 420){ }
// window.location.pathname = 'https://java.crmeb.net/';
/* 若你的项目未设置根目录(默认为 / 时),则使用下方代码 */
window.location.pathname = '';
}
}
} }
</script> </script>
</head> </head>
<body> <body>
<!-- <iframe src="https://java.crmeb.net/"></iframe> --> <!-- <iframe src="https://java.crmeb.net/"></iframe> -->
<!--若你的项目未设置根目录(默认为 / 时),则使用下方代码--> <!--若你的项目未设置根目录(默认为 / 时),则使用下方代码-->
<iframe src="/"></iframe> <iframe src="/" id="iframe"></iframe>
</body> </body>
</html> </html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -1,3 +1,13 @@
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import { EXPIRE } from '../config/app'; import { EXPIRE } from '../config/app';
class Cache { class Cache {
@ -7,6 +17,7 @@ class Cache {
this.cacheGetHandler = uni.getStorageSync; this.cacheGetHandler = uni.getStorageSync;
this.cacheClearHandler = uni.removeStorageSync; this.cacheClearHandler = uni.removeStorageSync;
this.cacheExpire = '_expire_2019_12_17_18_44'; this.cacheExpire = '_expire_2019_12_17_18_44';
this.name = 'storage';
} }
/** /**
@ -18,7 +29,7 @@ class Cache {
} }
/** /**
* 字符串转时间戳 * 日期字符串转时间戳
* @param {Object} expiresTime * @param {Object} expiresTime
*/ */
strTotime(expiresTime){ strTotime(expiresTime){
@ -27,17 +38,64 @@ class Cache {
return Math.round(new Date(expires_time).getTime() / 1000); return Math.round(new Date(expires_time).getTime() / 1000);
} }
setExpireCaheTag(key, expire) {
expire = expire !== undefined ? expire : EXPIRE;
if (typeof expire === 'number') {
let tag = this.cacheGetHandler(this.cacheExpire), newTag = [],newKeys = [];
if (typeof tag === 'object' && tag.length) {
newTag = tag.map(item => {
newKeys.push(item.key);
if (item.key === key) {
item.expire = expire === 0 ? 0 : this.time() + expire;
}
return item;
});
}
if (!newKeys.length || newKeys.indexOf(key) === -1) {
newTag.push({
key: key,
expire: expire === 0 ? 0 : this.time() + expire
});
}
this.cacheSetHandler(this.cacheExpire, newTag);
}
}
/** /**
* 设置过期时间缓存 * 设置过期时间缓存
* @param {Object} key * @param {Object} name key
* @param {Object} expire * @param {Object} value value
* @param {Object} expire 过期时间
* @param {Object} startTime 记录何时将值存入缓存毫秒级
*/ */
setExpireCahe(key,expire) setItem(params){
{ let obj = {
expire = expire !== undefined ? expire : EXPIRE; name:'',
if (expire) { value:'',
this.cacheSetHandler(key + this.cacheExpire,this.time() + expire) expires:"",
} startTime:new Date().getTime()
}
let options = {};
//将obj和传进来的params合并
Object.assign(options,obj,params);
if(options.expires){
//如果options.expires设置了的话
//以options.name为keyoptions为值放进去
// localStorage.setItem(options.name,JSON.stringify(options));
uni.setStorageSync(options.name,JSON.stringify(options));
}else{
//如果options.expires没有设置就判断一下value的类型
let type = Object.prototype.toString.call(options.value);
//如果value是对象或者数组对象的类型就先用JSON.stringify转一下再存进去
if(Object.prototype.toString.call(options.value) == '[object Object]'){
options.value = JSON.stringify(options.value);
}
if(Object.prototype.toString.call(options.value) == '[object Array]'){
options.value = JSON.stringify(options.value);
}
// localStorage.setItem(options.name,options.value);
uni.setStorageSync(options.name,options.value);
}
} }
/** /**
@ -76,8 +134,8 @@ class Cache {
if(typeof data === 'object') if(typeof data === 'object')
data = JSON.stringify(data); data = JSON.stringify(data);
try{ try{
this.setExpireCahe(key,expire); this.setExpireCaheTag(key,expire);
return this.cacheSetHandler(key,data); return this.cacheSetHandler(key,data);
}catch(e){ }catch(e){
return false; return false;
} }
@ -150,6 +208,39 @@ class Cache {
// }) // })
// } // }
} }
/**
* 获取缓存调用后无需转换数据类型
* @param {Object} key
*/
getItem(name){
// let item = localStorage.getItem(name);
let item = uni.getStorageSync(name);
//先将拿到的试着进行json转为对象的形式
try{
item = JSON.parse(item);
}catch(error){
//如果不行就不是json的字符串就直接返回
item = item;
}
//如果有startTime的值说明设置了失效时间
if(item.startTime){
let date = new Date().getTime();
//何时将值取出减去刚存入的时间与item.expires比较如果大于就是过期了如果小于或等于就还没过期
if(date - item.startTime > item.expires){
//缓存过期清除缓存返回false
// localStorage.removeItem(name);
uni.removeStorageSync(name);
return false;
}else{
//缓存未过期,返回值
return item.value;
}
}else{
//如果没有设置失效时间,直接返回值
return item;
}
}
} }

View File

@ -533,6 +533,30 @@ export default {
} }
return value; return value;
}, },
/**
* @param {Object} value
*/
formatMpQrCodeData(value){
let values = value.split(',');
let result = {};
if(values.length === 2){
let v1 = values[0].split(":");
if (v1[0] === 'pid') {
result.spread = v1[1];
} else{
result.id = v1[1];
}
let v2 = values[1].split(":");
if (v2[0] === 'pid') {
result.spread = v2[1];
}else{
result.id = v2[1];
}
}else{
result = values[0].split(":")[1];
}
return result;
},
// #endif // #endif
/* /*
* 合并数组 * 合并数组