6
0
Fork 0

活动添加分享

hui.zhou
h30830569 2022-06-06 17:13:05 +08:00
parent fcf7563f69
commit 17646d19b0
6 changed files with 146 additions and 94 deletions

View File

@ -29,6 +29,7 @@ export default {
// #endif // #endif
}, },
onShow: function (option) { onShow: function (option) {
console.log(option);
let invite_code = option.query.invite_code || strToParams(decodeURIComponent(option.query.scene)).invite_code let invite_code = option.query.invite_code || strToParams(decodeURIComponent(option.query.scene)).invite_code
uni.setStorageSync('INVITE_CODE',invite_code) uni.setStorageSync('INVITE_CODE',invite_code)
}, },

View File

@ -2,7 +2,7 @@
<cu-popup v-model="show" mode="bottom" border-radius="20" closeable close-icon-size="24"> <cu-popup v-model="show" mode="bottom" border-radius="20" closeable close-icon-size="24">
<view class="px-40rpx mt-40rpx"> <view class="px-40rpx mt-40rpx">
<view class="flex py-base"> <view class="flex py-base">
<image class="flex-none rounded-20rpx w-200rpx h-200rpx" :src="sku.cover" mode="aspectFill"></image> <image @tap="previewImage(sku.cover)" class="flex-none rounded-20rpx w-200rpx h-200rpx" :src="sku.cover" mode="aspectFill"></image>
<view class="flex flex-col justify-end ml-40rpx"> <view class="flex flex-col justify-end ml-40rpx">
<view class="font-bold text-hex-FF0200 mr-36rpx text-52rpx"> {{ sku.sell_price }} </view> <view class="font-bold text-hex-FF0200 mr-36rpx text-52rpx"> {{ sku.sell_price }} </view>
<view class="mt-10rpx text-28rpx"> 会员价{{ sku.vip_price }} </view> <view class="mt-10rpx text-28rpx"> 会员价{{ sku.vip_price }} </view>
@ -20,12 +20,12 @@
<view class="inline-block mr-24rpx mb-16rpx" v-for="(spce,index2) in item.items" :key="index2"> <view class="inline-block mr-24rpx mb-16rpx" v-for="(spce,index2) in item.items" :key="index2">
<view <view
@tap="onChangeSku(spce, item.items)" @tap="onChangeSku(spce, item.items)"
:class="spce.selected?'text-hex-FF0000 bg-hex-FDF2EC':'text-hex-333333 bg-hex-F8F8F8'" :class="spce.selected?'text-hex-FF0000 bg-hex-FDF2EC border border-solid border-hex-FF0000':'text-hex-333333 bg-hex-F8F8F8 border border-solid border-hex-F8F8F8'"
:text="spce.name" :text="spce.name"
class="cu-tag" class="cu-tag"
:disabled="spce.sku_id == 0" :disabled="spce.sku_id == 0"
:color="spce.selected ? '#FF0000' : '#333333'" :color="spce.selected ? '#FF0000' : '#333333'"
:bg-color="spce.selected ? '#FDF2EC' : '#F8F8F8'"
:border-color="spce.selected ? '#FDF2EC' : '#F8F8F8'" :border-color="spce.selected ? '#FDF2EC' : '#F8F8F8'"
shape="circle" shape="circle"
>{{spce.name}} >{{spce.name}}
@ -187,13 +187,19 @@ export default {
if (this.isOutStock) return this.$u.toast('超出库存'); if (this.isOutStock) return this.$u.toast('超出库存');
this.$emit(type, this.sku); this.$emit(type, this.sku);
}, },
//
previewImage(url){
uni.previewImage({
urls: [url],
})
}
}, },
}; };
</script> </script>
<style lang="scss"> <style lang="scss">
.cu-tag{ .cu-tag{
font-size: 30rpx; font-size: 30rpx;
border-radius: 30rpx; border-radius: 15rpx;
padding:10rpx 25rpx; padding:10rpx 40rpx;
} }
</style> </style>

View File

