1. 为所有登录跳转调用添加redirectTo跳转类型参数 2. 调整部分页面的onShow生命周期执行顺序和定时器包装 3. 补充缺失的ns-login组件引用到两个diy组件中 4. 修复部分页面登录后返回出现循环跳转的问题
301 lines
6.3 KiB
Vue
301 lines
6.3 KiB
Vue
<template>
|
|
<view class="container" :style="themeColor">
|
|
<swiper class="swiper" @change="getIndex">
|
|
<swiper-item v-for="(item, index) in poster" :key="index">
|
|
<view class="swiper-item">
|
|
<view class="poster-wrap">
|
|
<image :src="$util.img(item)" mode="widthFix" show-menu-by-longpress />
|
|
</view>
|
|
</view>
|
|
</swiper-item>
|
|
</swiper>
|
|
|
|
<!-- #ifdef H5 -->
|
|
<view class="tips">{{ $lang('longPressTip') }}</view>
|
|
<!-- #endif -->
|
|
|
|
<!-- #ifdef MP -->
|
|
<view class="btn color-base-bg color-base-border" @click="save">{{ $lang('savePoster') }}</view>
|
|
<!-- #endif -->
|
|
|
|
<uni-popup ref="popupDialog" :custom="true" :mask-click="false">
|
|
<view class="dialog-popup">
|
|
<view class="title">{{ $lang('dialogTitle') }}</view>
|
|
<view class="message">{{ $lang('authDeniedMessage') }}</view>
|
|
<view class="action-wrap">
|
|
<view @click="closeDialog">{{ $lang('cancel') }}</view>
|
|
<view>
|
|
<button type="default" open-type="openSetting" @opensetting="closeDialog"
|
|
hover-class="none">{{ $lang('authorizeNow') }}</button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</uni-popup>
|
|
|
|
<ns-login ref="login"></ns-login>
|
|
<loading-cover ref="loadingCover"></loading-cover>
|
|
|
|
<!-- 隐私弹窗 -->
|
|
<privacy-popup ref="privacyPopup"></privacy-popup>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
Weixin
|
|
} from 'common/js/wx-jssdk.js';
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
poster: [],
|
|
fenxiaoInfo: {},
|
|
posterIndex: 0,
|
|
//海报模板id
|
|
templateId: ['default'],
|
|
mpShareData: null //小程序分享数据
|
|
};
|
|
},
|
|
methods: {
|
|
/**
|
|
* 获取分销海报
|
|
*/
|
|
getPoster(id) {
|
|
return new Promise((resolve, reject) => {
|
|
this.$api.sendRequest({
|
|
url: '/fenxiao/api/fenxiao/poster',
|
|
data: {
|
|
page: this.$util.INDEX_PAGE_URL,
|
|
qrcode_param: JSON.stringify({}),
|
|
template_id: id
|
|
},
|
|
success: res => {
|
|
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
|
if (res.code >= 0) {
|
|
resolve(res.data.path);
|
|
}
|
|
},
|
|
fail: res => {
|
|
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
|
reject();
|
|
}
|
|
});
|
|
});
|
|
},
|
|
getIndex(e) {
|
|
this.posterIndex = e.detail.current;
|
|
},
|
|
save() {
|
|
// #ifdef MP
|
|
uni.downloadFile({
|
|
url: this.$util.img(this.poster[this.posterIndex]),
|
|
success: res => {
|
|
if (res.statusCode === 200) {
|
|
uni.saveImageToPhotosAlbum({
|
|
filePath: res.tempFilePath,
|
|
success: () => {
|
|
this.$util.showToast({
|
|
title: this.$lang('saveSuccess')
|
|
});
|
|
},
|
|
fail: res => {
|
|
if (res.errMsg == 'saveImageToPhotosAlbum:fail auth deny' ||
|
|
res.errMsg == 'saveImageToPhotosAlbum:fail:auth denied') {
|
|
this.$refs.popupDialog.open();
|
|
} else {
|
|
this.$util.showToast({
|
|
title: this.$lang('saveFail')
|
|
});
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
this.$util.showToast({
|
|
title: this.$lang('downloadFail')
|
|
});
|
|
}
|
|
},
|
|
fail: res => {
|
|
this.$util.showToast({
|
|
title: this.$lang('downloadFail')
|
|
});
|
|
}
|
|
});
|
|
// #endif
|
|
},
|
|
getFenxiaoDetail() {
|
|
this.poster = [];
|
|
try {
|
|
this.templateId.forEach((item, index) => {
|
|
this.getPoster(item).then(resolve => {
|
|
this.poster.push(resolve);
|
|
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
|
}).catch(reject => {
|
|
throw reject;
|
|
});
|
|
});
|
|
} catch {
|
|
this.$util.showToast({
|
|
title: this.$lang('posterGenerateFail')
|
|
});
|
|
}
|
|
},
|
|
|
|
closeDialog() {
|
|
this.$refs.popupDialog.close();
|
|
}
|
|
},
|
|
onLoad(option) {
|
|
setTimeout(() => {
|
|
if (!this.addonIsExist.fenxiao) {
|
|
this.$util.showToast({
|
|
title: this.$lang('merchantNotOpenFenxiao'),
|
|
mask: true,
|
|
duration: 2000
|
|
});
|
|
setTimeout(() => {
|
|
this.$util.redirectTo(this.$util.INDEX_PAGE_URL);
|
|
}, 2000);
|
|
}
|
|
}, 1000);
|
|
|
|
if (option.templateId) {
|
|
this.templateId = option.templateId.split(',');
|
|
}
|
|
|
|
if (this.storeToken) {
|
|
if (option.poster) {
|
|
this.poster = decodeURIComponent(option.poster).split(',')
|
|
setTimeout(() => {
|
|
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
|
}, 500)
|
|
} else {
|
|
this.getFenxiaoDetail();
|
|
}
|
|
|
|
} else {
|
|
this.$nextTick(() => {
|
|
this.$refs.login.open('/pages_promotion/fenxiao/promote_code', 'redirectTo');
|
|
});
|
|
}
|
|
},
|
|
onShow() {
|
|
//小程序分享
|
|
// #ifdef MP-WEIXIN
|
|
this.$util.getMpShare().then(res => {
|
|
this.mpShareData = res;
|
|
});
|
|
// #endif
|
|
},
|
|
//分享给好友
|
|
onShareAppMessage() {
|
|
return this.mpShareData.appMessage;
|
|
},
|
|
//分享到朋友圈
|
|
onShareTimeline() {
|
|
return this.mpShareData.timeLine;
|
|
},
|
|
watch: {
|
|
storeToken: function (nVal, oVal) {
|
|
if (nVal) {
|
|
this.getFenxiaoDetail();
|
|
}
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.container {
|
|
width: 100vw;
|
|
min-height: 100vh;
|
|
background-color: #f5f5f5;
|
|
}
|
|
|
|
.poster-wrap {
|
|
padding: 40rpx 0;
|
|
width: calc(100vw - 80rpx);
|
|
margin: 0 40rpx;
|
|
line-height: 1;
|
|
|
|
image {
|
|
border-radius: 20rpx;
|
|
overflow: hidden;
|
|
width: 100%;
|
|
}
|
|
}
|
|
|
|
.swiper {
|
|
height: 1240rpx;
|
|
}
|
|
|
|
.btn {
|
|
margin: 0 80rpx;
|
|
margin-top: 30rpx;
|
|
height: 80rpx;
|
|
line-height: 80rpx;
|
|
border-radius: $border-radius;
|
|
color: #fff;
|
|
text-align: center;
|
|
}
|
|
|
|
.tips {
|
|
text-align: center;
|
|
font-size: $font-size-base;
|
|
color: #999;
|
|
font-weight: 600;
|
|
margin-top: 20rpx;
|
|
}
|
|
|
|
.dialog-popup {
|
|
width: 580rpx;
|
|
background: #fff;
|
|
box-sizing: border-box;
|
|
border-radius: 10rpx;
|
|
overflow: hidden;
|
|
height: initial;
|
|
|
|
.title {
|
|
padding: 30rpx 30rpx 0 30rpx;
|
|
text-align: center;
|
|
font-size: 32rpx;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.message {
|
|
padding: 0 30rpx;
|
|
color: #666;
|
|
text-align: center;
|
|
font-size: $font-size-base;
|
|
line-height: 1.3;
|
|
margin-top: 30rpx;
|
|
}
|
|
|
|
.action-wrap {
|
|
margin-top: 50rpx;
|
|
height: 80rpx;
|
|
display: flex;
|
|
border-top: 2rpx solid #eee;
|
|
|
|
&>view {
|
|
flex: 1;
|
|
text-align: center;
|
|
line-height: 80rpx;
|
|
|
|
&:first-child {
|
|
border-right: 2rpx solid #eee;
|
|
color: #999;
|
|
}
|
|
|
|
button {
|
|
border: none;
|
|
line-height: 80rpx;
|
|
padding: 0;
|
|
margin: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style> |