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
},
onShow: function (option) {
console.log(option);
let invite_code = option.query.invite_code || strToParams(decodeURIComponent(option.query.scene)).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">
<view class="px-40rpx mt-40rpx">
<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="font-bold text-hex-FF0200 mr-36rpx text-52rpx"> {{ sku.sell_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
@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"
class="cu-tag"
:disabled="spce.sku_id == 0"
:color="spce.selected ? '#FF0000' : '#333333'"
:bg-color="spce.selected ? '#FDF2EC' : '#F8F8F8'"
:border-color="spce.selected ? '#FDF2EC' : '#F8F8F8'"
shape="circle"
>{{spce.name}}
@ -187,13 +187,19 @@ export default {
if (this.isOutStock) return this.$u.toast('超出库存');
this.$emit(type, this.sku);
},
//
previewImage(url){
uni.previewImage({
urls: [url],
})
}
},
};
</script>
<style lang="scss">
.cu-tag{
font-size: 30rpx;
border-radius: 30rpx;
padding:10rpx 25rpx;
border-radius: 15rpx;
padding:10rpx 40rpx;
}
</style>

View File

@ -1,9 +1,9 @@
<template>
<view class="h-full">
<loading-view v-if="isFirstLoading"></loading-view>
<loading-view v-if="isFirstLoading && isLogin "></loading-view>
<view
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 }"
>
<view class="">
@ -22,6 +22,7 @@
</view>
<view class="w-full" :style="{ height: 50 + statusBarHeight + 'px' }"> </view>
</view>
<view class="h-300rpx w-full"></view>
<view class="w-full relative">
<view class="h-100rpx"></view>
@ -89,12 +90,11 @@
>
</view>
<block>
<view class="p-30rpx">
<u-parse :html="draw_activity.desc"></u-parse>
</view>
</block>
<u-mask :show="show">
<view class="flex items-center justify-center h-full">
<view class="">
@ -230,6 +230,9 @@ export default {
};
},
computed: {
user() {
return this.$store.getters.user ?? {};
},
isApple() {
return uni.getSystemInfoSync().platform === 'ios';
},
@ -242,16 +245,44 @@ export default {
},
async onLoad({ id }) {
this.id = id;
setTimeout(()=>{
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: {
change(e) {
this.current = e.detail.current;
},
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() {
try {

View File

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

View File

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

View File

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