Compare commits

...

21 Commits

Author SHA1 Message Date
6deef6cdce 1 2026-04-14 18:11:00 +08:00
e894689918 最新版代码提交 2026-04-13 16:12:25 +08:00
26e57e4891 1 2026-04-10 19:00:01 +08:00
32fa3e9bd2 1 2026-04-10 17:32:50 +08:00
4002f91a54 1 2026-04-10 16:50:22 +08:00
a2fadc57b8 1 2026-04-10 15:47:09 +08:00
b251c899ca 1 2026-04-10 13:17:20 +08:00
cdf0bc5a01 1 2026-04-10 10:19:42 +08:00
7a490f0ffc 1 2026-04-09 17:03:37 +08:00
34148c6084 1 2026-04-09 16:50:25 +08:00
9b6b76f747 1 2026-04-09 15:54:26 +08:00
6ea50b824f 1 2026-04-09 14:31:44 +08:00
72e481c6c5 1 2026-04-09 10:12:23 +08:00
124beb0666 1 2026-04-08 16:11:18 +08:00
078e0bc8ab 1 2026-04-08 10:47:25 +08:00
1739401cb8 1 2026-04-07 19:48:56 +08:00
3afa2e8c10 1 2026-04-07 18:47:12 +08:00
7d1083bf5c fix: calculate actual total item count for multi-item orders 2026-04-07 17:57:00 +08:00
41f6f612fa 1 2026-04-07 17:51:16 +08:00
3b8c991e1a 1 2026-04-04 18:09:09 +08:00
46bbce84aa 1 2026-04-04 17:20:53 +08:00
23 changed files with 3528 additions and 2593 deletions

View File

