feat: 自定义底部导航栏及订单、分类、商品等页面更新

这个提交包含在:
wikiboss
2026-11-20 09:05:07 +08:00
父节点 9d2488a631
当前提交 096e31448c
共有 26 个文件被更改,包括 1083 次插入 和 254 次删除

查看文件

@@ -1,7 +1,7 @@
<template> <template>
<view class="cu-modal bottom-modal" :class="{ show: showAuth }" @tap="closeAuthModal" style="z-index: 10080;"> <view v-if="authType" class="auth-modal" @touchmove.stop.prevent="() => {}">
<view class="login-wrap cu-dialog form-wrap safe-area-inset-bottom" @tap.stop <view class="auth-modal__mask" @tap="closeAuthModal"></view>
style="border-radius: 20rpx 20rpx 0 0;"> <view class="login-wrap auth-modal__panel form-wrap safe-area-inset-bottom" @tap.stop>
<!-- 1.账号密码登录 <!-- 1.账号密码登录
<view v-if="authType === 'accountLogin'"> <view v-if="authType === 'accountLogin'">
<view class="head-box u-m-b-60 u-flex-col "> <view class="head-box u-m-b-60 u-flex-col ">
@@ -444,15 +444,7 @@
}, },
computed: { computed: {
...mapGetters(['initShop', 'isLogin', 'authType']), ...mapGetters(['initShop', 'isLogin', 'authType'])
showAuth: {
get() {
return !!this.authType;
},
set(value) {
value ? uni.hideTabBar() : uni.showTabBar();
}
}
}, },
mounted() {}, mounted() {},
methods: { methods: {
@@ -784,6 +776,36 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.auth-modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 10080;
}
.auth-modal__mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.6);
z-index: 1;
}
.auth-modal__panel {
position: absolute;
left: 0;
right: 0;
bottom: 0;
width: 100%;
z-index: 2;
border-radius: 20rpx 20rpx 0 0;
overflow: hidden;
}
@keyframes title-animation { @keyframes title-animation {
0% { 0% {
font-size: 32rpx; font-size: 32rpx;

查看文件

@@ -250,12 +250,9 @@
sku_price_id: sku.id, sku_price_id: sku.id,
goods_price: sku.price goods_price: sku.price
}]; }];
this.$Router.push({ this.$tools.toOrderConfirm({
path: '/pages/order/confirm', goodsList: confirmGoodsList,
query: { from: 'goods'
goodsList: confirmGoodsList,
from: 'goods'
}
}); });
}, },

查看文件

@@ -12,8 +12,8 @@
<text class="u-iconfont uicon-close-circle-fill close-icon" @tap.stop="showModal = false"></text> <text class="u-iconfont uicon-close-circle-fill close-icon" @tap.stop="showModal = false"></text>
<!-- 商品卡片--> <!-- 商品卡片-->
<view class="top u-flex modal-head__box"> <view class="top u-flex modal-head__box">
<image class="shop-img" :src="currentSkuPrice.image ? currentSkuPrice.image : goodsInfo.image" <image class="shop-img" :src="skuPreviewImage" mode="aspectFill"
mode="aspectFill"></image> @tap.stop="previewSkuImage"></image>
<view class=" goods-box u-flex-col u-row-between"> <view class=" goods-box u-flex-col u-row-between">
<view class="goods-title u-ellipsis-2">{{ goodsInfo.title }}</view> <view class="goods-title u-ellipsis-2">{{ goodsInfo.title }}</view>
<view class="u-flex u-row-between goods-bottom"> <view class="u-flex u-row-between goods-bottom">
@@ -163,12 +163,26 @@
}); });
that.$emit('getSkuText', str); that.$emit('getSkuText', str);
return str; return str;
},
skuPreviewImage() {
return (this.currentSkuPrice.image || this.goodsInfo.image || '').trim();
} }
}, },
methods: { methods: {
...mapActions(['addCartGoods', 'getCartList']), ...mapActions(['addCartGoods', 'getCartList']),
previewSkuImage() {
const url = this.skuPreviewImage;
if (!url) {
return;
}
this.$tools.previewImage([url], url);
},
jump(path, parmas) { jump(path, parmas) {
if (path === '/pages/order/confirm') {
this.$tools.toOrderConfirm(parmas || {});
return;
}
this.$Router.push({ this.$Router.push({
path: path, path: path,
query: parmas query: parmas
@@ -336,7 +350,7 @@
from: 'goods', from: 'goods',
orderType: that.goodsType, orderType: that.goodsType,
grouponBuyType: that.grouponBuyType, grouponBuyType: that.grouponBuyType,
grouponId: that.grouponId grouponId: Number(that.grouponId) || 0
}); });
} }
}, },

查看文件