@ -1,9 +1,9 @@
<template> <template>
<view class="h-full"> <view class="h-full">
<loading-view v-if="isFirstLoading"></loading-view> <loading-view v-if="isFirstLoading && isLogin "></loading-view>
<view <view
class="bg min-h-full overflow-hidden" class="bg min-h-full overflow-hidden"
v-else v-else-if="isLogin"
:style="{ backgroundImage: `url(${draw_activity.bg_image})`, backgroundColor: draw_activity.bg_color }" :style="{ backgroundImage: `url(${draw_activity.bg_image})`, backgroundColor: draw_activity.bg_color }"
> >
<view class=""> <view class="">
@ -22,79 +22,79 @@
</view> </view>
<view class="w-full" :style="{ height: 50 + statusBarHeight + 'px' }"> </view> <view class="w-full" :style="{ height: 50 + statusBarHeight + 'px' }"> </view>
</view> </view>
<view class="h-300rpx w-full"></view>
<view class="w-full relative"> <view class="h-300rpx w-full"></view>
<view class="h-100rpx"></view> <view class="w-full relative">
<view class="absolute top-0 z-9 left-0 px-30rpx message w-full"> <view class="h-100rpx"></view>
<view class="h-180rpx"> <view class="absolute top-0 z-9 left-0 px-30rpx message w-full">
<swiper <view class="h-180rpx">
vertical="vertical" <swiper
autoplay="play" vertical="vertical"
class="h-full" autoplay="play"
previous-margin="60rpx" class="h-full"
next-margin="60rpx" previous-margin="60rpx"
disable-touch next-margin="60rpx"
@change="change" disable-touch
circular @change="change"
:current="current" circular
> :current="current"
<swiper-item v-for="(item, index) in logsAll" :key="index" class="h-full flex items-start flex-col justify-center"> >
<view <swiper-item v-for="(item, index) in logsAll" :key="index" class="h-full flex items-start flex-col justify-center">
class="bg-hex-000 bg-opacity-30 text-white rounded-full px-20px h-44rpx leading-44rpx text-28rpx inline-block" <view
:class="index == current ? 'opacity1' : index + 1 == current ? 'opacity0' : index - 1 == current ? 'opacity2' :(current==logsAll.length-1 && index==0)?'opacity2' : 'opacity3'" class="bg-hex-000 bg-opacity-30 text-white rounded-full px-20px h-44rpx leading-44rpx text-28rpx inline-block"
> :class="index == current ? 'opacity1' : index + 1 == current ? 'opacity0' : index - 1 == current ? 'opacity2' :(current==logsAll.length-1 && index==0)?'opacity2' : 'opacity3'"
<text >
>恭喜{{ item.user.nickname }}抽中<text class="text-hex-ffde58">{{ item.prize.name }}</text></text <text
> >恭喜{{ item.user.nickname }}抽中<text class="text-hex-ffde58">{{ item.prize.name }}</text></text
</view> >
</swiper-item> </view>
</swiper> </swiper-item>
</view> </swiper>
<!-- <view v-for="item in logs" :key="item.id" class="opacity"> </view>
<view class="bg-hex-000 bg-opacity-30 text-white rounded-full px-20px h-44rpx leading-44rpx text-28rpx mb-10rpx inline-block"> <!-- <view v-for="item in logs" :key="item.id" class="opacity">
<text <view class="bg-hex-000 bg-opacity-30 text-white rounded-full px-20px h-44rpx leading-44rpx text-28rpx mb-10rpx inline-block">
>恭喜{{ item.user.nickname }}抽中<text class="text-hex-ffde58">{{ item.prize.name }}</text></text <text
> >恭喜{{ item.user.nickname }}抽中<text class="text-hex-ffde58">{{ item.prize.name }}</text></text
</view> >
</view> --> </view>
</view> </view> -->
<almost-lottery </view>
pointer-position="edge" <almost-lottery
:lottery-size="lotteryConfig.lotterySize" pointer-position="edge"
:action-size="lotteryConfig.actionSize" :lottery-size="lotteryConfig.lotterySize"
:ring-count="8" :action-size="lotteryConfig.actionSize"
:duration="8" :ring-count="8"
:prize-list="prizeList" :duration="8"
:prize-index="prizeIndex" :prize-list="prizeList"
@reset-index="prizeIndex = -1" :prize-index="prizeIndex"
@draw-start="handleDrawStart" @reset-index="prizeIndex = -1"
@draw-end="handleDrawEnd" @draw-start="handleDrawStart"
@finish="handleDrawFinish" @draw-end="handleDrawEnd"
v-if="prizeList.length" @finish="handleDrawFinish"
stroke-color="#ffffff" v-if="prizeList.length"
:str-font-size="18" stroke-color="#ffffff"
:strFontColors="['#fb6056']" :str-font-size="18"
:colors="['#ffeaa7', '#ffeaa7']" :strFontColors="['#fb6056']"
:stroked="true" :colors="['#ffeaa7', '#ffeaa7']"
:img-width="120" :stroked="true"
:img-height="120" :img-width="120"
:imgMarginStr="30" :img-height="120"
:strMarginOutside="16" :imgMarginStr="30"
:canvasCached="true" :strMarginOutside="16"
:lotteryBg="lotteryBg" :canvasCached="true"
:actionBg="actionBg" :lotteryBg="lotteryBg"
/> :actionBg="actionBg"
<view class="text-center mt-40rpx" />
>今天还可以抽 <text class="text-error">{{ freeNum }}</text> </view <view class="text-center mt-40rpx"
> >今天还可以抽 <text class="text-error">{{ freeNum }}</text> </view
</view> >
</view>
<block>
<view class="p-30rpx">
<u-parse :html="draw_activity.desc"></u-parse> <view class="p-30rpx">
</view> <u-parse :html="draw_activity.desc"></u-parse>
</block> </view>
</block>
<u-mask :show="show"> <u-mask :show="show">
<view class="flex items-center justify-center h-full"> <view class="flex items-center justify-center h-full">
<view class=""> <view class="">
@ -230,6 +230,9 @@ export default {
}; };
}, },
computed: { computed: {
user() {
return this.$store.getters.user ?? {};
},
isApple() { isApple() {
return uni.getSystemInfoSync().platform === 'ios'; return uni.getSystemInfoSync().platform === 'ios';
}, },
@ -242,16 +245,44 @@ export default {
}, },
async onLoad({ id }) { async onLoad({ id }) {
this.id = id; this.id = id;
this.getConfig(); setTimeout(()=>{
this.getLuckyLog(); if(!this.isLogin){
this.$u.route({
type:'redirectTo',
url:`/pages/login/index?redirec=${encodeURIComponent(`/pageB/lucky/index?id=${id}`)}`
})
}else{
this.getConfig();
this.getLuckyLog();
}
},300)
},
//
onShareAppMessage(res) {
let code = this.user.code ? this.user.code : '';
let shareObj = {
title: this.draw_activity.name,
path: `/pageB/lucky/index?id=${this.id}&invite_code=${code}`,
imageUrl: this.draw_activity.bg_image,
};
return shareObj;
}, },
methods: { methods: {
change(e) { change(e) {
this.current = e.detail.current; this.current = e.detail.current;
}, },
onBack() { onBack() {
uni.navigateBack(); const pages = getCurrentPages()
const prevPage = pages[pages.length - 2]
if(prevPage){
uni.navigateBack({})
}else{
uni.switchTab({
url:'/pages/index/index'
})
}
// uni.navigateBack();
}, },
async getConfig() { async getConfig() {
try { try {

View File

@ -62,13 +62,15 @@
</view> </view>
</template> </template>
<script> <script>
import { getWxCode } from '@/utils/login'; // import { getWxCode } from '@/utils/login';
import { wxMnpLogin,getWxCode } from '@/utils/login'
import { mapMutations } from 'vuex'; import { mapMutations } from 'vuex';
export default { export default {
data() { data() {
return { return {
check: false, check: false,
code:'', code:'',
redirec:null,
form: { form: {
phone: '', phone: '',
password: '', password: '',
@ -95,7 +97,10 @@ export default {
onReady() { onReady() {
// this.$refs.uForm.setRules(this.rules); // this.$refs.uForm.setRules(this.rules);
}, },
async onLoad({ type, phone }) { async onLoad({ type, phone,redirec}) {
this.redirec = redirec
this.form.phone = phone ?? ''; this.form.phone = phone ?? '';
/* #ifdef MP-WEIXIN */ /* #ifdef MP-WEIXIN */
this.code = await getWxCode(); this.code = await getWxCode();
@ -115,14 +120,23 @@ export default {
if(!code) return if(!code) return
const invite_code = uni.getStorageSync('INVITE_CODE'); const invite_code = uni.getStorageSync('INVITE_CODE');
// const code = await getWxCode(); // const code = await getWxCode();
if(!this.$store.getters.token){
await wxMnpLogin()
}
const params = {} const params = {}
if(!!invite_code) params.inviter_code = invite_code if(!!invite_code) params.inviter_code = invite_code
console.log(params.inviter_code);
const resData = await this.$api.post('/v1/wechat-mini/bind-phone', { const resData = await this.$api.post('/v1/wechat-mini/bind-phone', {
code:code, code:code,
...params ...params
}); });
this.LOGIN(resData.token); await this.LOGIN(resData.token);
uni.navigateBack({ // await this.LOGIN('555|bZL3mr19Tpgs4jRvpKkguoH865lL2zGLa35WdU7Z')
if(!!this.redirec) this.$u.route({
type:'redirectTo',
url:decodeURIComponent(this.redirec)
})
else uni.navigateBack({
delta: 1, delta: 1,
}); });
}, },

View File

@ -25,17 +25,17 @@ const mutations = {
RESET_STATE: (state) => { RESET_STATE: (state) => {
Object.assign(state, getDefaultState()) Object.assign(state, getDefaultState())
}, },
LOGIN(state, value) { async LOGIN(state, value) {
this.commit('user/SET_TOKEN',value) await this.commit('user/SET_TOKEN',value)
this.dispatch('user/getUserInfo',false) await this.dispatch('user/getUserInfo',false)
}, },
LOGOUT(){ LOGOUT(){
return this.dispatch('user/resetToken') return this.dispatch('user/resetToken')
}, },
// 登录 // 登录
SET_TOKEN(state, value) { async SET_TOKEN(state, value) {
state.token = value state.token = value
uni.setStorageSync(TOKEN, value); await uni.setStorageSync(TOKEN, value);
}, },
//获取用户信息 //获取用户信息
SET_USERINFO(state, value) { SET_USERINFO(state, value) {

View File

@ -22,7 +22,7 @@ export function getWxCode() {
export async function wxMnpLogin(){ export async function wxMnpLogin(){
store.commit('user/LOGOUT') store.commit('user/LOGOUT')
const code = await getWxCode() const code = await getWxCode()
silentLogin({code}) await silentLogin({code})
} }