@ -2,7 +2,7 @@ import request from "../utils/request";
import { LOGIN, GET_PHONE, USER_SHARE,USER_WALLET,RECHARGE_WALLET,USER_WXPAY,USER_TRANSACTION,USER_ADDITIONAL,MEMBER_TYPES,
USER_RECHARGE,USER_REDEEM,USER_HolderList,USER_MEMBERSHIP,USER_BINDPETS,USER_PETBINDING,USER_DISCOUNTFEE,USER_COUPONLIST,CANCEL_PET_ORDER,
GET_VIP_PRICE,POINTS_RECHARGE_LIST,POINTS_DONATE,POINTS_RECORDS,POINTS_RANK,OSS_STS,DONATION_SUMMARY,
USER_DISPATCHFEE,CANCEL_MALL_ORDER,DOUY_REVIEW
USER_DISPATCHFEE,CANCEL_MALL_ORDER,DOUY_REVIEW,CANCEL_NOMO_ORDER,LOGIN_PHONE
} from "./url";
// 微信登陆
export const getCodeByWxLogin = () => {
@ -10,7 +10,7 @@ export const getCodeByWxLogin = () => {
tt.login({
provider: "toutiao",
success: function (loginRes) {
// console.log(loginRes,'?1?')
console.log(loginRes,'?1?')
resolve(loginRes.code);
},
fail: function (err) {
@ -23,7 +23,7 @@ export const getCodeByWxLogin = () => {
import Store from "../store";
// 登录鉴权
export const login = (nickName, avatarUrl) => {
export const login = ( phone) => {
return getCodeByWxLogin().then((code) => {
// 从 vuex 中获取 referrerID如果通过二维码扫描进入
const referrerID = Store.state.user?.referrerID || 0;
@ -32,17 +32,11 @@ export const login = (nickName, avatarUrl) => {
url: LOGIN,
method: "POST",
data: {
nickName:nickName,
avatarUrl:avatarUrl,
code: code,
source:'douyin',
referrerID:0,
referrerType:'douyin'
// // yaoqing_code: inviteCode || null,
// phone: phone || null,
// source: "wechat",
// referrerID: Number(referrerID) || 0,
// referrerType: "wechat"
phone: phone || null,
source: 'douyin',
referrerID: 0,
referrerType: 'douyin'
},
}).then((res) => {
// 登录接口使用完 referrerID 后,清除一次,避免重复使用
@ -54,12 +48,13 @@ export const login = (nickName, avatarUrl) => {
});
};
// 获取手机号
export const getPhone = (code) => {
export const getPhone = (phoneCode, loginCode) => {
return request({
url: GET_PHONE,
method: "POST",
data: {
code: code
code: phoneCode,
loginCode: loginCode
},
});
};
@ -74,6 +69,18 @@ export const userShare = (id) => {
});
};
export const login_phone = (phone) => {
return request({
url: LOGIN_PHONE,
method: "POST",
data: {
phone
},
});
};
// 用户钱包
export const userWllet = (id) => {
return request({
@ -164,10 +171,11 @@ export const getDonationSummary = () => {
};
// 抖音审核
export const getdouyReview = () => {
export const getdouyReview = (data) => {
return request({
url: DOUY_REVIEW,
method: "GET"
method: "POST",
data,
});
};
@ -225,6 +233,15 @@ export const cancelPetOrderMall = (data) => {
});
};
// 未支付取消商城订单
export const cancelUnpaid = (data) => {
return request({
url: CANCEL_NOMO_ORDER,
method: "POST",
data: data
});
};
// 绑定宠物列表
export const bindPets = (data) => {
return request({

View File

@ -115,12 +115,12 @@ export const updateCartSelect = ({ is_select,cart_id }) => {
};
// 删除购物车
export const deleteCart = ({ cart_id }) => {
export const deleteCart = ({ id }) => {
return request({
url: DELETE_CART,
method: "post",
data: {
cart_id,
id,
},
});
};

View File

@ -56,8 +56,13 @@ export const CANCEL_PET_ORDER = '/order/pet/cancel'
// 抖音审核接口
export const DOUY_REVIEW = '/douyin/goods/order/appointment'
// 抖音未支付订单取消接口
export const CANCEL_NOMO_ORDER = '/douyin/goods/order/cancel'
export const LOGIN_PHONE = '/api/v1/auth/login'
// 取消商城接口
export const CANCEL_MALL_ORDER = '/douyin/goods/order/cancel'
export const CANCEL_MALL_ORDER = '/douyin/goods/order/refund'
// 卡包列表接口
export const USER_HolderList = '/membership/instances'
@ -198,7 +203,7 @@ export const GET_GOODS_CATEGORY = "/product/type/list";
// 商品列表
export const GET_GOODS_LIST = "/douyin/goods/product/online/query";
// 商品详情
export const GET_GOODS_DETAIL = "/product/detail";
export const GET_GOODS_DETAIL = "/douyin/goods/product/detail";
// 获取优惠券列表
export const GET_COUPON_LIST = "/app/coupon/coupon_list";
@ -227,7 +232,7 @@ export const UPDATE_CART_NUM = "/cart/update";
// 选择购物车商品
export const UPDATE_CART_SELECT = "/cart/select/all";
// 删除购物车
export const DELETE_CART = "/product/cart/delete";
export const DELETE_CART = "/douyin/goods/order/refund";
// 创建订单
export const CREATE_ORDER_NEW = "/product/order/create";
@ -236,9 +241,9 @@ export const CREATE_CART_ORDER = "/douyin/goods/order/create";
// 订单支付
export const PAY_ORDER_NEW = "/ttpay/jsapi";
// 订单列表
export const SHOP_ORDER_LIST = "/product/order/list";
export const SHOP_ORDER_LIST = "/douyin/goods/order/list";
// 订单详情
export const SHOP_ORDER_DETAILS = "/product/order/show";
export const SHOP_ORDER_DETAILS = "/douyin/goods/order/show";
// 取消订单
export const SHOP_ORDER_CANCEL = '/app/order/order_quxiao'
// 提醒发货

View File

@ -3,8 +3,8 @@ export default {
appName: "Wagoo",
appShareName: "Wagoo",
appId: "wx00e2dcdc7c02b23a",
apiBaseUrl: "https://api.wagoo.me/api/v1", // 服务端测试地址
// apiBaseUrl: "https://api.wagoo.pet/api/v1", // 服务端生产地址
// apiBaseUrl: "https://api.wagoo.me/api/v1", // 服务端测试地址
apiBaseUrl: "https://api.wagoo.pet/api/v1", // 服务端生产地址
// apiBaseUrl: "http:192.168.30.79", //本地接口
tencentMapKey: "WSBBZ-7OXK4-46QUC-KFB7B-4N3W7-M2BXM",
tencentSecret: "vb7D0PGj7xUvmOLuJz2Jd7ykTMpjiWRJ",

View File

@ -78,31 +78,30 @@
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao": {
"usingComponents": true,
"appid": "tte57093cd7a7fbf2401",
"libVersion": "2.0.0",
"setting": {
"urlCheck": false,
"minified": true,
"postcss": true,
"es6": true,
"minifyJS": true,
"minifyWXML": true,
"minifyWXSS": true
"mp-toutiao" : {
"usingComponents" : true,
"appid" : "tte57093cd7a7fbf2401",
"libVersion" : "2.0.0",
"setting" : {
"urlCheck" : false,
"minified" : true,
"postcss" : true,
"es6" : true,
"minifyJS" : true,
"minifyWXML" : true,
"minifyWXSS" : true
},
"privacy" : {
"usePrivacyCheck" : true,
"requiredPrivateInfos" : [ "makePhoneCall" ]
},
"plugins" : {
"lifeServicePlugin" : {
"version" : "*",
"provider" : "tta5a3d31e3aecfb9b11"
}
}
},
"privacy": {
"usePrivacyCheck": true,
"requiredPrivateInfos": ["makePhoneCall"]
}
},
"plugins": {
"lifeServicePlugin": {
"version": "*",
"provider": "tta5a3d31e3aecfb9b11"
}
},
"mp-qq" : {
"usingComponents" : true
}

View File

@ -96,7 +96,7 @@
</view> -->
</view>
<view class="payBtn" @click.stop="writeOff">
核销
预约
</view>
</view>
</view>
@ -147,6 +147,12 @@ export default {
components: {
InfoCell,
},
props: {
orderId: {
type: [String, Number],
default: null
}
},
data() {
return {
imgPrefix,
@ -156,7 +162,7 @@ export default {
ORDER_TYPE_RESERVATION,
ORDER_TYPE_SITE,
orderType: ORDER_TYPE_RESERVATION,
selectedPetType: PET_TYPE_CAT, // 默认选中“猫”
selectedPetType: PET_TYPE_CAT, // 默认选中"猫"
petInfo: {}, // 兼容下游,取 selectedPets[0]
selectedPets: [], // 多选宠物列表
parkState: "",
@ -168,11 +174,24 @@ export default {
address: null,
catHtmlData: "",
dogHtmlData: "",
tip: ''
tip: '',
localOrderId: null, // 本地存储的 orderId
};
},
mounted() {
this.initData();
// 如果有传入的 orderId保存到本地
if (this.orderId) {
this.localOrderId = this.orderId;
}
},
watch: {
// 监听 orderId 变化
orderId(newVal) {
if (newVal) {
this.localOrderId = newVal;
}
}
},
computed: {
// 展示价格discount_price 数组相加的总和
@ -186,26 +205,87 @@ export default {
}
},
methods: {
// 用于接收从父页面传递的数据
onShowFun(orderId) {
if (orderId) {
this.localOrderId = orderId;
}
},
// 核销按钮点击处理
async writeOff () {
const data = {
goods_order_id:1, //抖音商品订单id整数
order_date:'2026-03-01', //预约日期2026-03-01格式
period_id:1, //预约时间段id整数
address_id:1, //地址id整数
recipient_name:'用户姓名', //用户姓名
phone:123, //用户手机
park_desc:123, //停车描述
note:'哈哈' // 备注
// 校验必填项
if (Object.keys(this.reservationTime).length === 0) {
uni.showToast({
title: "请选择预约时间",
icon: "none",
});
return;
}
if (!this.address) {
uni.showToast({
title: "请选择服务地址",
icon: "none",
});
return;
}
if (!this.parkState) {
uni.showToast({
title: "请选择停车状况",
icon: "none",
});
return;
}
if (!this.localOrderId) {
uni.showToast({
title: "订单ID缺失",
icon: "none",
});
return;
}
const data = {
goods_order_id: Number(this.localOrderId), //抖音商品订单id整数
order_date: this.reservationTime.date, //预约日期('2026-03-01'格式)
period_id: Number(this.reservationTime.id), //预约时间段id整数
address_id: Number(this.address.id), //地址id整数
recipient_name: this.address.name || '用户姓名', //用户姓名
phone: this.address.phone || '', //用户手机
park_desc: this.parkState || '', //停车描述
note: this.otherParkState || '' // 备注
};
uni.showLoading({
title: "处理中",
mask: true,
});
getdouyReview(data).then((res) => {
uni.hideLoading();
if (res.code == 0) {
uni.showToast({
title: "预约成功",
icon: "none",
});
}
});
// 预约成功后清空数据并跳转
setTimeout(() => {
uni.reLaunch({
url: "/pages/client/index/index?activePageId=homePage",
});
}, 1500);
} else {
uni.showToast({
title: res.msg || "预约失败",
icon: "none",
});
}
}).catch((err) => {
uni.hideLoading();
console.error("预约失败:", err);
uni.showToast({
title: "预约失败,请重试",
icon: "none",
});
});
},
getPetShortName(pet) {

View File

@ -301,7 +301,7 @@
"style": {
"navigationBarTitleText": "申请售后"
}
},
},
{
"path": "details",
"style": {
@ -322,7 +322,7 @@
"style": {
"navigationBarTitleText": "商城订单",
"usingComponents": {
"pay-button-sdk": "tta5a3d31e3aecfb9b11://pay-button"
"pay-button": "tta5a3d31e3aecfb9b11://pay-button"
}
}
},

View File

@ -1,17 +1,28 @@
<template>
<view class="loginContainer">
<view class="body">
<image class="login-ground-img" :src="`${imgPrefix}loginGroundImg.png`" mode="widthFix" />
<image
class="login-ground-img"
:src="`${imgPrefix}loginGroundImg.png`"
mode="widthFix"
/>
<view class="btnConent">
<button v-show="!checked" class="loginBtn" @click="unCheckAndGetPhoneNumber">
<button
v-show="!checked"
class="loginBtn"
@click="unCheckAndGetPhoneNumber"
>
抖音用户信息授权登录
</button>
<button v-show="checked" class="loginBtn" @tap="getPhoneNumber" >
抖音用户信息授权登录
<button
v-show="checked"
class="loginBtn"
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
>
抖音用户信息授权登录
</button>
<view class="notLoginBtn" @click="goBack">
暂不登录
</view>
<view class="notLoginBtn" @click="goBack"> 暂不登录 </view>
</view>
</view>
@ -19,7 +30,11 @@
<view class="radioWrapper">
<view class="checkbox-wrapper" @click.stop="changeChecked">
<view class="checkbox" :class="{ 'checkbox-checked': checked }">
<image v-if="checked" class="check-icon" :src="require('@/static/images/y.png')" />
<image
v-if="checked"
class="check-icon"
:src="require('@/static/images/y.png')"
/>
</view>
<!-- <view v-if="uncheckMessageDialog" class="tooltip">
<view class="tooltip-content">请先勾选同意后再进行登录</view>
@ -28,7 +43,9 @@
</view>
<text class="radioText">
请阅读并同意
<text class="color" @click.stop="ptfwxy">帮宠到家平台服务协议</text>
<text class="color" @click.stop="ptfwxy"
>帮宠到家平台服务协议</text
>
<text class="color" @click.stop="ysxy">隐私协议</text>
</text>
</view>
@ -54,6 +71,16 @@ export default {
},
onLoad(options) {
this.yaoqing_code = options.yaoqing_code
tt.login({
provider: "toutiao",
success: function (loginRes) {
console.log('获取 login code 成功:', loginRes);
},
fail: function (err) {
console.log('获取 login code 失败:', err);
},
});
},
mounted() { },
methods: {
@ -81,14 +108,14 @@ export default {
duration: 2000
});
},
getmembeInfo(nickName,avatarUrl) {
getmembeInfo(phone) {
const inviteCode = this.yaoqing_code ? this.yaoqing_code : getApp().globalData.inviteCode
uni.showLoading({
title: "登录中...",
icon: "none",
mask: true,
});
login(nickName,avatarUrl).then((res) => {
login(phone).then((res) => {
uni.hideLoading()
this.$store.dispatch("user/setToken", res?.data?.token || "");
this.$store.dispatch("user/setUserInfo", res?.data || {});
@ -143,77 +170,128 @@ export default {
// });
// }),
async getPhoneNumber(e) {
// console.log(e,'?')
// return
// 检查是否有 code
// if (!e.detail.code) {
console.log('获取手机号事件:', e);
this.getmembeInfo(e.detail.code)
// // 检查是否有 code
// if (!e.detail || !e.detail.code) {
// uni.showToast({
// title: "获取手机号失败,请重试",
// title: "用户取消授权或获取手机号失败",
// icon: "none",
// });
// return;
// }
// uni.showLoading({
// title: "获取手机号中...",
// title: "登录中...",
// icon: "none",
// mask: true,
// });
try {
let that = this
tt.getUserProfile({
// try {
// const that = this;
// let loginCode = null;
success(res) {
console.log(res,'???')
// this.nickName = res.res.userInfo.nickName
// this.avatarUrl = res.userInfo.avatarUrl
that.getmembeInfo(res.userInfo.nickName,res.userInfo.avatarUrl)
// console.log(res,'--=')
},
fail(res) {
console.log("getUserProfile 调用失败", res);
},
// // 先获取 login code
// try {
// loginCode = await new Promise((resolve, reject) => {
// tt.login({
// provider: "toutiao",
// success: function (loginRes) {
// console.log('获取 login code 成功:', loginRes);
// resolve(loginRes.code);
// },
// fail: function (err) {
// console.log('获取 login code 失败:', err);
// reject(err);
// },
// });
// });
// } catch (loginErr) {
// throw new Error('获取登录凭证失败');
// }
});
// // 拿着 phone code 和 login code 获取手机号
// let phone = null;
// try {
// const codeRes = await getPhone(e.detail.code, loginCode);
// phone = codeRes?.data?.phoneNumber || "";
// console.log('获取手机号成功:', phone);
// } catch (phoneErr) {
// console.error('获取手机号失败:', phoneErr);
// throw new Error('获取手机号失败');
// }
// const inviteCode = this.yaoqing_code ? this.yaoqing_code : getApp().globalData.inviteCode
// console.log('获取到邀请码----->', inviteCode)
// 手机号登录
// 拿着code获取手机号
// const codeRes = await getPhone(e.detail.code);
// const phone = codeRes?.data?.phoneNumber || "";
// if (!phone) {
// throw new Error('获取手机号失败,请重试');
// }
// if (!phone) {
// uni.hideLoading();
// uni.showToast({
// title: "获取手机号失败,请重试",
// icon: "none",
// });
// return;
// }
} catch (error) {
uni.hideLoading();
console.error("获取手机号失败:", error);
// 检查是否是 access_token 相关错误
const errorMsg = error?.message || error || "";
if (errorMsg.includes("access_token") || errorMsg.includes("invalid credential")) {
uni.showToast({
title: "服务暂时不可用,请稍后重试",
icon: "none",
duration: 3000,
});
} else {
uni.showToast({
title: errorMsg || "获取手机号失败,请重试",
icon: "none",
});
}
}
// 获取用户信息
// tt.getUserProfile({
// success: async (profileRes) => {
// console.log('获取用户信息成功:', profileRes);
// const nickName = profileRes.userInfo?.nickName || '';
// const avatarUrl = profileRes.userInfo?.avatarUrl || '';
// try {
// const inviteCode = that.yaoqing_code ? that.yaoqing_code : getApp().globalData.inviteCode;
// // 登录
// const loginRes = await login(nickName, avatarUrl, phone);
// uni.hideLoading();
// that.$store.dispatch("user/setToken", loginRes?.data?.token || "");
// that.$store.dispatch("user/setUserInfo", loginRes?.data || {});
// var pages = getCurrentPages();
// if (inviteCode) {
// uni.reLaunch({
// url: "/pages/client/index/index",
// });
// return;
// }
// if (pages.length === 1) {
// uni.reLaunch({
// url: "/pages/client/index/index",
// });
// return;
// }
// uni.navigateBack();
// } catch (loginErr) {
// uni.hideLoading();
// console.error('登录失败:', loginErr);
// uni.showToast({
// title: loginErr || "登录失败,请重试",
// icon: "none",
// });
// }
// },
// fail: (profileErr) => {
// uni.hideLoading();
// console.log("getUserProfile 调用失败", profileErr);
// uni.showToast({
// title: "获取用户信息失败",
// icon: "none",
// });
// },
// });
// } catch (error) {
// uni.hideLoading();
// console.error("获取手机号失败:", error);
// const errorMsg = error?.message || error || "";
// if (errorMsg.includes("access_token") || errorMsg.includes("invalid credential")) {
// uni.showToast({
// title: "服务暂时不可用,请稍后重试",
// icon: "none",
// duration: 3000,
// });
// } else {
// uni.showToast({
// title: errorMsg || "获取手机号失败,请重试",
// icon: "none",
// });
// }
// }
},
loginAction() {
if (!this.checked) {
@ -300,8 +378,8 @@ export default {
.notLoginBtn {
background-color: #fff;
color: #FF19A0;
border: 1rpx solid #FF19A0;
color: #ff19a0;
border: 1rpx solid #ff19a0;
border-radius: 300rpx;
padding: 26rpx 0rpx;
text-align: center;
@ -333,13 +411,13 @@ export default {
display: flex;
align-items: center;
justify-content: center;
background: #FFFFFF;
background: #ffffff;
transition: all 0.3s ease;
flex-shrink: 0;
&.checkbox-checked {
border-color: #FF19A0;
background: #FF19A0;
border-color: #ff19a0;
background: #ff19a0;
}
.check-icon {
@ -362,7 +440,7 @@ export default {
.tooltip-content {
font-size: 24rpx;
color: #FFFFFF;
color: #ffffff;
line-height: 1.4;
}
@ -385,7 +463,7 @@ export default {
color: #9b939a;
.color {
color: #FF19A0;
color: #ff19a0;
font-size: 22rpx;
}
}

View File

@ -1,196 +1,146 @@
<template>
<view class="flex-row-start goods-item" @click.stop="$emit('clickCard', data)">
<image class="goods-img" :src="data.product_pic" mode="aspectFill" />
<view class="goods-content">
<view class="text-multi-ellipse fs-28 app-fc-main app-font-bold goods-name">
{{ data.product_name || "" }}
</view>
<!-- <view class="flex-row-start label">
<image class="hot-icon" :src="`${imgPrefix}mall-hot.png`"></image>
<view class="fs-20 app-fc-main label-name">{{data.sales}}人买过</view>
</view> -->
<view class="price-row">
<view class="flex-row-start">
<text class="fs-28 price-text">
¥
<text class="fs-28">{{data.prices[0].original_price || 0 }}</text>
</text>
<!-- <text class="fs-20 price-label">到手价</text> -->
</view>
<text class="fs-24 origin-price" v-if="minPrice.price_shichang">
¥{{ minPrice.price_shichang || 0 }}
</text>
</view>
<view class="buy-now-btn-wrapper" @click.stop="handleBuyNow">
<text class="buy-now-btn">立即购买</text>
</view>
</view>
</view>
<view class="goods-item" >
<image @click.stop="handleBuyNow" class="goods-img" :src="data.product_pic" mode="aspectFill" />
<view class="fs-24 app-fc-main goods-name">
{{ data.product_name || "" }}
</view>
<view class="flex-row-start label">
<image class="hot-icon" :src="`${imgPrefix}mall-hot.png`"></image>
<view class="fs-20 app-fc-main label-name">32人买过</view>
</view>
<view class="flex-row-between" style="margin-top: 12rpx; align-items: baseline;">
<view class="price-wrapper">
<text class="fs-28" style="color: #FF19A0;">
¥
<text class="fs-28">{{
data.prices[0].original_price / 100 || 0
}}</text>
</text>
</view>
<view class="buy-now-btn" @click.stop="handleBuyNow">
立即购买
</view>
</view>
</view>
</template>
<script>
import { imgPrefix } from '@/utils/common';
import {
imgPrefix
} from '@/utils/common';
export default {
props: {
index: {
type: Number,
default: 0,
},
data: {
type: Object,
default: () => {},
},
},
data() {
return {
imgPrefix,
isAnimating: false,
};
},
computed: {
// minPrice() {
// let minPrice = {};
// let minPriceValue = 0;
// this.data.price_list.map((v) => {
// if (!minPriceValue || minPriceValue > +v.price) {
// minPriceValue = +v.price;
// minPrice = { ...v };
// }
// });
// return minPrice;
// },
labelList() {
return this.data.label.split(",").filter((v) => !!v);
},
},
mounted() {},
methods: {
// 触发添加购物车动画
triggerAddCartAnimation() {
this.isAnimating = true;
setTimeout(() => {
this.isAnimating = false;
}, 600);
},
// 立即购买
handleBuyNow() {
this.$emit('buyNow', this.data);
},
},
};
export default {
props: {
index: {
type: Number,
default: 0,
},
data: {
type: Object,
default: () => {},
},
},
data() {
return {
imgPrefix,
};
},
computed: {
labelList() {
return (this.data?.label || "").split(",").filter((v) => !!v);
},
},
mounted() {},
methods: {
handleBuyNow() {
// 触发购买事件,通知父组件
this.$emit('addToCar', this.data);
},
triggerAddCartAnimation() {
// 保留方法以兼容父组件调用
}
},
};
</script>
<style lang="scss" scoped>
.goods-item {
background: #fff;
border-radius: 40rpx;
width: 100%;
padding: 20rpx;
box-sizing: border-box;
margin-bottom: 20rpx;
position: relative;
border-bottom: 1rpx solid #F5F5F5;
.goods-item {
background: #fff;
border-radius: 16rpx;
padding: 20rpx;
box-sizing: border-box;
margin-bottom: 22rpx;
position: relative;
width: 100%;
min-width: 0;
overflow: hidden;
.goods-img {
border-radius: 20rpx;
width: 160rpx;
height: 160rpx;
}
.goods-img {
display: block;
width: 100%;
max-width: 100%;
height: 260rpx;
border-radius: 16rpx;
background: #f5f5f5;
}
.goods-content {
flex: 1;
overflow: hidden;
margin-left: 20rpx;
}
.goods-name {
margin: 16rpx 0 12rpx 0;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
word-wrap: break-word;
word-break: break-all;
font-size: 24rpx;
color: #3D3D3D;
}
.goods-name {
margin: 0 0 12rpx;
}
.label {
background-color: #ffecf3;
display: inline-flex;
align-items: center;
border-radius: 4rpx;
padding: 4rpx 8rpx;
.label {
background-color: #ffecf3;
display: inline-flex;
align-items: center;
border-radius: 4rpx;
margin-bottom: 12rpx;
.hot-icon {
width: 28rpx;
height: 28rpx;
}
.hot-icon {
width: 28rpx;
height: 28rpx;
margin-right: 6rpx;
}
.label-name {
padding-left: 4rpx;
color: #FF19A0;
font-size: 20rpx;
}
}
.label-name {
padding: 4rpx 8rpx;
color: #FF19A0;
}
}
.flex-row-between {
display: flex;
justify-content: space-between;
align-items: center;
}
.price-row {
margin-top: 12rpx;
display: flex;
flex-direction: column;
}
.flex-row-start {
display: flex;
justify-content: flex-start;
align-items: center;
}
.price-text {
color: #3D3D3D;
}
.price-wrapper {
display: flex;
align-items: baseline;
}
.price-label {
color: #999;
margin-left: 8rpx;
}
.origin-price {
color: #999;
margin-top: 8rpx;
}
.add-cart-icon {
width: 44rpx;
height: 44rpx;
position: absolute;
bottom: 20rpx;
right: 20rpx;
transition: transform 0.3s ease;
&.add-cart-icon-animate {
animation: addCartBounce 0.6s ease;
}
}
.buy-now-btn-wrapper {
margin-top: 16rpx;
display: flex;
justify-content: flex-end;
.buy-now-btn {
background: linear-gradient(90deg, #FF19A0, #FF4DB8);
color: #FFFFFF;
font-size: 24rpx;
padding: 12rpx 32rpx;
border-radius: 24rpx;
font-weight: 500;
}
}
}
@keyframes addCartBounce {
0% {
transform: scale(1) rotate(0deg);
}
25% {
transform: scale(1.2) rotate(-10deg);
}
50% {
transform: scale(1.3) rotate(10deg);
}
75% {
transform: scale(1.1) rotate(-5deg);
}
100% {
transform: scale(1) rotate(0deg);
}
}
</style>
.buy-now-btn {
background: #FF19A0;
color: #fff;
font-size: 20rpx;
padding: 10rpx 20rpx;
border-radius: 30rpx;
font-weight: 500;
flex-shrink: 0;
}
}
</style>

View File

@ -70,8 +70,14 @@
<scroll-view class="category-right" scroll-y :refresher-enabled="true"
:refresher-triggered="refreshTriggered" @refresherrefresh="onRefresh" @scrolltolower="onLoadMore">
<view class="goods-list">
<good-item v-for="good in goodsList" :key="good.product_id" :ref="`goodItem_${good.product_id}`"
:data="good" @addToCar="addToCar" @clickCard="jumpToDetail" />
<view class="goods-list-item left">
<good-item v-for="(good, i) in leftColumnGoods" :key="2 * i" :ref="`goodItem_${good.product_id}`"
:data="good" @addToCar="addToCar" />
</view>
<view class="goods-list-item right">
<good-item v-for="(good, i) in rightColumnGoods" :key="2 * i + 1" :ref="`goodItem_${good.product_id}`"
:data="good" @addToCar="addToCar" />
</view>
</view>
</scroll-view>
</view>
@ -109,6 +115,7 @@ import CategoryModal from "./components/CategoryModal.vue";
import {
getGoodsListData
} from "../../../api/shop";
import { getCategoryGoodsWithCache } from "@/utils/goodsCache";
export default {
components: {
@ -152,6 +159,8 @@ export default {
total: 0,
page: 1,
size: 10,
nextCursor: '',
hasMore: true,
refreshTriggered: false,
isLoading: false,
petOrderId: '',
@ -179,6 +188,12 @@ export default {
) || {}
);
},
leftColumnGoods() {
return this.goodsList.filter((v, i) => i % 2 === 0);
},
rightColumnGoods() {
return this.goodsList.filter((v, i) => i % 2 === 1);
},
},
mounted() {
this.getCategoryList();
@ -195,6 +210,10 @@ export default {
},
onShow() {
this.getCartListData();
// 页面显示时检查是否需要刷新商品数据
if (this.selectCategoryId) {
this.getShopList(false);
}
},
watch: {
selectCategoryId(val) {
@ -224,27 +243,70 @@ export default {
}
});
},
changeCateg(item) {
changeCateg(item) {
this.changeId = item.id
this.selectCategoryId = item.id;
this.page = 1; // 切换分类时重置分页
this.nextCursor = '';
this.hasMore = true;
this.goodsList = []; // 清空当前商品列表
this.showAllCategory = false;
// console.log(item,'--')
this.getShopList(true); // 切换分类时强制刷新
},
// 商品列表
getShopList() {
getGoodsListData({
getShopList(forceRefresh = false) {
// 如果不是第一页且没有更多数据,直接返回
if (this.page > 1 && !this.hasMore) {
return;
}
const params = {
type: this.changeId,
p: this.page,
num: this.size,
keyword: "",
is_tui: 0,
})
cursor: this.nextCursor,
};
// 第一页使用缓存,后续页直接请求
if (this.page > 1) {
getGoodsListData(params)
.then((res) => {
const list = res?.data.data?.products || res?.data || [];
const hasMore = res?.data.data?.has_more;
const nextCursor = res?.data.data?.next_cursor || '';
this.goodsList = [...this.goodsList, ...list];
this.hasMore = hasMore;
this.nextCursor = nextCursor;
this.total = res?.count || 0;
})
.finally(() => {
this.isLoading = false;
this.refreshTriggered = false;
});
return;
}
// 第一页使用缓存
getCategoryGoodsWithCache(params, forceRefresh)
.then((res) => {
const list = res?.data || [];
this.goodsList =
this.page === 1 ? list : [...this.goodsList, ...list];
this.total = res?.count || 0;
const list = res?.data?.products || res?.data || [];
const hasMore = res?.data?.has_more;
const nextCursor = res?.data?.next_cursor || '';
// 只有当数据有变化时才更新商品列表,避免不必要的刷新
if (res.hasChanged !== false || this.goodsList.length === 0) {
this.goodsList = list;
}
this.hasMore = hasMore;
this.nextCursor = nextCursor;
this.total = res?.count || list.length || 0;
})
.catch((err) => {
console.error('获取商品列表失败', err);
})
.finally(() => {
this.isLoading = false;
@ -349,15 +411,17 @@ export default {
url: `/pages/client/shop/details?product_id=${details.product_id}&petOrderId=${this.petOrderId}&petOrderAddressId=${this.petOrderAddressId}`,
});
},
onRefresh() {
onRefresh() {
this.refreshTriggered = true;
this.page = 1;
this.size = 10;
this.total = 0;
this.getShopList();
this.nextCursor = '';
this.hasMore = true;
this.getShopList(true); // 下拉刷新时强制刷新
},
onLoadMore() {
if (!this.isLoading && this.total > this.goodsList.length) {
if (!this.isLoading && this.hasMore) {
this.page++;
this.getShopList();
}
@ -385,7 +449,7 @@ export default {
height: 100%;
align-items: stretch;
position: relative;
padding-top: calc(var(--status-bar-height, 0px) + 88rpx + 20rpx);
padding-top: 0;
.custom-navbar {
position: fixed;
@ -394,7 +458,7 @@ export default {
right: 0;
z-index: 999;
background: #ff19a0;
border-radius: 0px 0px 16px 16px;
border-radius: 0px;
.status-bar {
background: #ff19a0;
@ -589,6 +653,24 @@ export default {
.category-right {
flex: 1;
height: 100%;
.goods-list {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: flex-start;
margin-top: 20rpx;
padding: 0 20rpx 120rpx;
.goods-list-item {
flex: 1;
min-width: 0;
&.left {
margin-right: 20rpx;
}
}
}
}
}
}

View File

@ -6,7 +6,7 @@
<!-- 可拖动联系客服组件 -->
<DraggableContact ref="draggableContact" :onClick="handleContactClick" />
<scroll-view class="homeContainer" scroll-y :show-scrollbar="false" :enhanced="true">
<scroll-view class="homeContainer" scroll-y :show-scrollbar="false" :enhanced="true" @scrolltolower="onLoadMore" :refresher-enabled="true" :refresher-triggered="refreshTriggered" @refresherrefresh="onRefresh">
<view class="swiperWrapper">
<swiper indicator-dots="true" autoplay="true" interval="3000" duration="500" circular="true"
class="swiper">
@ -48,6 +48,9 @@
<view class="loginBtn" @click="toLogin" v-if="!userInfo.userID">
注册/登陆
</view>
<view class="logoutBtn" @click="logout" v-if="userInfo.userID">
退出登录
</view>
</view>
<view class="shadowBackground" />
@ -59,11 +62,11 @@
</view> -->
<view class="goods-list">
<view class="goods-list-item left">
<good-item v-for="(good, i) in leftColumnGoods" :index="2 * i" :key="2 * i" :data="good"
<good-item v-for="(good, i) in leftColumnGoods" :index="2 * i" :key="2 * i" :data="good" :isHome="true"
@addToCar="addToCar" />
</view>
<view class="goods-list-item right">
<good-item v-for="(good, i) in rightColumnGoods" :index="2 * i + 1" :key="2 * i + 1" :data="good"
<good-item v-for="(good, i) in rightColumnGoods" :index="2 * i + 1" :key="2 * i + 1" :data="good" :isHome="true"
@addToCar="addToCar" />
</view>
</view>
@ -85,6 +88,9 @@ import {
import {
userWllet
} from "../../../api/login";
import {
loginOut,
} from "../../../api/user";
import WeChatCopyModal from "@/components/WeChatCopyModal.vue";
import GoodItem from "../shop/components/GoodItem.vue";
import DraggableContact from "@/components/DraggableContact.vue";
@ -92,6 +98,7 @@ import {
getGoodsClassify,
getGoodsListData
} from "@/api/shop";
import { getHomeGoodsWithCache } from "@/utils/goodsCache";
export default {
name: "HomePage",
@ -107,6 +114,8 @@ export default {
goodsList: [], // 商品列表
goodsTotal: 0, // 商品总数
goodPage: 1, // 当前页码
nextCursor: '', // 下一页游标
hasMore: true, // 是否还有更多数据
isLoadingGoods: false, // 是否正在加载商品
refreshTriggered: false, // 刷新是否已触发
cartCount: 0, // 购物车数量
@ -171,22 +180,68 @@ export default {
return this.cartCount > 9 ? "9+" : this.cartCount;
}
},
created() {
created() {
this.goodPage = 1;
this.nextCursor = '';
this.hasMore = true;
this.goodsList = [];
this.getGoodsList()
},
onShow() {
// 页面显示时检查是否需要刷新商品数据
this.getGoodsList(false);
},
methods: {
getGoodsList() {
getGoodsList(forceRefresh = false) {
if (this.isLoadingGoods) return;
if (!this.hasMore && this.goodPage > 1) return;
this.isLoadingGoods = true;
const params = {
type: 0
type: 0,
cursor: this.nextCursor
}
getGoodsListData(params)
// 加载更多时直接请求,不使用缓存
if (this.goodPage > 1) {
getGoodsListData(params)
.then((res) => {
const list = res?.data.data?.products || res?.data || [];
const hasMore = res?.data.data?.has_more;
const nextCursor = res?.data.data?.next_cursor || '';
this.goodsList = [...this.goodsList, ...list];
this.hasMore = hasMore;
this.nextCursor = nextCursor;
this.goodsTotal = res?.count || 0;
})
.catch((err) => {
console.error('获取商品列表失败', err);
})
.finally(() => {
this.isLoadingGoods = false;
this.refreshTriggered = false;
});
return;
}
// 第一页使用缓存
getHomeGoodsWithCache(params, forceRefresh)
.then((res) => {
const list = res?.data.data.products || [];
this.goodsList = list;
console.log(this.goodsList,'???')
this.goodsTotal = res?.count || 0;
const list = res?.data.data?.products || res?.data.data || [];
const hasMore = res?.data.data?.has_more;
const nextCursor = res?.data.data?.next_cursor || '';
// 只有当数据有变化时才更新商品列表,避免不必要的刷新
if (res.hasChanged !== false || this.goodsList.length === 0) {
this.goodsList = list;
}
this.hasMore = hasMore;
this.nextCursor = nextCursor;
this.goodsTotal = res?.count || list.length || 0;
})
.catch((err) => {
console.error('获取商品列表失败', err);
})
.finally(() => {
this.isLoadingGoods = false;
@ -198,6 +253,17 @@ export default {
url: "/pages/client/auth/index",
});
},
logout() {
loginOut();
// 清除Vuex中的用户状态
this.$store.dispatch('user/deleteToken');
this.$store.dispatch('user/clearUserInfo');
// 清除本地缓存
uni.clearStorageSync();
uni.reLaunch({
url: "/pages/client/auth/index",
});
},
// 统一的 token 检查方法,未登录时弹窗让用户自主选择
async checkTokenAndExecute(callback) {
const token = uni.getStorageSync('token');
@ -321,24 +387,38 @@ export default {
// 立即购买
addToCar(goodsData) {
console.log(goodsData,'--=')
uni.navigateTo({
url: `/pages/client/order/create`,
success: (res) => {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit("createOrder", {
goodList: [{
...this.goodsData,
goods_id:goodsData.product.out_id,
// price_id:goodsData.prices[0].price_id,
number:1,
goods_name: goodsData.product.product_name,
price_name: goodsData?.product.product_name,
goods_price: goodsData.product.product_type,
product_pic:goodsData.product.product_type
}, ],
});
},
});
// Parse image_list and get the first image URL
let firstImageUrl = '';
const imageList = goodsData.product.attr_key_value_map.image_list;
if (imageList) {
try {
// Try to parse as JSON if it's a string
const parsedList = typeof imageList === 'string' ? JSON.parse(imageList) : imageList;
if (Array.isArray(parsedList) && parsedList.length > 0) {
firstImageUrl = parsedList[0].url || parsedList[0] || '';
}
} catch (e) {
console.error('Error parsing image_list:', e);
}
}
uni.navigateTo({
url: `/pages/client/order/create?product_id=${goodsData.product.product_id}`,
// success: (res) => {
// // 通过eventChannel向被打开页面传送数据
// res.eventChannel.emit("createOrder", {
// goodList: [{
// ...this.goodsData,
// goods_id:goodsData.product.out_id,
// // price_id:goodsData.prices[0].price_id,
// product_pic: firstImageUrl,
// number:1,
// goods_name: goodsData.product.product_name,
// price_name: goodsData?.product.product_name,
// goods_price: goodsData.sku.actual_amount / 100
// }, ],
// });
// },
});
},
@ -361,6 +441,19 @@ export default {
});
}
},
onLoadMore() {
if (!this.isLoadingGoods && this.hasMore) {
this.goodPage++;
this.getGoodsList();
}
},
onRefresh() {
this.refreshTriggered = true;
this.goodPage = 1;
this.nextCursor = '';
this.hasMore = true;
this.getGoodsList(true);
},
},
};
</script>
@ -369,6 +462,7 @@ export default {
.home-page {
height: 100vh;
background-color: #ffecf3;
padding-top: 0;
}
.recommand-goods-wrapper {
@ -381,7 +475,8 @@ export default {
flex-direction: row;
justify-content: flex-start;
align-items: flex-start;
margin-top: 16rpx;
margin-top: 50rpx;
padding: 0 20rpx;
.goods-list-item {
flex: 1;
@ -427,10 +522,13 @@ export default {
.swiperWrapper {
position: relative;
margin-top: -88rpx;
.swiper {
height: 552rpx;
width: 100%;
padding-top: 88rpx;
box-sizing: content-box;
.swiper-img {
width: 100%;
@ -572,6 +670,16 @@ export default {
margin-left: 8rpx;
}
}
.logoutBtn {
background: #FF19A0;
border-radius: 218px;
color: #fff;
font-size: 23rpx;
padding: 16rpx 24rpx;
display: flex;
align-items: center;
}
}
.shadowBackground {

View File

@ -21,6 +21,7 @@
<reservation
v-show="activePageId === 'reservationPage'"
ref="reservationPage"
:orderId="orderId"
/>
</view>
<tab-bar
@ -60,6 +61,7 @@ export default {
path: "/pages/client/index/index",
},
getUserInfoPromise: null, // 用于防止重复调用 getUserInfo
orderId: null, // 存储从订单页面传递过来的 orderId
};
},
methods: {
@ -165,12 +167,17 @@ export default {
this.$store.dispatch('user/setReferrerID', Number(option.referrerID) || 0);
}
// 处理从订单页面传递的 orderId
if (option?.orderId) {
this.orderId = option.orderId;
}
// 处理页面跳转参数
if (option?.activePageId) {
const targetPageId = option.activePageId;
// 如果目标页面与当前页面不同,触发切换
if (this.activePageId !== targetPageId) {
this.handleTabChange([targetPageId]);
this.handleTabChange([targetPageId], option.orderId);
} else {
this.activePageId = targetPageId;
}

View File

@ -14,12 +14,18 @@
{{ userInfo.userID && userInfo.username ? userInfo.username : '嗨,你好呀' }}
</view>
</view>
<view class="userPhone" v-if="userInfo.phone">
{{ userInfo.phone }}
</view>
<!-- <view class="vipWrapper">
<image class="lableImg" :src="`${imgPrefix}home-vipLabel.png`" mode=""></image>
v{{ userInfo.vipLevel || 1 }}会员
</view> -->
</view>
</view>
<view class="logoutBtn" @click="showLogoutModal = true">
退出登录
</view>
<!-- <view class="userRight">
<view class="userRgihtItemView" @click="jumpTo('/pages/client/recharge/index?tab=points')">
<view class="num">
@ -300,6 +306,10 @@ components: {
logout() {
loginOut();
this.showLogoutModal = false;
// 清除Vuex中的用户状态
this.$store.dispatch('user/deleteToken');
this.$store.dispatch('user/clearUserInfo');
// 清除本地缓存
uni.clearStorageSync();
uni.reLaunch({
url: "/pages/client/auth/index",
@ -330,13 +340,17 @@ title: '请添加客服号',
overflow-y: auto;
-webkit-overflow-scrolling: touch;
height: calc(100vh - #{$app_tabbar_height + 26});
padding-top: 0;
.mineGroundImgView {
position: relative;
margin-top: -88rpx;
.groundImg {
width: 100%;
height: 552rpx;
padding-top: 88rpx;
box-sizing: content-box;
}
}
@ -386,6 +400,21 @@ title: '请添加客服号',
font-size: 28rpx;
font-weight: 500;
}
.userPhone {
font-size: 24rpx;
color: #999;
margin-top: 8rpx;
}
}
.logoutBtn {
background: #FF19A0;
color: #fff;
padding: 16rpx 32rpx;
border-radius: 50rpx;
font-size: 24rpx;
font-weight: 500;
}
.userRight {
@ -460,7 +489,7 @@ title: '请添加客服号',
width: calc(100vw - 40rpx);
background-color: #fff;
margin: auto;
margin-top: 20rpx;
margin-top:46rpx;
border-radius: 16rpx;
margin-bottom: 26rpx;

View File

@ -3,7 +3,7 @@
<view class="edit-content">
<view class="flex-row-between edit-cell">
<text class="title">头像</text>
<button class="flex-row-end user-avator" open-type="chooseAvatar" @chooseavatar="chooseavatar">
<button class="flex-row-end user-avator" @click="chooseavatar">
<image class="avator-icon" :src="userInfo.head_pic_url" />
<!-- <image class="arrow-icon" :src="`${imgPrefix}right-arrow.png`" /> -->
</button>
@ -174,30 +174,41 @@ export default {
});
},
// 更新头像
async chooseavatar(e) {
const {
avatarUrl
} = e.detail;
chooseavatar() {
let that = this;
uni.showLoading({
title: "上传中..."
});
try {
const { url, objectKey } = await uploadImageToOSS_PUT(avatarUrl);
console.log(url, objectKey, 'url, objectKey')
this.userInfo.head_pic_url = url; // 同时更新 head_pic_url因为模板使用的是这个字段
this.userInfo.head_pic = objectKey;
this.$forceUpdate();
uni.hideLoading();
} catch (error) {
console.error('头像上传失败:', error);
uni.hideLoading();
uni.showToast({
title: error?.message || "头像上传失败",
icon: "none"
});
}
uni.chooseImage({
count: 1, // 只选一张图片
sourceType: ['album', 'camera'], // 来源:相册、相机
success: async function(res) {
try {
const { url, objectKey } = await uploadImageToOSS_PUT(res.tempFilePaths[0]);
that.userInfo.head_pic_url = url; // 同时更新 head_pic_url因为模板使用的是这个字段
that.userInfo.head_pic = objectKey;
that.$forceUpdate();
uni.hideLoading();
uni.showToast({
title: "上传成功",
icon: "success",
});
} catch (error) {
console.error('头像上传失败:', error);
uni.hideLoading();
uni.showToast({
title: error?.message || "头像上传失败",
icon: "none"
});
}
},
fail: function(err) {
console.log('选择图片失败:', err.errMsg);
uni.hideLoading();
}
});
},
onChange(value, key) {
this.userInfo[key] = value;

View File

@ -4,15 +4,12 @@
<image class="good-icon" :src="data[0].product_pic" mode="aspectFill" @click="$emit('clickGoodImg', data[0])" />
<view class="good-content" @click="$emit('clickGoodInfo', data[0])">
<view class="goods-row-first">
<view class="goods-name">{{ data[0].product_name || "" }}</view>
<text class="goods-price">¥{{ data[0].goods_price || actual_price }}</text>
</view>
<view class="goods-row-second">
<view class="goods-spec">
{{ data[0].shuxing_name || "" }}{{ data[0].shuxing_name && data[0].price_name ? ";" : "" }}{{ data[0].price_name || "" }}
<view class="goods-name">{{ data[0].goods_name || "" }}</view>
<view class="fs-28 app-fc-main goods-price">
¥{{ data[0].goods_price || data[0].product_actual_price }}
</view>
<text class="goods-count">{{ data[0].number || 1 }}</text>
</view>
<view class="fs-24 app-fc-normal">{{ data[0].number || 1 }}</view>
</view>
</template>
@ -24,7 +21,7 @@
<view class="good-info-right">
<text class="good-total-price">¥{{ actual_price }}</text>
<text class="fs-24 app-fc-normal good-num">
{{ goodsImgs.length }}
{{ totalCount }}
</text>
</view>
</view>
@ -56,6 +53,11 @@
return sum + price * number;
}, 0).toFixed(2);
},
totalCount() {
return this.data.reduce((sum, item) => {
return sum + parseInt(item.number || 1);
}, 0);
},
},
mounted() {
console.log(this.data,'--')
@ -76,68 +78,43 @@
&.good-info {
padding-top: 20rpx;
align-items: center;
align-items: flex-start;
.good-icon {
width: 100rpx;
height: 100rpx;
border-radius: 8rpx;
width: 160rpx;
height: 160rpx;
border-radius: 16rpx;
background: #f5f5f5;
margin-right: 20rpx;
flex-shrink: 0;
}
.good-content {
flex: 1;
min-width: 0;
overflow: hidden;
height: 160rpx;
display: flex;
flex-direction: column;
min-height: 100rpx;
justify-content: space-between;
.goods-row-first {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8rpx;
align-items: flex-start;
width: 100%;
.goods-name {
flex: 1;
font-size: 28rpx;
color: #3D3D3D;
line-height: 40rpx;
margin-right: 16rpx;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin-right: 20rpx;
}
.goods-price {
flex-shrink: 0;
font-size: 28rpx;
color: #3D3D3D;
font-weight: 500;
}
}
.goods-row-second {
display: flex;
align-items: center;
justify-content: space-between;
.goods-spec {
flex: 1;
font-size: 24rpx;
color: #999;
margin-right: 20rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.goods-count {
flex-shrink: 0;
font-size: 24rpx;
color: #999;
}
}
}

View File

@ -1,21 +1,30 @@
<template>
<view class="order-item">
<view class="flex-row-between order-title" @click="jumpToDetails">
<text class="fs-24 app-fc-normal">
订单编号{{ data.order_no || "-" }}
</text>
<!-- 待支付状态显示倒计时横幅 -->
<view v-if="data.status === SHOP_ORDER_UNPAY && !data.tui_status && countDownTime > 0"
class="order-status-banner">
<view class="status-banner-left">
<text class="status-text">等待付款</text>
</view>
<view class="status-banner-right">
<text class="countdown-text">{{ formatCountdown(countDownTime) }}</text>
</view>
</view>
<!-- 其他状态显示原有样式 -->
<view v-else-if="
<view class="order-item">
<view class="flex-row-between order-title" @click="jumpToDetails">
<text class="fs-24 app-fc-normal">
订单编号{{ data.order_no || "-" }}
</text>
<!-- 待支付状态显示倒计时横幅 -->
<view
v-if="
data.status === SHOP_ORDER_UNPAY &&
!data.tui_status &&
countDownTime > 0
"
class="order-status-banner"
>
<view class="status-banner-left">
<text class="status-text">等待付款</text>
</view>
<view class="status-banner-right">
<text class="countdown-text">{{
formatCountdown(countDownTime)
}}</text>
</view>
</view>
<!-- 其他状态:显示原有样式 -->
<view
v-else-if="
([
SHOP_ORDER_CANCEL,
SHOP_ORDER_UNPAY,
@ -26,428 +35,548 @@
].includes(data.status) &&
!data.tui_status) ||
[SHOP_ORDER_AFTERSALE_REJECT].includes(data.tui_status)
" class="flex-center fs-24 order-btn" :class="[
"
class="flex-center fs-24 order-btn"
:class="[
![SHOP_ORDER_DONE, SHOP_ORDER_CANCEL, SHOP_ORDER_UNREMARK].includes(
data.status
)
? 'app-fc-mark confirm'
: 'cancel',
]">
{{ orderStatus }}
</view>
<view v-if="
]"
>
{{ orderStatus }}
</view>
<view
v-if="
[SHOP_ORDER_AFTERSALE, SHOP_ORDER_AFTERSALE_DONE].includes(
data.tui_status
)
" class="flex-center fs-24 order-btn cancel">
{{ refundOrderStatus }}
</view>
</view>
<view class="order-content" :class="{ 'split-border': showStatusBtn }" @click="jumpToDetails">
<good-info :data="data.items" :actual_price="data.actual_price" />
<view v-if="data.type && data.type !== 1" class="fs-24 app-fc-mark order-type">
随车订单
</view>
</view>
<view v-if="showStatusBtn" class="order-btns">
<!-- 待支付 -->
<template v-if="[SHOP_ORDER_UNPAY].includes(data.status)">
<view class="flex-center fs-24 app-fc-main cancel-order-btn" @click.stop="$emit('cancelOrder', data)">
取消订单
</view>
<view class="order-btns-right">
<!-- <view class="flex-center fs-24 app-fc-main status-btn" @click.stop="$emit('concactService', data)">
"
class="flex-center fs-24 order-btn cancel"
>
{{ refundOrderStatus }}
</view>
</view>
<view
class="order-content"
:class="{ 'split-border': showStatusBtn }"
@click="jumpToDetails"
>
<good-info :data="data.items" :actual_price="data.actual_price" />
<view
v-if="data.type && data.type !== 1"
class="fs-24 app-fc-mark order-type"
>
随车订单
</view>
</view>
<view v-if="showStatusBtn" class="order-btns">
<!-- 待支付 -->
<template v-if="[SHOP_ORDER_UNPAY].includes(data.status)">
<view
class="flex-center fs-24 app-fc-main cancel-order-btn"
@click.stop="$emit('cancelOrder', data)"
>
取消订单
</view>
<view class="order-btns-right">
<!-- <view class="flex-center fs-24 app-fc-main status-btn" @click.stop="$emit('concactService', data)">
联系客服
</view> -->
<view class="flex-center fs-24 app-fc-white status-btn confirm" @click.stop="$emit('pay', data)">
立即支付
</view>
</view>
</template>
<view
class="flex-center fs-24 app-fc-white status-btn confirm"
@click.stop="$emit('pay', data)"
>
立即支付
</view>
</view>
</template>
<!-- 待预约 -->
<template v-if="[SHOP_ORDER_UNSLIVER].includes(data.status)">
<view class="order-btns-right">
<view class="flex-center fs-24 app-fc-main status-btn" @click.stop="$emit('refund', data)">
申请退款
</view>
<view class="flex-center fs-24 app-fc-white status-btn confirm"
@click.stop="jumpToReservation">
立即预约
</view>
</view>
</template>
<!-- 待预约 -->
<template v-if="[SHOP_ORDER_UNSLIVER].includes(data.status)">
<view class="order-btns-right">
<!-- <view
class="flex-center fs-24 app-fc-main status-btn"
@click.stop="remindRefund(data.order_id)"
>
申请退款
</view> -->
<view
class="flex-center fs-24 app-fc-white status-btn confirm"
@click.stop="jumpToReservation(data.order_id)"
>
立即预约
</view>
</view>
</template>
<!-- 待收货 -->
<template v-if="[SHOP_ORDER_UNRECEIVE].includes(data.status)">
<!-- <view class="flex-center fs-24 app-fc-main status-btn" @click.stop="$emit('concactService', data)">
<!-- 待收货 -->
<template v-if="[SHOP_ORDER_UNRECEIVE].includes(data.status)">
<!-- <view class="flex-center fs-24 app-fc-main status-btn" @click.stop="$emit('concactService', data)">
联系客服
</view> -->
<view class="flex-center fs-24 app-fc-main status-btn" @click.stop="$emit('afterSale', data)">
申请售后
</view>
<!-- 随车订单不显示物流 -->
<!-- <view v-if="data.pay_type !== pay_type_BYCAR" class="flex-center fs-24 app-fc-main status-btn"
<!-- <view
class="flex-center fs-24 app-fc-main status-btn"
@click.stop="$emit('afterSale', data)"
>
申请售后
</view> -->
<!-- 随车订单不显示物流 -->
<!-- <view v-if="data.pay_type !== pay_type_BYCAR" class="flex-center fs-24 app-fc-main status-btn"
@click.stop="$emit('checkSliver', data)">
查看物流
</view> -->
<view class="flex-center fs-24 app-fc-white status-btn confirm"
@click.stop="$emit('confirmSliver', data)">
确认收货
</view>
</template>
<!-- <view
class="flex-center fs-24 app-fc-white status-btn confirm"
@click.stop="$emit('confirmSliver', data)"
>
确认收货
</view> -->
</template>
<!-- 已签收未评价 -->
<template v-if="[SHOP_ORDER_UNREMARK].includes(data.status)">
<!-- <view class="flex-center fs-24 app-fc-main status-btn" @click.stop="$emit('concactService', data)">
<!-- 已签收未评价 -->
<template v-if="[SHOP_ORDER_UNREMARK].includes(data.status)">
<!-- <view class="flex-center fs-24 app-fc-main status-btn" @click.stop="$emit('concactService', data)">
联系客服
</view> -->
<view class="flex-center fs-24 app-fc-white status-btn confirm" @click.stop="$emit('remark', data)">
立即评价
</view>
</template>
<view
class="flex-center fs-24 app-fc-white status-btn confirm"
@click.stop="$emit('remark', data)"
>
立即评价
</view>
</template>
<!-- 已完成 -->
<template v-if="[SHOP_ORDER_DONE].includes(data.status)">
<!-- <view class="flex-center fs-24 app-fc-main status-btn" @click.stop="$emit('concactService', data)">
<!-- 已完成 -->
<template v-if="[SHOP_ORDER_DONE].includes(data.status)">
<!-- <view class="flex-center fs-24 app-fc-main status-btn" @click.stop="$emit('concactService', data)">
联系客服
</view> -->
<view class="flex-center fs-24 app-fc-white status-btn confirm "
style="visibility: hidden;"
>
</view>
</template>
<template v-if="[SHOP_ORDER_DONE].includes(data.status)">
<!-- <view class="flex-center fs-24 app-fc-main status-btn" @click.stop="$emit('concactService', data)">
<view
class="flex-center fs-24 app-fc-white status-btn confirm"
style="visibility: hidden"
>
</view>
</template>
<template v-if="[SHOP_ORDER_DONE].includes(data.status)">
<!-- <view class="flex-center fs-24 app-fc-main status-btn" @click.stop="$emit('concactService', data)">
联系客服
</view> -->
<view class="flex-center fs-24 app-fc-white status-btn confirm"
@click.stop="$emit('remarkDetails', data)">
查看评价
</view>
</template>
</view>
</view>
<view
class="flex-center fs-24 app-fc-white status-btn confirm"
@click.stop="$emit('remarkDetails', data)"
>
查看评价
</view>
</template>
</view>
</view>
</template>
<script>
import PopUpModal from "@/components/PopUpModal.vue";
import GoodInfo from "./GoodInfo.vue";
import {
SHOP_ORDER_STATUS,
SHOP_ORDER_UNPAY,
SHOP_ORDER_UNSLIVER,
SHOP_ORDER_UNRECEIVE,
SHOP_ORDER_DONE,
SHOP_ORDER_CANCEL,
SHOP_ORDER_AFTERSALE,
SHOP_ORDER_AFTERSALE_DONE,
SHOP_ORDER_AFTERSALE_REJECT,
SHOP_ORDER_AFTERSALE_STATUS,
SHOP_ORDER_UNREMARK,
pay_type_ADDRESS,
pay_type_BYCAR,
pay_type_BYPET
} from "@/constants/app.business";
import PopUpModal from "@/components/PopUpModal.vue";
import GoodInfo from "./GoodInfo.vue";
import { walletTransaction, cancelPetOrderMall } from "../../../../api/login";
export default {
props: {
data: {
type: Object,
default: () => {},
},
},
data() {
return {
pay_type_ADDRESS,
pay_type_BYCAR,
pay_type_BYPET,
SHOP_ORDER_STATUS,
SHOP_ORDER_UNPAY,
SHOP_ORDER_UNSLIVER,
SHOP_ORDER_UNRECEIVE,
SHOP_ORDER_DONE,
SHOP_ORDER_CANCEL,
SHOP_ORDER_AFTERSALE,
SHOP_ORDER_AFTERSALE_DONE,
SHOP_ORDER_AFTERSALE_REJECT,
SHOP_ORDER_UNREMARK,
showCancelModal: false,
countDownTime: 0,
countDownTimer: null,
};
},
components: {
GoodInfo,
PopUpModal
},
options: {
styleIsolation: "shared",
},
computed: {
// 抖音退款组件需要的订单ID
orderId() {
return this.data.order_id || this.data.order_no || "";
},
// 抖音退款组件需要的订单状态1=待核销/待发货2=已核销/已发货)
orderStatusForSDK() {
// 根据你的业务状态映射到抖音SDK需要的状态
// SHOP_ORDER_UNSLIVER = 待发货 -> 映射为 1
if (this.data.status === SHOP_ORDER_UNSLIVER) {
return 1;
}
// SHOP_ORDER_UNRECEIVE = 待收货 -> 映射为 2
if (this.data.status === SHOP_ORDER_UNRECEIVE) {
return 2;
}
return 1;
},
// 订单总金额(单位:分)
orderTotalAmount() {
const price = this.data.actual_price || 0;
// 转换为分
return Math.round(parseFloat(price) * 100);
},
// UniApp 需要传入的退款参数对象
refundParams() {
return {
reasonCode: [410],
note: '用户申请退款',
applySource: 101,
afterSaleType: 3,
needRefundPackFee: true
}
},
orderStatus() {
return SHOP_ORDER_STATUS[this.data.status] || "";
},
refundOrderStatus() {
return SHOP_ORDER_AFTERSALE_STATUS[this.data.tui_status] || "";
},
showStatusBtn() {
return (
([
SHOP_ORDER_UNPAY,
SHOP_ORDER_UNSLIVER,
SHOP_ORDER_UNRECEIVE,
SHOP_ORDER_DONE,
SHOP_ORDER_UNREMARK,
].includes(this.data.status) &&
!this.data.tui_status) || [SHOP_ORDER_AFTERSALE_REJECT].includes(this.data.tui_status)
);
},
},
watch: {
showCancelModal(val) {
this.$emit("disableScroll", val);
},
'data.daojishi'(newVal) {
if (this.data.status === this.SHOP_ORDER_UNPAY && newVal) {
this.countDownTime = newVal;
this.startCountDown();
}
},
'data.status'(newVal) {
if (newVal === this.SHOP_ORDER_UNPAY && this.data.daojishi) {
this.countDownTime = this.data.daojishi;
this.startCountDown();
} else {
this.stopCountDown();
}
},
},
mounted() {
// console.log(this.data,'--=')
if (this.data.status === SHOP_ORDER_UNPAY && this.data.daojishi) {
this.countDownTime = this.data.daojishi;
this.startCountDown();
}
},
beforeDestroy() {
this.stopCountDown();
},
methods: {
// 退款回调(组件触发)
handleRefund(event) {
const { status, result, outOrderNo } = event.detail
console.log('退款回调:', { status, result, outOrderNo })
if (status === 'success') {
uni.showToast({
title: '退款申请已提交',
icon: 'success'
})
this.$emit('refund', this.data)
} else {
uni.showToast({
title: result?.errMsg || '退款失败,请稍后重试',
icon: 'none'
})
}
},
// 错误处理
handleError(event) {
console.error('退款组件报错:', event.detail)
uni.showToast({
title: '组件加载失败,请稍后重试',
icon: 'none'
})
},
startCountDown() {
this.stopCountDown();
if (this.countDownTime > 0) {
this.countDownTimer = setInterval(() => {
if (this.countDownTime > 0) {
this.countDownTime--;
} else {
this.stopCountDown();
// 倒计时结束,可以触发刷新
this.$emit('countdownEnd', this.data);
}
}, 1000);
}
},
stopCountDown() {
if (this.countDownTimer) {
clearInterval(this.countDownTimer);
this.countDownTimer = null;
}
},
formatCountdown(seconds) {
const hour = Math.floor(seconds / 3600);
const minutes = Math.floor((seconds - hour * 3600) / 60);
return `${hour}小时${minutes}分钟`;
},
orderCancel() {
this.showCancelModal = false;
},
cancel() {
this.showCancelModal = false;
},
jumpToDetails() {
this.$emit('jumpToDetails', this.data)
},
jumpToReservation() {
uni.reLaunch({
url: '/pages/client/index/index?activePageId=reservationPage'
});
},
},
};
import {
SHOP_ORDER_STATUS,
SHOP_ORDER_UNPAY,
SHOP_ORDER_UNSLIVER,
SHOP_ORDER_UNRECEIVE,
SHOP_ORDER_DONE,
SHOP_ORDER_CANCEL,
SHOP_ORDER_AFTERSALE,
SHOP_ORDER_AFTERSALE_DONE,
SHOP_ORDER_AFTERSALE_REJECT,
SHOP_ORDER_AFTERSALE_STATUS,
SHOP_ORDER_UNREMARK,
pay_type_ADDRESS,
pay_type_BYCAR,
pay_type_BYPET,
} from "@/constants/app.business";
export default {
props: {
data: {
type: Object,
default: () => {},
},
},
data() {
return {
pay_type_ADDRESS,
pay_type_BYCAR,
pay_type_BYPET,
SHOP_ORDER_STATUS,
SHOP_ORDER_UNPAY,
SHOP_ORDER_UNSLIVER,
SHOP_ORDER_UNRECEIVE,
SHOP_ORDER_DONE,
SHOP_ORDER_CANCEL,
SHOP_ORDER_AFTERSALE,
SHOP_ORDER_AFTERSALE_DONE,
SHOP_ORDER_AFTERSALE_REJECT,
SHOP_ORDER_UNREMARK,
showCancelModal: false,
countDownTime: 0,
countDownTimer: null,
};
},
components: {
GoodInfo,
PopUpModal,
},
options: {
styleIsolation: "shared",
},
computed: {
// 抖音退款组件需要的订单ID
orderId() {
return this.data.order_id || this.data.order_no || "";
},
// 抖音退款组件需要的订单状态1=待核销/待发货2=已核销/已发货)
orderStatusForSDK() {
// 根据你的业务状态映射到抖音SDK需要的状态
// SHOP_ORDER_UNSLIVER = 待发货 -> 映射为 1
if (this.data.status === SHOP_ORDER_UNSLIVER) {
return 1;
}
// SHOP_ORDER_UNRECEIVE = 待收货 -> 映射为 2
if (this.data.status === SHOP_ORDER_UNRECEIVE) {
return 2;
}
return 1;
},
// 订单总金额(单位:分)
orderTotalAmount() {
const price = this.data.actual_price || 0;
// 转换为分
return Math.round(parseFloat(price) * 100);
},
// UniApp 需要传入的退款参数对象
refundParams() {
return {
reasonCode: [410],
note: "用户申请退款",
applySource: 101,
afterSaleType: 3,
needRefundPackFee: true,
};
},
orderStatus() {
return SHOP_ORDER_STATUS[this.data.status] || "";
},
refundOrderStatus() {
return SHOP_ORDER_AFTERSALE_STATUS[this.data.tui_status] || "";
},
showStatusBtn() {
return (
([
SHOP_ORDER_UNPAY,
SHOP_ORDER_UNSLIVER,
SHOP_ORDER_UNRECEIVE,
SHOP_ORDER_DONE,
SHOP_ORDER_UNREMARK,
].includes(this.data.status) &&
!this.data.tui_status) ||
[SHOP_ORDER_AFTERSALE_REJECT].includes(this.data.tui_status)
);
},
},
watch: {
showCancelModal(val) {
this.$emit("disableScroll", val);
},
"data.daojishi"(newVal) {
if (this.data.status === this.SHOP_ORDER_UNPAY && newVal) {
this.countDownTime = newVal;
this.startCountDown();
}
},
"data.status"(newVal) {
if (newVal === this.SHOP_ORDER_UNPAY && this.data.daojishi) {
this.countDownTime = this.data.daojishi;
this.startCountDown();
} else {
this.stopCountDown();
}
},
},
mounted() {
// console.log(this.data,'--=')
if (this.data.status === SHOP_ORDER_UNPAY && this.data.daojishi) {
this.countDownTime = this.data.daojishi;
this.startCountDown();
}
},
beforeDestroy() {
this.stopCountDown();
},
methods: {
remindRefund(id) {
const data = {
id: Number(id),
};
uni.showLoading({
icon: "none",
title: "处理中",
mask: true,
});
cancelPetOrderMall(data)
.then((res) => {
uni.hideLoading();
const plugin = tt.requirePlugin("lifeServicePlugin");
let res1 = {
code: 0,
result: "success",
msg: "success",
data: {
outOrderNo: "DYG177556196373493862814838179",
refundInfo: {
reason: ["计划有变,暂时不需要了"]
},
// refundInfo: {
// reason:["计划有变,暂时不需要了"],
// reasonCode:[401],
// },
itemOrderList:[
{
"itemOrderId": "1093391915337944382",
"refundAmount": 9000
}],
// goodsList: [
// { goodsId: "7625832097692813354", goodsType: 1, quantity: 1 },
// ],
},
};
// console.log('applyRefund options', JSON.stringify(options))
console.log(res1.data,'??')
plugin.applyRefund({
itemOrderList:res1.data.itemOrderList,
// goodsList: res1.data.goodsList,
outOrderNo: res1.data.outOrderNo,
refundInfo: res1.data.refundInfo,
success: (res) => {
uni.showToast({
title: "退款申请已提交",
icon: "success",
});
this.$emit("refund", this.data);
},
fail: (err) => {
console.log("退款失败:", err);
// 处理session过期错误
if (err && err.errMsg && err.errMsg.includes("session已过期")) {
uni.showModal({
title: "提示",
content: "会话已过期,请重新登录后再试",
showCancel: false,
confirmText: "确定",
success: () => {
// 清除当前用户信息并跳转到登录页
this.$store.dispatch("user/deleteToken");
this.$store.dispatch("user/clearUserInfo");
uni.clearStorageSync();
uni.reLaunch({
url: "/pages/client/auth/index",
});
},
});
} else {
uni.showToast({
title: err?.errMsg || err?.msg || "退款失败,请重试",
icon: "none",
});
}
},
});
})
.catch((err) => {
uni.hideLoading();
console.error("获取退款信息失败:", err);
uni.showToast({
title: err?.msg || "获取退款信息失败",
icon: "none",
});
});
},
// 退款回调(组件触发)
handleRefund(event) {
const { status, result, outOrderNo } = event.detail;
console.log("退款回调:", { status, result, outOrderNo });
if (status === "success") {
uni.showToast({
title: "退款申请已提交",
icon: "success",
});
this.$emit("refund", this.data);
} else {
uni.showToast({
title: result?.errMsg || "退款失败,请稍后重试",
icon: "none",
});
}
},
// 错误处理
handleError(event) {
console.error("退款组件报错:", event.detail);
uni.showToast({
title: "组件加载失败,请稍后重试",
icon: "none",
});
},
startCountDown() {
this.stopCountDown();
if (this.countDownTime > 0) {
this.countDownTimer = setInterval(() => {
if (this.countDownTime > 0) {
this.countDownTime--;
} else {
this.stopCountDown();
// 倒计时结束,可以触发刷新
this.$emit("countdownEnd", this.data);
}
}, 1000);
}
},
stopCountDown() {
if (this.countDownTimer) {
clearInterval(this.countDownTimer);
this.countDownTimer = null;
}
},
formatCountdown(seconds) {
const hour = Math.floor(seconds / 3600);
const minutes = Math.floor((seconds - hour * 3600) / 60);
return `${hour}小时${minutes}分钟`;
},
orderCancel() {
this.showCancelModal = false;
},
cancel() {
this.showCancelModal = false;
},
jumpToDetails() {
this.$emit("jumpToDetails", this.data);
},
jumpToReservation(orderId) {
uni.reLaunch({
url: `/pages/client/index/index?activePageId=reservationPage&orderId=${orderId}`,
});
},
},
};
</script>
<style lang="scss" scoped>
.order-item {
width: calc(100vw - 40rpx);
background: #fff;
margin: 20rpx;
border-radius: 30rpx;
box-sizing: border-box;
padding: 20rpx;
margin-bottom: 0;
.order-item {
width: calc(100vw - 40rpx);
background: #fff;
margin: 20rpx;
border-radius: 30rpx;
box-sizing: border-box;
padding: 20rpx;
margin-bottom: 0;
.order-title {
padding-bottom: 20rpx;
border-bottom: 1rpx solid #ececec;
.order-title {
padding-bottom: 20rpx;
border-bottom: 1rpx solid #ececec;
.order-btn {
width: 104rpx;
height: 48rpx;
border-radius: 48rpx;
.order-btn {
width: 104rpx;
height: 48rpx;
border-radius: 48rpx;
&.confirm {
background: #fef6ff;
}
&.confirm {
background: #fef6ff;
}
&.cancel {
background: #f7f7f7;
color: #afa5ae;
}
}
&.cancel {
background: #f7f7f7;
color: #afa5ae;
}
}
.order-status-banner {
display: flex;
align-items: center;
border-radius: 48rpx;
overflow: hidden;
.order-status-banner {
display: flex;
align-items: center;
border-radius: 48rpx;
overflow: hidden;
.status-banner-left {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
background: #FF19A0;
padding: 8rpx;
flex-shrink: 0;
border-radius: 10px 0px 10px 10px;
.status-banner-left {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
background: #ff19a0;
padding: 8rpx;
flex-shrink: 0;
border-radius: 10px 0px 10px 10px;
.status-text {
font-size: 20rpx;
color: #FFFFFF;
}
}
.status-text {
font-size: 20rpx;
color: #ffffff;
}
}
.status-banner-right {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
background: #FFF0F8;
padding: 8rpx;
flex-shrink: 0;
.status-banner-right {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
background: #fff0f8;
padding: 8rpx;
flex-shrink: 0;
.countdown-text {
font-size: 20rpx;
color: #ff19a0;
}
}
}
}
.countdown-text {
font-size: 20rpx;
color: #FF19A0;
}
}
}
}
.order-btns {
padding-top: 20rpx;
display: flex;
justify-content: flex-end;
align-items: center;
.cancel-order-btn {
font-size: 24rpx;
color: #9b939a;
padding: 16rpx 0;
}
.order-btns {
padding-top: 20rpx;
display: flex;
justify-content: flex-end;
align-items: center;
.order-btns-right {
display: flex;
align-items: center;
}
.cancel-order-btn {
font-size: 24rpx;
color: #9B939A;
padding: 16rpx 0;
}
.status-btn {
width: 70px;
height: 34px;
// padding: 16rpx 20rpx;
border-radius: 64rpx;
border: 1px solid #ff19a0;
margin-left: 20rpx;
.order-btns-right {
display: flex;
align-items: center;
}
&.confirm {
color: $app_color_main;
border: 1px solid $app_color_main;
}
}
}
.status-btn {
width: 70px;
height: 34px;
// padding: 16rpx 20rpx;
border-radius: 64rpx;
border: 1px solid #FF19A0;;
margin-left: 20rpx;
&.confirm {
color: $app_color_main;
border: 1px solid $app_color_main;
}
}
}
::v-deep {
.good-info-multi {
padding-top: 20rpx;
}
}
}
::v-deep {
.good-info-multi {
padding-top: 20rpx;
}
}
}
</style>

View File

@ -1,98 +1,89 @@
<template>
<view class="order-create-container">
<!-- 商品信息 -->
<view class="info-cell goods-info-cell">
<template>
<view
class="goods-item"
v-for="(item, index) in orderData"
:key="index"
>
<image
class="goods-img"
:src="item.item_pic || item.product_pic"
mode="aspectFill"
/>
<view class="goods-content">
<view class="goods-row-first">
<view class="goods-name">{{
item.item_name || item.product_name
}}</view>
<text class="goods-price"
>¥{{ item.product_price || item.goods_price }}</text
>
</view>
<view class="goods-row-second">
<text class="goods-count">{{ item.number || 1 }}</text>
<view class="page-container">
<view class="order-create-container">
<!-- 商品信息 -->
<view class="info-cell goods-info-cell">
<template>
<view
class="goods-item"
v-for="(item, index) in orderData"
:key="index"
>
<image
class="goods-img"
:src="item.image"
mode="aspectFill"
/>
<view class="goods-content">
<!-- <view class="goods-name">{{
item.name
}}</view> -->
<view class="price-wrapper">
<text class="final-price-label">到手价</text>
<text class="final-price">¥{{ item.price }}</text>
</view>
<view class="sales-info">
<text class="sales-count">{{ item.name }}</text>
</view>
</view>
</view>
</view>
</template>
</view>
<view class="info-cell pay-cell">
<view class="flex-row-between pay-info">
<text class="pay-label">商品金额</text>
<text class="pay-value">{{ payPrice }}</text>
</view>
<view
v-if="couponList.length"
class="flex-row-between pay-info coupon-row"
@click="showCouponModal = true"
>
<text class="pay-label">优惠券</text>
<view class="flex-row-end">
<text class="coupon-price">
{{ couponFee ? `- ¥${couponFee}` : "请选择" }}
</text>
<image
class="arrow-icon"
src="@/static/images/arrow_right_black.png"
mode="widthFix"
/>
</view>
</view>
<!-- <view class="flex-row-between pay-info">
<text class="pay-label">运费</text>
<text class="pay-value">{{ sliverFee ? `${sliverFee}` : "包邮" }}</text>
</view> -->
<view class="flex-row-between pay-price">
<text class="pay-label">需付款</text>
<text class="pay-total">{{ payPrice }}</text>
</template>
</view>
</view>
<!-- <view class="info-cell payment-method-cell">
<view class="payment-item" @click.stop="selectOption1('1')">
<view class="payment-left">
<image class="payment-icon" src="@/static/images/douy.png" mode="widthFix" />
<text class="payment-text">抖音支付</text>
</view>
<image class="payment-check"
:src="selected2 ? require('@/static/images/cart_checked.png') : require('@/static/images/unchecked.png')"
mode="widthFix" />
</view>
</view> -->
<!-- 可拖动联系客服组件 -->
<DraggableContact ref="draggableContact" :onClick="handleContactBtnClick" />
<view class="place-view"></view>
<view class="order-create-bottom">
<!-- <view class="cancel-btn" @click="cancelOrder">
<text class="cancel-btn-text">取消订单</text>
</view> -->
<view class="pay-btn" @click="createOrder">
<text class="pay-btn-text">立即支付</text>
</view>
</view>
<good-info-modal
v-if="showGoodInfoModal"
:goods="orderData"
@close="showGoodInfoModal = false"
<!-- 图片撑满屏幕宽度 -->
<!-- <image
class="full-width-img"
src="https://static.wagoo.pet/statics/1.png"
mode="widthFix"
/> -->
<image
class="full-width-img"
src="https://static.wagoo.pet/statics/2.png"
mode="widthFix"
/>
<image
class="full-width-img"
src="https://static.wagoo.pet/statics/3.png"
mode="widthFix"
/>
<!-- <image
class="full-width-img"
src="https://static.wagoo.pet/statics/4.png"
mode="widthFix"
/> -->
<!-- <image
class="full-width-img"
src="https://static.wagoo.pet/statics/5.png"
mode="widthFix"
/> -->
<!-- <image
class="full-width-img"
src="https://static.wagoo.pet/statics/6.png"
mode="widthFix"
/> -->
<view class="order-create-container">
<!-- 可拖动联系客服组件 -->
<DraggableContact ref="draggableContact" :onClick="handleContactBtnClick" />
<view class="place-view"></view>
<view class="order-create-bottom">
<view class="price-info">
<text class="current-price">¥{{ orderPrice.toFixed(2) }}</text>
</view>
<view class="pay-btn" @click="createOrder">
<text class="pay-btn-text">立即购买</text>
</view>
</view>
<good-info-modal
v-if="showGoodInfoModal"
:goods="orderData"
@close="showGoodInfoModal = false"
/>
</view>
</view>
</template>
@ -112,6 +103,10 @@ import { getAddressInfo } from "../../../api/address";
import { COUPON_TYPE_GOODS } from "../../../constants/app.business";
import { walletTransaction } from "../../../api/login";
import { imgPrefix, jumpToWeChat } from "@/utils/common";
import {
addCart,
getGoodsDetail,
} from "@/api/shop";
const sliverList = [
{
@ -125,155 +120,166 @@ const sliverList = [
];
export default {
components: {
SelectModal,
GoodInfoModal,
RechargeCouponModal,
DraggableContact,
},
data() {
return {
payPrice: 0,
type: "",
orderData: [],
addressInfo: {},
sliverInfo: {},
selectSliverInfo: {},
showSliverModal: false,
sliverTypeList: sliverList,
showGoodInfoModal: false,
showCouponModal: false,
couponList: [],
serviceOrderList: [],
useCouponInfo: null,
petOrderId: "",
petOrderAddressId: "",
orderPrice: 0,
confirmPrice: 0,
selected1: false,
selected2: false,
selected3: false,
selected4: true,
recharge: true,
record: false,
walletBalance: "1000.00",
imgPrefix,
WeChat: undefined,
wallet: "2",
};
},
computed: {
goodsImgs() {
return this.orderData.map((item) => item.goods_pic).filter((v) => !!v);
},
sliverFee() {
return this.orderData.reduce((total, prev) => total + +prev.yunfei, 0);
},
couponFee() {
return +this.useCouponInfo?.card_money || 0;
},
usefullCouponList() {
return this.couponList.filter((v) => +v.card_money < this.orderPrice);
},
},
onLoad(option) {
const { type, petOrderId = "", petOrderAddressId = "" } = option;
this.type = type;
this.petOrderId = petOrderId;
this.petOrderAddressId = petOrderAddressId;
if (petOrderAddressId) {
getAddressInfo(petOrderAddressId).then((res) => {
this.addressInfo = {
...res?.info,
};
});
}
uni.$on("selectAddress", this.addressChange);
const eventChannel = this.getOpenerEventChannel();
eventChannel.on("createOrder", (data) => {
this.orderData = data?.goodList || [];
this.payPrice = (data?.goodList || []).reduce(
(sum, item) =>
sum +
Number((item.product_price || item.goods_price) * item.number || 0),
0
);
console.log(data, "--=?");
const price = this.orderData.reduce(
(total, prev) => total + +prev.item_price,
0
);
this.orderPrice = +price.toFixed(2);
this.confirmPrice = +(this.orderPrice - this.couponFee).toFixed(2);
});
},
methods: {
createOrder(isPrePay) {
return new Promise((resolve, reject) => {
if (!isPrePay) {
uni.showLoading({
title: "处理中",
mask: true,
});
}
const params = {
id: Number(this.orderData[0].goods_id),
};
// console.log(this.orderData,'???')
createCartOrder(params)
.then((res) => {
const plugin = tt.requirePlugin("tta5a3d31e3aecfb9b11");
plugin.createOrder({
goodsList: [
{
quantity: 10, // 购买数量 必填
price: 1, // 商品价格 必填
goodsName: "测试商品", // 商品名称 必填
goodsPhoto:"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.ibaotu.com%2Fgif%2F19%2F48%2F47%2F76Z888piCd6W.gif%21fwpaa50%2Ffw%2F700&refer=http%3A%2F%2Fpic.ibaotu.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1644654365&t=5fc9b5fdad0a16264a9a9c09c14b3af9", // 商品图片链接 必填
goodsId: "123", // 商品ID 必填(请务必使用小程序商品)
goodsType: 2, // 商品类型 必填
},
],
payment: {
totalAmount: 10, // 订单总价 必填
},
success: (res) => {
const { orderId, outOrderNo } = res;
console.log("success res", res);
console.log("orderId", orderId, "outOrderNo", outOrderNo);
this.setData({ orderId, outOrderNo });
uni.navigateTo({
url:"/pages/client/order/list",
});
},
fail: (res) => {
console.log("fail res", res);
const { orderId, outOrderNo, errNo, errMsg, errLogId } = res;
if (errLogId) {
console.log("预下单失败", errNo, errMsg, errLogId);
}
if (orderId || outOrderNo) {
console.log("支付失败", errNo, errMsg, orderId, outOrderNo);
}
console.log(errNo, errMsg);
},
});
resolve();
})
.catch((err) => {});
});
},
},
components: {
SelectModal,
GoodInfoModal,
RechargeCouponModal,
DraggableContact,
},
data() {
return {
orderData:[],
payPrice: 0,
orPrice:0,
type: "",
orderData: [],
addressInfo: {},
sliverInfo: {},
selectSliverInfo: {},
showSliverModal: false,
sliverTypeList: sliverList,
showGoodInfoModal: false,
showCouponModal: false,
couponList: [],
serviceOrderList: [],
useCouponInfo: null,
petOrderId: "",
petOrderAddressId: "",
orderPrice: 0,
confirmPrice: 0,
selected1: false,
selected2: false,
selected3: false,
selected4: true,
recharge: true,
record: false,
imgPrefix,
WeChat: undefined,
wallet: "2",
orderId: "",
outOrderNo: "",
};
},
computed: {
goodsImgs() {
return this.orderData.map((item) => item.goods_pic).filter((v) => !!v);
},
sliverFee() {
return this.orderData.reduce((total, prev) => total + +prev.yunfei, 0);
},
couponFee() {
return +this.useCouponInfo?.card_money || 0;
},
usefullCouponList() {
return this.couponList.filter((v) => +v.card_money < this.orderPrice);
},
},
onLoad(option) {
// console.log(option,'?')
this.getGoodsList(option.product_id)
},
methods: {
getGoodsList(id) {
getGoodsDetail({
product_id:id,
})
.then((res) => {
this.orderData = res.data
this.orPrice = res.data.price
this.orderPrice = res.data[0].price
console.log( this.orderData,'--=??')
})
},
createOrder(isPrePay) {
return new Promise((resolve, reject) => {
if (!isPrePay) {
uni.showLoading({
title: "支付中",
mask: true,
});
}
console.log(this.orderData[0].goods_id,'-=-')
const params = {
id: Number(this.orderData[0].goods_id),
};
createCartOrder(params)
.then((res) => {
if (typeof tt !== "undefined" && tt.requirePlugin) {
try {
const plugin = tt.requirePlugin("lifeServicePlugin");
if (plugin && plugin.createOrder) {
uni.hideLoading();
plugin.createOrder({
skuList: res.data.skuList,
bookInfo: res.data.bookInfo,
contactInfo: res.data.contactInfo,
callbackData: res.data.callbackData,
storeInfo: res.data.storeInfo,
tradeOption: res.data.tradeOption,
payment: res.data.payment,
success: (res) => {
const { orderId, outOrderNo } = res;
console.log("success res", res);
console.log("orderId", orderId, "outOrderNo", outOrderNo);
this.orderId = orderId;
this.outOrderNo = outOrderNo;
uni.navigateTo({
url: "/pages/client/order/list",
});
},
fail: (res) => {
console.log("fail res", res);
uni.showToast({
title: "支付失败",
icon: "none",
});
},
});
}else {
console.error("Plugin or createOrder method not found");
uni.showToast({
title: "支付插件初始化失败",
icon: "none",
});
}
} catch (error) {
console.error("Error requiring plugin:", error);
uni.showToast({
title: "支付插件加载失败",
icon: "none",
});
}
} else {
console.log("TikTok Mini Program environment not detected");
uni.showToast({
title: "请在抖音小程序中打开",
icon: "none",
});
}
resolve();
})
.catch((err) => {
uni.hideLoading();
console.error("createCartOrder error:", err);
uni.showToast({
title: "创建订单失败",
icon: "none",
});
reject(err);
});
});
},
},
};
</script>
<style lang="scss" scoped>
.page-container {
min-height: 100%;
background: #f7f8fa;
}
.order-create-container {
height: 100%;
padding: 20rpx;
box-sizing: border-box;
background: #f7f8fa;
@ -285,99 +291,13 @@ export default {
box-sizing: border-box;
margin-bottom: 20rpx;
.arrow-icon {
width: 11rpx;
height: 18rpx;
flex-shrink: 0;
}
&.address-info-cell {
.address-content {
display: flex;
flex-direction: column;
width: 100%;
position: relative;
}
.address-row-first {
display: flex;
align-items: center;
width: 100%;
margin-bottom: 10rpx;
}
.address-row-second {
display: flex;
width: 100%;
}
.address-icon {
width: 24rpx;
height: 32rpx;
flex-shrink: 0;
margin-right: 12rpx;
}
.address-placeholder {
font-size: 24rpx;
color: #3d3d3d;
padding: 20rpx 0rpx;
padding-bottom: 10rpx;
}
.address-name {
font-size: 28rpx;
color: #3d3d3d;
.address-phone {
margin-left: 8rpx;
}
}
.address-details {
font-size: 24rpx;
color: #999;
margin-left: 36rpx;
}
.arrow-icon {
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
width: 11rpx;
height: 18rpx;
flex-shrink: 0;
}
}
&.sliver-info-cell {
.sliver-content {
display: flex;
align-items: center;
width: 100%;
}
.sliver-icon {
width: 34rpx;
height: 34rpx;
flex-shrink: 0;
}
.sliver-text {
flex: 1;
margin-left: 20rpx;
font-size: 24rpx;
color: #3d3d3d;
}
}
&.goods-info-cell {
padding: 0;
.goods-item {
display: flex;
align-items: center;
align-items: flex-start;
flex-direction: column;
width: 100%;
padding: 24rpx 20rpx;
box-sizing: border-box;
@ -388,211 +308,69 @@ export default {
}
.goods-img {
width: 100rpx;
height: 100rpx;
width: 100%;
height: 355px;
border-radius: 16rpx;
margin-right: 20rpx;
flex-shrink: 0;
background: #f5f5f5;
}
.goods-content {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
min-height: 100rpx;
justify-content: flex-start;
min-height: 200rpx;
min-width: 0;
overflow: hidden;
padding-top: 8rpx;
.goods-row-first {
.goods-name {
font-size: 28rpx;
color: #3d3d3d;
line-height: 40rpx;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
margin-bottom: 16rpx;
}
.price-wrapper {
display: flex;
align-items: center;
justify-content: space-between;
align-items: baseline;
margin-bottom: 12rpx;
.goods-name {
flex: 1;
font-size: 28rpx;
color: #3d3d3d;
line-height: 40rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin-right: 20rpx;
.final-price-label {
font-size: 24rpx;
color: #ff19a0;
background: linear-gradient(to right, #ffeef7, #fff);
padding: 4rpx 12rpx;
border-radius: 4rpx 0 0 4rpx;
margin-right: 8rpx;
}
.goods-price {
flex-shrink: 0;
font-size: 28rpx;
color: #3d3d3d;
.final-price {
font-size: 48rpx;
color: #ff19a0;
font-weight: 700;
margin-right: 12rpx;
}
}
.sales-info {
.sales-count {
font-size: 20px;
font-weight: 500;
}
}
.goods-row-second {
display: flex;
align-items: center;
justify-content: space-between;
.goods-spec {
flex: 1;
font-size: 24rpx;
color: #999;
margin-right: 20rpx;
}
.goods-count {
flex-shrink: 0;
font-size: 24rpx;
color: #999;
line-height: 20px;
text-align: justify;
color: #3D3D3D;
}
}
}
}
.goods-multi {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
.goods-imgs {
display: flex;
align-items: center;
flex: 1;
.goods-img-small {
width: 100rpx;
height: 100rpx;
margin-right: 8rpx;
border-radius: 16rpx;
flex-shrink: 0;
}
}
.goods-count-wrapper {
flex-shrink: 0;
.goods-count-text {
font-size: 24rpx;
color: #999;
}
}
}
}
&.pay-cell {
.pay-info {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16rpx 0;
.pay-label {
font-size: 24rpx;
color: #9b939a;
}
.pay-value {
font-size: 24rpx;
color: #3d3d3d;
}
}
.coupon-row {
.coupon-price {
font-size: 28rpx;
color: #ff19a0;
margin-right: 12rpx;
}
}
.pay-price {
display: flex;
align-items: center;
justify-content: space-between;
padding-top: 16rpx;
margin-top: 16rpx;
border-top: 1rpx solid #e5e5e5;
.pay-label {
font-size: 28rpx;
color: #3d3d3d;
}
.pay-total {
font-size: 28rpx;
color: #ff19a0;
font-weight: 500;
}
}
}
&.payment-method-cell {
.payment-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 24rpx 0;
&:not(:last-child) {
border-bottom: 1rpx solid #e5e5e5;
}
.payment-left {
display: flex;
align-items: center;
.payment-icon {
width: 40rpx;
height: 40rpx;
margin-right: 20rpx;
}
.payment-text {
font-size: 24rpx;
color: #3d3d3d;
}
}
.payment-check {
width: 36rpx;
height: 36rpx;
flex-shrink: 0;
}
}
}
&.pay-type {
.pay-icon {
width: 52rpx;
height: 52rpx;
margin-right: 18rpx;
}
.pay-select-icon {
width: 36rpx;
height: 36rpx;
}
.pay-type-text {
flex: 1;
}
}
&.good-list {
padding: 20rpx;
.good-img {
width: 160rpx;
height: 160rpx;
margin-right: 20rpx;
border-radius: 20rpx;
}
.good-num {
margin-right: 12rpx;
}
}
}
@ -613,71 +391,49 @@ export default {
box-sizing: border-box;
display: flex;
align-items: center;
gap: 20rpx;
justify-content: space-between;
box-shadow: 0px -2px 10px 0px rgba(0, 0, 0, 0.05);
.cancel-btn {
flex: 1;
height: 92rpx;
border-radius: 92rpx;
border: 2rpx solid #ff19a0;
background: #fff;
.price-info {
display: flex;
align-items: center;
justify-content: center;
align-items: baseline;
.cancel-btn-text {
font-size: 30rpx;
.current-price {
font-size: 40rpx;
color: #ff19a0;
font-weight: 500;
font-weight: 700;
margin-right: 12rpx;
}
.original-price {
font-size: 24rpx;
color: #999;
text-decoration: line-through;
}
}
.pay-btn {
flex: 1;
height: 92rpx;
border-radius: 92rpx;
flex: 0 0 auto;
height: 72rpx;
padding: 0 40rpx;
border-radius: 72rpx;
background: #ff19a0;
display: flex;
align-items: center;
justify-content: center;
.pay-btn-text {
font-size: 30rpx;
font-size: 32rpx;
color: #fff;
font-weight: 500;
font-weight: 600;
}
}
}
.sliver-content {
padding: 16rpx 0;
.sliver-item {
padding: 52rpx 0;
margin: 0 52rpx;
width: calc(100% - 52rpx * 2);
box-sizing: border-box;
border-bottom: 1rpx solid #f7f3f7;
&.disabled {
opacity: 0.5;
}
.select-icon {
width: 32rpx;
height: 32rpx;
margin-left: 20rpx;
}
}
.sliver-btn {
width: 630rpx;
height: 92rpx;
background: #fe019b;
border-radius: 92rpx;
margin: 18rpx auto 10rpx;
}
}
}
.full-width-img {
width: calc(100% - 40rpx);
margin: 0 20rpx;
display: block;
}
</style>

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@
class="flex-column-start news-item">
<order-item :data="data" @disableScroll="disableScrollAction" @cancelOrder="cancelOrderAction"
@refund="handleRefundFromItem" @concactService="jumpToWeChat" @confirmSliver="confirmSliver" @remindSilver="remindSliver" @pay="pay"
@afterSale="afterSale" @checkSliver="checkSliver" @remark="remark" @remarkDetails="remarkDetails"
@checkSliver="checkSliver" @remark="remark" @remarkDetails="remarkDetails"
@jumpToDetails="jumpToDetails" />
</view>
<uni-load-more v-if="isLoading || (!isLoading && total && total === list.length)"
@ -101,7 +101,7 @@ import ContactModal from "@/components/ContactModal.vue";
import SliverInfo from "./components/SliverInfo.vue";
import WeChatCopyModal from "@/components/WeChatCopyModal.vue";
import DraggableContact from "@/components/DraggableContact.vue";
import { walletTransaction, cancelPetOrderRefund, cancelPetOrderMall } from "../../../api/login";
import { walletTransaction, cancelPetOrderRefund, cancelPetOrderMall,cancelUnpaid } from "../../../api/login";
import {
@ -250,14 +250,14 @@ export default {
mask: true,
});
const data = {
id: this.orderInfo.order_id,
id: Number(this.orderInfo.order_id),
// business_type:1
}
// 判断是取消订单还是退款
const apiPromise = this.cancelModalContent.includes('退款')
? cancelPetOrderRefund(data)
: cancelPetOrderMall(data);
? cancelUnpaid(data)
: cancelUnpaid(data);
apiPromise.then((res) => {
uni.hideLoading();
@ -303,23 +303,26 @@ export default {
},
// 支付
pay(data) {
uni.showLoading({
icon: "none",
title: "支付中",
mask: true,
});
uni.showLoading({
icon: "none",
title: "支付中",
mask: true,
});
console.log(data,'-?')
const plugin = tt.requirePlugin('tta5a3d31e3aecfb9b11');
const plugin = tt.requirePlugin('lifeServicePlugin');
// 先隐藏loading让插件显示自己的弹窗
uni.hideLoading();
plugin.continueToPay({
orderId: "orderId", // 内部订单号
outOrderNo: "outOrderNo", // 外部订单号 2个订单号必填一个
orderId:data.douyin_order_id, // 内部订单号
// outOrderNo: "outOrderNo", // 外部订单号 2个订单号必填一个
success: (res) => {
const { orderId, outOrderNo } = res;
console.log("success res", res);
console.log("orderId", orderId, "outOrderNo", outOrderNo);
this.reloadData();
},
fail: (res) => {
uni.hideLoading();
const { orderId, outOrderNo, errNo, errMsg, errLogId } = res;
if (errLogId) {
console.log("查询订单信息失败", errNo, errMsg, errLogId);
@ -327,6 +330,11 @@ plugin.continueToPay({
if (orderId || outOrderNo) {
console.log("支付失败", errNo, errMsg, orderId, outOrderNo);
}
// 隐藏抖音的报错信息,显示自定义中文提示
uni.showToast({
title: "支付失败",
icon: "none",
});
},
});
// payOrder({

View File

@ -1,6 +1,6 @@
<template>
<view class="goods-item" >
<image class="goods-img" :src="data.product_pic" mode="aspectFill" />
<view class="goods-item" :class="{ 'goods-item-home': isHome }">
<image @click.stop="handleBuyNow" class="goods-img" :src="getProductImage(data)" mode="aspectFill" />
<view class=" fs-24 app-fc-main goods-name">
{{ data.product.product_name || "" }}
</view>
@ -13,7 +13,7 @@
<text class="fs-28" style="color: #3D3D3D;">
¥
<text class="fs-28">{{
data.product.product_type || 0
data.sku.actual_amount / 100 || 0
}}</text>
</text>
<!-- <text class="fs-24 origin-price">
@ -34,7 +34,7 @@
} from '@/utils/common';
export default {
props: {
props: {
index: {
type: Number,
default: 0,
@ -43,6 +43,10 @@
type: Object,
default: () => {},
},
isHome: {
type: Boolean,
default: false,
},
},
data() {
return {
@ -65,6 +69,26 @@
// 触发购买事件,通知父组件
this.$emit('addToCar', this.data);
},
getProductImage(data) {
// Try to get product_pic first
if (data.product_pic) {
return data.product_pic;
}
// Try to parse image_list from attr_key_value_map
if (data.product?.attr_key_value_map?.image_list) {
try {
const imageList = data.product.attr_key_value_map.image_list;
const parsedList = typeof imageList === 'string' ? JSON.parse(imageList) : imageList;
if (Array.isArray(parsedList) && parsedList.length > 0) {
return parsedList[0].url || parsedList[0] || '';
}
} catch (e) {
console.error('Error parsing image_list:', e);
}
}
return '';
}
},
};
</script>
@ -73,7 +97,7 @@
.goods-item {
background: #fff;
border-radius: 16rpx;
padding: 20rpx;
padding: 2rpx;
box-sizing: border-box;
margin-bottom: 22rpx;
position: relative;
@ -81,15 +105,24 @@
min-width: 0;
overflow: hidden;
&.goods-item-home {
padding: 20rpx;
}
.goods-img {
display: block;
// width: 260rpx;
height: 260rpx;
width: 100%;
max-width: 100%;
height: 320rpx;
// max-width: 100%;
border-radius: 16rpx;
background: #f5f5f5;
}
&.goods-item-home .goods-img {
height: 145px;
}
.goods-name {
margin: 20rpx 0;
// overflow: hidden;

View File

@ -21,7 +21,7 @@
<view class="flex-row-between" style="margin-top: 20rpx">
<view class="">
<text class="app-fc-mark fs-28"></text>
<text class="app-fc-mark fs-28">{{picList[0].actual_price || 0 }}</text>
<text class="app-fc-mark fs-28">{{picList[0].actual_price / 100 || 0 }}</text>
<!-- <text class="fs-24 origin-price">
¥{{ minPrice.price_shichang || 0 }}
</text> -->
@ -410,7 +410,7 @@
number,
goods_name: this.details.goods_name,
price_name: priceInfo?.price_name,
goods_price: +(+priceInfo?.actual_price * number).toFixed(2),
goods_price: +((priceInfo?.actual_price / 100) * number).toFixed(2),
}, ],
});
},

View File

@ -56,14 +56,24 @@
@scrolltolower="onLoadMore"
>
<view class="goods-list">
<good-item
v-for="good in goodsList"
:key="good.product_id"
:ref="`goodItem_${good.product_id}`"
:data="good"
@addToCar="addToCar"
@buyNow="handleBuyNow"
/>
<view class="goods-list-item left">
<good-item
v-for="(good, i) in leftColumnGoods"
:index="2 * i"
:key="2 * i"
:data="good"
@addToCar="addToCar"
/>
</view>
<view class="goods-list-item right">
<good-item
v-for="(good, i) in rightColumnGoods"
:index="2 * i + 1"
:key="2 * i + 1"
:data="good"
@addToCar="addToCar"
/>
</view>
</view>
<view v-if="isLoading" class="loading-wrapper flex-center">
<uni-load-more status="loading" :show-text="false" />
@ -98,7 +108,7 @@
<script>
import { imgPrefix } from "@/utils/common";
import GoodItem from "../category/components/GoodItem.vue";
import GoodItem from "../shop/components/GoodItem.vue";
import AddGoodsModal from "@/components/goods/AddGoodsModal.vue";
import ContactModal from "@/components/ContactModal.vue";
import WeChatCopyModal from "@/components/WeChatCopyModal.vue";
@ -160,6 +170,8 @@ export default {
total: 0,
page: 1,
size: 10,
nextCursor: '',
hasMore: true,
showModal: false,
addGoodInfo: null,
showContactModal: false,
@ -179,6 +191,12 @@ export default {
cartShowCount() {
return this.cartCount > 9 ? "9+" : this.cartCount;
},
leftColumnGoods() {
return this.goodsList.filter((v, i) => i % 2 === 0);
},
rightColumnGoods() {
return this.goodsList.filter((v, i) => i % 2 === 1);
},
},
mounted() {
this.initData();
@ -247,6 +265,9 @@ export default {
initData() {
this.getCategoryList();
this.page = 1;
this.nextCursor = '';
this.hasMore = true;
this.goodsList = [];
this.getGoodsList();
this.getCartListData();
},
@ -265,17 +286,25 @@ export default {
// 商品列表
getGoodsList() {
if (this.isLoading) return;
if (!this.hasMore && this.page > 1) return;
this.isLoading = true;
getGoodsListData({
type: this.selectCategoryId ? this.selectCategoryId : 1,
p: this.page,
num: this.size,
keyword: this.searchKeyword,
type: this.selectCategoryId ? this.selectCategoryId : 0,
cursor: this.nextCursor,
})
.then((res) => {
const list = res?.data || [];
this.goodsList =
this.page === 1 ? list : [...this.goodsList, ...list];
const list = res?.data.data.products || [];
const hasMore = res?.data.data.has_more;
const nextCursor = res?.data.data.next_cursor || '';
if (this.page === 1) {
this.goodsList = list;
} else {
this.goodsList = [...this.goodsList, ...list];
}
this.hasMore = hasMore;
this.nextCursor = nextCursor;
this.total = res?.count || 0;
})
.finally(() => {
@ -288,10 +317,12 @@ export default {
this.page = 1;
this.size = 10;
this.total = 0;
this.nextCursor = '';
this.hasMore = true;
this.getGoodsList();
},
onLoadMore() {
if (!this.isLoading && this.total > this.goodsList.length) {
if (!this.isLoading && this.hasMore) {
this.page++;
this.getGoodsList();
}
@ -349,11 +380,38 @@ export default {
this.cartCountBounce = false;
}, 600);
},
addToCar(good) {
this.showModal = true;
this.addGoodInfo = {
...good,
};
addToCar(goodsData) {
// Parse image_list and get the first image URL
let firstImageUrl = '';
const imageList = goodsData.product.attr_key_value_map.image_list;
if (imageList) {
try {
// Try to parse as JSON if it's a string
const parsedList = typeof imageList === 'string' ? JSON.parse(imageList) : imageList;
if (Array.isArray(parsedList) && parsedList.length > 0) {
firstImageUrl = parsedList[0].url || parsedList[0] || '';
}
} catch (e) {
console.error('Error parsing image_list:', e);
}
}
uni.navigateTo({
url: `/pages/client/order/create?product_id=${goodsData.product.product_id}`,
// success: (res) => {
// // 通过eventChannel向被打开页面传送数据
// res.eventChannel.emit("createOrder", {
// goodList: [{
// goods_id:goodsData.product.out_id,
// product_pic: firstImageUrl,
// number:1,
// goods_name: goodsData.product.product_name,
// price_name: goodsData?.product.product_name,
// goods_price: goodsData.sku.actual_amount / 100
// }, ],
// });
// },
});
},
// 购物车列表
getCartListData() {
@ -380,31 +438,31 @@ export default {
// 立即购买
handleBuyNow(good) {
uni.navigateTo({
url: `/pages/client/order/create`,
success: (res) => {
// 通过 eventChannel 向被打开页面传送数据
res.eventChannel.emit("createOrder", {
goodList: [
{
goods_id: good.product_id,
item_type: good.type,
price_id: good.prices?.[0]?.price_id,
price_desc: good.prices?.[0]?.price_desc,
item_name: good.product_name,
item_price: good.prices?.[0]?.actual_price,
item_pic: good.product_pic,
number: 1,
product_id: good.product_id,
product_name: good.product_name,
product_pic: good.product_pic,
goods_price: good.prices?.[0]?.actual_price,
product_price: good.prices?.[0]?.actual_price,
original_price: good.prices?.[0]?.original_price,
yunfei: good.yunfei || 0,
},
],
});
},
url: `/pages/client/order/create?product_id=${good.product.product_id}`,
// success: (res) => {
// // 通过 eventChannel 向被打开页面传送数据
// res.eventChannel.emit("createOrder", {
// goodList: [
// {
// goods_id: good.product_id,
// item_type: good.type,
// price_id: good.prices?.[0]?.price_id,
// price_desc: good.prices?.[0]?.price_desc,
// item_name: good.product_name,
// item_price: good.prices?.[0]?.actual_price,
// item_pic: good.product_pic,
// number: 1,
// product_id: good.product_id,
// product_name: good.product_name,
// product_pic: good.product_pic,
// goods_price: good.prices?.[0]?.actual_price / 100,
// product_price: good.prices?.[0]?.actual_price / 100,
// original_price: good.prices?.[0]?.original_price,
// yunfei: good.yunfei || 0,
// },
// ],
// });
// },
});
},
},
@ -437,7 +495,7 @@ export default {
align-items: center;
justify-content: center;
padding: 0 32rpx;
height: 88rpx;
height: 80rpx;
box-sizing: border-box;
margin-bottom: 20px;
@ -598,4 +656,21 @@ export default {
.loading-wrapper {
padding: 10rpx 0;
}
</style>
.goods-list {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: flex-start;
padding: 0 20rpx;
.goods-list-item {
flex: 1;
min-width: 0;
&.left {
margin-right: 20rpx;
}
}
}
</style>

335
src/utils/goodsCache.js Normal file
View File

@ -0,0 +1,335 @@
/**
* 商品数据缓存工具
* 用于首页和分类页的商品列表缓存,避免重复请求相同数据
*/
import { getGoodsListData } from '@/api/shop'
// 缓存存储对象
const goodsCache = {
// 首页商品缓存
home: null,
// 分类页商品缓存key为分类ID
category: {}
}
// 缓存过期时间5分钟单位毫秒
const CACHE_EXPIRE_TIME = 5 * 60 * 1000
/**
* 计算数据的哈希值,用于判断数据是否有变化
* @param {Array} data - 商品数据列表
* @returns {string} 数据哈希值
*/
function calculateDataHash(data) {
if (!data || !Array.isArray(data) || data.length === 0) {
return 'empty'
}
// 使用商品ID、价格、更新时间等关键信息计算哈希
const keyData = data.map(item => {
const product = item.product || item
return `${product.product_id || product.id}-${product.updated_at || Date.now()}-${item.sku?.actual_amount || product.price || 0}`
}).join('|')
// 简单的字符串哈希函数
let hash = 0
for (let i = 0; i < keyData.length; i++) {
const char = keyData.charCodeAt(i)
hash = ((hash << 5) - hash) + char
hash = hash & hash // 转换为32位整数
}
return hash.toString()
}
/**
* 获取缓存的首页商品数据
* @returns {Object|null} 缓存的商品数据,包含数据、哈希值和时间戳
*/
export function getHomeGoodsCache() {
return goodsCache.home
}
/**
* 设置首页商品缓存
* @param {Array} data - 商品数据列表
*/
export function setHomeGoodsCache(data) {
goodsCache.home = {
data,
hash: calculateDataHash(data),
timestamp: Date.now()
}
}
/**
* 获取指定分类的商品缓存
* @param {Number|String} categoryId - 分类ID
* @returns {Object|null} 缓存的商品数据
*/
export function getCategoryGoodsCache(categoryId) {
return goodsCache.category[categoryId] || null
}
/**
* 设置指定分类的商品缓存
* @param {Number|String} categoryId - 分类ID
* @param {Array} data - 商品数据列表
*/
export function setCategoryGoodsCache(categoryId, data) {
goodsCache.category[categoryId] = {
data,
hash: calculateDataHash(data),
timestamp: Date.now()
}
}
/**
* 检查缓存是否有效
* @param {Object} cache - 缓存对象
* @returns {Boolean} 缓存是否有效
*/
function isCacheValid(cache) {
if (!cache) return false
const now = Date.now()
// 检查缓存是否过期
if (now - cache.timestamp > CACHE_EXPIRE_TIME) {
return false
}
return true
}
/**
* 获取首页商品数据(带缓存)
* @param {Object} params - 请求参数
* @param {Boolean} forceRefresh - 是否强制刷新
* @returns {Promise} 商品数据
*/
export function getHomeGoodsWithCache(params, forceRefresh = false) {
return new Promise((resolve, reject) => {
const cache = getHomeGoodsCache()
// 如果有有效缓存且不强制刷新,先返回缓存数据
if (!forceRefresh && isCacheValid(cache)) {
// 先从缓存返回数据
resolve({
data: { data: { products: cache.data } },
fromCache: true
})
}
// 无论是否有缓存,都请求最新数据进行对比
getGoodsListData(params).then(res => {
const newData = res?.data.data?.products || res?.data.data || []
const hasMore = res?.data.data?.has_more
const nextCursor = res?.data.data?.next_cursor || ''
const newHash = calculateDataHash(newData)
// 检查数据是否有变化
const hasChanged = !cache || cache.hash !== newHash
if (hasChanged || forceRefresh) {
// 更新缓存
setHomeGoodsCache(newData)
// 如果没有缓存或者数据有变化,返回最新数据
if (!cache || forceRefresh) {
resolve({
...res,
data: {
...res.data,
data: {
...res.data.data,
products: newData,
has_more: hasMore,
next_cursor: nextCursor
}
},
fromCache: false,
hasChanged: true
})
} else {
// 如果已有缓存但数据有变化,通知更新
resolve({
...res,
data: {
...res.data,
data: {
...res.data.data,
products: newData,
has_more: hasMore,
next_cursor: nextCursor
}
},
fromCache: false,
hasChanged: true
})
}
} else {
// 数据没有变化,更新缓存时间戳
cache.timestamp = Date.now()
resolve({
data: {
data: {
products: cache.data,
has_more: hasMore,
next_cursor: nextCursor
}
},
fromCache: true,
hasChanged: false
})
}
}).catch(err => {
// 如果请求失败但有缓存,返回缓存
if (cache) {
resolve({
data: {
data: {
products: cache.data,
has_more: false,
next_cursor: ''
}
},
fromCache: true,
error: err
})
} else {
reject(err)
}
})
})
}
/**
* 获取分类页商品数据(带缓存)
* @param {Object} params - 请求参数
* @param {Boolean} forceRefresh - 是否强制刷新
* @returns {Promise} 商品数据
*/
export function getCategoryGoodsWithCache(params, forceRefresh = false) {
const categoryId = params.type || params.category_id || ''
return new Promise((resolve, reject) => {
const cache = getCategoryGoodsCache(categoryId)
// 如果有有效缓存且不强制刷新,先返回缓存数据
if (!forceRefresh && isCacheValid(cache)) {
resolve({
data: cache.data,
count: cache.data.length,
fromCache: true
})
}
// 无论是否有缓存,都请求最新数据进行对比
getGoodsListData(params).then(res => {
const newData = res?.data.data?.products || res?.data || []
const hasMore = res?.data.data?.has_more
const nextCursor = res?.data.data?.next_cursor || ''
const newHash = calculateDataHash(newData)
// 检查数据是否有变化
const hasChanged = !cache || cache.hash !== newHash
if (hasChanged || forceRefresh) {
// 更新缓存
setCategoryGoodsCache(categoryId, newData)
if (!cache || forceRefresh) {
resolve({
...res,
data: {
...res.data,
data: {
...res.data.data,
products: newData,
has_more: hasMore,
next_cursor: nextCursor
}
},
fromCache: false,
hasChanged: true
})
} else {
resolve({
...res,
data: {
...res.data,
data: {
...res.data.data,
products: newData,
has_more: hasMore,
next_cursor: nextCursor
}
},
fromCache: false,
hasChanged: true
})
}
} else {
// 数据没有变化,更新缓存时间戳
cache.timestamp = Date.now()
resolve({
data: newData,
data: {
products: cache.data,
has_more: hasMore,
next_cursor: nextCursor
},
count: cache.data.length,
fromCache: true,
hasChanged: false
})
}
}).catch(err => {
// 如果请求失败但有缓存,返回缓存
if (cache) {
resolve({
data: cache.data,
data: {
products: cache.data,
has_more: false,
next_cursor: ''
},
count: cache.data.length,
fromCache: true,
error: err
})
} else {
reject(err)
}
})
})
}
/**
* 清除所有商品缓存
*/
export function clearGoodsCache() {
goodsCache.home = null
goodsCache.category = {}
}
/**
* 清除指定分类的商品缓存
* @param {Number|String} categoryId - 分类ID
*/
export function clearCategoryGoodsCache(categoryId) {
if (goodsCache.category[categoryId]) {
delete goodsCache.category[categoryId]
}
}
export default {
getHomeGoodsCache,
setHomeGoodsCache,
getCategoryGoodsCache,
setCategoryGoodsCache,
getHomeGoodsWithCache,
getCategoryGoodsWithCache,
clearGoodsCache,
clearCategoryGoodsCache
}