@@ -4,8 +4,8 @@
<view class="tabbar-item" v-for="(tab, index) in tabbarList" :key="tab.name + index" <view class="tabbar-item" v-for="(tab, index) in tabbarList" :key="tab.name + index"
@tap.stop="handleTabTap(index)"> @tap.stop="handleTabTap(index)">
<view class="img-box" v-if="showIcon"> <view class="img-box" v-if="showIcon">
<image class="tabbar-icon" :src="isActive(tab) ? tab.activeImage : tab.image" <image class="tabbar-icon" :src="iconSrc(tab)" mode="aspectFit"
mode="aspectFit"></image> @error="onIconError(tab)"></image>
<view v-if="tab.path == '/pages/index/cart' && cartNum" class="badge">{{ cartNum }}</view> <view v-if="tab.path == '/pages/index/cart' && cartNum" class="badge">{{ cartNum }}</view>
</view> </view>
<view class="tabbar-text" v-if="showText" <view class="tabbar-text" v-if="showText"
@@ -56,13 +56,17 @@ export default {
name: 'shoproTabbar', name: 'shoproTabbar',
data() { data() {
return { return {
currentPath: '' currentPath: '',
activeIconFallback: {}
}; };
}, },
computed: { computed: {
...mapGetters(['cartNum', 'tabbarData']), ...mapGetters(['cartNum', 'tabbarData']),
useCustomTabbarData() {
return !!(this.tabbarData && this.tabbarData.list && this.tabbarData.list.length);
},
tabbarConfig() { tabbarConfig() {
if (this.tabbarData && this.tabbarData.list && this.tabbarData.list.length) { if (this.useCustomTabbarData) {
return this.tabbarData; return this.tabbarData;
} }
return DEFAULT_TABBAR; return DEFAULT_TABBAR;
@@ -91,6 +95,13 @@ export default {
mounted() { mounted() {
this.refreshTabbar(); this.refreshTabbar();
}, },
// #ifdef MP-WEIXIN
pageLifetimes: {
show() {
this.updateCurrentPath();
}
},
// #endif
methods: { methods: {
normalizePath(path = '') { normalizePath(path = '') {
return path.split('?')[0]; return path.split('?')[0];
@@ -101,21 +112,57 @@ export default {
} }
return this.normalizePath(this.currentPath) === this.normalizePath(tab.path); return this.normalizePath(this.currentPath) === this.normalizePath(tab.path);
}, },
isLikelyIconUrl(url = '') {
if (!url || typeof url !== 'string') {
return false;
}
const value = url.trim();
if (!value || /^#([0-9a-fA-F]{3,8})$/.test(value)) {
return false;
}
return true;
},
resolveIconUrl(url = '') {
if (!this.isLikelyIconUrl(url)) {
return '';
}
const value = url.trim();
if (!this.useCustomTabbarData) {
return value;
}
return this.$tools.formatTabIconUrl(value);
},
iconSrc(tab) {
if (!tab) {
return '';
}
const pathKey = this.normalizePath(tab.path);
const normalIcon = this.resolveIconUrl(tab.image);
if (!this.isActive(tab) || this.activeIconFallback[pathKey]) {
return normalIcon;
}
const activeRaw = tab.activeImage || tab.active_image || '';
const activeIcon = this.resolveIconUrl(activeRaw);
if (activeIcon && activeIcon !== normalIcon) {
return activeIcon;
}
return normalIcon;
},
onIconError(tab) {
if (!tab || !tab.path || !this.isActive(tab)) {
return;
}
const pathKey = this.normalizePath(tab.path);
if (!this.activeIconFallback[pathKey]) {
this.$set(this.activeIconFallback, pathKey, true);
}
},
updateCurrentPath() { updateCurrentPath() {
const route = this.$Route || {}; const route = this.$Route || {};
this.currentPath = route.path === '/pages/index/index' ? route.path : (route.fullPath || route.path || ''); this.currentPath = route.path === '/pages/index/index' ? route.path : (route.fullPath || route.path || '');
}, },
hideNativeTabBar() {
// #ifdef MP-WEIXIN
uni.hideTabBar({
animation: false,
fail: () => {}
});
// #endif
},
refreshTabbar() { refreshTabbar() {
this.updateCurrentPath(); this.updateCurrentPath();
this.hideNativeTabBar();
}, },
handleTabTap(index) { handleTabTap(index) {
const tab = this.tabbarList[index]; const tab = this.tabbarList[index];
@@ -158,30 +205,33 @@ export default {
justify-content: center; justify-content: center;
padding: 8rpx 0 6rpx; padding: 8rpx 0 6rpx;
box-sizing: border-box; box-sizing: border-box;
overflow: visible;
.img-box { .img-box {
position: relative; position: relative;
width: 50rpx; width: 50rpx;
height: 50rpx; height: 50rpx;
flex-shrink: 0; flex-shrink: 0;
overflow: visible;
.badge { .badge {
position: absolute; position: absolute;
display: inline-flex; display: inline-flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
line-height: 24rpx; min-width: 28rpx;
padding: 4rpx 10rpx; height: 28rpx;
line-height: 1;
padding: 0 8rpx;
border-radius: 100rpx; border-radius: 100rpx;
color: #fff; color: #fff;
font-size: 24rpx; font-size: 20rpx;
z-index: 9; z-index: 9;
background-color: #fa3534; background-color: #fa3534;
transform: scale(0.8); top: -10rpx;
transform-origin: center center; right: -18rpx;
top: -6rpx;
right: -16rpx;
white-space: nowrap; white-space: nowrap;
box-sizing: border-box;
} }
} }

18
custom-tab-bar/index.vue 普通文件
查看文件

@@ -0,0 +1,18 @@
<template>
<!-- 占位:禁用微信原生 tabBar 图标,实际底部导航由 shopro-tabbar 渲染 -->
<view class="custom-tab-bar-placeholder"></view>
</template>
<script>
export default {
name: 'CustomTabBar'
};
</script>
<style>
.custom-tab-bar-placeholder {
height: 0;
width: 100%;
overflow: hidden;
}
</style>

查看文件

@@ -1,7 +1,7 @@
{ {
"name" : "小众厨房设备1", "name" : "初始商城",
"appid" : "__UNI__C77F3FE", "appid" : "__UNI__C77F3FE",
"description" : "小众厨房设备1", "description" : "初始商城",
"versionName" : "1.3.9", "versionName" : "1.3.9",
"versionCode" : 137, "versionCode" : 137,
"transformPx" : false, "transformPx" : false,
@@ -97,7 +97,7 @@
"payment" : { "payment" : {
"weixin" : { "weixin" : {
"__platform__" : [ "ios", "android" ], "__platform__" : [ "ios", "android" ],
"appid" : "wx8dab4aa7e442592a", "appid" : "",
"UniversalLinks" : "https://m.*****.top/uni-universallinks/__*****" "UniversalLinks" : "https://m.*****.top/uni-universallinks/__*****"
}, },
"alipay" : { "alipay" : {
@@ -115,13 +115,13 @@
"oauth" : { "oauth" : {
"apple" : {}, "apple" : {},
"weixin" : { "weixin" : {
"appid" : "wx8dab4aa7e442592a", "appid" : "",
"UniversalLinks" : "https://m.*****.top/uni-universallinks/__*****" "UniversalLinks" : "https://m.*****.top/uni-universallinks/__*****"
} }
}, },
"share" : { "share" : {
"weixin" : { "weixin" : {
"appid" : "wx8dab4aa7e442592a", "appid" : "",
"UniversalLinks" : "https://m.*****.top/uni-universallinks/__*****" "UniversalLinks" : "https://m.*****.top/uni-universallinks/__*****"
} }
}, },
@@ -164,12 +164,12 @@
} }
}, },
"kernel" : { "kernel" : {
"ios" : "WKWebview" //或者 "WKWebview" "ios" : "WKWebview" //或者 "WKWebview"
} }
}, },
"quickapp" : {}, "quickapp" : {},
"mp-weixin" : { "mp-weixin" : {
"appid" : "wxc99af35376585e88", "appid" : "wxbf3e451cf462301a",
"setting" : { "setting" : {
"urlCheck" : false, "urlCheck" : false,
"es6" : true, //消除大多数样式警告 "es6" : true, //消除大多数样式警告

查看文件

@@ -94,20 +94,6 @@
"group": "商城" "group": "商城"
} }
}, },
{
"path": "pages/live/list",
"name": "video",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": true
},
"meta": {
"auth": false,
"async": true,
"title": "直播",
"group": "直播"
}
},
{ {
"path": "pages/index/money", "path": "pages/index/money",
"name": "money", "name": "money",
@@ -928,23 +914,6 @@
"group": "用户" "group": "用户"
} }
}, },
{
"path": "live",
"style": {
"navigationStyle": "custom",
"navigationBarTextStyle": "white",
"app-plus": {
"titleNView": false,
"scrollIndicator": "none"
}
},
"meta": {
"auth": true,
"async": true,
"title": "开启直播",
"group": "直播"
}
},
{ {
"path": "set", "path": "set",
"style": { "style": {
@@ -1118,6 +1087,7 @@
"backgroundColor": "#FFFFFF" "backgroundColor": "#FFFFFF"
}, },
"tabBar": { "tabBar": {
"custom": true,
"color": "#333", "color": "#333",
"selectedColor": "#4C7AF3", "selectedColor": "#4C7AF3",
"backgroundColor": "#ffffff", "backgroundColor": "#ffffff",

查看文件

@@ -178,10 +178,15 @@ export default {
getGoodsList() { getGoodsList() {
let that = this; let that = this;
that.loadStatus = 'loading'; that.loadStatus = 'loading';
that.$http('goods.lists', { let goodsIds = that.activityInfo.goods_ids;
goods_ids: that.activityInfo.goods_ids, if (goodsIds === undefined || goodsIds === null || goodsIds === 'undefined') {
page: that.currentPage goodsIds = '';
}).then(res => { }
const params = { page: that.currentPage };
if (goodsIds) {
params.goods_ids = goodsIds;
}
that.$http('goods.lists', params).then(res => {
if (res.code === 1) { if (res.code === 1) {
that.goodsList = [...that.goodsList, ...res.data.data]; that.goodsList = [...that.goodsList, ...res.data.data];
that.isEmpty = !that.goodsList.length; that.isEmpty = !that.goodsList.length;

查看文件

@@ -14,7 +14,7 @@
<view class="content_box"> <view class="content_box">
<scroll-view scroll-y="true" enable-back-to-top @scrolltolower="loadMore" refresher-background="#f5f5f5" class="scroll-box"> <scroll-view scroll-y="true" enable-back-to-top @scrolltolower="loadMore" refresher-background="#f5f5f5" class="scroll-box">
<block v-for="groupon in myGrouponList" :key="groupon.id"> <block v-for="groupon in myGrouponList" :key="groupon.id">
<view class="group-card"> <view class="group-card" v-if="groupon.goods && groupon.groupon">
<image v-if="stateId !== 'ing'" class="group-state" :src="grouponStatus[groupon.groupon.status]" mode=""></image> <image v-if="stateId !== 'ing'" class="group-state" :src="grouponStatus[groupon.groupon.status]" mode=""></image>
<view class="goods-content"> <view class="goods-content">
<shopro-mini-card <shopro-mini-card
@@ -96,6 +96,16 @@ export default {
}, },
computed: {}, computed: {},
onLoad() { onLoad() {
this._skipFirstShow = true;
this.getMyGroupon();
},
onShow() {
if (this._skipFirstShow) {
this._skipFirstShow = false;
return;
}
this.currentPage = 1;
this.myGrouponList = [];
this.getMyGroupon(); this.getMyGroupon();
}, },
onPullDownRefresh() { onPullDownRefresh() {

查看文件

@@ -61,9 +61,17 @@ export default {
computed: { computed: {
activityMap() { activityMap() {
let obj = {}; let obj = {};
this.detail.forEach(item => { (this.detail || []).forEach(item => {
if (!item || !item.type) {
return;
}
obj[item.type] = item; obj[item.type] = item;
obj[item.type].num = item.goods_ids.split(',').length; const goodsIds = item.goods_ids;
if (goodsIds === null || goodsIds === undefined || goodsIds === '') {
obj[item.type].num = 0;
} else {
obj[item.type].num = String(goodsIds).split(',').filter(Boolean).length;
}
}); });
return obj; return obj;
} }

查看文件

@@ -19,7 +19,7 @@
</view> </view>
<view class="time" v-if="g.expiretime && g.time">剩余时间{{ g.time.h }}:{{ g.time.m }}:{{ g.time.s }}</view> <view class="time" v-if="g.expiretime && g.time">剩余时间{{ g.time.h }}:{{ g.time.m }}:{{ g.time.s }}</view>
</view> </view>
<button class="u-reset-button join-btn" @tap="jump('/pages/activity/groupon/detail', { id: g.id })">去参团</button> <button class="u-reset-button join-btn" @tap="handleJoin(g.id)">去参团</button>
</view> </view>
</view> </view>
</block> </block>
@@ -44,7 +44,7 @@
</view> </view>
<view class="time" v-if="g.expiretime && g.time">剩余时间{{ g.time.h }}:{{ g.time.m }}:{{ g.time.s }}</view> <view class="time" v-if="g.expiretime && g.time">剩余时间{{ g.time.h }}:{{ g.time.m }}:{{ g.time.s }}</view>
</view> </view>
<button class="u-reset-button join-btn" @tap="joinTeam('/pages/activity/groupon/detail', { id: g.id })">去参团</button> <button class="u-reset-button join-btn" @tap="handleJoin(g.id)">去参团</button>
</view> </view>
</view> </view>
</view> </view>
@@ -100,12 +100,9 @@ export default {
query: parmas query: parmas
}); });
}, },
joinTeam(path, parmas) { handleJoin(grouponId) {
this.showModal = false; this.showModal = false;
this.$Router.push({ this.$emit('join', grouponId);
path: path,
query: parmas
});
}, },
onMoreGrouponTeam() { onMoreGrouponTeam() {
this.showModal = true; this.showModal = true;

查看文件

@@ -44,13 +44,19 @@
<view class="" id="goods"> <view class="" id="goods">
<swiper :indicator-dots="true" @change="changeSwiper" :autoplay="autoplay" :interval="3000" <swiper :indicator-dots="true" @change="changeSwiper" :autoplay="autoplay" :interval="3000"
:duration="1000" style="height: 750rpx;"> :duration="1000" style="height: 750rpx;">
<swiper-item style="width: 100%;height: 100%;" v-for="(item,index) in goodsInfo.images"> <swiper-item style="width: 100%;height: 100%;" v-for="(item,index) in goodsInfo.images"
<view class="swiper-item" style="width: 100%;height: 100%;"> :key="index">
<image :src="item.src" mode="aspectFill" v-if="item.type == 0 && detailType != 'score'"> <view class="swiper-item goods-swiper-item" @tap.stop="onGoodsSwiper(index)"
v-if="detailType == 'score' || item.type == 0">
<image class="goods-swiper-image" :src="item.src" mode="aspectFill"
:lazy-load="false" v-if="item.type == 0 && detailType != 'score'">
</image> </image>
<image :src="item" mode="aspectFill" v-if="detailType == 'score'"></image> <image class="goods-swiper-image" :src="item" mode="aspectFill" :lazy-load="false"
v-if="detailType == 'score'"></image>
</view>
<view class="swiper-item" style="width: 100%;height: 100%;" v-else-if="item.type == 1">
<view @tap="playVideo(index)" class="" <view @tap="playVideo(index)" class=""
style="width: 100%;height: 100%;position: relative;" v-if="item.type == 1"> style="width: 100%;height: 100%;position: relative;">
<video :controls="true" :show-center-play-btn="false" :show-play-btn="false" <video :controls="true" :show-center-play-btn="false" :show-play-btn="false"
:id="'myVideo'+index" :src="item.src" style="width: 100%;height: 100%;"></video> :id="'myVideo'+index" :src="item.src" style="width: 100%;height: 100%;"></video>
<view v-if="is_play != 'play'" @tap.stop="playVideo(index)" class="" <view v-if="is_play != 'play'" @tap.stop="playVideo(index)" class=""
@@ -118,8 +124,8 @@
<!-- 拼团人--> <!-- 拼团人-->
<sh-groupon <sh-groupon
v-if="goodsInfo.activity && goodsInfo.activity.type === 'groupon' && goodsInfo.activity.rules.team_card === '1' && detailType !== 'score'" v-if="goodsInfo.activity && goodsInfo.activity.type === 'groupon' && detailType !== 'score'"
:grouponData="goodsInfo"></sh-groupon> :grouponData="goodsInfo" @join="onJoinGroupon"></sh-groupon>
<!-- 拼团玩法 --> <!-- 拼团玩法 -->
<view <view
@@ -292,9 +298,9 @@
<button <button
class=" tool-btn u-reset-button groupon-btn u-flex-col u-row-center u-col-center" class=" tool-btn u-reset-button groupon-btn u-flex-col u-row-center u-col-center"
:style="goodsInfo.activity.rules.is_alone === '0' ? 'width:400rpx' : ''" :style="goodsInfo.activity.rules.is_alone === '0' ? 'width:400rpx' : ''"
@tap="payGroupon('groupon')"> @tap="payGroupon(joinGrouponId ? 'join' : 'groupon')">
<text class="price font-OPPOSANS">¥{{ goodsInfo.groupon_price }}</text> <text class="price font-OPPOSANS">¥{{ goodsInfo.groupon_price }}</text>
<text class="price-title">我要开团</text> <text class="price-title">{{ joinGrouponId ? '立即参团' : '我要开团' }}</text>
</button> </button>
</view> </view>
</block> </block>
@@ -311,7 +317,8 @@
<shopro-sku v-model="showSku" :goodsInfo="goodsInfo" <shopro-sku v-model="showSku" :goodsInfo="goodsInfo"
:activityRules="activityRules" :activityRules="activityRules"
:buyType="goodsInfo.activity_type == 'robbuy' || goodsInfo.activity_type == 'seckill' || goodsInfo.activity_type == 'timer' || detailType === 'score' ? 'buy' : buyType" :buyType="goodsInfo.activity_type == 'robbuy' || goodsInfo.activity_type == 'seckill' || goodsInfo.activity_type == 'timer' || detailType === 'score' ? 'buy' : buyType"
:grouponBuyType="grouponBuyType" :goodsType="detailType === 'score' ? 'score' : 'goods'" :grouponBuyType="grouponBuyType" :grouponId="joinGrouponId"
:goodsType="detailType === 'score' ? 'score' : 'goods'"
@changeType="changeType" @getSkuText="getSkuText"></shopro-sku> @changeType="changeType" @getSkuText="getSkuText"></shopro-sku>
<shopro-share v-model="showShare" :posterInfo="goodsInfo" :posterType="'goods'"></shopro-share> <shopro-share v-model="showShare" :posterInfo="goodsInfo" :posterType="'goods'"></shopro-share>
</template> </template>
@@ -377,6 +384,7 @@
buyType: 'sku', buyType: 'sku',
is_play: 'stop', is_play: 'stop',
grouponBuyType: 'alone', //拼团购买方式。 grouponBuyType: 'alone', //拼团购买方式。
joinGrouponId: 0, // 参团ID,0表示开团
showEmpty: false, showEmpty: false,
showEmptyText: '', showEmptyText: '',
showServe: false, showServe: false,
@@ -582,8 +590,30 @@
}, },
// 轮播图预览 // 轮播图预览
onGoodsSwiper(e) { onGoodsSwiper(index) {
this.$tools.previewImage(this.goodsInfo.images, e); const images = this.goodsInfo.images || [];
let urls = [];
let currentUrl = '';
if (this.detailType === 'score') {
urls = images.map((img) => this.$tools.formatImageUrl(img));
currentUrl = urls[index];
} else {
const current = images[index];
if (!current || Number(current.type) !== 0) {
return;
}
urls = images
.filter((img) => Number(img.type) === 0)
.map((img) => this.$tools.formatImageUrl(img.src));
currentUrl = this.$tools.formatImageUrl(current.src);
}
if (!urls.length || !currentUrl) {
return;
}
this.$tools.previewImage(urls, currentUrl);
}, },
getActivityRules(e) { getActivityRules(e) {
if (e) { if (e) {
@@ -742,8 +772,12 @@
if (this.isLogin) { if (this.isLogin) {
if (type === 'groupon') { if (type === 'groupon') {
this.grouponBuyType = 'groupon'; this.grouponBuyType = 'groupon';
this.joinGrouponId = 0;
} else if (type === 'join') {
this.grouponBuyType = 'groupon';
} else { } else {
this.grouponBuyType = 'alone'; this.grouponBuyType = 'alone';
this.joinGrouponId = 0;
} }
this.buyType = 'buy'; this.buyType = 'buy';
this.showSku = true; this.showSku = true;
@@ -751,6 +785,12 @@
this.$store.dispatch('showAuthModal'); this.$store.dispatch('showAuthModal');
} }
}, },
onJoinGroupon(grouponId) {
this.joinGrouponId = Number(grouponId) || 0;
this.grouponBuyType = 'groupon';
this.buyType = 'buy';
this.showSku = true;
},
// 预约抢购 // 预约抢购
handleRobOrder() { handleRobOrder() {
if (!this.isLogin) { if (!this.isLogin) {
@@ -859,6 +899,18 @@
font-weight: bold; font-weight: bold;
} }
.goods-swiper-item {
width: 100%;
height: 100%;
}
.goods-swiper-image {
width: 100%;
height: 100%;
display: block;
pointer-events: none;
}
// 标题栏 // 标题栏
.nav-box { .nav-box {
position: fixed; position: fixed;
@@ -866,6 +918,14 @@
min-height: 140rpx; min-height: 140rpx;
z-index: 888; z-index: 888;
top: 0; top: 0;
pointer-events: none;
.back-box,
.back-hover,
.tool-button,
.nav-item {
pointer-events: auto;
}
.back-box { .back-box {
background-color: rgba(#000, 0.18); background-color: rgba(#000, 0.18);

查看文件

@@ -184,7 +184,7 @@
this.$u.toast('活动商品只能单独购买'); this.$u.toast('活动商品只能单独购买');
return false; return false;
} }
that.jump('/pages/order/confirm', { that.$tools.toOrderConfirm({
goodsList: confirmcartList, goodsList: confirmcartList,
from: 'cart' from: 'cart'
}); });

查看文件

@@ -1,12 +1,12 @@
<template> <template>
<view class="content_box"> <view class="content_box">
<view class="u-flex u-col-center wrapper-box"> <view class="u-flex u-col-center wrapper-box">
<view class="scroll-box" style="background-color: #F6F6F6;"> <view class="scroll-box left-scroll-box" style="background-color: #F6F6F6;">
<scroll-view class="left u-flex-col u-col-center" enable-flex enable-back-to-top scroll-y> <scroll-view class="left" enable-back-to-top scroll-y>
<view class="type-list u-ellipsis-1" :class="[{ 'list-active': listId == index }]" <view class="type-list" :class="[{ 'list-active': listId == index }]"
v-for="(item, index) in categoryData" :key="index" @tap="onType(index)"> v-for="(item, index) in categoryData" :key="index" @tap="onType(index)">
<view class="line" :class="[{ 'line-active': listId == index }]"></view> <view class="line" :class="[{ 'line-active': listId == index }]"></view>
{{ item.name }} <text class="type-name">{{ item.name }}</text>
</view> </view>
<view class="hack-tabbar"></view> <view class="hack-tabbar"></view>
</scroll-view> </scroll-view>
@@ -189,10 +189,14 @@
background: #fff; background: #fff;
} }
.left-scroll-box {
flex: none;
width: 220rpx;
}
.left { .left {
width: 200upx; width: 220rpx;
height: 100%; height: 100%;
flex: 1;
.list-active { .list-active {
background: #fff; background: #fff;
@@ -205,22 +209,37 @@
} }
.type-list { .type-list {
height: 110upx; flex-shrink: 0;
min-height: 88rpx;
position: relative; position: relative;
width: 200rpx; width: 220rpx;
padding-left: 16rpx; padding: 16rpx 12rpx 16rpx 16rpx;
line-height: 110rpx; box-sizing: border-box;
display: flex;
align-items: center;
font-size: 28upx; font-size: 28upx;
font-weight: 400; font-weight: 400;
color: rgba(102, 102, 102, 1); color: rgba(102, 102, 102, 1);
.type-name {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
word-break: break-all;
white-space: normal;
line-height: 1.4;
width: 100%;
}
.line { .line {
width: 10upx; width: 10upx;
height: 40rpx; height: 40rpx;
position: absolute; position: absolute;
left: 0; left: 0;
border-radius: 5rpx; border-radius: 5rpx;
top:35rpx; top: 50%;
transform: translateY(-50%);
} }
} }
} }

查看文件

@@ -2,9 +2,9 @@
<view class="catgory-wrap"> <view class="catgory-wrap">
<view class="u-flex wrapper-box"> <view class="u-flex wrapper-box">
<!-- 左侧分类列表 --> <!-- 左侧分类列表 -->
<scroll-view enable-flex scroll-y scroll-with-animation class="u-tab-view menu-scroll-view" <scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view"
:scroll-top="scrollLeftTop"> :scroll-top="scrollLeftTop">
<view v-for="(item, index) in tabbarList" :key="index" class="u-tab-item u-ellipsis-1" <view v-for="(item, index) in tabbarList" :key="index" class="u-tab-item"
:class="[currentTab == index ? 'u-tab-item-active' : '']" :data-current="index" :class="[currentTab == index ? 'u-tab-item-active' : '']" :data-current="index"
@tap.stop="swichMenu(index)"> @tap.stop="swichMenu(index)">
<text class="menu-name">{{ item.name }}</text> <text class="menu-name">{{ item.name }}</text>
@@ -37,7 +37,7 @@
</view> </view>
<view class="goods-subtitle u-p-x-20 u-m-b-10 u-ellipsis-1">{{ item.subtitle }}</view> <view class="goods-subtitle u-p-x-20 u-m-b-10 u-ellipsis-1">{{ item.subtitle }}</view>
<!-- 满减,满折 --> <!-- 满减,满折 -->
<view class="u-p-x-20" v-if="item.activity_discounts_tags.length"> <view class="u-p-x-20" v-if="item.activity_discounts_tags && item.activity_discounts_tags.length">
<view class="tag-box u-m-b-10 u-m-r-10" <view class="tag-box u-m-b-10 u-m-r-10"
v-for="(tag, index1) in item.activity_discounts_tags" :key="index1">{{ tag }}</view> v-for="(tag, index1) in item.activity_discounts_tags" :key="index1">{{ tag }}</view>
</view> </view>
@@ -448,24 +448,39 @@
// 左侧menu // 左侧menu
.u-tab-view { .u-tab-view {
width: 200rpx; flex-shrink: 0;
width: 220rpx;
height: 100%; height: 100%;
.u-tab-item { .u-tab-item {
height: 84rpx; flex-shrink: 0;
min-height: 84rpx;
background: #f6f6f6; background: #f6f6f6;
width: 200rpx; width: 220rpx;
padding-left: 16rpx; padding: 16rpx 12rpx 16rpx 16rpx;
font-size: 26rpx; font-size: 26rpx;
color: #444; color: #444;
font-weight: 400; font-weight: 400;
line-height: 84rpx; line-height: 1.4;
box-sizing: border-box;
display: flex;
align-items: center;
.menu-name {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
word-break: break-all;
white-space: normal;
width: 100%;
}
} }
.u-tab-item-active { .u-tab-item-active {
position: relative; position: relative;
color: #000; color: #000;
font-size: 30rpx; font-size: 28rpx;
font-weight: bold; font-weight: bold;
background: #fff; background: #fff;
} }
@@ -476,7 +491,8 @@
border-left: 4px solid #4C7AF3; border-left: 4px solid #4C7AF3;
height: 32rpx; height: 32rpx;
left: 0; left: 0;
top: 26rpx; top: 50%;
transform: translateY(-50%);
} }
} }
} }

查看文件

@@ -1,11 +1,11 @@
<template> <template>
<view class="content_box"> <view class="content_box">
<view class="u-flex u-col-center wrapper-box"> <view class="u-flex u-col-center wrapper-box">
<view class="scroll-box" style="background-color: #F6F6F6;"> <view class="scroll-box left-scroll-box" style="background-color: #F6F6F6;">
<scroll-view class="left u-flex-col u-col-center" enable-flex enable-back-to-top scroll-y> <scroll-view class="left" enable-back-to-top scroll-y>
<view class="type-list u-ellipsis-1" :class="[{ 'list-active': listId == index }]" v-for="(item, index) in categoryData" :key="index" @tap="onType(index)"> <view class="type-list" :class="[{ 'list-active': listId == index }]" v-for="(item, index) in categoryData" :key="index" @tap="onType(index)">
<view class="line" :class="[{ 'line-active': listId == index }]"></view> <view class="line" :class="[{ 'line-active': listId == index }]"></view>
{{ item.name }} <text class="type-name">{{ item.name }}</text>
</view> </view>
<view class="hack-tabbar"></view> <view class="hack-tabbar"></view>
</scroll-view> </scroll-view>
@@ -24,8 +24,10 @@
</view> </view>
</view> </view>
<view class="item-box u-flex"> <view class="item-box u-flex">
<view class="u-flex-col goods-item" @tap="jump('/pages/goods/list', { id: mlist.id })" v-for="(mlist, index2) in list.children" :key="index2"> <view class="u-flex-col u-col-center goods-item" @tap="jump('/pages/goods/list', { id: mlist.id })" v-for="(mlist, index2) in list.children" :key="index2">
<image class="item-img" lazy-load :src="mlist.image" mode="aspectFill"></image> <view class="item-img-wrap">
<image class="item-img" lazy-load :src="mlist.image" mode="aspectFill"></image>
</view>
<view class="item-title u-ellipsis-1 ">{{ mlist.name }}</view> <view class="item-title u-ellipsis-1 ">{{ mlist.name }}</view>
</view> </view>
</view> </view>
@@ -115,10 +117,14 @@ export default {
background: #fff; background: #fff;
} }
.left-scroll-box {
flex: none;
width: 220rpx;
}
.left { .left {
width: 200upx; width: 220rpx;
height: 100%; height: 100%;
flex: 1;
.list-active { .list-active {
background: #fff; background: #fff;
@@ -131,20 +137,37 @@ export default {
} }
.type-list { .type-list {
height: 84upx; flex-shrink: 0;
min-height: 84rpx;
position: relative; position: relative;
width: 200rpx; width: 220rpx;
padding-left: 16rpx; padding: 16rpx 12rpx 16rpx 16rpx;
line-height: 84rpx; box-sizing: border-box;
display: flex;
align-items: center;
font-size: 28upx; font-size: 28upx;
font-weight: 400; font-weight: 400;
color: rgba(102, 102, 102, 1); color: rgba(102, 102, 102, 1);
.type-name {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
word-break: break-all;
white-space: normal;
line-height: 1.4;
width: 100%;
}
.line { .line {
width: 10upx; width: 10upx;
height: 100%; height: 40rpx;
position: absolute; position: absolute;
left: 0; left: 0;
top: 50%;
transform: translateY(-50%);
border-radius: 5rpx;
} }
} }
} }
@@ -179,27 +202,42 @@ export default {
.item-box { .item-box {
flex-wrap: wrap; flex-wrap: wrap;
width: 100%;
align-items: flex-start;
.goods-item { .goods-item {
width: calc((100% - 40rpx) / 3);
margin-right: 20rpx; margin-right: 20rpx;
margin-bottom: 20rpx; margin-bottom: 20rpx;
box-sizing: border-box;
&:nth-child(3n) { &:nth-child(3n) {
margin-right: 0; margin-right: 0;
} }
.item-img { .item-img-wrap {
width: 150rpx; width: 100%;
height: 150rpx; height: 0;
background: #f5f5f5; padding-bottom: 100%;
position: relative;
border-radius: 6rpx; border-radius: 6rpx;
overflow: hidden;
background: #f5f5f5;
}
.item-img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
} }
.item-title { .item-title {
font-size: 24rpx; font-size: 24rpx;
line-height: 24rpx; line-height: 24rpx;
margin-top: 10rpx; margin-top: 10rpx;
width: 150rpx; width: 100%;
text-align: center; text-align: center;
} }
} }

查看文件

@@ -1,239 +1,514 @@
<template> <template>
<view class="content_box"> <view class="content_box">
<view class="u-flex u-col-center wrapper-box"> <view class="u-flex u-col-center wrapper-box">
<view class="scroll-box" style="background-color: #F6F6F6;">
<scroll-view class="left u-flex-col u-col-center" enable-flex enable-back-to-top scroll-y> <view class="scroll-box left-scroll-box" style="background-color: #F6F6F6;">
<scroll-view class="left" enable-back-to-top scroll-y>
<view class="type-list u-flex u-col-center" :class="[{ 'list-active': listId == index }]" <view class="type-list u-flex u-col-center" :class="[{ 'list-active': listId == index }]"
v-for="(item, index) in categoryData" :key="index" @tap="onType(index)"> v-for="(item, index) in categoryData" :key="index" @tap="onType(index)">
<view class="u-ellipsis-1 list-item" :class="[{ 'line-active': listId == index }]">
{{ item.name }} <view class="list-item" :class="[{ 'line-active': listId == index }]">
<text class="type-name">{{ item.name }}</text>
</view> </view>
</view> </view>
<view class="hack-tabbar"></view> <view class="hack-tabbar"></view>
</scroll-view> </scroll-view>
</view> </view>
<view style="height: 100%;width: 100%;"> <view style="height: 100%;width: 100%;">
<scroll-view scroll-y class="scroll-box" enable-back-to-top scroll-with-animation> <scroll-view scroll-y class="scroll-box" enable-back-to-top scroll-with-animation>
<view class="right" v-if="categoryData.length"> <view class="right" v-if="categoryData.length">
<image class="type-img" v-if="categoryData[listId].image" :src="categoryData[listId].image" <image class="type-img" v-if="categoryData[listId].image" :src="categoryData[listId].image"
lazy-load mode="aspectFill"></image> lazy-load mode="aspectFill"></image>
<view class="type-box u-flex u-col-center u-row-center"> <view class="type-box u-flex u-col-center u-row-center">
<view class="u-iconfont uicon-minus" style="color: #d3d3d3;font-size: 28rpx;"></view> <view class="u-iconfont uicon-minus" style="color: #d3d3d3;font-size: 28rpx;"></view>
<text class="type-title">{{ categoryData[listId].name }}</text> <text class="type-title">{{ categoryData[listId].name }}</text>
<view class="u-iconfont uicon-minus" style="color: #d3d3d3;font-size: 28rpx;"></view> <view class="u-iconfont uicon-minus" style="color: #d3d3d3;font-size: 28rpx;"></view>
</view> </view>
<view class="item-list"> <view class="item-list">
<view class="item-box u-flex"> <view class="item-box u-flex">
<view class="u-flex-col u-col-center goods-item" <view class="u-flex-col u-col-center goods-item"
@tap="jump('/pages/goods/list', { id: list.id })" @tap="jump('/pages/goods/list', { id: list.id })"
v-for="(list, index1) in categoryData[listId].children" :key="index1"> v-for="(list, index1) in categoryData[listId].children" :key="index1">
<image class="item-img" lazy-load :src="list.image" mode="aspectFill"></image>
<view class="item-title u-ellipsis-1 ">{{ list.name }}</view> <view class="item-img-wrap">
<image class="item-img" lazy-load :src="list.image" mode="aspectFill"></image>
</view>
<view class="item-title u-ellipsis-1">{{ list.name }}</view>
</view> </view>
</view> </view>
<!-- 缺省页 -->
<shopro-empty v-show="!categoryData[listId].children.length" <shopro-empty v-show="!categoryData[listId].children.length"
:image="$IMG_URL + '/imgs/empty/empty_goods.png'" marginTop="200rpx" :image="$IMG_URL + '/imgs/empty/empty_goods.png'" marginTop="200rpx"
tipText="暂无该商品,还有更多好货等着你噢~"></shopro-empty> tipText="暂无该商品,还有更多好货等着你噢~"></shopro-empty>
<view class="hack-tabbar"></view> <view class="hack-tabbar"></view>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import { import {
mapMutations, mapMutations,
mapActions, mapActions,
mapState, mapState,
mapGetters mapGetters
} from 'vuex'; } from 'vuex';
export default { export default {
components: {}, components: {},
data() { data() {
return { return {
listId: 0, listId: 0,
categoryData: {} categoryData: {}
}; };
}, },
computed: {}, computed: {},
props: { props: {
categoryStyleId: { categoryStyleId: {
type: Number, type: Number,
default: 0 default: 0
}, },
oldCategoryType: { oldCategoryType: {
type: Number, type: Number,
default: 0 default: 0
}, },
categoryIndex: { categoryIndex: {
type: Number, type: Number,
default: -1 default: -1
} }
}, },
created() { created() {
this.getCategory(); this.getCategory();
}, },
methods: { methods: {
getCategory() { getCategory() {
this.$http('category.detail', { this.$http('category.detail', {
id: this.categoryStyleId id: this.categoryStyleId
}).then(res => { }).then(res => {
if (res.code === 1) { if (res.code === 1) {
this.categoryData = res.data.children; this.categoryData = res.data.children;
this.listId = this.categoryIndex < 0 ? 0 : this.categoryIndex; this.listId = this.categoryIndex < 0 ? 0 : this.categoryIndex;
// 如果oldCategoryType = 3并且分类下没有子分类则显示商品
if (this.oldCategoryType == 3 && !this.categoryData[this.listId].children.length) { if (this.oldCategoryType == 3 && !this.categoryData[this.listId].children.length) {
this.handleCategoryChange(2, this.listId); this.handleCategoryChange(2, this.listId);
} }
} }
}); });
}, },
onType(id) { onType(id) {
this.listId = id; this.listId = id;
// 如果oldCategoryType = 3并且点击的分类下没有子分类则显示商品
if (this.oldCategoryType == 3 && !this.categoryData[id].children.length) { if (this.oldCategoryType == 3 && !this.categoryData[id].children.length) {
this.handleCategoryChange(2, id); this.handleCategoryChange(2, id);
} }
}, },
// 分类类型切换
handleCategoryChange(categoryType, categoryIndex) { handleCategoryChange(categoryType, categoryIndex) {
this.$emit('categoryChange', { this.$emit('categoryChange', {
type: categoryType, type: categoryType,
index: categoryIndex index: categoryIndex
}); });
}, },
// 路由跳转
jump(path, parmas) { jump(path, parmas) {
this.$Router.push({ this.$Router.push({
path: path, path: path,
query: parmas query: parmas
}); });
} }
} }
}; };
</script> </script>
<style lang="scss"> <style lang="scss">
.hack-tabbar { .hack-tabbar {
height: calc(100rpx + env(safe-area-inset-bottom) / 2); height: calc(100rpx + env(safe-area-inset-bottom) / 2);
width: 100%; width: 100%;
} }
.content_box { .content_box {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
overflow: hidden; overflow: hidden;
height: 100%; height: 100%;
} }
.wrapper-box { .wrapper-box {
flex: 1; flex: 1;
margin-top: 1upx; margin-top: 1upx;
height: 100%; height: 100%;
} }
.scroll-box { .scroll-box {
height: 100%; height: 100%;
flex: 1; flex: 1;
background: #fff; background: #fff;
} }
.left-scroll-box {
flex: none;
width: 220rpx;
}
.left { .left {
width: 200upx;
width: 220rpx;
height: 100%; height: 100%;
flex: 1;
.list-active { .list-active {
background: #fff; background: #fff;
color: #ffff !important;
} }
.list-item { .list-item {
width: 180rpx;
height: 64rpx; width: 200rpx;
line-height: 64rpx;
padding-left: 14rpx; min-height: 64rpx;
padding: 12rpx 14rpx;
box-sizing: border-box;
display: flex;
align-items: center;
font-size: 28upx;
font-weight: 400;
color: rgba(102, 102, 102, 1);
} }
.line-active { .line-active {
width: 180rpx;
height: 64rpx;
background: #4C7AF3; background: #4C7AF3;
border-radius: 0rpx 32rpx 32rpx 0rpx; border-radius: 0rpx 32rpx 32rpx 0rpx;
color: #fff; color: #fff;
.type-name {
color: #fff;
}
} }
.type-list { .type-list {
height: 100rpx;
min-height: 100rpx;
position: relative; position: relative;
width: 200rpx;
font-size: 28upx; width: 220rpx;
font-weight: 400;
color: rgba(102, 102, 102, 1); padding: 8rpx 0;
box-sizing: border-box;
} }
.type-name {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
word-break: break-all;
white-space: normal;
line-height: 1.4;
width: 100%;
}
} }
.right { .right {
padding: 0 30upx; padding: 0 30upx;
flex: 1; flex: 1;
height: 100%; height: 100%;
.type-img { .type-img {
width: 505rpx; width: 505rpx;
height: 150rpx; height: 150rpx;
background: #ccc; background: #ccc;
margin-top: 30rpx; margin-top: 30rpx;
border-radius: 10rpx; border-radius: 10rpx;
} }
.type-box { .type-box {
height: 84rpx; height: 84rpx;
.type-title { .type-title {
font-size: 28rpx; font-size: 28rpx;
font-weight: bold; font-weight: bold;
padding: 0 16rpx; padding: 0 16rpx;
} }
.more {
font-size: 26rpx;
color: #999;
}
} }
.item-list { .item-list {
.item-box { .item-box {
flex-wrap: wrap; flex-wrap: wrap;
width: 100%;
align-items: flex-start;
.goods-item { .goods-item {
width: calc((100% - 40rpx) / 3);
margin-right: 20rpx; margin-right: 20rpx;
margin-bottom: 20rpx; margin-bottom: 20rpx;
box-sizing: border-box;
&:nth-child(3n) { &:nth-child(3n) {
margin-right: 0; margin-right: 0;
} }
.item-img {
width: 150rpx;
height: 150rpx; .item-img-wrap {
width: 100%;
height: 0;
padding-bottom: 100%;
position: relative;
border-radius: 6rpx; border-radius: 6rpx;
overflow: hidden;
background: #f5f5f5; background: #f5f5f5;
} }
.item-title { .item-img {
font-size: 24rpx; position: absolute;
margin-top: 10rpx; top: 0;
width: 150rpx; left: 0;
text-align: center; width: 100%;
height: 100%;
} }
.item-title {
font-size: 24rpx;
margin-top: 10rpx;
width: 100%;
text-align: center;
}
} }
} }
} }
} }
</style>
</style>

查看文件

@@ -257,12 +257,9 @@
sku_price_id: sku.id, sku_price_id: sku.id,
goods_price: sku.price goods_price: sku.price
}]; }];
this.$Router.push({ this.$tools.toOrderConfirm({
path: '/pages/order/confirm', goodsList: confirmGoodsList,
query: { from: 'goods'
goodsList: confirmGoodsList,
from: 'goods'
}
}); });
}, },

查看文件

@@ -118,7 +118,7 @@ export default {
flex: 4; flex: 4;
} }
.all-order { .all-order {
position: relative;
.cut-off--line { .cut-off--line {
position: absolute; position: absolute;
top: 50%; top: 50%;
@@ -126,6 +126,7 @@ export default {
right: calc(750rpx/5) - 15rpx; right: calc(750rpx/5) - 15rpx;
width: 30rpx; width: 30rpx;
height: 136rpx; height: 136rpx;
display: none;
} }
} }

查看文件

@@ -19,7 +19,7 @@
<view class="u-flex"> <view class="u-flex">
<!-- 个人信息 --> <!-- 个人信息 -->
<view class="info-box"> <view class="info-box">
<view class="u-flex" @tap="$Router.push('/pages/user/info')"> <view class="u-flex" @tap="onUserHeadTap">
<view class="head-img-wrap"> <view class="head-img-wrap">
<image class="head-img" :src="userInfo.avatar || $IMG_URL + '/imgs/base_avatar.png'" <image class="head-img" :src="userInfo.avatar || $IMG_URL + '/imgs/base_avatar.png'"
mode="aspectFill"></image> mode="aspectFill"></image>
@@ -176,6 +176,13 @@
// 绑定手机号 // 绑定手机号
bindMobile() { bindMobile() {
this.showAuthModal('bindMobile'); this.showAuthModal('bindMobile');
},
onUserHeadTap() {
if (!this.isLogin) {
this.showAuthModal('smsLogin');
return;
}
this.$Router.push('/pages/user/info');
} }
} }
}; };

查看文件

@@ -24,10 +24,14 @@
</view> </view>
</view> </view>
<view class="pre-tip-box u-p-20" v-if="preTip">
<text class="pre-tip-text">{{ preTip }}</text>
</view>
<view class="u-m-b-10"> <view class="u-m-b-10">
<!-- 确认订单商品卡片 --> <!-- 确认订单商品卡片 -->
<view class="goods-list" v-for="g in perGoodsList" :key="g.sku_price_id"> <view class="goods-list" v-for="g in perGoodsList" :key="g.sku_price_id">
<view class="goods-card u-p-30"> <view class="goods-card u-p-30" v-if="g.detail">
<shopro-mini-card :title="g.detail.title" :image="g.detail.image"> <shopro-mini-card :title="g.detail.title" :image="g.detail.image">
<template #describe> <template #describe>
<view class="order-sku u-ellipsis-1"> <view class="order-sku u-ellipsis-1">
@@ -379,7 +383,9 @@
<view class="checkTime-content content_box u-flex"> <view class="checkTime-content content_box u-flex">
<view class="checkTime-content__left"> <view class="checkTime-content__left">
<view class="left-item u-flex u-row-center u-col-center" @tap="check('day', index)" <view class="left-item u-flex u-row-center u-col-center" @tap="check('day', index)"
:class="{ 'item--active': checkDayCur == index }" v-for="(day, index) in checkTime.day" :class="{ 'item--active': checkDayCur == index }"
v-for="(day, index) in checkTime.day"
v-if="isDayAvailableForExpress(index, timePickerExpressType)"
:key="day.value"> :key="day.value">
{{ day.title }} {{ day.title }}
</view> </view>
@@ -387,7 +393,9 @@
<scroll-view class="checkTime-content__right scroll-box" :scroll-into-view="'c' + checkTimeId" <scroll-view class="checkTime-content__right scroll-box" :scroll-into-view="'c' + checkTimeId"
scroll-y scroll-with-animation> scroll-y scroll-with-animation>
<view class="right-item" :id="'c' + time.split(':')[0]" @tap="check('time', index)" <view class="right-item" :id="'c' + time.split(':')[0]" @tap="check('time', index)"
:class="{ 'item--active': checkTimeCur == index }" v-for="(time, index) in checkTime.time" :class="{ 'item--active': checkTimeCur == index }"
v-for="(time, index) in checkTime.time"
v-if="isTimeAvailable(checkDayCur, index, timePickerExpressType)"
:key="time"> :key="time">
{{ time }} {{ time }}
</view> </view>
@@ -419,6 +427,7 @@
dispatchId: 0, dispatchId: 0,
platform: this.$platform.get(), platform: this.$platform.get(),
totalNum: 0, totalNum: 0,
preTip: '',
couponList: [], //优惠券列表 couponList: [], //优惠券列表
addressData: {}, //收货地址 addressData: {}, //收货地址
addressId: 0, //收货地址ID addressId: 0, //收货地址ID
@@ -478,7 +487,7 @@
grouponBuyType: 'alone', grouponBuyType: 'alone',
grouponId: 0, grouponId: 0,
goodsList: [], //传递过来的参数 goodsList: [], //传递过来的参数
perGoodsList: {}, //确认单订单商品 perGoodsList: [], //确认单订单商品
currentGoodsId: 0, //当前商品id. currentGoodsId: 0, //当前商品id.
currentSkuId: 0, //商品的规格ID currentSkuId: 0, //商品的规格ID
remark: '', remark: '',
@@ -492,6 +501,7 @@
selfPhone: '', //编辑手机号 selfPhone: '', //编辑手机号
getFocus: false, //获取焦点。 getFocus: false, //获取焦点。
checkType: '自提', checkType: '自提',
timePickerExpressType: 'selfetch',
checkTimeCur: 0, //默认选中时间。 checkTimeCur: 0, //默认选中时间。
checkTimeId: 'c1', //锚点用 checkTimeId: 'c1', //锚点用
checkDayCur: 0, //默认日期 checkDayCur: 0, //默认日期
@@ -587,11 +597,27 @@
}); });
}, },
async onLoad() { async onLoad() {
this.goodsList = this.$Route.query.goodsList; const storedGoodsList = uni.getStorageSync('order_confirm_goods_list');
if (storedGoodsList) {
this.goodsList = this.$tools.normalizeOrderGoodsList(storedGoodsList);
uni.removeStorageSync('order_confirm_goods_list');
} else {
this.goodsList = this.$tools.normalizeOrderGoodsList(this.$Route.query.goodsList);
}
if (!this.goodsList.length) {
this.$u.toast('未获取到商品信息,请重新选择');
setTimeout(() => {
this.$Router.back();
}, 1500);
return;
}
this.from = this.$Route.query.from; this.from = this.$Route.query.from;
this.orderType = this.$Route.query.orderType; this.orderType = this.$Route.query.orderType;
this.grouponBuyType = this.$Route.query.grouponBuyType; this.grouponBuyType = this.$Route.query.grouponBuyType || 'alone';
this.grouponId = this.$Route.query.grouponId; this.grouponId = Number(this.$Route.query.grouponId || 0);
if (this.grouponId > 0) {
this.grouponBuyType = 'groupon';
}
await this.init(); await this.init();
}, },
methods: { methods: {
@@ -699,16 +725,129 @@
] ]
}; };
this.checkTime = obj; this.checkTime = obj;
this.applyDefaultDispatchTime('selfetch');
},
parseTimeToMinutes(timeStr) {
const parts = (timeStr || '').split(':');
const h = parseInt(parts[0], 10) || 0;
const m = parseInt(parts[1], 10) || 0;
return h * 60 + m;
},
getNowMinutes() {
const now = new Date();
return now.getHours() * 60 + now.getMinutes();
},
isDayAvailableForExpress(dayIndex, expressType) {
if (expressType === 'store') {
return dayIndex >= 1;
}
return true;
},
isTimeAvailable(dayIndex, timeIndex, expressType) {
const times = this.checkTime.time || [];
const timeStr = times[timeIndex];
if (!timeStr) {
return false;
}
const slotMinutes = this.parseTimeToMinutes(timeStr);
if (expressType === 'store') {
if (dayIndex < 1) {
return false;
}
if (dayIndex === 1 && slotMinutes < this.parseTimeToMinutes('10:00')) {
return false;
}
return true;
}
if (expressType === 'selfetch' && dayIndex === 0) {
return slotMinutes > this.getNowMinutes();
}
return true;
},
getAvailableTimeIndices(dayIndex, expressType) {
const indices = [];
const times = this.checkTime.time || [];
for (let i = 0; i < times.length; i++) {
if (this.isTimeAvailable(dayIndex, i, expressType)) {
indices.push(i);
}
}
return indices;
},
syncCheckTimeId() {
const time = (this.checkTime.time || [])[this.checkTimeCur];
if (time) {
this.checkTimeId = time.split(':')[0];
}
},
applyDefaultDispatchTime(expressType) {
if (!this.checkTime.day || !this.checkTime.time) {
return;
}
if (expressType !== 'selfetch' && expressType !== 'store') {
return;
}
let dayCur = expressType === 'store' ? 1 : 0;
let timeIndices = this.getAvailableTimeIndices(dayCur, expressType);
if (!timeIndices.length && expressType === 'selfetch') {
dayCur = 1;
timeIndices = this.getAvailableTimeIndices(dayCur, 'selfetch');
}
if (!timeIndices.length && expressType === 'store') {
for (let d = 2; d < this.checkTime.day.length; d++) {
const idx = this.getAvailableTimeIndices(d, 'store');
if (idx.length) {
dayCur = d;
timeIndices = idx;
break;
}
}
}
this.checkDayCur = dayCur;
this.checkTimeCur = timeIndices.length ? timeIndices[0] : 0;
this.syncCheckTimeId();
},
normalizeDispatchTimeSelection(expressType) {
if (!this.checkTime.day || !this.checkTime.time) {
return;
}
expressType = expressType || this.expressTypeCur;
if (expressType !== 'selfetch' && expressType !== 'store') {
return;
}
if (!this.isDayAvailableForExpress(this.checkDayCur, expressType)) {
this.applyDefaultDispatchTime(expressType);
return;
}
if (!this.isTimeAvailable(this.checkDayCur, this.checkTimeCur, expressType)) {
const indices = this.getAvailableTimeIndices(this.checkDayCur, expressType);
if (indices.length) {
this.checkTimeCur = indices[0];
} else {
this.applyDefaultDispatchTime(expressType);
}
}
this.syncCheckTimeId();
}, },
// 格式日期 // 格式日期
check(type, index) { check(type, index) {
const expressType = this.timePickerExpressType || this.expressTypeCur;
if (type == 'time') { if (type == 'time') {
if (!this.isTimeAvailable(this.checkDayCur, index, expressType)) {
this.$u.toast('所选时间不可用');
return;
}
this.checkTimeCur = index; this.checkTimeCur = index;
this.checkTimeId = this.checkTime['time'][index].split(':')[[0]]; this.checkTimeId = this.checkTime['time'][index].split(':')[[0]];
} }
if (type == 'day') { if (type == 'day') {
if (!this.isDayAvailableForExpress(index, expressType)) {
return;
}
this.checkDayCur = index; this.checkDayCur = index;
this.normalizeDispatchTimeSelection(expressType);
} }
}, },
@@ -763,6 +902,37 @@
} }
}); });
}, },
applyPreResult(res) {
const payload = res && res.data ? res.data : null;
if (!payload) {
return false;
}
this.orderPre = payload;
this.perGoodsList = this.$tools.normalizePreGoodsList(payload.new_goods_list);
this.expressList = this.orderPre.expressList || [];
const tip = res.msg || payload.msg || '';
this.preTip = tip && tip !== '计算成功' ? tip : '';
this.totalNum = 0;
this.perGoodsList.forEach(item => {
item.selType = item.dispatch_type;
this.totalNum += Number(item.goods_num) || 0;
this.goodsList.forEach(goods => {
if (item.goods_id == goods.goods_id && item.sku_price_id == goods.sku_price_id) {
goods.dispatch_type = item.dispatch_type;
if (item.store_id) {
goods.store_id = item.store_id;
}
if (item.expressList && item.expressList.length) {
const express = item.expressList.find(v => v.active === 1);
if (express) {
goods.dispatch_id = express.id;
}
}
}
});
});
return this.perGoodsList.length > 0;
},
// 订单信息 // 订单信息
getPre() { getPre() {
let that = this; let that = this;
@@ -775,32 +945,13 @@
buy_type: that.grouponBuyType, buy_type: that.grouponBuyType,
groupon_id: that.grouponId, groupon_id: that.grouponId,
dispatch_id: that.dispatchId dispatch_id: that.dispatchId
}).then(res => { }, '', false).then(res => {
if (res.data) { const ok = that.applyPreResult(res);
that.orderPre = res.data; if (!ok) {
that.perGoodsList = res.data.new_goods_list; that.preTip = (res && res.msg) ? res.msg : '订单信息加载失败,请返回重试';
that.expressList = that.orderPre.expressList; if (res && res.code === 0 && res.msg) {
that.totalNum = 0; that.$u.toast(res.msg);
that.perGoodsList.map(item => { }
item.selType = item.dispatch_type;
that.totalNum += item.goods_num;
that.goodsList.forEach(goods => {
if (item.goods_id == goods.goods_id && item.sku_price_id == goods
.sku_price_id) {
goods.dispatch_type = item.dispatch_type;
if (item.store_id) {
goods.store_id = item.store_id;
}
// 处理多商品所选快递信息
if (item.expressList.length) {
let express = item.expressList.find(v => v.active === 1);
goods.dispatch_id = express.id;
}
}
});
});
} }
}); });
}, },
@@ -888,8 +1039,14 @@
this.expressTypeCur = item.dispatch_type; this.expressTypeCur = item.dispatch_type;
this.selfPhone = item.dispatch_phone ? item.dispatch_phone : this.addressData && this this.selfPhone = item.dispatch_phone ? item.dispatch_phone : this.addressData && this
.addressData.phone; .addressData.phone;
this.checkDayCur = item.checkDayCur ? item.checkDayCur : 0; if (item.checkDayCur !== undefined && item.checkDayCur !== null && item.checkTimeCur !==
this.checkTimeCur = item.checkTimeCur ? item.checkTimeCur : 0; undefined && item.checkTimeCur !== null) {
this.checkDayCur = item.checkDayCur;
this.checkTimeCur = item.checkTimeCur;
this.normalizeDispatchTimeSelection(this.expressTypeCur);
} else {
this.applyDefaultDispatchTime(this.expressTypeCur);
}
if (this.expressTypeCur == 'selfetch') { if (this.expressTypeCur == 'selfetch') {
!this.lat && this.getLocation(); !this.lat && this.getLocation();
this.storeList.forEach(store => { this.storeList.forEach(store => {
@@ -921,6 +1078,7 @@
} }
} }
this.normalizeDispatchTimeSelection(this.expressTypeCur);
this.showExpressType = false; this.showExpressType = false;
this.changeGoodsList(); this.changeGoodsList();
this.getPre(); this.getPre();
@@ -928,6 +1086,9 @@
// 更改提交数据 // 更改提交数据
changeGoodsList() { changeGoodsList() {
if (this.expressTypeCur === 'selfetch' || this.expressTypeCur === 'store') {
this.normalizeDispatchTimeSelection(this.expressTypeCur);
}
this.goodsList.forEach(goods => { this.goodsList.forEach(goods => {
if (goods.goods_id == this.currentGoodsId && this.currentSkuId == goods.sku_price_id) { if (goods.goods_id == this.currentGoodsId && this.currentSkuId == goods.sku_price_id) {
goods.dispatch_type = this.expressTypeCur; goods.dispatch_type = this.expressTypeCur;
@@ -951,6 +1112,7 @@
changeExpressType(cur) { changeExpressType(cur) {
this.expressTypeCur = cur; this.expressTypeCur = cur;
this.getFocus = false; this.getFocus = false;
this.applyDefaultDispatchTime(cur);
cur === 'selfetch' && !this.lat && this.getLocation(); cur === 'selfetch' && !this.lat && this.getLocation();
}, },
@@ -970,6 +1132,8 @@
default: default:
this.checkType = '自提'; this.checkType = '自提';
} }
this.timePickerExpressType = type;
this.normalizeDispatchTimeSelection(type);
this.showCheckTime = !this.showCheckTime; this.showCheckTime = !this.showCheckTime;
} }
} }
@@ -977,6 +1141,17 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.pre-tip-box {
background: #fff7e8;
margin: 0 0 10rpx;
}
.pre-tip-text {
font-size: 26rpx;
color: #e6a23c;
line-height: 1.5;
}
// 发票弹窗 // 发票弹窗
.invoice-modal { .invoice-modal {
width: 750rpx; width: 750rpx;

查看文件

@@ -399,10 +399,11 @@
// 是否为待提货的自提订单 // 是否为待提货的自提订单
isSelfetchOrderDetail(orderDetail) { isSelfetchOrderDetail(orderDetail) {
if (!orderDetail || !orderDetail.item || !orderDetail.item.length) return false; if (!orderDetail || !orderDetail.item || !orderDetail.item.length) return false;
if (orderDetail.status >= 1 && orderDetail.item.some(item => item.dispatch_type === 'selfetch')) { const selfetchItem = orderDetail.item.find(item => item.dispatch_type === 'selfetch');
return true; if (!selfetchItem) return false;
} return orderDetail.status >= 1
return false; && selfetchItem.dispatch_status === 1
&& selfetchItem.refund_status <= 0;
}, },
// 详情页出示核销码 // 详情页出示核销码

查看文件

@@ -22,22 +22,25 @@
</view> </view>
<!-- 到店自提 --> <!-- 到店自提 -->
<view class="u-flex-col u-col-center u-m-b-20 u-p-y-20" v-if="expressType == 'selfetch' && itemDetail.status_code !== 'refund_finish' && qrcodeList.length"> <view class="u-flex-col u-col-center u-m-b-20 u-p-y-20" v-if="expressType == 'selfetch' && itemDetail.status_code !== 'refund_finish' && usableVerifyList.length">
<image class="qr-code--img u-m-y-20" :src="allqrcodepath" mode=""></image> <image class="qr-code--img u-m-y-20" :src="allqrcodepath" mode=""></image>
<view class="all-qrcode-title u-m-b-20">总核销码</view> <view class="all-qrcode-title u-m-b-20">总核销码</view>
<view class="detail-item"> <view class="detail-item">
<view class="item-title u-flex">核销码</view> <view class="item-title u-flex">核销码</view>
<view class="u-flex u-row-between u-m-y-20" v-for="code in qrcodeList" :key="code.code"> <view class="u-flex u-row-between u-m-y-20" v-for="code in usableVerifyList" :key="code.code">
<view> <view>
<text :style="code.status_code !== 'nouse' ? 'color:#999' : ''" class="item-content">{{ code.code }}</text> <text class="item-content">{{ code.code }}</text>
<text :style="code.status_code !== 'nouse' ? 'color:#999' : ''" class="item-status u-m-x-30">{{ code.status_name }}</text> <text class="item-status u-m-x-30">{{ code.status_name }}</text>
</view> </view>
<button class="u-reset-button check-code" v-if="code.status_code == 'nouse'" @tap="checkCode(code.code)">查看</button> <button class="u-reset-button check-code" @tap="checkCode(code.code)">查看</button>
</view> </view>
<view class="item-tip">为保障您的权益,未到店消费前请不要将提货码提供给商家</view> <view class="item-tip">为保障您的权益,未到店消费前请不要将该核销码展示给商家</view>
</view> </view>
</view> </view>
<view class="verify-empty-tip u-p-20" v-else-if="expressType == 'selfetch' && itemDetail.status_code !== 'refund_finish' && verifyEmptyTip">
{{ verifyEmptyTip }}
</view>
</view> </view>
<!-- 自提 --> <!-- 自提 -->
@@ -126,7 +129,31 @@ export default {
showQrcode: false //二维码弹窗 showQrcode: false //二维码弹窗
}; };
}, },
computed: {}, computed: {
usableVerifyList() {
return (this.qrcodeList || []).filter((code) => code.status_code === 'nouse');
},
verifyEmptyTip() {
if (this.expressType !== 'selfetch') {
return '';
}
if (this.itemDetail.dispatch_status === 0) {
return '商家正在处理订单,核销码将在备货完成后发放,请稍后再试';
}
if (!this.qrcodeList.length) {
return '暂无可用核销码,请联系商家处理';
}
const hasUsed = this.qrcodeList.some((code) => code.status_code === 'used');
const hasExpire = this.qrcodeList.some((code) => code.status_code === 'expire');
if (hasUsed && !hasExpire) {
return '订单已核销完成';
}
if (hasExpire) {
return '核销码已过期,请联系商家重新处理订单';
}
return '暂无可用核销码,请联系商家处理';
}
},
onLoad() { onLoad() {
this.expressType = this.$Route.query.expressType; this.expressType = this.$Route.query.expressType;
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
@@ -163,6 +190,11 @@ export default {
}, },
// 查看核销码 // 查看核销码
checkCode(code) { checkCode(code) {
const target = (this.qrcodeList || []).find((item) => item.code === code);
if (!target || target.status_code !== 'nouse') {
this.$u.toast('该核销码已失效');
return;
}
this.qrcode = code; this.qrcode = code;
this.shareFc('qrcode').then(res => { this.shareFc('qrcode').then(res => {
this.showQrcode = true; this.showQrcode = true;
@@ -185,13 +217,12 @@ export default {
that.autosendList = JSON.parse(res.data.ext_arr.autosend_content); that.autosendList = JSON.parse(res.data.ext_arr.autosend_content);
} }
if (that.expressType == 'selfetch') { if (that.expressType == 'selfetch') {
let _arr = []; const usableList = (that.qrcodeList || []).filter((code) => code.status_code === 'nouse');
that.qrcodeList.forEach(code => { that.qrcode = usableList.map((code) => code.code).join(',');
_arr.push(code.code); if (usableList.length) {
});
that.qrcode = _arr.join(',');
if (that.qrcodeList.length) {
that.shareFc(); that.shareFc();
} else {
that.allqrcodepath = '';
} }
} }
} }
@@ -287,6 +318,15 @@ export default {
.content_box { .content_box {
padding: 20rpx; padding: 20rpx;
} }
.verify-empty-tip {
background: #fff;
border-radius: 20rpx;
font-size: 28rpx;
color: #999;
line-height: 44rpx;
text-align: center;
margin-bottom: 20rpx;
}
.no-radius { .no-radius {
border-radius: 0 !important; border-radius: 0 !important;
} }

查看文件

@@ -148,11 +148,12 @@
// 是否需要显示“出示核销码”按钮 // 是否需要显示“出示核销码”按钮
isSelfetchOrder(order) { isSelfetchOrder(order) {
if (!order.item || !order.item.length) return false; if (!order.item || !order.item.length) return false;
// 已支付且包含自提商品 const selfetchItem = order.item.find(item => item.dispatch_type === 'selfetch');
if (order.status >= 1 && order.item.some(item => item.dispatch_type === 'selfetch')) { if (!selfetchItem) return false;
return true; // 已支付、待核销的自提订单
} return order.status >= 1
return false; && selfetchItem.dispatch_status === 1
&& selfetchItem.refund_status <= 0;
}, },
// 出示核销码 // 出示核销码
goSelfetchCode(order) { goSelfetchCode(order) {

查看文件

@@ -213,7 +213,7 @@
...mapGetters(['userInfo', 'initRecharge']), ...mapGetters(['userInfo', 'initRecharge']),
ruleDisplay() { ruleDisplay() {
const r = this.ruleInfo || {}; const r = this.ruleInfo || {};
const min = r.min != null && r.min !== '' && Number(r.min) > 0 ? r.min : 1; const min = r.min != null && r.min !== '' && Number(r.min) > 0 ? r.min : 0;
const max = r.max != null && r.max !== '' && Number(r.max) > 0 ? r.max : '不限'; const max = r.max != null && r.max !== '' && Number(r.max) > 0 ? r.max : '不限';
const withdrawTime = r.withdraw_time || r.withdraw_time_text || const withdrawTime = r.withdraw_time || r.withdraw_time_text ||
(r.withdraw_start && r.withdraw_end ? `${r.withdraw_start} 至 ${r.withdraw_end}` : '') || (r.withdraw_start && r.withdraw_end ? `${r.withdraw_start} 至 ${r.withdraw_end}` : '') ||

查看文件

@@ -11,6 +11,55 @@ export default {
* @param {String} path - 跳转路径 * @param {String} path - 跳转路径
* @param {isTabbar} isTabbar - 是否是底部导航 * @param {isTabbar} isTabbar - 是否是底部导航
*/ */
/** 规范化确认订单商品列表(路由 query / 本地缓存) */
normalizePreGoodsList(raw) {
const list = this.normalizeOrderGoodsList(raw);
if (list.length) {
return list;
}
if (raw && typeof raw === 'object' && !Array.isArray(raw)) {
return Object.keys(raw)
.sort((a, b) => Number(a) - Number(b))
.map(k => raw[k])
.filter(Boolean);
}
return [];
},
normalizeOrderGoodsList(raw) {
if (!raw) {
return [];
}
if (typeof raw === 'string') {
try {
raw = JSON.parse(raw);
} catch (e) {
return [];
}
}
if (Array.isArray(raw)) {
return raw.filter(Boolean);
}
if (typeof raw === 'object') {
return [raw];
}
return [];
},
/**
* 跳转确认订单页(同时写入本地缓存,避免小程序路由丢失复杂参数)
*/
toOrderConfirm(query = {}) {
const goodsList = this.normalizeOrderGoodsList(query.goodsList);
if (goodsList.length) {
uni.setStorageSync('order_confirm_goods_list', goodsList);
}
router.push({
path: '/pages/order/confirm',
query: {
...query,
goodsList
}
});
},
routerTo(path, isTabbar) { routerTo(path, isTabbar) {
if (path) { if (path) {
// 是否跳转外部链接 // 是否跳转外部链接
@@ -38,19 +87,78 @@ export default {
console.log(`%cerr:没有填写跳转路径`, 'color:green;background:yellow'); console.log(`%cerr:没有填写跳转路径`, 'color:green;background:yellow');
} }
}, },
formatImageUrl(url = '') {
if (!url) {
return '';
}
if (/^(https?:)?\/\//.test(url) || url.indexOf('data:') === 0) {
return url.indexOf('//') === 0 ? `https:${url}` : url;
}
const base = IMG_URL || '';
return url.indexOf('/') === 0 ? `${base}${url}` : `${base}/${url}`;
},
/** 底部导航图标:本地 static 不拼域名,其余走 CDN */
formatTabIconUrl(url = '') {
if (!url || typeof url !== 'string') {
return '';
}
const value = url.trim();
if (!value) {
return '';
}
if (/^(https?:)?\/\//.test(value) || value.indexOf('data:') === 0) {
return value.indexOf('//') === 0 ? `https:${value}` : value;
}
if (/^\/?static\//.test(value)) {
return value.charAt(0) === '/' ? value : `/${value}`;
}
return this.formatImageUrl(value);
},
/** 隐藏微信原生 tabBar(使用自定义底部导航时) */
hideNativeTabBar() {
// #ifdef MP-WEIXIN
uni.hideTabBar({
animation: false,
fail: () => {}
});
// #endif
},
/** /**
* 图片处理-预览图片 * 图片处理-预览图片
* @param {Array} urls - 图片列表 * @param {Array} urls - 图片列表
* @param {Number} current - 首个预览下标 * @param {Number|String} current - 预览下标或当前图片链接
*/ */
previewImage(urls = [], current = 0) { previewImage(urls = [], current = 0) {
const previewUrls = (urls || [])
.map((item) => {
if (typeof item === 'string') {
return this.formatImageUrl(item);
}
if (item && item.src) {
return this.formatImageUrl(item.src);
}
return '';
})
.filter(Boolean);
if (!previewUrls.length) {
return;
}
let currentUrl = previewUrls[0];
if (typeof current === 'number') {
currentUrl = previewUrls[current] || previewUrls[0];
} else if (typeof current === 'string') {
currentUrl = this.formatImageUrl(current);
}
uni.previewImage({ uni.previewImage({
urls: urls, urls: previewUrls,
current: current, current: currentUrl,
indicator: 'default', indicator: 'default',
loop: true, loop: true,
fail(err) { fail(err) {
console.log('previewImage出错', urls, err) console.log('previewImage出错', previewUrls, err)
}, },
}) })
}, },