6
0
Fork 0

抽奖活动 调整奖品图片大小

master
panliang 2026-05-16 10:03:15 +08:00
parent 2769ef550f
commit e85f87d859
9 changed files with 233 additions and 312 deletions

View File

@ -1,7 +1,6 @@
<script> <script>
// import { checkUpdate } from '@/utils/check-update'; // import { checkUpdate } from '@/utils/check-update';
import { strToParams } from '@/utils/tools'; import { strToParams } from '@/utils/tools';
import { wxMnpLogin } from '@/utils/login';
export default { export default {
data() { data() {
return { return {
@ -14,10 +13,6 @@ export default {
this.$store.dispatch('app/getSys'); this.$store.dispatch('app/getSys');
this.$store.dispatch('app/getArticle'); this.$store.dispatch('app/getArticle');
/* #ifdef MP-WEIXIN */
wxMnpLogin()
/* #endif */
// #ifdef APP-PLUS // #ifdef APP-PLUS
// const clientInfo = plus.push.getClientInfo() // const clientInfo = plus.push.getClientInfo()
// console.log(clientInfo); // console.log(clientInfo);

View File

@ -441,6 +441,8 @@
let prizeCount = this.prizeList.length let prizeCount = this.prizeList.length
let baseAngle = Math.PI * 2 / prizeCount let baseAngle = Math.PI * 2 / prizeCount
ctx.font = "bold 28px sans-serif";
// //
ctx.setFontSize(this.higtFontSize) ctx.setFontSize(this.higtFontSize)

View File

@ -1,8 +1,7 @@
<template> <template>
<view class="h-full"> <view class="h-full">
<loading-view v-if="isFirstLoading && isLogin"></loading-view> <loading-view v-if="isFirstLoading"></loading-view>
<view class="bg min-h-full overflow-hidden" v-else-if="isLogin" <view v-else class="bg min-h-full overflow-hidden" :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="">
<view class="fixed top-0 left-0 w-full bg z-10" :style="{ backgroundImage: `url(${draw_activity.bg_image})` }"> <view class="fixed top-0 left-0 w-full bg z-10" :style="{ backgroundImage: `url(${draw_activity.bg_image})` }">
<view :style="{ height: statusBarHeight + 'px' }"></view> <view :style="{ height: statusBarHeight + 'px' }"></view>
@ -32,52 +31,34 @@
</swiper-item> </swiper-item>
</swiper> </swiper>
</view> </view>
<!-- <view v-for="item in logs" :key="item.id" class="opacity">
<view class="bg-hex-000 bg-opacity-30 text-white rounded-full px-20px h-44rpx leading-44rpx text-28rpx mb-10rpx inline-block">
<text
>恭喜{{ item.user.nickname }}抽中<text class="text-hex-ffde58">{{ item.prize.name }}</text></text
>
</view>
</view> -->
</view> </view>
<almost-lottery pointer-position="edge" :lottery-size="lotteryConfig.lotterySize" <almost-lottery pointer-position="edge" :lottery-size="lotteryConfig.lotterySize"
:action-size="lotteryConfig.actionSize" :ring-count="8" :duration="8" :prize-list="prizeList" :action-size="lotteryConfig.actionSize" :ring-count="8" :duration="8" :prize-list="prizeList"
:prize-index="prizeIndex" @reset-index="prizeIndex = -1" @draw-start="handleDrawStart" :prize-index="prizeIndex" @reset-index="prizeIndex = -1" @draw-start="handleDrawStart"
@draw-end="handleDrawEnd" @finish="handleDrawFinish" v-if="prizeList.length" stroke-color="#ffffff" @draw-end="handleDrawEnd" @finish="handleDrawFinish" v-if="prizeList.length" stroke-color="#ffffff"
:strFontSize="28" :strMaxLen="10" :strFontColors="['#fb6056']" :colors="['#ffeaa7', '#ffeaa7']" :strFontSize="36" :strMaxLen="10"
:colors="prizeBgColors"
:strFontColors="['#FFFFFF']"
:stroked="true" :img-width="120" :img-height="120" :imgMarginStr="30" :strMarginOutside="32" :stroked="true" :img-width="120" :img-height="120" :imgMarginStr="30" :strMarginOutside="32"
:canvasCached="true"
:lotteryBg="lotteryBg" :lotteryBg="lotteryBg"
:actionBg="actionBg" :actionBg="actionBg"
/> :imgDrawed="false"
strDirection="vertical"
/>
<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>
<view class="p-30rpx"> <view class="p-30rpx">
<u-parse :html="draw_activity.desc"></u-parse> <u-parse :html="draw_activity.desc"></u-parse>
</view> </view>
<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="prize-result" v-if="prizeData.prize">
<view class="pr-30rpx text-right"> <view class="prize-title text-center h-42rpx leading-40rpx text-30rpx text-hex-f74a2c bg-gradient-to-t to-hex-fff4e5 from-hex-ffd4b2 w-240rpx rounded-full mx-auto">{{ results.name }}</view>
<image src="/static/images/app/app_update_close.png" alt="" srcset="" class="w-48rpx h-48rpx" <view class="prize-image text-center mx-auto mx-auto w-500rpx h-800rpx" style="margin: 30rpx 0">
@click="show = false"></image> <image :src="results.goods" alt="" class="w-full h-full"></image>
</view>
<view class="w-600rpx h-600rpx relative" v-if="prizeData.prize">
<image v-if="prizeData.prize.type == 0" :src="results.goods" class="w-full h-full"></image>
<block v-if="prizeData.prize.type != 0">
<view class="absolute top-178rpx left-0 right-0 text-center mx-auto mx-auto w-300rpx h-290rpx">
<image :src="results.goods" alt="" class="w-full h-full"></image>
</view>
<view class="absolute top-116rpx left-0 right-0 text-center h-42rpx leading-40rpx text-30rpx text-hex-f74a2c bg-gradient-to-t to-hex-fff4e5 from-hex-ffd4b2 w-240rpx rounded-full mx-auto">
{{ results.name }}
</view>
<view v-if="!!results.btn" @click="onResults" class="absolute top-486rpx left-0 right-0 text-center h-54rpx leading-54rpx text-28rpx text-white bg-img w-280rpx mx-auto">
{{ results.btn }}
</view>
</block>
</view> </view>
<view v-if="results.btn" @click="onResults" class="prize-btn text-center h-54rpx leading-54rpx text-28rpx text-white bg-img w-280rpx mx-auto">{{ results.btn }}</view>
</view> </view>
</view> </view>
</u-mask> </u-mask>
@ -125,9 +106,9 @@ export default {
show: false, show: false,
prizeData: {}, prizeData: {},
results: { results: {
name: '50元消费体验价', name: '',
btn: '充值账户余额内', btn: '确定',
goods: 'https://ystmp.oss-cn-beijing.aliyuncs.com/wechart/lucky/hb.png', goods: '',
}, },
// //
isDev: process.env.NODE_ENV === 'development', isDev: process.env.NODE_ENV === 'development',
@ -142,9 +123,9 @@ export default {
// UI // UI
// 稿 // 稿
lotteryBg: "/static/images/almost-lottery__bg.png", lotteryBg: "https://jiqu-library.peidikeji.cn/uniapp/almost-lottery/almost-lottery__bg.png",
// //
actionBg: "/static/images/almost-lottery__action.png", actionBg: "https://jiqu-library.peidikeji.cn/uniapp/almost-lottery/almost-lottery__action.png",
// //
prizeList: [], prizeList: [],
// //
@ -184,6 +165,10 @@ export default {
}, },
], ],
}, },
// ['#ffeaa7', '#ffeaa7']
prizeBgColors: [],
// ['#FFFFFF']
prizeFontColors: []
}; };
}, },
computed: { computed: {
@ -202,17 +187,19 @@ export default {
}, },
async onLoad({ id }) { async onLoad({ id }) {
this.id = id; this.id = id;
setTimeout(() => { this.getConfig();
if (!this.isLogin) { this.getLuckyLog();
this.$u.route({ // setTimeout(() => {
type: 'redirectTo', // if (!this.isLogin) {
url: `/pages/login/index?redirec=${encodeURIComponent(`/pageB/lucky/index?id=${id}`)}` // this.$u.route({
}) // type: 'redirectTo',
} else { // url: `/pages/login/index?redirec=${encodeURIComponent(`/pageB/lucky/index?id=${id}`)}`
this.getConfig(); // })
this.getLuckyLog(); // } else {
} // this.getConfig();
}, 300) // this.getLuckyLog();
// }
// }, 300)
}, },
// //
@ -257,6 +244,14 @@ export default {
if (prize.type == 1) { if (prize.type == 1) {
this.show = false; this.show = false;
this.showAddress = true; this.showAddress = true;
}
//
else if (prize.type == 6) {
this.show = false;
//
uni.navigateTo({
url: '/pageA/coupon/coupon'
});
} else { } else {
this.show = false; this.show = false;
} }
@ -292,6 +287,18 @@ export default {
return { prizeId: e.id, prizeName: e.name, prizeStock: 10, prizeWeight: 200, prizeImage: e.icon, ...e }; return { prizeId: e.id, prizeName: e.name, prizeStock: 10, prizeWeight: 200, prizeImage: e.icon, ...e };
}); });
//
const prizeBgColors = []
const prizeFontColors = []
for (var i = 0; i < data.length; i++) {
const item = data[i]
prizeBgColors.push(item.other?.bgColor ?? "#22292f")
prizeFontColors.push(item.other?.textColor ?? "#FFFFFF")
}
this.prizeBgColors = prizeBgColors
this.prizeFontColors = prizeFontColors
this.draw_log_id = this.config.draw_log_id; this.draw_log_id = this.config.draw_log_id;
this.prizeList = data; this.prizeList = data;
if (!!this.draw_log_id && !this.showAddress) { if (!!this.draw_log_id && !this.showAddress) {
@ -344,14 +351,19 @@ export default {
// //
let prize = this.prizeList[this.prizeIndex]; let prize = this.prizeList[this.prizeIndex];
// type = 1
// type = 6
const { type, prizeImage, name, amount } = prize; const { type, prizeImage, name, amount } = prize;
this.draw_log_id = this.prizeData.id; this.draw_log_id = this.prizeData.id;
this.results.name = name; this.results.name = name;
this.results.btn = ''; this.results.btn = '确定';
if (type == 1) { if (type == 1) {
// this.showAddress = true // this.showAddress = true
this.results.btn = '填写地址'; this.results.btn = '填写地址';
} }
if (type == 6) {
this.results.btn = '查看我的优惠券';
}
this.results.goods = prizeImage; this.results.goods = prizeImage;
this.show = true; this.show = true;
this.prizeing = false; this.prizeing = false;

View File

@ -3,7 +3,8 @@
<!-- 导航栏 --> <!-- 导航栏 -->
<u-navbar :border-bottom="false" :is-back="false" :background="{ background: '#ffffff' }"> <u-navbar :border-bottom="false" :is-back="false" :background="{ background: '#ffffff' }">
<view class="pl-base w-full" @tap="$u.route('/pages/search/search')"> <view class="pl-base w-full" @tap="$u.route('/pages/search/search')">
<u-search class="w-full" :disabled="true" placeholder="搜索商品名称" v-model="searchText" :show-action="false"></u-search> <u-search class="w-full" :disabled="true" placeholder="搜索商品名称" v-model="searchText"
:show-action="false"></u-search>
</view> </view>
<template #right> <template #right>
<view class="mx-base relative" @tap="$u.routeAuth('/pageA/news/index')"> <view class="mx-base relative" @tap="$u.routeAuth('/pageA/news/index')">
@ -14,39 +15,28 @@
</view> </view>
</template> </template>
</u-navbar> </u-navbar>
<mescroll-body :bottombar="false" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption"> <mescroll-body :bottombar="false" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
:down="downOption" :up="upOption">
<view class="px-base"> <view class="px-base">
<!-- 轮播图 --> <!-- 轮播图 -->
<view> <view>
<swiper <swiper class="swipers h-400rpx text-center mt-base m-auto rounded15rpx overflow" circular="true"
class="swipers h-400rpx text-center mt-base m-auto rounded15rpx overflow" autoplay="true" indicator-dots="true" indicator-color="#ffffff" indicator-active-color="#378264">
circular="true" <swiper-item class="flex justify-center w-full h-full"
autoplay="true" v-for="(item, index) in bannerList['wechat_mini_top_banner']" :key="index">
indicator-dots="true" <image :src="`${item.image}?x-oss-process=image/resize,w_750/quality,q_90`" mode="aspectFill"
indicator-color="#ffffff" class="w-full h-full" @tap="jumpByOption(item)" />
indicator-active-color="#378264"
>
<swiper-item class="flex justify-center w-full h-full" v-for="(item, index) in bannerList['wechat_mini_top_banner']" :key="index">
<image
:src="`${item.image}?x-oss-process=image/resize,w_750/quality,q_90`"
mode="aspectFill"
class="w-full h-full"
@tap="jumpByOption(item)"
/>
</swiper-item> </swiper-item>
</swiper> </swiper>
</view> </view>
<!-- tabs --> <!-- tabs -->
<block v-if="!isVerify"> <block v-if="!isVerify">
<view class="grid grid-cols-5"> <view class="grid grid-cols-5">
<view <view @tap="jumpByOption(item)" class="py-25rpx flex flex-col justify-center items-center"
@tap="jumpByOption(item)" v-for="(item, index) in bannerList['wechat_mini_top_navigation_banner']" :key="index">
class="py-25rpx flex flex-col justify-center items-center"
v-for="(item, index) in bannerList['wechat_mini_top_navigation_banner']"
:key="index"
>
<view class="flex items-end"> <view class="flex items-end">
<u-image width="70rpx" height="70rpx" :src="`${item.image}?x-oss-process=image/resize,w_70/quality,q_90`" :lazy-load="true"></u-image> <u-image width="70rpx" height="70rpx"
:src="`${item.image}?x-oss-process=image/resize,w_70/quality,q_90`" :lazy-load="true"></u-image>
</view> </view>
<view class="text-md mt-14rpx text-hex-txBase">{{ item.name }}</view> <view class="text-md mt-14rpx text-hex-txBase">{{ item.name }}</view>
</view> </view>
@ -58,20 +48,11 @@
<indexTitle></indexTitle> <indexTitle></indexTitle>
<!-- 第一张广告图 --> <!-- 第一张广告图 -->
<view class="grid grid-cols-2 gap-x-20rpx mt-10rpx"> <view class="grid grid-cols-2 gap-x-20rpx mt-10rpx">
<view <view v-for="(item, index) in bannerList['wechat_mini_recommend_banner']" :key="index"
v-for="(item, index) in bannerList['wechat_mini_recommend_banner']" :class="index == 0 ? 'col-start-1 col-span-2' : ''" class="mt-20rpx">
:key="index" <u-image border-radius="15rpx" width="100%" height="260rpx"
:class="index == 0 ? 'col-start-1 col-span-2' : ''" :src="`${item.image}?x-oss-process=image/resize,w_750/quality,q_90`" :lazy-load="true"
class="mt-20rpx" @tap="jumpByOption(item)"></u-image>
>
<u-image
border-radius="15rpx"
width="100%"
height="260rpx"
:src="`${item.image}?x-oss-process=image/resize,w_750/quality,q_90`"
:lazy-load="true"
@tap="jumpByOption(item)"
></u-image>
</view> </view>
</view> </view>
</view> </view>
@ -82,19 +63,10 @@
<!-- 左右滑动 --> <!-- 左右滑动 -->
<view class="px-base"> <view class="px-base">
<scroll-view scroll-x="true" class="mt-base scroll pb-10rpx"> <scroll-view scroll-x="true" class="mt-base scroll pb-10rpx">
<view <view class="scroll-item mt-10rpx mr-20rpx" v-for="(item, index) in recommendList"
class="scroll-item mt-10rpx mr-20rpx" @tap="$u.route('/pages/product_details/index', { skuId: item.id })" :key="index">
v-for="(item, index) in recommendList" <u-image border-radius="15rpx" width="260rpx" height="260rpx"
@tap="$u.route('/pages/product_details/index', { skuId: item.id })" :src="`${item.cover}?x-oss-process=image/resize,w_260/quality,q_90`" :lazy-load="true"></u-image>
:key="index"
>
<u-image
border-radius="15rpx"
width="260rpx"
height="260rpx"
:src="`${item.cover}?x-oss-process=image/resize,w_260/quality,q_90`"
:lazy-load="true"
></u-image>
<view class="text-md w-240rpx line-1 text-hex-bgBase h-40rpx">{{ item.name }}</view> <view class="text-md w-240rpx line-1 text-hex-bgBase h-40rpx">{{ item.name }}</view>
<view class="text-md text-txBase">{{ item.sell_price }}</view> <view class="text-md text-txBase">{{ item.sell_price }}</view>
<view class="flex items-center" v-if="item.vip_price"> <view class="flex items-center" v-if="item.vip_price">
@ -107,32 +79,17 @@
</view> </view>
<!-- 第四张广告图 --> <!-- 第四张广告图 -->
<view class="mt-base" v-for="(item, index) in bannerList['wechat_mini_floor_banner']" :key="index"> <view class="mt-base" v-for="(item, index) in bannerList['wechat_mini_floor_banner']" :key="index">
<u-image <u-image @tap="jumpByOption(item)" border-radius="15rpx" width="100%" height="220rpx"
@tap="jumpByOption(item)" :src="`${item.image}?x-oss-process=image/resize,w_750/quality,q_90`" :lazy-load="true"></u-image>
border-radius="15rpx"
width="100%"
height="220rpx"
:src="`${item.image}?x-oss-process=image/resize,w_750/quality,q_90`"
:lazy-load="true"
></u-image>
</view> </view>
<!-- --> <!-- -->
<view class="bg-white m-auto shdow mt-base px-base"> <view class="bg-white m-auto shdow mt-base px-base">
<indexTitle name="热销商品"></indexTitle> <indexTitle name="热销商品"></indexTitle>
<scroll-view scroll-x="true" class="mt-base scroll"> <scroll-view scroll-x="true" class="mt-base scroll">
<view <view class="scroll-item mt-10rpx mr-20rpx" v-for="(item, index) in hotList"
class="scroll-item mt-10rpx mr-20rpx" @tap="$u.route('/pages/product_details/index', { skuId: item.id })" :key="index">
v-for="(item, index) in hotList" <u-image border-radius="15rpx" width="260rpx" height="260rpx"
@tap="$u.route('/pages/product_details/index', { skuId: item.id })" :src="`${item.cover}?x-oss-process=image/resize,w_260/quality,q_90`" :lazy-load="true"></u-image>
:key="index"
>
<u-image
border-radius="15rpx"
width="260rpx"
height="260rpx"
:src="`${item.cover}?x-oss-process=image/resize,w_260/quality,q_90`"
:lazy-load="true"
></u-image>
<view class="text-md w-240rpx line-1 text-hex-bgBase h-40rpx">{{ item.name }}</view> <view class="text-md w-240rpx line-1 text-hex-bgBase h-40rpx">{{ item.name }}</view>
<view class="text-md text-txBase">{{ item.sell_price }}</view> <view class="text-md text-txBase">{{ item.sell_price }}</view>
<view class="flex items-center" v-if="item.vip_price"> <view class="flex items-center" v-if="item.vip_price">
@ -146,19 +103,10 @@
<view class="bg-white m-auto shdow mt-base px-base" v-if="boutique_books.length"> <view class="bg-white m-auto shdow mt-base px-base" v-if="boutique_books.length">
<indexTitle name="精品书籍"></indexTitle> <indexTitle name="精品书籍"></indexTitle>
<scroll-view scroll-x="true" class="mt-base scroll"> <scroll-view scroll-x="true" class="mt-base scroll">
<view <view class="scroll-item mt-10rpx mr-20rpx" v-for="(item, index) in boutique_books"
class="scroll-item mt-10rpx mr-20rpx" @tap="$u.route('/pages/product_details/index', { skuId: item.id })" :key="index">
v-for="(item, index) in boutique_books" <u-image border-radius="15rpx" width="260rpx" height="260rpx"
@tap="$u.route('/pages/product_details/index', { skuId: item.id })" :src="`${item.cover}?x-oss-process=image/resize,w_260/quality,q_90`" :lazy-load="true"></u-image>
:key="index"
>
<u-image
border-radius="15rpx"
width="260rpx"
height="260rpx"
:src="`${item.cover}?x-oss-process=image/resize,w_260/quality,q_90`"
:lazy-load="true"
></u-image>
<view class="text-md w-240rpx line-1 text-hex-bgBase h-40rpx">{{ item.name }}</view> <view class="text-md w-240rpx line-1 text-hex-bgBase h-40rpx">{{ item.name }}</view>
<view class="text-md text-txBase">{{ item.sell_price }}</view> <view class="text-md text-txBase">{{ item.sell_price }}</view>
<view class="flex items-center" v-if="item.vip_price"> <view class="flex items-center" v-if="item.vip_price">
@ -172,19 +120,10 @@
<view class="bg-white m-auto shdow mt-base px-base" v-if="natural_water_feature.length"> <view class="bg-white m-auto shdow mt-base px-base" v-if="natural_water_feature.length">
<indexTitle name="自然水景"></indexTitle> <indexTitle name="自然水景"></indexTitle>
<scroll-view scroll-x="true" class="mt-base scroll"> <scroll-view scroll-x="true" class="mt-base scroll">
<view <view class="scroll-item mt-10rpx mr-20rpx" v-for="(item, index) in natural_water_feature"
class="scroll-item mt-10rpx mr-20rpx" @tap="$u.route('/pages/product_details/index', { skuId: item.id })" :key="index">
v-for="(item, index) in natural_water_feature" <u-image border-radius="15rpx" width="260rpx" height="260rpx"
@tap="$u.route('/pages/product_details/index', { skuId: item.id })" :src="`${item.cover}?x-oss-process=image/resize,w_260/quality,q_90`" :lazy-load="true"></u-image>
:key="index"
>
<u-image
border-radius="15rpx"
width="260rpx"
height="260rpx"
:src="`${item.cover}?x-oss-process=image/resize,w_260/quality,q_90`"
:lazy-load="true"
></u-image>
<view class="text-md w-240rpx line-1 text-hex-bgBase h-40rpx">{{ item.name }}</view> <view class="text-md w-240rpx line-1 text-hex-bgBase h-40rpx">{{ item.name }}</view>
<view class="text-md text-txBase">{{ item.sell_price }}</view> <view class="text-md text-txBase">{{ item.sell_price }}</view>
<view class="flex items-center" v-if="item.vip_price"> <view class="flex items-center" v-if="item.vip_price">
@ -198,19 +137,10 @@
<view class="bg-white m-auto shdow mt-base px-base" v-if="ornamental_creatures.length"> <view class="bg-white m-auto shdow mt-base px-base" v-if="ornamental_creatures.length">
<indexTitle name="观赏生物"></indexTitle> <indexTitle name="观赏生物"></indexTitle>
<scroll-view scroll-x="true" class="mt-base scroll"> <scroll-view scroll-x="true" class="mt-base scroll">
<view <view class="scroll-item mt-10rpx mr-20rpx" v-for="(item, index) in ornamental_creatures"
class="scroll-item mt-10rpx mr-20rpx" @tap="$u.route('/pages/product_details/index', { skuId: item.id })" :key="index">
v-for="(item, index) in ornamental_creatures" <u-image border-radius="15rpx" width="260rpx" height="260rpx"
@tap="$u.route('/pages/product_details/index', { skuId: item.id })" :src="`${item.cover}?x-oss-process=image/resize,w_260/quality,q_90`" :lazy-load="true"></u-image>
:key="index"
>
<u-image
border-radius="15rpx"
width="260rpx"
height="260rpx"
:src="`${item.cover}?x-oss-process=image/resize,w_260/quality,q_90`"
:lazy-load="true"
></u-image>
<view class="text-md w-240rpx line-1 text-hex-bgBase h-40rpx">{{ item.name }}</view> <view class="text-md w-240rpx line-1 text-hex-bgBase h-40rpx">{{ item.name }}</view>
<view class="text-md text-txBase">{{ item.sell_price }}</view> <view class="text-md text-txBase">{{ item.sell_price }}</view>
<view class="flex items-center" v-if="item.vip_price"> <view class="flex items-center" v-if="item.vip_price">
@ -224,19 +154,10 @@
<view class="bg-white m-auto shdow mt-base px-base" v-if="coral_aquatic_plants.length"> <view class="bg-white m-auto shdow mt-base px-base" v-if="coral_aquatic_plants.length">
<indexTitle name="珊瑚水草"></indexTitle> <indexTitle name="珊瑚水草"></indexTitle>
<scroll-view scroll-x="true" class="mt-base scroll"> <scroll-view scroll-x="true" class="mt-base scroll">
<view <view class="scroll-item mt-10rpx mr-20rpx" v-for="(item, index) in coral_aquatic_plants"
class="scroll-item mt-10rpx mr-20rpx" @tap="$u.route('/pages/product_details/index', { skuId: item.id })" :key="index">
v-for="(item, index) in coral_aquatic_plants" <u-image border-radius="15rpx" width="260rpx" height="260rpx"
@tap="$u.route('/pages/product_details/index', { skuId: item.id })" :src="`${item.cover}?x-oss-process=image/resize,w_260/quality,q_90`" :lazy-load="true"></u-image>
:key="index"
>
<u-image
border-radius="15rpx"
width="260rpx"
height="260rpx"
:src="`${item.cover}?x-oss-process=image/resize,w_260/quality,q_90`"
:lazy-load="true"
></u-image>
<view class="text-md w-240rpx line-1 text-hex-bgBase h-40rpx">{{ item.name }}</view> <view class="text-md w-240rpx line-1 text-hex-bgBase h-40rpx">{{ item.name }}</view>
<view class="text-md text-txBase">{{ item.sell_price }}</view> <view class="text-md text-txBase">{{ item.sell_price }}</view>
<view class="flex items-center" v-if="item.vip_price"> <view class="flex items-center" v-if="item.vip_price">
@ -250,19 +171,10 @@
<view class="bg-white m-auto shdow mt-base px-base" v-if="equipment_consumables.length"> <view class="bg-white m-auto shdow mt-base px-base" v-if="equipment_consumables.length">
<indexTitle name="设备耗材"></indexTitle> <indexTitle name="设备耗材"></indexTitle>
<scroll-view scroll-x="true" class="mt-base scroll"> <scroll-view scroll-x="true" class="mt-base scroll">
<view <view class="scroll-item mt-10rpx mr-20rpx" v-for="(item, index) in equipment_consumables"
class="scroll-item mt-10rpx mr-20rpx" @tap="$u.route('/pages/product_details/index', { skuId: item.id })" :key="index">
v-for="(item, index) in equipment_consumables" <u-image border-radius="15rpx" width="260rpx" height="260rpx"
@tap="$u.route('/pages/product_details/index', { skuId: item.id })" :src="`${item.cover}?x-oss-process=image/resize,w_260/quality,q_90`" :lazy-load="true"></u-image>
:key="index"
>
<u-image
border-radius="15rpx"
width="260rpx"
height="260rpx"
:src="`${item.cover}?x-oss-process=image/resize,w_260/quality,q_90`"
:lazy-load="true"
></u-image>
<view class="text-md w-240rpx line-1 text-hex-bgBase h-40rpx">{{ item.name }}</view> <view class="text-md w-240rpx line-1 text-hex-bgBase h-40rpx">{{ item.name }}</view>
<view class="text-md text-txBase">{{ item.sell_price }}</view> <view class="text-md text-txBase">{{ item.sell_price }}</view>
<view class="flex items-center" v-if="item.vip_price"> <view class="flex items-center" v-if="item.vip_price">
@ -297,6 +209,8 @@ import popupView from './components/popup-view.vue';
import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js'; import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';
import { checkUpdate } from '@/utils/check-update'; import { checkUpdate } from '@/utils/check-update';
import CartMixin from '@/pages/shop_cart/mixin'; import CartMixin from '@/pages/shop_cart/mixin';
import { wxMnpLogin } from '@/utils/login'
const defaultBanner = { const defaultBanner = {
wechat_mini_top_banner: [], wechat_mini_top_banner: [],
wechat_mini_recommend_banner: [], wechat_mini_recommend_banner: [],
@ -331,11 +245,11 @@ export default {
}, },
noMoreSize: 1, noMoreSize: 1,
}, },
boutique_books:[],// boutique_books: [],//
natural_water_feature:[],// natural_water_feature: [],//
ornamental_creatures:[],// ornamental_creatures: [],//
coral_aquatic_plants:[],// coral_aquatic_plants: [],//
equipment_consumables:[]// equipment_consumables: []//
}; };
}, },
computed: { computed: {
@ -356,23 +270,25 @@ export default {
return shareObj; return shareObj;
}, },
onLoad(e) { onLoad(e) {
/* #ifdef MP-WEIXIN */
wxMnpLogin()
/* #endif */
this.init(); this.init();
this.getpopAdver(); this.getpopAdver();
this.$store.dispatch('user/getUserInfo');
this.$store.dispatch('user/getNewsNum'); this.$store.dispatch('user/getNewsNum');
}, },
methods: { methods: {
//- //-
async getrecGoods(){ async getrecGoods() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.$api this.$api
.get('/v1/product/part', { .get('/v1/product/part', {
params: { params: {
part:'boutique_books', part: 'boutique_books',
}, },
}) })
.then((res) => { .then((res) => {
this.boutique_books=res.data this.boutique_books = res.data
resolve(res); resolve(res);
}) })
.catch((err) => { .catch((err) => {
@ -381,16 +297,16 @@ export default {
}); });
}, },
// //
async getnatural_water_feature(){ async getnatural_water_feature() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.$api this.$api
.get('/v1/product/part', { .get('/v1/product/part', {
params: { params: {
part:'natural_water_feature', part: 'natural_water_feature',
}, },
}) })
.then((res) => { .then((res) => {
this.natural_water_feature=res.data this.natural_water_feature = res.data
resolve(res); resolve(res);
}) })
.catch((err) => { .catch((err) => {
@ -399,16 +315,16 @@ export default {
}); });
}, },
// //
async getornamental_creatures(){ async getornamental_creatures() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.$api this.$api
.get('/v1/product/part', { .get('/v1/product/part', {
params: { params: {
part:'ornamental_creatures', part: 'ornamental_creatures',
}, },
}) })
.then((res) => { .then((res) => {
this.ornamental_creatures=res.data this.ornamental_creatures = res.data
resolve(res); resolve(res);
}) })
.catch((err) => { .catch((err) => {
@ -417,16 +333,16 @@ export default {
}); });
}, },
// //
async getcoral_aquatic_plants(){ async getcoral_aquatic_plants() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.$api this.$api
.get('/v1/product/part', { .get('/v1/product/part', {
params: { params: {
part:'coral_aquatic_plants', part: 'coral_aquatic_plants',
}, },
}) })
.then((res) => { .then((res) => {
this.coral_aquatic_plants=res.data this.coral_aquatic_plants = res.data
resolve(res); resolve(res);
}) })
.catch((err) => { .catch((err) => {
@ -435,16 +351,16 @@ export default {
}); });
}, },
// //
async getequipment_consumables(){ async getequipment_consumables() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.$api this.$api
.get('/v1/product/part', { .get('/v1/product/part', {
params: { params: {
part:'equipment_consumables', part: 'equipment_consumables',
}, },
}) })
.then((res) => { .then((res) => {
this.equipment_consumables=res.data this.equipment_consumables = res.data
resolve(res); resolve(res);
}) })
.catch((err) => { .catch((err) => {
@ -454,7 +370,7 @@ export default {
}, },
// //
init() { init() {
return Promise.all([this.getHot(), this.getBanner(), this.getRecommend(),this.getrecGoods(),this.getnatural_water_feature(),this.getornamental_creatures(),this.getcoral_aquatic_plants(),this.getequipment_consumables()]); return Promise.all([this.getHot(), this.getBanner(), this.getRecommend(), this.getrecGoods(), this.getnatural_water_feature(), this.getornamental_creatures(), this.getcoral_aquatic_plants(), this.getequipment_consumables()]);
}, },
async downCallback() { async downCallback() {
await this.init(); await this.init();
@ -553,14 +469,14 @@ export default {
return this.bannerList[key] ?? []; return this.bannerList[key] ?? [];
}, },
jumpByOption(e) { jumpByOption(e) {
const whiteRouter = ['/pages/user_sign/index', '/pageA/user_sign/index','/pages/points/swap','/pageB/lucky/index']; const whiteRouter = ['/pages/user_sign/index', '/pageA/user_sign/index', '/pages/points/swap', '/pageB/lucky/index'];
const tabRouter = ['/pages/sort/index', '/pages/shop_cart/index', '/pages/healthy/index', '/pages/me/me']; const tabRouter = ['/pages/sort/index', '/pages/shop_cart/index', '/pages/healthy/index', '/pages/me/me'];
if (!!e.jump_link) { if (!!e.jump_link) {
if (e.jump_type == 1) { if (e.jump_type == 1) {
if (tabRouter.findIndex((el) => e.jump_link?.includes(el)) >= 0) { if (tabRouter.findIndex((el) => e.jump_link?.includes(el)) >= 0) {
const params = this.getParams(e.jump_link); const params = this.getParams(e.jump_link);
// console.log(params); // console.log(params);
if(Object.keys(params.params).length>0) { if (Object.keys(params.params).length > 0) {
uni.$emit('jumpTab', params.params) uni.$emit('jumpTab', params.params)
uni.switchTab({ uni.switchTab({
url: params.path url: params.path
@ -579,9 +495,9 @@ export default {
getParams(str) { getParams(str) {
var result = {}; var result = {};
const arr =str.split('?') const arr = str.split('?')
const url = arr[0]; const url = arr[0];
if(arr.length>1){ if (arr.length > 1) {
var strParams = arr[1]; var strParams = arr[1];
var arrParams = strParams.split('&'); var arrParams = strParams.split('&');
arrParams.forEach((item) => { arrParams.forEach((item) => {

View File

@ -61,7 +61,7 @@
</template> </template>
<script> <script>
// import { getWxCode } from '@/utils/login'; // import { getWxCode } from '@/utils/login';
import { wxMnpLogin,getWxCode } from '@/utils/login' import { getWxCode } from '@/utils/login'
import { mapMutations } from 'vuex'; import { mapMutations } from 'vuex';
export default { export default {
data() { data() {
@ -115,9 +115,6 @@ export default {
const { code } = e.detail; const { code } = e.detail;
if(!code) return if(!code) return
const invite_code = uni.getStorageSync('INVITE_CODE'); const invite_code = uni.getStorageSync('INVITE_CODE');
// if(!this.$store.getters.token){
// await wxMnpLogin(invite_code)
// }
const params = { const params = {
openid: uni.getStorageSync("openid"), openid: uni.getStorageSync("openid"),
invite_code: invite_code invite_code: invite_code

View File

@ -5,70 +5,77 @@
</template> </template>
<script> <script>
import { import { strToParams } from '@/utils/tools';
strToParams import { wxMnpLogin } from '@/utils/login'
} from '@/utils/tools'; export default {
import { data() {
wxMnpLogin return {
} from '@/utils/login' scene: null
export default { };
data() { },
return { async onLoad(e) {
scene: null //
}; /* #ifdef MP-WEIXIN */
}, wxMnpLogin()
onLoad(e) { /* #endif */
const scene = strToParams(decodeURIComponent(e.scene))
console.log(scene) const scene = strToParams(decodeURIComponent(e.scene))
this.scene = scene console.log(scene)
// this.scene = scene
uni.removeStorageSync('desk'); //
// invite_code uni.removeStorageSync('desk');
if (scene.i) { // invite_code
uni.setStorageSync('INVITE_CODE', scene.i) if (scene.i) {
} uni.setStorageSync('INVITE_CODE', scene.i)
// }
if (scene.p) { //
uni.reLaunch({ if (scene.p) {
url: '/pages/product_details/index?skuId=' + scene.product uni.reLaunch({
}) url: '/pages/product_details/index?skuId=' + scene.product
} })
// }
else if (scene.o) { //
uni.reLaunch({ else if (scene.o) {
url: '/pageB/select_product/com_order?id=' + scene.o uni.reLaunch({
}) url: '/pageB/select_product/com_order?id=' + scene.o
} })
// 线 }
else if (scene.oo) { // 线
uni.reLaunch({ else if (scene.oo) {
url: '/pageB/offline_order/user/order_preview?id=' + scene.oo uni.reLaunch({
}) url: '/pageB/offline_order/user/order_preview?id=' + scene.oo
} })
// }
else if (scene.d) { //
const desk = scene.d else if (scene.d) {
uni.setStorageSync('desk', desk); const desk = scene.d
// uni.setStorageSync('desk', desk);
const id = scene.c //
// id const id = scene.c
const mid = scene.s // id
uni.reLaunch({ const mid = scene.s
url: `/pageB/select_product/search?mid=${mid}&cid=${id}` uni.reLaunch({
}); url: `/pageB/select_product/search?mid=${mid}&cid=${id}`
} });
// }
else if (scene.vip) { //
uni.reLaunch({ else if (scene.vip) {
url: `/pageB/svip/index` uni.reLaunch({
}); url: `/pageB/svip/index`
} });
// }
else { // scene=draw%3D1
uni.switchTab({ else if (scene.draw) {
url: '/pages/index/index' uni.reLaunch({
}) url: '/pageB/lucky/index?id=' + scene.draw
} });
}
//
else {
uni.switchTab({
url: '/pages/index/index'
})
} }
} }
}
</script> </script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -1,6 +1,4 @@
import { import { http } from '@/utils/request'
http
} from '@/utils/request'
import store from '@/store' import store from '@/store'
@ -19,28 +17,22 @@ export function getWxCode() {
} }
//小程序静默登录 //小程序静默登录
export async function wxMnpLogin(invite_code){ export async function wxMnpLogin(invite_code) {
store.commit('user/LOGOUT') // 判断是否有 auth_token
const code = await getWxCode() var token = store.getters.token
invite_code=invite_code?invite_code: uni.getStorageSync('INVITE_CODE') if (token) {
await silentLogin({code,invite_code}) // 获取 当前用户信息
await store.dispatch('user/getUserInfo', false)
return;
}
// 没有 auth_token, 再调用 wx.login 登录
store.commit('user/LOGOUT')
const code = await getWxCode()
invite_code = invite_code ? invite_code : uni.getStorageSync('INVITE_CODE')
const resData = await http.post(`/v1/wechat-mini/login`, { code, invite_code }, { custom: { toast: false } })
uni.setStorageSync("openid", resData.openid)
if (resData.token) {
store.commit('user/LOGIN', resData.token)
}
} }
async function silentLogin(data){
// const provider = 'wechat-mini'
// const resData = await http.post(`/v1/socialite/code-auth/${provider}`,data,{
// custom:{
// toast:false
// }
// })
const resData = await http.post(`/v1/wechat-mini/login`,data,{
custom:{
toast:false
}
})
uni.setStorageSync("openid", resData.openid)
if (resData.token) {
store.commit('user/LOGIN', resData.token)
}
}