feat(custom): 新增若干营销功能
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-07-17 22:32:56 +08:00
parent 243b414675
commit d3bb76a858
15 changed files with 507 additions and 7 deletions

9
src/api/code.ts Normal file
View File

@@ -0,0 +1,9 @@
import request from "../utils/request";
// 获取二维码信息
export const getQrCode = (data: object) =>
request("/qrcode/get", data, "POST");
// 绑定二维码
export const bindQrCode = (data: object) =>
request("/qrcode/bind", data, "POST");

View File

@@ -86,3 +86,7 @@ export const getActiveOrderDetail = (data: object) =>
// 校验交易密码
export const checkTradePwd = (data: object) =>
request('/user/check/payPassword', data, 'POST');
// 获取活动商品或者活动积分商品
export const getHdOrJfGoods = (data: object) =>
request('/activity/goods', data, 'POST');

View File

@@ -73,7 +73,7 @@ export default defineAppConfig({
},
{
root: 'pages/marketing',
pages: ['sign/index'],
pages: ['sign/index', 'yq/index', 'scratch/index'],
},
{
root: 'pages/search',

View File

@@ -1,15 +1,57 @@
<template>
<view class="flex flex-col items-center pt-[208px]">
<back />
<image class="h-[152px]" :src="par.header" />
<view class="list mt-[30px]">
<view class="bg-white w-[700px] h-[300px] rounded-[20px]"></view>
<view class="list mt-[30px]" v-if="data.length > 0">
<view
class="bg-white p-[20px] w-[700px] rounded-[20px] mb-[20px] flex"
v-for="(item, index) in data"
:key="index">
<image
class="w-[200px] h-[200px] rounded-[10px] mr-[10px]"
:src="item.cover"></image>
<view class="flex-1 flex flex-col justify-between">
<nut-ellipsis
style="font-size: 20px"
direction="end"
:rows="2"
:content="item.name"></nut-ellipsis>
<view>
<view class="text-[#9E9E9E] text-[26px]"
>剩余: {{ item.stock }}</view
>
<view class="flex justify-between items-end">
<view>
<view class="text-[#F83D3D] text-[30px] font-bold"
>{{ item.number }}</view
>
<view class="text-[#F83D3D] text-[30px] font-bold"
>{{ item.exchange }}积分</view
>
</view>
<nut-button type="primary" size="mini" @click="toPay(item)"
>购买</nut-button
>
</view>
</view>
</view>
</view>
</view>
<nut-empty
class="mt-[130px]"
v-else
image="empty"
description="暂时没有商品"></nut-empty>
</view>
</template>
<script setup lang="ts">
import {ref} from 'vue';
import Taro from '@tarojs/taro';
import {getHdOrJfGoods, createActiveOrder} from '@/api/goods';
import {getUserPoint} from '@/api/admin';
import {addCart} from '@/api/cart';
import Back from '@/components/Back.vue';
const par = ref<any>({});
@@ -32,7 +74,66 @@ Taro.useLoad(e => {
...par.value,
type: e.type,
};
getList();
});
const data = ref<any[]>([]);
const page = ref({
page: 1,
pageSize: 10,
itemCount: 0,
});
const getList = async () => {
Taro.showLoading({
title: '加载中',
});
const res = await getHdOrJfGoods({
PageNum: page.value.page,
PageSize: page.value.pageSize,
type: Number(par.value.type),
});
data.value.push(...res.data.data);
page.value.itemCount = res.data.total;
Taro.hideLoading();
};
Taro.useReachBottom(() => {
if (page.value.page < Math.ceil(page.value.itemCount / page.value.pageSize)) {
page.value.page++;
getList();
}
});
const toPay = async item => {
const tk = Taro.getStorageSync('token');
if (!tk) {
Taro.navigateTo({
url: '/pages/users/login/index',
});
return;
}
await addCart({
Bid: item.Store.bid,
Gid: item.gid,
Number: 1,
});
const user_info = Taro.getStorageSync('userInfo');
const data = await getUserPoint({
phone: user_info.data.phone,
bid: item.Store.bid,
});
const res = await createActiveOrder({
Bid: [item.Store.bid],
custID: data.data.store_user_id,
});
Taro.navigateTo({
url: `/pages/goods/pay/index?oid=${res.data.oid}&bid=${item.Store.bid}&OrderType=1`,
});
};
</script>
<style lang="scss">

View File

@@ -115,7 +115,8 @@ page {
}
.ad {
background-image: url('https://jdt168.oss-cn-guangzhou.aliyuncs.com/ad.png');
// background-image: url('https://jdt168.oss-cn-guangzhou.aliyuncs.com/ad.png');
background-image: url('https://pic.imgdb.cn/item/6697aa0dd9c307b7e95c94d9.png');
background-size: 100% 100%;
height: 180px;
margin: 20px;

View File

@@ -41,7 +41,8 @@
<view class="text">{{ item.name }}</view>
</view>
</view>
<view class="ad" @click="showTips('该功能暂未开放')"></view>
<navigator class="ad" url="/pages/marketing/yq/index" open-type="navigate" hover-class="none">
</navigator>
<MerList :get-user-location="getUserLocal" />
</view>
</template>

View File

@@ -0,0 +1,3 @@
export default definePageConfig({
navigationBarTitleText: "刮奖",
});

View File

@@ -0,0 +1,67 @@
page {
background-color: #ffab00;
}
.bg {
position: relative;
background-image: url('https://pic.imgdb.cn/item/6697c1bbd9c307b7e97c2665.png');
background-size: 100% 100%;
background-repeat: no-repeat;
height: 1800px;
.box {
position: absolute;
top: 378px;
left: 50%;
transform: translate(-50%, 0);
.tc {
height: 365px;
width: 575px;
}
.textBg {
background-image: url('https://pic.imgdb.cn/item/6697d455d9c307b7e9932fbc.png');
background-size: 100% 100%;
background-repeat: no-repeat;
font-weight: bolder;
font-size: 60px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
}
.btn {
background-image: url('https://pic.imgdb.cn/item/6697c87fd9c307b7e984a370.png');
background-size: 100% 100%;
width: 600px;
height: 130px;
position: absolute;
top: 760px;
left: 50%;
transform: translate(-50%, 0);
}
.img {
background-image: url('https://pic.imgdb.cn/item/6697c956d9c307b7e985b5b9.png');
background-size: 100% 100%;
width: 700px;
height: 500px;
position: absolute;
top: 950px;
left: 50%;
transform: translate(-50%, 0);
}
.img1 {
background-image: url('https://pic.imgdb.cn/item/6697c956d9c307b7e985b5c0.png');
background-size: 100% 100%;
width: 700px;
height: 500px;
position: absolute;
top: 1500px;
left: 50%;
transform: translate(-50%, 0);
}
}

View File

@@ -0,0 +1,141 @@
<template>
<view class="bg">
<view class="box">
<image
v-if="status === 0"
class="tc"
@click="kk"
src="https://pic.imgdb.cn/item/6697c82bd9c307b7e9843788.png" />
<view
class="tc text-[#F33D00] text-center textBg"
v-else-if="status === 1">
<view>恭喜获得游戏豆奖励</view>
<view>{{ codeInfo.pulse }}</view>
</view>
<image
class="tc"
v-else
src="https://pic.imgdb.cn/item/6697d32ed9c307b7e991c2c5.png"></image>
</view>
<view class="btn">
<nut-button
v-if="!isLogin"
style="width: 100%; height: 100%; opacity: 0"
type="primary"
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
>手机号一键登录</nut-button
>
<nut-button
v-else
style="width: 100%; height: 100%; opacity: 0"
type="primary"
@click="ok"
>领取</nut-button
>
</view>
<view class="img"></view>
<view class="img1"></view>
</view>
</template>
<script setup lang="ts">
import Taro from '@tarojs/taro';
import {ref} from 'vue';
import {getPhone, login} from '@/api/user';
import {getQrCode, bindQrCode} from '@/api/code';
import './index.scss';
const status = ref(0);
const optData = ref<any>({});
const isLogin = ref(false);
const codeInfo = ref<any>({});
Taro.useLoad(opt => {
optData.value = opt;
const tk = Taro.getStorageSync('token');
if (tk) {
isLogin.value = true;
}
getInfo();
});
const getInfo = async () => {
const res = await getQrCode({
code: optData.value.qid,
});
codeInfo.value = res.data.data;
};
const kk = () => {
if (codeInfo.value.pulse > 0) {
status.value = 1;
} else {
status.value = 2;
}
};
const ok = async () => {
const res = await bindQrCode({
qid: optData.value.qid,
});
Taro.showToast({
title: res.msg,
icon: 'none',
mask: true,
});
setTimeout(() => {
Taro.switchTab({
url: '/pages/index/index',
});
}, 2000);
};
const userInfo = ref({
phone: '',
});
const getPhoneNumber = async (e: any) => {
Taro.showLoading({
title: '授权手机号中',
mask: true,
});
const {code} = e.detail;
const res = await getPhone({
code: code,
});
userInfo.value.phone = res.data.phone;
if (!res.data.phone)
return Taro.showToast({
title: '手机号获取失败',
icon: 'none',
});
Taro.login({
success: async res => {
Taro.setStorageSync('wx_code', res.code);
const ress = await login({
Code: Taro.getStorageSync('wx_code'),
Phone: userInfo.value.phone,
Referee: Taro.getStorageSync('bind_id'),
});
Taro.showToast({
title: `${ress.msg},请再次领取`,
icon: 'success',
});
Taro.setStorageSync('token', ress.data.token);
Taro.removeStorageSync('wx_code');
Taro.removeStorageSync('bind_id');
isLogin.value = true;
},
complete: () => {
Taro.hideLoading();
},
});
};
</script>
<style lang="scss"></style>

View File

@@ -0,0 +1,4 @@
export default definePageConfig({
navigationBarTitleText: '',
navigationStyle: 'custom',
});

View File

@@ -0,0 +1,32 @@
page {
background-image: url('https://pic.imgdb.cn/item/6697ab53d9c307b7e95e032c.png');
background-size: 100% 100%;
background-repeat: no-repeat;
}
.tag {
width: 140px;
height: 40px;
border-radius: 8px;
background-image: linear-gradient(
90deg,
rgb(254, 43, 34) 0%,
rgb(255, 193, 0) 100%
);
color: #fff;
font-size: 24px;
text-align: center;
line-height: 40px;
}
.stock {
width: 140px;
height: 40px;
border-radius: 8px;
border: 0.5px solid rgba(254, 46, 33, 1);
color: rgba(254, 46, 33, 1);
font-size: 24px;
text-align: center;
line-height: 40px;
margin-left: 30px;
}

View File

@@ -0,0 +1,128 @@
<template>
<view class="flex flex-col items-center pt-[208px]">
<back />
<image
class="h-[600px] mb-[10px]"
src="https://pic.imgdb.cn/item/6697ac7bd9c307b7e95f3f39.png"
mode="scaleToFill" />
<view class="bg-white p-[20px] w-[700px] rounded-[20px]">
<view class="flex flex-col" v-if="data.length > 0">
<view class="mb-[20px] flex" v-for="(item, index) in data" :key="index">
<image
class="w-[200px] h-[200px] rounded-[10px] mr-[10px]"
:src="item.cover"
mode="scaleToFill" />
<view class="flex-1 flex flex-col justify-between">
<view>
<nut-ellipsis
direction="end"
:rows="2"
style="font-size: 20px"
:content="item.name"></nut-ellipsis>
<view class="flex items-center mt-[10px]">
<view class="tag">直播摇球机</view>
<view class="stock">剩余: {{ item.stock }}</view>
</view>
</view>
<view
class="flex justify-between items-center bg-[#FEF3F1] rounded-full w-full h-[70px] pl-[20px]">
<view class="flex">
<view class="text-[#F83D3D] text-[28px] font-bold"
>{{ item.number }}</view
>
<view class="text-[#F83D3D] text-[28px] font-bold ml-[20px]"
>{{ item.exchange }}积分</view
>
</view>
<nut-button type="primary" size="small" @click="toPay(item)">
<view class="flex items-center">
<view class="pr-[5px] text-[28px]">购买</view>
<RectRight size="15" />
</view>
</nut-button>
</view>
</view>
</view>
</view>
<nut-empty v-else image="empty" description="暂时没有商品"></nut-empty>
</view>
</view>
</template>
<script setup lang="ts">
import {ref} from 'vue';
import Taro from '@tarojs/taro';
import {getHdOrJfGoods, createActiveOrder} from '@/api/goods';
import {getUserPoint} from '@/api/admin';
import {addCart} from '@/api/cart';
import Back from '@/components/Back.vue';
import {RectRight} from '@nutui/icons-vue-taro';
import './index.scss';
const data = ref<any[]>([]);
Taro.useLoad(() => {
getList();
});
const page = ref({
page: 1,
pageSize: 10,
itemCount: 0,
});
const getList = async () => {
Taro.showLoading({
title: '加载中',
});
const res = await getHdOrJfGoods({
PageNum: page.value.page,
PageSize: page.value.pageSize,
type: 3,
});
data.value.push(...res.data.data);
page.value.itemCount = res.data.total;
Taro.hideLoading();
};
Taro.useReachBottom(() => {
if (page.value.page < Math.ceil(page.value.itemCount / page.value.pageSize)) {
page.value.page++;
getList();
}
});
const toPay = async item => {
console.log(item);
const tk = Taro.getStorageSync('token');
if (!tk) {
Taro.navigateTo({
url: '/pages/users/login/index',
});
return;
}
await addCart({
Bid: item.Store.bid,
Gid: item.gid,
Number: 1,
});
const user_info = Taro.getStorageSync('userInfo');
const data = await getUserPoint({
phone: user_info.data.phone,
bid: item.Store.bid,
});
const res = await createActiveOrder({
Bid: [item.Store.bid],
custID: data.data.store_user_id,
});
Taro.navigateTo({
url: `/pages/goods/pay/index?oid=${res.data.oid}&bid=${item.Store.bid}&OrderType=1`,
});
};
</script>
<style lang="scss"></style>