wangfukang 3 weeks ago
parent
commit
ad1f2c6415
  1. 2
      components/tab-bar/delivery.vue
  2. 183
      components/tab-bar/myCenter.vue

2
components/tab-bar/delivery.vue

@ -217,7 +217,7 @@
</view> </view>
<view style="flex: 1;text-align: right;"> <view style="flex: 1;text-align: right;">
{{(item.deliveryFee + item.deliveryFeeMarketplace).toFixed(2)}} <text style="color: #777;font-size: 20rpx;" {{(item.deliveryFee + item.deliveryFeeMarketplace).toFixed(2)}} <text style="color: #777;font-size: 20rpx;"
v-if="item.deliveryFeeMarketplace != null">包含{{item.deliveryFeeMarketplace}}平台佣金</text> v-if="item.deliveryFeeMarketplace != null && item.deliveryFeeMarketplace > 0">包含{{item.deliveryFeeMarketplace}}平台佣金</text>
</view> </view>
</view> </view>
</view> </view>

183
components/tab-bar/myCenter.vue

@ -6,7 +6,7 @@
<view class="top-zone fade-up" style="animation-delay: 0ms;"> <view class="top-zone fade-up" style="animation-delay: 0ms;">
<view class="profile-row"> <view class="profile-row">
<view class="avatar-card"> <view class="avatar-card">
<image :key="'avatar-' + package3StaticVersion" class="avatar-img" src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/1575f2987ee8435c88cabc1c1fcfde0e.png" mode="aspectFill"></image> <image class="avatar-img" :src="getMyCenterImage('avatar')" mode="aspectFill"></image>
</view> </view>
<view class="profile-main"> <view class="profile-main">
<view class="name-row"> <view class="name-row">
@ -29,7 +29,7 @@
<view class="saving-hero fade-up" hover-class="tap-soft" hover-stay-time="80" <view class="saving-hero fade-up" hover-class="tap-soft" hover-stay-time="80"
style="animation-delay: 50ms;" @tap="navigatorTo('qianbao')"> style="animation-delay: 50ms;" @tap="navigatorTo('qianbao')">
<image :key="'saving-' + package3StaticVersion" class="saving-bg" src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/d59656fe69e6455093123ed769850403.png" mode="aspectFit"></image> <image class="saving-bg" :src="getMyCenterImage('savingHero')" mode="aspectFit"></image>
<view class="saved-badge">已经帮你省下</view> <view class="saved-badge">已经帮你省下</view>
<view class="saved-main"> <view class="saved-main">
<view class="saved-money money-roll">¥{{savedMoney}}</view> <view class="saved-money money-roll">¥{{savedMoney}}</view>
@ -42,7 +42,7 @@
<view class="quick-item" hover-class="tap-soft" hover-stay-time="80" <view class="quick-item" hover-class="tap-soft" hover-stay-time="80"
v-for="(item,index) in quickItems" :key="index" @tap="navigatorTo(item.action)"> v-for="(item,index) in quickItems" :key="index" @tap="navigatorTo(item.action)">
<view class="quick-icon-wrap"> <view class="quick-icon-wrap">
<image :key="item.icon + '-' + package3StaticVersion" class="quick-icon" :class="'quick-icon--' + item.type" :src="item.icon" <image class="quick-icon" :class="'quick-icon--' + item.type" :src="item.icon"
mode="aspectFit"></image> mode="aspectFit"></image>
</view> </view>
<view class="quick-title" :class="'quick-title--' + item.type">{{item.title}}</view> <view class="quick-title" :class="'quick-title--' + item.type">{{item.title}}</view>
@ -53,7 +53,7 @@
<view class="section-card earn-section fade-up" style="animation-delay: 100ms;"> <view class="section-card earn-section fade-up" style="animation-delay: 100ms;">
<view class="section-head"> <view class="section-head">
<view class="head-main"> <view class="head-main">
<image :key="'earn-' + package3StaticVersion" class="title-icon" src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/c2e8e71e51e24ad4b717c405b5e8bb22.png" mode="aspectFit"></image> <image class="title-icon" :src="getMyCenterImage('earnTitle')" mode="aspectFit"></image>
<view> <view>
<view class="section-title">今天还能省钱又赚钱</view> <view class="section-title">今天还能省钱又赚钱</view>
<!-- <view class="section-desc">每日都有新机会省钱又赚钱</view> --> <!-- <view class="section-desc">每日都有新机会省钱又赚钱</view> -->
@ -72,7 +72,7 @@
<text>{{item.subPost}}</text> <text>{{item.subPost}}</text>
</view> </view>
<view class="task-visual"> <view class="task-visual">
<image :key="item.icon + '-' + package3StaticVersion" class="task-asset" :class="'task-asset--' + item.type" :src="item.icon" <image class="task-asset" :class="'task-asset--' + item.type" :src="item.icon"
mode="aspectFit"></image> mode="aspectFit"></image>
</view> </view>
<view class="task-btn">{{item.cta}}</view> <view class="task-btn">{{item.cta}}</view>
@ -98,7 +98,7 @@
<view class="identity-title">{{item.title}}</view> <view class="identity-title">{{item.title}}</view>
<view class="identity-desc">{{item.desc}}</view> <view class="identity-desc">{{item.desc}}</view>
<view class="identity-foot"> <view class="identity-foot">
<image :key="item.icon + '-' + package3StaticVersion" class="identity-icon" :class="'identity-icon--' + item.type" :src="item.icon" <image class="identity-icon" :class="'identity-icon--' + item.type" :src="item.icon"
mode="aspectFit"></image> mode="aspectFit"></image>
<!-- <view class="identity-go"></view> --> <!-- <view class="identity-go"></view> -->
</view> </view>
@ -121,7 +121,7 @@
<view class="life-title">{{item.title}}</view> <view class="life-title">{{item.title}}</view>
<view class="life-desc">{{item.desc}}</view> <view class="life-desc">{{item.desc}}</view>
<view class="life-visual"> <view class="life-visual">
<image :key="item.icon + '-' + package3StaticVersion" class="life-asset" :class="'life-asset--' + item.type" :src="item.icon" <image class="life-asset" :class="'life-asset--' + item.type" :src="item.icon"
mode="aspectFit"></image> mode="aspectFit"></image>
</view> </view>
</view> </view>
@ -139,7 +139,7 @@
<!-- 未注册兼职弹窗 --> <!-- 未注册兼职弹窗 -->
<uni-popup ref="jianzhiPopup" background-color="rgba(2, 171, 255, 1)" borderRadius="40px 40px 40px 40px"> <uni-popup ref="jianzhiPopup" background-color="rgba(2, 171, 255, 1)" borderRadius="40px 40px 40px 40px">
<view class="jianzhi-content" @tap="navigatorTo('partTimeReg')"> <view class="jianzhi-content" @tap="navigatorTo('partTimeReg')">
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/faf25c687bc1417282ebac719fd1bfba.png" alt="" <img :src="getMyCenterImage('jianzhiPopup')" alt=""
style="width: 100%;height: 100%;"> style="width: 100%;height: 100%;">
<view style="position: absolute;bottom: -50px;left: 130px;" @tap.stop="$refs.jianzhiPopup.close()"> <view style="position: absolute;bottom: -50px;left: 130px;" @tap.stop="$refs.jianzhiPopup.close()">
<uni-icons type="close" size="40" color="#fff"></uni-icons> <uni-icons type="close" size="40" color="#fff"></uni-icons>
@ -193,6 +193,30 @@
</template> </template>
<script> <script>
const MY_CENTER_IMAGE_CACHE_KEY = 'my_center_image_cache_v1'
const MY_CENTER_IMAGE_CACHE_TTL = 30 * 24 * 60 * 60 * 1000
const MY_CENTER_IMAGE_CACHE_LIMIT = 30
const myCenterImageDownloading = {}
const MY_CENTER_IMAGE_URLS = {
avatar: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/1575f2987ee8435c88cabc1c1fcfde0e.png',
savingHero: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/d59656fe69e6455093123ed769850403.png',
earnTitle: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/c2e8e71e51e24ad4b717c405b5e8bb22.png',
taskGroup: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/7c183db1b23c4beab01548ceb1e9b009.png',
taskCash: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/99b4e791056f45dfbea2941127ee406f.png',
taskSchool: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/2e7e3d41d2964bb694f1a89e3f159927.png',
taskWallet: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/8be6d13d974346498390fd4509f392be.png',
identityMerchant: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/8953e4af95944d7c94936efaffe155c6.png',
identityShop: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/f19689fe650a4a439f7d9096d354b47e.png',
identityDelivery: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/bca3af00ef5c4d68baa19ff79246f8d2.png',
identityRule: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/93dfc625782a4a64927d862ec655bca3.png',
quickOrder: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/4b5151ee6d804b2db41f7235ed63b04a.png',
quickCoupon: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/9f48dc7d60a8481abd06b5a7e46487d8.png',
quickAddress: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/6857012140ad41238cfdec20953f4444.png',
quickCollect: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/9098995c67ae4271b23e0ac90c3abcad.png',
quickAgent: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/8493b053a0164882b20f6d4019de3a77.png',
jianzhiPopup: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/faf25c687bc1417282ebac719fd1bfba.png'
}
export default { export default {
data() { data() {
return { return {
@ -220,7 +244,7 @@
collegeRank: Number(uni.getStorageSync('collegeRank')) || 18, collegeRank: Number(uni.getStorageSync('collegeRank')) || 18,
menuButtonInfo: {}, menuButtonInfo: {},
statusBarHeight: 0, statusBarHeight: 0,
package3StaticVersion: 0 myCenterImages: {}
} }
}, },
computed: { computed: {
@ -280,7 +304,7 @@
subPre: '', subPre: '',
subEm: '省钱没有商量', subEm: '省钱没有商量',
subPost: '', subPost: '',
icon: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/7c183db1b23c4beab01548ceb1e9b009.png', icon: this.getMyCenterImage('taskGroup'),
cta: '去拼团', cta: '去拼团',
action: 'groupPending' action: 'groupPending'
}, { }, {
@ -289,7 +313,7 @@
subPre: '', subPre: '',
subEm: '22:00', subEm: '22:00',
subPost: ' 开奖', subPost: ' 开奖',
icon: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/99b4e791056f45dfbea2941127ee406f.png', icon: this.getMyCenterImage('taskCash'),
cta: '去参与', cta: '去参与',
action: 'planet' action: 'planet'
}, { }, {
@ -298,7 +322,7 @@
subPre: '', subPre: '',
subEm: '有现金奖励哦', subEm: '有现金奖励哦',
subPost: '', subPost: '',
icon: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/2e7e3d41d2964bb694f1a89e3f159927.png', icon: this.getMyCenterImage('taskSchool'),
cta: '去排位', cta: '去排位',
action: 'planet' action: 'planet'
}, { }, {
@ -307,7 +331,7 @@
subPre: '', subPre: '',
subEm: '¥' + this.balance, subEm: '¥' + this.balance,
subPost: '', subPost: '',
icon: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/8be6d13d974346498390fd4509f392be.png', icon: this.getMyCenterImage('taskWallet'),
cta: '去提现', cta: '去提现',
action: 'qianbao' action: 'qianbao'
}] }]
@ -317,27 +341,27 @@
type: 'merchant', type: 'merchant',
title: '商家入驻', title: '商家入驻',
desc: '开店赚钱', desc: '开店赚钱',
icon: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/8953e4af95944d7c94936efaffe155c6.png', icon: this.getMyCenterImage('identityMerchant'),
action: 'merchant' action: 'merchant'
}, { }, {
type: 'shop', type: 'shop',
title: '商家中心', title: '商家中心',
desc: '待处理订单', desc: '待处理订单',
icon: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/f19689fe650a4a439f7d9096d354b47e.png', icon: this.getMyCenterImage('identityShop'),
count: this.shopCounts, count: this.shopCounts,
action: this.hasShop ? 'merchantCenter' : 'merchant' action: this.hasShop ? 'merchantCenter' : 'merchant'
}, { }, {
type: 'delivery', type: 'delivery',
title: '兼职主页', title: '兼职主页',
desc: '待处理订单', desc: '待处理订单',
icon: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/bca3af00ef5c4d68baa19ff79246f8d2.png', icon: this.getMyCenterImage('identityDelivery'),
count: this.workerCounts, count: this.workerCounts,
action: this.hasWorker ? 'jianzhizhuye' : 'jianzhizhuce' action: this.hasWorker ? 'jianzhizhuye' : 'jianzhizhuce'
}, { }, {
type: 'rule', type: 'rule',
title: '接单规则', title: '接单规则',
desc: '设置接单范围', desc: '设置接单范围',
icon: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/93dfc625782a4a64927d862ec655bca3.png', icon: this.getMyCenterImage('identityRule'),
action: 'partTimeReg' action: 'partTimeReg'
}] }]
}, },
@ -346,49 +370,156 @@
type: 'order', type: 'order',
title: '我的订单', title: '我的订单',
tip: '', tip: '',
icon: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/4b5151ee6d804b2db41f7235ed63b04a.png', icon: this.getMyCenterImage('quickOrder'),
action: 'dingdan' action: 'dingdan'
}, { }, {
type: 'coupon', type: 'coupon',
title: '优惠券', title: '优惠券',
tip: '', tip: '',
icon: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/9f48dc7d60a8481abd06b5a7e46487d8.png', icon: this.getMyCenterImage('quickCoupon'),
action: 'youhui' action: 'youhui'
}, { }, {
type: 'address', type: 'address',
title: '收货地址', title: '收货地址',
tip: '', tip: '',
icon: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/6857012140ad41238cfdec20953f4444.png', icon: this.getMyCenterImage('quickAddress'),
action: 'address' action: 'address'
}, { }, {
type: 'collect', type: 'collect',
title: '投诉吐槽', title: '投诉吐槽',
tip: '', tip: '',
icon: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/9098995c67ae4271b23e0ac90c3abcad.png', icon: this.getMyCenterImage('quickCollect'),
action: 'collect' action: 'collect'
}, { }, {
type: 'agent', type: 'agent',
title: '成为代理', title: '成为代理',
tip: '', tip: '',
icon: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/8493b053a0164882b20f6d4019de3a77.png', icon: this.getMyCenterImage('quickAgent'),
action: 'agent' action: 'agent'
}] }]
} }
}, },
created() { created() {
this.applyCachedMyCenterImages()
this.setMenuButtonInfo() this.setMenuButtonInfo()
}, },
mounted() { mounted() {
this.setMenuButtonInfo() this.setMenuButtonInfo()
this.refreshPackage3Static()
uni.$on('myCenterCountsChange', this.setPendingCounts) uni.$on('myCenterCountsChange', this.setPendingCounts)
}, },
beforeDestroy() { beforeDestroy() {
uni.$off('myCenterCountsChange', this.setPendingCounts) uni.$off('myCenterCountsChange', this.setPendingCounts)
}, },
methods: { methods: {
refreshPackage3Static() { getMyCenterImage(key) {
this.package3StaticVersion += 1 return this.myCenterImages[key] || MY_CENTER_IMAGE_URLS[key] || ''
},
getMyCenterImageCache() {
const cache = uni.getStorageSync(MY_CENTER_IMAGE_CACHE_KEY)
return cache && typeof cache === 'object' ? cache : {}
},
saveMyCenterImageCache(cache) {
uni.setStorageSync(MY_CENTER_IMAGE_CACHE_KEY, cache)
},
isMyCenterImageCacheValid(cacheItem) {
return !!(cacheItem && cacheItem.path && cacheItem.path.indexOf('__tmp__') === -1 && Date.now() - Number(cacheItem.savedAt || 0) < MY_CENTER_IMAGE_CACHE_TTL)
},
applyCachedMyCenterImages() {
const cache = this.getMyCenterImageCache()
Object.keys(MY_CENTER_IMAGE_URLS).forEach((key) => {
const imageUrl = MY_CENTER_IMAGE_URLS[key]
const cacheItem = cache[imageUrl]
if (this.isMyCenterImageCacheValid(cacheItem)) {
this.$set(this.myCenterImages, key, cacheItem.path)
return
}
this.$set(this.myCenterImages, key, imageUrl)
this.cacheMyCenterImage(key, imageUrl)
})
this.pruneMyCenterImageCache(cache, Object.keys(MY_CENTER_IMAGE_URLS).map(key => MY_CENTER_IMAGE_URLS[key]))
},
cacheMyCenterImage(key, imageUrl) {
if (myCenterImageDownloading[imageUrl]) return
myCenterImageDownloading[imageUrl] = true
uni.downloadFile({
url: imageUrl,
success: (downloadRes) => {
if (downloadRes.statusCode !== 200 || !downloadRes.tempFilePath) {
this.$set(this.myCenterImages, key, imageUrl)
delete myCenterImageDownloading[imageUrl]
return
}
uni.saveFile({
tempFilePath: downloadRes.tempFilePath,
success: (saveRes) => {
const cache = this.getMyCenterImageCache()
const oldCacheItem = cache[imageUrl]
if (oldCacheItem && oldCacheItem.path && oldCacheItem.path !== saveRes.savedFilePath) {
uni.removeSavedFile({
filePath: oldCacheItem.path,
fail: () => {}
})
}
cache[imageUrl] = {
path: saveRes.savedFilePath,
savedAt: Date.now()
}
this.saveMyCenterImageCache(cache)
this.$set(this.myCenterImages, key, saveRes.savedFilePath)
},
fail: () => {
this.$set(this.myCenterImages, key, imageUrl)
},
complete: () => {
delete myCenterImageDownloading[imageUrl]
}
})
},
fail: () => {
this.$set(this.myCenterImages, key, imageUrl)
delete myCenterImageDownloading[imageUrl]
},
complete: (downloadRes) => {
if (!downloadRes || downloadRes.statusCode !== 200) {
this.$set(this.myCenterImages, key, imageUrl)
delete myCenterImageDownloading[imageUrl]
}
}
})
},
pruneMyCenterImageCache(cache, activeUrls) {
const activeUrlMap = activeUrls.reduce((result, url) => {
result[url] = true
return result
}, {})
const now = Date.now()
Object.keys(cache).forEach((url) => {
const item = cache[url]
const isExpired = !this.isMyCenterImageCacheValid(item)
if (isExpired && !activeUrlMap[url]) {
item && item.path && uni.removeSavedFile({
filePath: item.path,
fail: () => {}
})
delete cache[url]
}
})
const urls = Object.keys(cache).sort((a, b) => Number(cache[a].savedAt || now) - Number(cache[b].savedAt || now))
while (urls.length > MY_CENTER_IMAGE_CACHE_LIMIT) {
const url = urls.shift()
if (activeUrlMap[url]) {
urls.push(url)
if (urls.every(itemUrl => activeUrlMap[itemUrl])) break
continue
}
const item = cache[url]
item && item.path && uni.removeSavedFile({
filePath: item.path,
fail: () => {}
})
delete cache[url]
}
this.saveMyCenterImageCache(cache)
}, },
setMenuButtonInfo() { setMenuButtonInfo() {
try { try {
@ -440,7 +571,7 @@
}) })
}, },
init() { init() {
this.refreshPackage3Static() this.applyCachedMyCenterImages()
this.schoolShop = this.normalizeShopList(uni.getStorageSync('schoolShop')) this.schoolShop = this.normalizeShopList(uni.getStorageSync('schoolShop'))
this.worker = uni.getStorageSync('worker') this.worker = uni.getStorageSync('worker')
let shopId = uni.getStorageSync('shopId') let shopId = uni.getStorageSync('shopId')

Loading…
Cancel
Save