Commit 163d32b4 authored by ziyu's avatar ziyu

improvement: 商品点击增加loading

parent b047f4b7
<template>
<div class="loading-wrapper">
<van-popup show="{{show}}" overlay="{{showoverLay}}" close-on-click-overlay="{{false}}" round>
<view class="loading" v-show="showoverLay">
<van-loading type="spinner">跳转中...</van-loading>
</view>
</van-popup>
</div>
</template>
<script>
import wepy from '@wepy/core';
wepy.component({
props: {
show:{
type:Boolean,
default: false,
}
},
data: {
showoverLay: false,
},
watch: {
show(val) {
if(val){
this.showoverLay = false;
setTimeout(()=>{
this.showoverLay = true;
},500)
}
}
},
created() {
},
methods: {
}
});
</script>
<style lang="less">
.loading{
padding:40rpx;
}
</style>
<config>
{
usingComponents: {
'van-popup':'~@/components/vant/popup/index',
'van-loading': '~@/components/vant/loading/index'
}
}
</config>
<wxs module="tools" src="../../common/common.wxs"></wxs> <wxs module="tools" src="../../common/common.wxs"></wxs>
<template> <template>
<view>
<view class="footer"> <view class="footer">
<swiper <swiper
class="footswiper" class="footswiper"
...@@ -31,6 +32,8 @@ ...@@ -31,6 +32,8 @@
</swiper-item> </swiper-item>
</swiper> </swiper>
</view> </view>
<go-loading show="{{showLoading}}"></go-loading>
</view>
</template> </template>
<script> <script>
import wepy from '@wepy/core'; import wepy from '@wepy/core';
...@@ -100,7 +103,10 @@ ...@@ -100,7 +103,10 @@
}, },
toViewPage(e) { toViewPage(e) {
let item = e.$wx.currentTarget.dataset.item; let item = e.$wx.currentTarget.dataset.item;
if(this.showLoading) return;
this.showLoading = true;
getGoodsUrl({skuId:item.sourceId}).then(data=>{ getGoodsUrl({skuId:item.sourceId}).then(data=>{
this.showLoading = false;
wx.navigateToMiniProgram({ wx.navigateToMiniProgram({
appId: 'wx91d27dbf599dff74', appId: 'wx91d27dbf599dff74',
path: 'pages/union/proxy/proxy?spreadUrl=' + encodeURIComponent(data), // 跳转小程序的路径 path: 'pages/union/proxy/proxy?spreadUrl=' + encodeURIComponent(data), // 跳转小程序的路径
...@@ -109,6 +115,8 @@ ...@@ -109,6 +115,8 @@
success(res) { success(res) {
} }
}); });
}).catch(()=>{
this.showLoading = false;
}) })
}, },
touchStart (event) { touchStart (event) {
...@@ -264,7 +272,7 @@ ...@@ -264,7 +272,7 @@
<config> <config>
{ {
"usingComponents": { "usingComponents": {
'goods-loading': '~@/components/custom/loading', "go-loading": "~@/components/custom/goloading"
} }
} }
</config> </config>
...@@ -67,12 +67,12 @@ ...@@ -67,12 +67,12 @@
nextQueue: [], nextQueue: [],
prevQueue: [], prevQueue: [],
curQueue: [], curQueue: [],
circular: true, circular: false,
_last: 1, _last: 1,
_invalidUp: 0, _invalidUp: 0,
_invalidDown: 0, _invalidDown: 0,
_videoContexts: [], _videoContexts: [],
currentIndex:0, currentIndex:1,
videoPause: false, videoPause: false,
videoLoading: false, videoLoading: false,
}, },
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
</view> </view>
<view class="search-last" v-show="isLoading"><van-loading type="spinner" text-size="26rpx">加载中</van-loading></view> <view class="search-last" v-show="isLoading"><van-loading type="spinner" text-size="26rpx">加载中</van-loading></view>
<view class="search-last" v-show="isDone">没有更多了~</view> <view class="search-last" v-show="isDone">没有更多了~</view>
<go-loading show="{{showLoading}}"></go-loading>
</view> </view>
</template> </template>
<script> <script>
...@@ -37,6 +38,7 @@ ...@@ -37,6 +38,7 @@
list:[], list:[],
isDone:false, isDone:false,
isLoading:false, isLoading:false,
showLoading:false,
}, },
methods:{ methods:{
backUrl() { backUrl() {
...@@ -70,7 +72,10 @@ ...@@ -70,7 +72,10 @@
toJingdong(event) { toJingdong(event) {
const sourceId = event.$wx.currentTarget.dataset.id; const sourceId = event.$wx.currentTarget.dataset.id;
if(sourceId === undefined) return; if(sourceId === undefined) return;
if(this.showLoading) return;
this.showLoading = true;
getGoodsUrl({skuId:sourceId}).then(data=>{ getGoodsUrl({skuId:sourceId}).then(data=>{
this.showLoading = false;
wx.navigateToMiniProgram({ wx.navigateToMiniProgram({
appId: 'wx91d27dbf599dff74', appId: 'wx91d27dbf599dff74',
path: 'pages/union/proxy/proxy?spreadUrl=' + encodeURIComponent(data), // 跳转小程序的路径 path: 'pages/union/proxy/proxy?spreadUrl=' + encodeURIComponent(data), // 跳转小程序的路径
...@@ -79,6 +84,8 @@ ...@@ -79,6 +84,8 @@
success(res) { success(res) {
} }
}); });
}).catch(()=>{
this.showLoading = false;
}) })
} }
}, },
...@@ -96,6 +103,7 @@ ...@@ -96,6 +103,7 @@
"van-field": "../components/vant/field/index", "van-field": "../components/vant/field/index",
"van-image": "../components/vant/image/index", "van-image": "../components/vant/image/index",
"van-loading": "../components/vant/loading/index", "van-loading": "../components/vant/loading/index",
"go-loading": "~@/components/custom/goloading",
} }
} }
</config> </config>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment