Commit b8bf8d29 authored by heyihong's avatar heyihong
parents 5b93760a c86d8a32
<script setup>
import { getTokenUser } from './api/index';
import { sgyOrderGetStatus } from './api/order';
import testJson from './static/json/test.json';
import { getToken } from './utils/auth';
import { setOrderDic } from './utils/orderDic';
onLaunch(() => {
if (!getToken()) signIn();
console.log('App Launch');
sgyOrderGetStatus().then((res) => {
if (res.code === 0) {
setOrderDic(res.data.store);
}
});
});
onShow(() => {
......
<template>
<view @tap="toShop(item.shopId)" class="card" v-for="(item, index) in cardData" :key="index">
<view @tap="toShop(item.shopId)" class="card" v-for="item in cardData" :key="item.shopId">
<image class="img" :src="item.shopLogo" mode="aspectFill" />
<view class="right">
<text class="text">{{ item.shopName }}</text>
......
......@@ -94,3 +94,11 @@ export function receiveCoupon(data) {
data,
});
}
// 列表顶部优惠商品
export function prodSpecial(data) {
return request({
url: `/sgyrdd/prod/special`,
method: 'GET',
data,
});
}
......@@ -3,7 +3,7 @@ import { request } from '../utils/request';
// 订单列表接口
export function getOrderList(data) {
return request({
url: '/sgyrdd/sgyOrder/groupBuy/page',
url: '/sgyrdd/sgyOrder/page',
method: 'GET',
data,
});
......@@ -52,3 +52,20 @@ export function getShopDetail(data) {
data,
});
}
// 立即支付
export function repaymentApi(data) {
return request({
url: '/sgyrdd/sgyOrder/repayment',
method: 'POST',
data,
});
}
// 查询各类订单状态
export function sgyOrderGetStatus(data) {
return request({
url: '/sgyrdd/sgyOrder/getStatus',
method: 'GET',
data,
});
}
<template>
<div class="container">
<div class="container" style="padding-bottom: 10rpx">
<view class="bg-img"></view>
<view class="top">
<!-- 搜索 -->
<Search>
<Search @toSearch="toSearch">
<image class="food" :src="pics" mode="widthFix" />
</Search>
<!-- 类别选择 -->
<scroll-view class="scroll-x" scroll-x="true" @scroll="scroll">
<view class="foodCard" v-for="(item, index) in 5" :key="index">
<image class="test5" src="../../static/index/test5.png" mode="widthFix" />
<scroll-view
v-if="topDiscountedProducts.length > 0"
class="scroll-x"
scroll-x="true"
@scroll="scroll"
>
<view
@click="jumpProductDetails(item.prodId)"
class="foodCard"
v-for="(item, index) in topDiscountedProducts"
:key="index"
>
<view class="test5">
<image class="img1" :src="imgUrl + item.pic" />
<image class="img2" src="../../static/index/icon-tab.png" />
</view>
<view class="content">
<text class="title">【热销】贵阳火神烧烤单人畅吃</text>
<text class="title">{{ item.prodName }}</text>
<view class="labelBox">
<view class="item" v-for="(item, index) in 4" :key="index">30天有效</view>
<view class="item" v-for="(lab, index) in item.labels" :key="index">{{ lab }}</view>
<view
style="background: transparent"
class="item"
v-if="!item.labels || item.labels.length === 0"
></view>
</view>
<view class="price">
<view class="discounts">4.5折</view>
<text class="text">39.9</text>
<text class="text2">58</text>
<!-- <view class="discounts">4.5折</view> -->
<text class="text">{{ item.price }}</text>
<text class="text2">{{ item.oriPrice }}</text>
<view class="btn">
<text class="text3">仅剩余5张</text>
<image class="qiang" src="../../static/index/qiang.png" mode="widthFix" />
<!-- <text class="text3">仅剩余5张</text> -->
<text class="text3">立即抢购</text>
<!-- <image class="qiang" src="../../static/index/qiang.png" mode="widthFix" /> -->
</view>
</view>
</view>
......@@ -59,7 +78,7 @@
</view>
</view>
<view class="bootom-bottom">
<view
<!-- <view
@tap="choice(index)"
class="item"
:class="{ light: active === index }"
......@@ -67,69 +86,170 @@
:key="index"
>
{{ item }}
</view>
</view> -->
</view>
<!-- 美食类别 -->
<Classification v-show="rotate" />
<Classification v-show="rotate" :category="categoryData" @foodCategory="foodCategory" />
<!-- 附近筛选 -->
<Position v-show="rotate2" />
<Position v-show="rotate2" @nearby="nearby" @popular="popular" @region="region" />
<!-- 排序筛选 -->
<Sort v-show="rotate3" />
<Sort v-show="rotate3" @sortParams="sortParams" />
</view>
<FoodDetails :cardData="cardData" />
<view
style="width: 100%; text-align: center; font-size: 24rpx; margin-top: 10rpx; color: #888989"
v-if="params.isEnd"
>
没有更多啦~
</view>
</div>
</template>
<script setup>
import {} from 'vue';
import FoodDetails from '../../components/index/FoodDetails.vue';
import Search from '../../components/index/Search.vue';
import Classification from '../../components/index/Classification.vue';
import Position from '../../components/index/Position.vue';
import Sort from '../../components/index/Sort.vue';
import { getByParentId, merchantList } from '../../api/index';
import { getByParentId, merchantList, prodSpecial } from '../../api/index';
const isLoadReachBottom = ref(null);
const imgUrl = import.meta.env.VITE_APP_IMG_URL;
const business = reactive(['优选商家', '超值半价', '今日可订', '经典单人']);
const active = ref(null);
const categoryData = ref([]);
const rotate = ref(false);
const rotate2 = ref(false);
const rotate3 = ref(false);
const parentIds = ref(null);
const categoryId = ref(null);
const topDiscountedProducts = ref([]);
const params = ref({
current: 1,
size: 15,
// lon,
// lat,
lon: 106.68650025025502,
lat: 26.567192352601154,
isEnd: false,
});
const pics = ref(null);
onLoad((option) => {
const { parentId, pic } = option;
parentIds.value = parentId;
categoryId.value = parentId;
pics.value = pic;
query(parentId);
prodSpecialFn();
});
onMounted(() => {
getMerchantList();
getLocationFn().then((res) => {
const { lat, lon } = res;
getMerchantList(lat, lon);
});
});
// distance参数来源
const nearby = (distance) => {
console.log('distance', distance);
if (distance === 0) {
delete params.value.distance;
} else {
params.value.distance = distance;
}
refresh().then(() => {
getMerchantList();
});
};
// communityName参数来源
const popular = (communityName) => {
params.value.communityName = communityName;
if (params.value.area) {
delete params.value.area;
}
refresh().then(() => {
getMerchantList();
});
};
// 搜索
const toSearch = (keyword) => {
params.value.keyword = keyword;
refresh().then(() => {
getMerchantList();
});
};
// 排序参数来源
const sortParams = (sortType) => {
const { sortName, sortMode } = sortType;
params.value.sortName = sortName;
params.value.sortMode = sortMode;
refresh().then(() => {
getMerchantList();
});
};
// area参数来源
const region = (area) => {
console.log('area', area);
params.value.area = area;
if (params.value.communityName) {
delete params.value.communityName;
}
refresh().then(() => {
getMerchantList();
});
};
onReachBottom(() => {
console.log('到底了');
if (isLoadReachBottom.value === true) return;
isLoadReachBottom.value = true;
getMerchantList().then(() => {
isLoadReachBottom.value = false;
});
});
// categoryId参数来源
const foodCategory = (categoryId) => {
params.value.categoryIds = [categoryId];
refresh().then(() => {
getMerchantList();
});
};
/**
* @description: 刷新
*/
function refresh() {
return new Promise((resolve, reject) => {
cardData.value = [];
params.value.current = 1;
params.value.isEnd = false;
resolve();
});
}
// 根据父级分类id查询子分类列表
const query = (parentId) => {
getByParentId(parentId).then((res) => {
console.log('打印res', res);
categoryData.value = res.data;
});
};
function jumpProductDetails(prodId) {
xma.navigateTo({
url: `/pages/packageDetails/packageDetails?prodId=${prodId}`,
params: {
productId: 123,
},
});
}
const prodSpecialFn = () => {
prodSpecial({ categoryId: categoryId.value }).then((res) => {
res.data.data = res.data.data.map((el) => {
if (el.labels) {
el.labels = el.labels.split(',');
}
return el;
});
topDiscountedProducts.value = res.data.data;
});
};
// onLoad(option) {
// //option为object类型,会序列化上个页面传递的参数
// console.log(option.id); //打印出上个页面传递的参数。
// console.log(option.name); //打印出上个页面传递的参数。
// },
const choice = (index) => {
active.value = index;
};
const cardData = ref([
{
text: '测试',
},
{
text: '测试',
},
{
text: '测试',
},
]);
const cardData = ref([]);
const locationFiltering = (index) => {
switch (index) {
......@@ -152,14 +272,19 @@ const locationFiltering = (index) => {
};
// 商家列表分页-搜索列表
const getMerchantList = () => {
const data = {
current: 1,
size: 10,
lon: 106.68650025025502,
lat: 26.567192352601154,
};
merchantList(data).then((res) => {
console.log('商家列表', res);
if (params.value.isEnd === true)
return new Promise((resolve) => {
resolve();
});
xma.showLoading({
title: '加载中...',
mask: true,
});
return merchantList(params.value).then((res) => {
if (res.data.content.length < params.value.size) {
params.value.isEnd = true;
}
params.value.current += 1;
res.data.content.forEach((item) => {
item.shopLogo = import.meta.env.VITE_APP_IMG_URL + item.shopLogo;
if (item.evaluationVos.length > 0) {
......@@ -170,9 +295,30 @@ const getMerchantList = () => {
item.labels = item.labels.split(',');
}
});
cardData.value = res.data.content;
return new Promise((resolve) => {
cardData.value = cardData.value.concat(res.data.content);
xma.hideLoading();
setTimeout(() => {
resolve();
}, 500);
});
});
};
function getLocationFn() {
return new Promise((resolve, reject) => {
xma.getLocation({
type: 'wgs84',
isHighAccuracy: true,
success: function (res) {
// 经纬度
resolve({ lat: res.latitude, lon: res.longitude });
},
fail: function (err) {
return err;
},
});
});
}
</script>
<style lang="scss" scoped>
......@@ -190,7 +336,7 @@ page {
}
.top {
width: 100%;
height: 666rpx;
min-height: 420rpx;
border-radius: 0rpx 0rpx 0rpx 0rpx;
overflow: hidden;
.food {
......@@ -213,6 +359,22 @@ page {
overflow: hidden;
.test5 {
width: 100%;
height: 168 * 2rpx;
position: relative;
.img1 {
width: 100%;
height: 168 * 2rpx;
position: absolute;
top: 0;
left: 0;
}
.img2 {
width: 100%;
position: absolute;
left: 0;
bottom: 0;
height: 56rpx;
}
}
.content {
display: flex;
......@@ -276,7 +438,8 @@ page {
border-radius: 10rpx;
background: #fcdbdb;
box-sizing: border-box;
margin-left: 66rpx;
margin-left: auto;
margin-right: 20rpx;
.text3 {
font-size: 20rpx;
color: #fa5151;
......
......@@ -76,7 +76,12 @@
</view>
</view>
<view class="nearby-bootom">
<view class="contentBox" v-for="(item, index) in foodNearbyData" :key="index">
<view
@click="jumpProductDetails(item)"
class="contentBox"
v-for="(item, index) in foodNearbyData"
:key="index"
>
<!-- <image class="img" src="../../static/index/eatFood.png" mode="widthFix" /> -->
<image class="img" :src="item.shopLogo" mode="aspectFill" />
<text class="one">{{ item.shopName }}</text>
......@@ -201,6 +206,11 @@ onMounted(() => {
getMerchantList();
getCouponMainList();
});
function jumpProductDetails(item) {
xma.navigateTo({
url: '/pages/shop/shop?shopId=' + item.shopId,
});
}
// 登录
// const signIn = () => {
// getTokenUser(testJson).then((res) => {
......
......@@ -18,25 +18,26 @@
<image src="@/static/shop/wx-icon.png"></image>
微信
</view>
<radio class="radio" color="#F12A2A" value="'wx'" :checked="'wx' == selectType" />
<radio class="radio" color="#F12A2A" value="TENPAY" :checked="'TENPAY' == selectType" />
</view>
<view class="pay-item">
<view class="icon">
<image src="@/static/shop/yzf-icon.png"></image>
翼支付
</view>
<radio class="radio" color="#F12A2A" value="'yzf'" :checked="'yzf' == selectType" />
<radio class="radio" color="#F12A2A" value="BESTPAY" :checked="'BESTPAY' == selectType" />
</view>
</radio-group>
<view class="footer">
<wd-button type="error">危险按钮</wd-button>
<wd-button type="error" @tap="toPay">立即支付</wd-button>
</view>
</view>
</wd-popup>
</template>
<script setup>
const selectType = ref('wx');
const emits = defineEmits(['payment']);
const selectType = ref('TENPAY');
const show = ref(false);
function radioChange(evt) {
......@@ -44,7 +45,14 @@ function radioChange(evt) {
selectType.value = value;
}
const open = () => {
const toPay = () => {
emits('payment', { selectType: selectType.value, orderNumber: orderNumber.value });
show.value = false;
};
const orderNumber = ref('');
const open = (e) => {
orderNumber.value = e;
show.value = true;
};
const close = () => {
......
......@@ -43,10 +43,10 @@
</view>
<view
class="btn-info"
v-if="item.status == 3"
@tap="handleDetail(item.orderNumber)"
v-if="item.status == 3 || item.status == 2"
@tap="handleQrcode(item)"
>
查看预约
核销码
</view>
<view
class="btn-info"
......@@ -63,14 +63,18 @@
<view
class="btn-error"
v-if="item.status == 2 || item.status == 3 || item.status == 4"
@click="handleRefund(item.orderNumber)"
@click="handleRefund(item)"
>
申请退款
</view>
<view class="btn-error" v-if="item.status == 5" @tap="anotherOrder(item)">
再来一单
</view>
<view class="btn-error" v-if="item.status == 1" @tap="payNow(item.orderNumber)">
<view
class="btn-error"
v-if="item.status == 1"
@tap="openPayment(item.orderNumber, index)"
>
立即支付
</view>
</view>
......@@ -83,14 +87,20 @@
</block>
</wd-tabs>
</view>
<Payment ref="PaymentRef"></Payment>
<Payment ref="PaymentRef" @payment="payNow"></Payment>
</view>
</template>
<script setup>
import Header from './components/Header/index.vue';
import Payment from './components/Payment/index.vue';
import { getOrderList, deleteOrderApi, cancelOrderApi } from '@/api/order';
import {
getOrderList,
deleteOrderApi,
cancelOrderApi,
repaymentApi,
getOrderDetail,
} from '@/api/order';
const fileDomain = import.meta.env.VITE_APP_IMG_URL;
const tabs = ref([
......@@ -130,6 +140,38 @@ const statusList = ref({
7: '已退款',
});
onShow(() => {
console.log(pendingPaymentOrder.value);
if (pendingPaymentOrder.value) {
// 查询订单状态决定是否支付
getOrderDetail({ orderNumber: pendingPaymentOrder.value }).then((res) => {
console.log(res.data.status);
switch (res.data.status) {
case '1':
xma.showToast({
title: '支付失败',
icon: 'error',
duration: 2000,
});
pendingPaymentOrder.value = null;
break;
case '2':
xma.redirectTo({
url: `/pages/shop/paymentSuccessful?outTradeNos=${pendingPaymentOrder.value}`,
});
break;
case '3':
xma.redirectTo({
url: `/pages/shop/paymentSuccessful?outTradeNos=${pendingPaymentOrder.value}`,
});
break;
default:
break;
}
});
}
});
// 触底函数
onReachBottom(() => {
if (dataList.value.length >= total.value) {
......@@ -190,22 +232,6 @@ const initDataList = () => {
getList();
};
const handleDetail = (id) => {
uni.navigateTo({
url: `/pages/order/detail?orderNumber=${id}`,
});
};
/**
* 拨打商家电话
* @param {*} phoneNumber
*/
function callShopPhone(phoneNumber) {
xma.makePhoneCall({
phoneNumber, // 仅为示例
});
}
/**
* 删除订单
* @param {*} orderNumber
......@@ -249,12 +275,33 @@ const handleCancel = (orderNumber) => {
};
/**
* 立即支付
* 唤起支付组件
* @param {*} orderNumber
*/
const changeIndex = ref(0);
const PaymentRef = ref(null);
const payNow = (orderNumber) => {
PaymentRef.value.open();
const openPayment = (orderNumber, idx) => {
changeIndex.value = idx;
PaymentRef.value.open(orderNumber);
};
/**
* 立即支付
* @param {*} orderNumber
*/
const pendingPaymentOrder = ref(null); // 待支付订单
const payNow = async (data) => {
console.log(data);
const param = {
orderNumber: data.orderNumber,
tradeType: data.selectType,
};
const res = await repaymentApi(param);
const { paymentUrl, outTradeNo } = res.data.result;
// 修改列表待付款订单号
dataList.value[changeIndex.value].orderNumber = outTradeNo;
pendingPaymentOrder.value = outTradeNo;
window.location.href = paymentUrl;
};
/**
......@@ -279,21 +326,60 @@ const onFinish = async (orderNumber) => {
initDataList();
};
const handleDetail = (id) => {
// 清空查询待付款状态
pendingPaymentOrder.value = null;
uni.navigateTo({
url: `/pages/order/detail?orderNumber=${id}`,
});
};
/**
* 拨打商家电话
* @param {*} phoneNumber
*/
function callShopPhone(phoneNumber) {
// 清空查询待付款状态
pendingPaymentOrder.value = null;
xma.makePhoneCall({
phoneNumber, // 仅为示例
});
}
/**
* 再来一单
*/
const anotherOrder = (item) => {
// 清空查询待付款状态
pendingPaymentOrder.value = null;
xma.navigateTo({
url: `/pages/shop/confirmOrder?prodId=${item.orderItems[0].prodId}&skuId=${item.orderItems[0].skuId}`,
});
};
/**
* 查看核销码
*/
const handleQrcode = (item) => {
// 清空查询待付款状态
pendingPaymentOrder.value = null;
xma.navigateTo({
url: `/pages/order/ticketCode?orderNumber=${item.orderNumber}`,
});
};
/**
* 售后详情
*/
const handleRemark = (item) => {
xma.navigateTo({
url: `/pages/order/remark?orderNumber=${item.orderNumber}&shopName=${item.shopName}`,
});
};
/**
* 申请退款
*/
const handleRefund = (item) => {
xma.navigateTo({
url: `/pages/order/refund?orderNumber=${item.orderNumber}`,
......
......@@ -7,12 +7,20 @@
<text class="title">单号:1111111111</text>
</view>
<view class="content-item">
<view class="item-left">
<view class="item-top">
<image class="item-img" mode="aspectFill" src="/static/ticket/logo.png"></image>
<view class="item-info">
<text>血糯米</text>
<text>¥0.01</text>
</view>
</view>
<view class="item-buttom">
<text></text>
<text>1</text>
<text>件商品 实付款</text>
<text></text>
<text class="price">0.01</text>
</view>
</view>
</view>
</view>
......@@ -33,10 +41,31 @@ page {
margin: 0 auto;
.content {
padding-top: 44px;
padding: 108rpx 10rpx 0;
display: flex;
flex-direction: column;
gap: 20rpx;
.content-box {
background-color: #fff;
border-radius: 16rpx;
padding: 0 20rpx;
display: flex;
flex-direction: column;
.content-item {
border-bottom: 1rpx solid #f3f3f3;
padding: 20rpx 0;
.title {
font-size: 28rpx;
color: #333;
}
.item-top {
}
}
}
}
}
</style>
......@@ -25,7 +25,13 @@
<h5>上传图片/视频</h5>
</wd-col>
</wd-row>
<wd-upload accept="media" multiple :file-list="fileList" :action="action" @change="handleChange"></wd-upload>
<wd-upload
accept="media"
multiple
:file-list="fileList"
:action="action"
@change="handleChange"
></wd-upload>
<wd-row>
<wd-col :span="24" custom-class="text">
......
......@@ -4,21 +4,21 @@
<view class="content">
<!-- 使用状态 -->
<view class="status">
<view class="status-text">老凯里酸汤鱼双人餐</view>
<view class="detail">有效期:2023-07-04 23:59</view>
<view class="status-text">{{ orderDetail.shopName }}</view>
<view class="detail">有效期:{{ orderDetail.receiverTime }}</view>
</view>
<!-- 券码信息 -->
<view class="info">
<view class="box">
<text class="title">酸汤鱼双人套餐</text>
<text class="code">0115 8156 9126</text>
<text class="title">{{ orderDetail.orderItems[0].prodName }}</text>
<text class="code">{{ orderDetail.orderNumber }}</text>
</view>
<view class="rectangle-with-semicircles"></view>
<view class="qrcode line">
<!-- 二维码 -->
<view class="qr-box">
<image src="@/static/order/QR-code.png" class="qr"></image>
<image :src="qrcode" class="qr"></image>
<text class="qr-text">请向商家出示此核销码</text>
</view>
</view>
......@@ -29,6 +29,45 @@
<script setup>
import Header from './components/Header/index.vue';
import { getOrderDetail } from '@/api/order';
import QRCode from 'qrcode';
onLoad((options) => {
console.log(options);
getOrderDetailFn(options.orderNumber);
});
/**
* 获取订单详情
*/
const orderDetail = ref();
function getOrderDetailFn(orderNumber) {
getOrderDetail({ orderNumber }).then((res) => {
orderDetail.value = res.data;
const outTradeNo = res.data.orderNumber;
const indexOfDash = outTradeNo.indexOf('-');
if (indexOfDash !== -1) {
res.data.orderNumber = outTradeNo.substring(indexOfDash + 1);
} else {
console.log(`订单编号 ${outTradeNo} 中没有找到 "-" 符号。`);
}
if (orderDetail.value.status === '2' || orderDetail.value.status === '3') {
codeDetail(orderDetail.value.orderNumber);
}
});
}
const qrcode = ref('');
const codeDetail = (item) => {
const data = {
type: 'write-off',
no: item,
};
QRCode.toDataURL(JSON.stringify(data)).then((img) => {
console.log(img);
qrcode.value = img;
});
};
</script>
<style scoped lang="scss">
......@@ -39,6 +78,7 @@ page {
.container {
width: 375 * 2rpx;
margin: 0 auto;
.content {
padding-top: 44px;
display: flex;
......
......@@ -182,14 +182,25 @@ onShow(() => {
if (outTradeNos.value) {
// 查询订单状态决定是否支付
getOrderDetail({ orderNumber: outTradeNos.value }).then((res) => {
if (orderDetail.value.status === '2' || orderDetail.value.status === '3') {
xma.redirectTo({
url: `/pages/shop/paymentSuccessful?outTradeNos=${outTradeNos.value}`,
});
} else {
xma.redirectTo({
url: `/pages/shop/paymentSuccessful?outTradeNos=${outTradeNos.value}`,
});
switch (res.data.status) {
case '1':
xma.showToast({
title: '支付失败',
icon: 'error',
duration: 2000,
});
break;
case '2':
xma.redirectTo({
url: `/pages/shop/paymentSuccessful?outTradeNos=${outTradeNos.value}`,
});
case '3':
xma.redirectTo({
url: `/pages/shop/paymentSuccessful?outTradeNos=${outTradeNos.value}`,
});
break;
default:
break;
}
});
}
......
const TokenKey = 'ORDER_DICT';
export function getOrderDic() {
return xma.getStorageSync(TokenKey);
}
export function setOrderDic(token) {
return xma.setStorageSync(TokenKey, token);
}
export function removeOrderDic() {
return xma.removeStorageSync(TokenKey);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment