From a9d507a13f5eff939b9dfb2242a204d445460d42 Mon Sep 17 00:00:00 2001 From: xuxueyang <xuxy@fengyuntec.com> Date: 星期二, 06 八月 2024 18:26:25 +0800 Subject: [PATCH] update 跳转的逻辑栈 --- pages/login/supplier-login.vue | 6 sub_pages/customer/trade/list.vue | 44 +++++--- components/footer/customer-footer.vue | 13 ++ components/footer/managefooter.vue | 2 components/footer/supplier-footer.vue | 2 manifest.json | 2 pages/login/supplier-reg.vue | 2 sub_pages/customer/shop/shop.vue | 111 +++++++++++++++++++-- sub_pages/customer/trade/trade.vue | 3 store/index.js | 8 - sub_pages/customer/trade/detail.vue | 62 +++++++++++- 11 files changed, 206 insertions(+), 49 deletions(-) diff --git a/components/footer/customer-footer.vue b/components/footer/customer-footer.vue index 3cc049b..0627f98 100644 --- a/components/footer/customer-footer.vue +++ b/components/footer/customer-footer.vue @@ -93,12 +93,23 @@ } } + //判断,如果上上上级别,就是要跳转的,改为返回,避免堆栈太多 + const pages = getCurrentPages(); + //如果上一层就是购物车,那么就返回,而不是跳转 + // console.log('toShopping',pages) + if (pages && pages.length >= 2) { + if ( ('/' + pages[pages.length - 2].route) === item.pagePath) { + uni.navigateBack() + return + } + } + uni.navigateTo({ url: item.pagePath }) } else { - uni.redirectTo({ + uni.reLaunch({ url: item.pagePath }); diff --git a/components/footer/managefooter.vue b/components/footer/managefooter.vue index 3767afe..cff3253 100644 --- a/components/footer/managefooter.vue +++ b/components/footer/managefooter.vue @@ -60,7 +60,7 @@ }, methods: { go(item){ - uni.redirectTo({ url: item.pagePath }) + uni.reLaunch({ url: item.pagePath }) // uni.switchTab({ url: item.pagePath }) } } diff --git a/components/footer/supplier-footer.vue b/components/footer/supplier-footer.vue index ebae554..2f6d329 100644 --- a/components/footer/supplier-footer.vue +++ b/components/footer/supplier-footer.vue @@ -68,7 +68,7 @@ if (this.flg == ('' + index)) { return } - uni.redirectTo({ + uni.reLaunch({ url: item.pagePath }); diff --git a/manifest.json b/manifest.json index 782394c..2848179 100644 --- a/manifest.json +++ b/manifest.json @@ -49,7 +49,7 @@ "quickapp" : {}, /* 快应用特有相关 */ "mp-weixin" : { - "appid" : "wx6d0ecc4e18710458", + "appid" : "wx1441324401626290", "setting" : { "urlCheck" : false, "es6" : true, diff --git a/pages/login/supplier-login.vue b/pages/login/supplier-login.vue index d1d069f..dcb669d 100644 --- a/pages/login/supplier-login.vue +++ b/pages/login/supplier-login.vue @@ -423,7 +423,7 @@ }, 1000) }, toHome() { - uni.redirectTo({ + uni.reLaunch({ url: '/pages/home/home' }) }, @@ -439,7 +439,7 @@ }) // #endif // #ifdef PUB_SUPPLIER - uni.redirectTo({ + uni.reLaunch({ url: '/pages/login/supplier-reg' }) // #endif @@ -448,7 +448,7 @@ // uni.navigateTo({ // url: '/sub_pages/customer/customer-info/customer-info' + addstr // }) - uni.redirectTo({ + uni.reLaunch({ url: '/pages/login/supplier-reg' }) // todo 如果是有分享id的,可能需要提前进行绑定 diff --git a/pages/login/supplier-reg.vue b/pages/login/supplier-reg.vue index fdcce4a..e8d03b4 100644 --- a/pages/login/supplier-reg.vue +++ b/pages/login/supplier-reg.vue @@ -288,7 +288,7 @@ }, 1000) }, toLogin() { - uni.redirectTo({ + uni.reLaunch({ url: '/pages/login/supplier-login' }) diff --git a/store/index.js b/store/index.js index 7d00f52..9346fa3 100644 --- a/store/index.js +++ b/store/index.js @@ -55,9 +55,7 @@ state.currentInfo = {} storage.removeItem('token') message.showToast('退出登录成功') - // uni.redirectTo({ - // url: '/views/login/login' - // }) + }, setOpenid(state, openid) { state.openid = openid @@ -354,9 +352,7 @@ console.log("启用结果2:", ret); }); // #endif - // uni.redirectTo({ - // url: '/views/app/app-home/app-home' - // }) + uni.reLaunch({ url: '/pages/home/supplier-home' }) diff --git a/sub_pages/customer/shop/shop.vue b/sub_pages/customer/shop/shop.vue index 2318028..a3e0675 100644 --- a/sub_pages/customer/shop/shop.vue +++ b/sub_pages/customer/shop/shop.vue @@ -38,7 +38,7 @@ </view> <view class="tj-info m-t-12"> <view class="form-item"> - <view class="value">0</view> + <view class="value">{{page.total || 0}}</view> <view class="label">发布</view> </view> <view class="form-item"> @@ -63,20 +63,16 @@ <view class="brand-info"> <view v-if="flg==='0'" class="brand-info-0"> <view class="component-filter-container" style="padding-top: 12rpx;"> - <!-- <view class="flex1"> - 排序 + <view class="flex1" @click.stop="$refs.popup_column.open()"> + 排序{{ query.columnStr&&('-'+query.columnStr) || '' }} <image src="../../../static/common/icon-arrow-down.png" class="icon-arrow-down"></image> </view> - <view class="flex1"> - 等级 + <view class="flex1" @click.stop="$refs.popup_level.open()"> + {{ query.levelStr || '级别' }} <image src="../../../static/common/icon-arrow-down.png" class="icon-arrow-down"></image> </view> - <view class="flex1"> - 参数 - <image src="../../../static/common/icon-arrow-down.png" class="icon-arrow-down"></image> - </view> --> </view> - <view class="top-title"> + <view class="top-title m-t-12"> 报价已包含打包费、材料费、交易佣金 </view> <view class="component-shop-item flex" v-for="(item,index) of list" :key="index" @@ -112,7 +108,7 @@ </view> <view class="bottom-buttons flex"> <view class="m-l-0 m-r-a"> - <view class="m-r-15"> + <view class="m-r-15 desc-gray other-info"> 颜色:{{item.color||'-'}} </view> </view> @@ -163,8 +159,55 @@ </view> --> </view> </view> + <uni-popup ref="popup_column" type="bottom"> + <view class="component-popup_input_all"> + <view class="text-center m-b-40" style="font-size: 48rpx;font-weight: 600;">点击选择不同排序</view> + <view v-for="(item,i) in order_columns" :key="i" class="m-t-20"> + <view class="m-t-12 flex value-items"> + <view class="value-item" @click="()=>{ + if(each.value!==query.value){ + query.column = each.value + query.columnStr = each.label + refreshList('post') + $refs.popup_column.close() + } + }" :class="[query.column==each.value?'cur':'']" v-for="(each, j) in item" :key="j"> + {{ each.label || '-' }} + </view> + </view> + </view> + <view class="button-space"></view> + <view> + <view class="button-green" @click="$refs.popup_column.close()">关闭 + </view> + </view> + </view> + </uni-popup> - + <uni-popup ref="popup_level" type="bottom"> + <view class="component-popup_input_all"> + <view class="text-center m-b-40" style="font-size: 48rpx;font-weight: 600;">点击选择不同级别</view> + <view v-for="(item,i) in level_columns" :key="i" class="m-t-20"> + <view class="m-t-12 flex value-items"> + <view class="value-item" @click="()=>{ + if(each.value!==query.value){ + query.level = each.value + query.levelStr = each.label + refreshList('post') + $refs.popup_level.close() + } + }" :class="[query.level==each.value?'cur':'']" v-for="(each, j) in item" :key="j"> + {{ each.label || '-' }} + </view> + </view> + </view> + <view class="button-space"></view> + <view> + <view class="button-green" @click="$refs.popup_level.close()">关闭 + </view> + </view> + </view> + </uni-popup> </view> </template> @@ -197,6 +240,21 @@ list: [], id: '', catgoryTree: undefined, + query: { + columnStr: '', + column: '', + levelStr: '', + level: '', + }, + level_show: false, + level_columns: [ + [] + ], + + order_show: false, + order_columns: [ + [] + ] } }, onLoad(options) { @@ -208,6 +266,30 @@ this.listApi = `/api/customer/flower/list` this.query.supplierId = this.id this.getList('post') + this.$http.request('get', '/api/code/value', { + params: { + type: 'FLOWER_LEVEL' + } + }).then(res => { + var data = res.data + this.level_columns = [data || []] + this.level_columns[0].unshift({ + label: '全部', + value: '' + }) + }) + this.$http.request('get', '/api/code/value', { + params: { + type: 'FLOWER_ORDER_BY' + } + }).then(res => { + var data = res.data + this.order_columns = [data || []] + this.order_columns[0].unshift({ + label: '默认', + value: '' + }) + }) }, // #ifdef PUB_CUSTOMER onShareAppMessage() { @@ -401,6 +483,11 @@ } }, + toDetail(item) { + uni.navigateTo({ + url: `/sub_pages/customer/trade/detail?id=${item.id}` + }) + }, } } </script> diff --git a/sub_pages/customer/trade/detail.vue b/sub_pages/customer/trade/detail.vue index 25d4601..c050b1c 100644 --- a/sub_pages/customer/trade/detail.vue +++ b/sub_pages/customer/trade/detail.vue @@ -160,7 +160,7 @@ this.id = options.id || '' // #ifdef PUB_CUSTOMER - if (options.partnerUserId) { + if (options.partnerUserId) { let tmp = this tmp.sharePartnerUserId = options.partnerUserId //合伙人绑定的,判断当前用户,是否有登录,登录没绑定,没登录先缓存合伙人id,等注册和登录时候再弄 @@ -398,14 +398,62 @@ }) return } - uni.navigateTo({ - url: '/sub_pages/customer/shopping/shopping' - }) + //判断堆栈,如果是购物车,就直接返回 + const pages = getCurrentPages(); + //如果上一层就是购物车,那么就返回,而不是跳转 + // console.log('toShopping',pages) + if (pages && pages.length >= 2) { + if (pages[pages.length - 2].route === "sub_pages/customer/shopping/shopping") { + uni.navigateBack() + return + } + } + if (pages.length >= 10) { + //直接强制购物车 + uni.reLaunch({ + url: '/sub_pages/customer/shopping/shopping' + }) + } else { + uni.navigateTo({ + url: '/sub_pages/customer/shopping/shopping' + }) + } + }, openbrand() { - uni.navigateTo({ - url: '/sub_pages/customer/shop/shop?id=' + (this.dto.supplierId || '') - }) + //也要判断一下是否重复进入 + //判断堆栈,如果是店铺,就直接返回 + //或者是:从商铺到列表再到详情,再到商铺,这种也不行 + const pages = getCurrentPages(); + console.log('toShopping', pages) + if (pages && pages.length >= 2) { + if (pages[pages.length - 2].route === "sub_pages/customer/shop/shop") { + uni.navigateBack() + return + } + } + if (pages && pages.length >= 3) { + if (pages[pages.length - 3].route === "sub_pages/customer/shop/shop" && + pages[pages.length - 2].route === "sub_pages/customer/trade/list" + ) { + uni.navigateBack({ + delta: 2 + }) + return + } + } + + if (pages.length >= 10) { + //直接强制购物车 + uni.reLaunch({ + url: '/sub_pages/customer/shop/shop?id=' + (this.dto.supplierId || '') + }) + } else { + uni.navigateTo({ + url: '/sub_pages/customer/shop/shop?id=' + (this.dto.supplierId || '') + }) + } + } } } diff --git a/sub_pages/customer/trade/list.vue b/sub_pages/customer/trade/list.vue index 929a99a..6b961df 100644 --- a/sub_pages/customer/trade/list.vue +++ b/sub_pages/customer/trade/list.vue @@ -104,8 +104,7 @@ </view> - <view class="icon-shop" v-if="list&&list.length>0" - @click="goto('/sub_pages/customer/shopping/shopping',true)"> + <view class="icon-shop" v-if="list&&list.length>0" @click="toShopping"> <!-- 购物图标 --> <!-- 如果有购买的东西,就要附带数字了 --> <view v-if="shoptotal>0" class="number"> @@ -213,12 +212,14 @@ name: '', category: '', zoneId: '', + + + params: [], + supplierName: '', + columnStr: '', + column: '', levelStr: '', level: '', - column: '', - params: [], - supplierName:'', - columnStr: '', }, categoryInfo: {}, params: [], @@ -265,19 +266,19 @@ console.log('options', options) this.query.category = options.categoryId || options.category || '' this.query.zoneId = options.zoneId || '' - this.query.name = options.name || '' - this.query.supplierName = options.supplierName || '' - - + this.query.name = options.name || '' + this.query.supplierName = options.supplierName || '' + + if (this.query.name) { uni.setNavigationBarTitle({ title: '商品列表-' + this.query.name }) - } - if (this.query.supplierName) { - uni.setNavigationBarTitle({ - title: '商品列表-' + this.query.supplierName - }) + } + if (this.query.supplierName) { + uni.setNavigationBarTitle({ + title: '商品列表-' + this.query.supplierName + }) } this.listApi = '/api/customer/flower/list' this.getList('post') @@ -421,6 +422,19 @@ this.refreshList('post') }, + toShopping() { + if (!this.currentInfo.id) { + // await this.$message.confirm('请前往登录') + uni.navigateTo({ + url: '/pages/login/supplier-login?source=jump' + }) + return + } + //直接强制购物车 + uni.reLaunch({ + url: '/sub_pages/customer/shopping/shopping' + }) + }, toDetail(item) { uni.navigateTo({ url: `/sub_pages/customer/trade/detail?id=${item.id}` diff --git a/sub_pages/customer/trade/trade.vue b/sub_pages/customer/trade/trade.vue index ff15aae..9419328 100644 --- a/sub_pages/customer/trade/trade.vue +++ b/sub_pages/customer/trade/trade.vue @@ -9,7 +9,8 @@ </view> <view class="flex1 input"> - <u-input :placeholder="type==='category'?'请输入分类名称':'请输入店铺名称'" v-model="query.name" clearable @confirm="buttonSearchFlow" @clear="()=>{ + <u-input :placeholder="type==='category'?'请输入分类名称':'请输入店铺名称'" v-model="query.name" clearable + @confirm="buttonSearchFlow" @clear="()=>{ $nextTick(()=>{buttonSearchFlow()}) }"> <template slot="suffix"> -- Gitblit v1.9.3