23
This commit is contained in:
parent
a8b3793ee4
commit
c51cfc3b29
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
// 测试环境配置 - .NET 10 后端
|
||||
const testing = {
|
||||
baseUrl: 'https://app.zpc-xy.com/honey/api',
|
||||
// baseUrl: 'https://api.hanimanghe.top',
|
||||
// baseUrl: 'https://app.zpc-xy.com/honey/api',
|
||||
baseUrl: 'https://api.hanimanghe.top',
|
||||
// baseUrl: 'http://192.168.1.24:5238',
|
||||
// baseUrl: 'http://192.168.195.15:2822',
|
||||
imageUrl: 'https://youdas-1308826010.cos.ap-shanghai.myqcloud.com',
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@
|
|||
|
||||
<script>
|
||||
import { calcMallOrderMoney, createOrder, createMallOrder } from '@/common/server/order.js';
|
||||
import { getGoodsDetail } from '@/common/server/goods.js';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
|
|
@ -159,12 +160,23 @@ export default {
|
|||
onLoad(options) {
|
||||
if (options.goods_id) {
|
||||
this.goodsId = options.goods_id;
|
||||
// 从列表页传来的图片作为兜底
|
||||
if (options.imgurl) {
|
||||
this.goodsInfo = { imgurl: decodeURIComponent(options.imgurl) };
|
||||
}
|
||||
this.loadDetail();
|
||||
}
|
||||
this.$c.getRule(10).then(res => {
|
||||
if (res.status == 1) this.sendRuleData = res.data;
|
||||
});
|
||||
},
|
||||
onShow() {
|
||||
// 登录回来后,如果还没有支付信息,重新加载
|
||||
const token = uni.getStorageSync('token');
|
||||
if (token && !this.orderData && this.goodsId) {
|
||||
this.loadDetail();
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
showRule(val) {
|
||||
if (val) {
|
||||
|
|
@ -178,26 +190,63 @@ export default {
|
|||
uni.navigateBack();
|
||||
},
|
||||
async loadDetail() {
|
||||
// 用 mall_ordermoney 获取商品详情和支付信息
|
||||
const res = await calcMallOrderMoney({
|
||||
prize_num: 1,
|
||||
goods_id: this.goodsId,
|
||||
num: 1,
|
||||
});
|
||||
if (res.status == 1) {
|
||||
this.orderData = res.data;
|
||||
this.goodsInfo = res.data.goods || {};
|
||||
const ext = res.data.goods_extend || {};
|
||||
if (ext.pay_wechat == 1) {
|
||||
this.zhifu = 0;
|
||||
} else if (ext.pay_currency2 == 1) {
|
||||
this.zhifu = 1;
|
||||
// 1. 先用 goods_detail 获取商品基本信息(不需要登录)
|
||||
try {
|
||||
const detailRes = await getGoodsDetail(this.goodsId);
|
||||
if (detailRes.status == 1 && detailRes.data) {
|
||||
// goods_detail 返回 { data: { goods: {...}, goodslist: [...] } }
|
||||
this.goodsInfo = detailRes.data.goods || detailRes.data;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('获取商品详情失败', e);
|
||||
}
|
||||
|
||||
// 2. 已登录时,再调 calcMallOrderMoney 获取支付信息
|
||||
const token = uni.getStorageSync('token');
|
||||
if (token) {
|
||||
try {
|
||||
const res = await calcMallOrderMoney({
|
||||
prize_num: 1,
|
||||
goods_id: this.goodsId,
|
||||
num: 1,
|
||||
});
|
||||
if (res.status == 1) {
|
||||
this.orderData = res.data;
|
||||
// 用订单接口的数据补充商品信息(含 imgurl_detail、goods_describe 等)
|
||||
if (res.data.goods) {
|
||||
this.goodsInfo = { ...this.goodsInfo, ...res.data.goods };
|
||||
}
|
||||
const ext = res.data.goods_extend || {};
|
||||
if (ext.pay_wechat == 1) {
|
||||
this.zhifu = 0;
|
||||
} else if (ext.pay_currency2 == 1) {
|
||||
this.zhifu = 1;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('获取支付信息失败', e);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onBuy() {
|
||||
if (!this.orderData) return;
|
||||
const token = uni.getStorageSync('token');
|
||||
if (!token) {
|
||||
uni.showToast({ title: '请先登录', icon: 'none' });
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({ url: '/pages/user/login' });
|
||||
}, 300);
|
||||
return;
|
||||
}
|
||||
// 登录后如果还没加载支付信息,先加载
|
||||
if (!this.orderData) {
|
||||
this.loadDetail().then(() => {
|
||||
if (this.orderData) {
|
||||
this.$refs.orderPop.open();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.$refs.orderPop.open();
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ export default {
|
|||
|
||||
order_money(data) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/mall/detail?goods_id=' + data.id
|
||||
url: '/pages/mall/detail?goods_id=' + data.id + '&imgurl=' + encodeURIComponent(data.imgurl || '')
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -339,6 +339,7 @@ public class GoodsService : IGoodsService
|
|||
{
|
||||
g.Id,
|
||||
g.Title,
|
||||
g.ImgUrl,
|
||||
g.ImgUrlDetail,
|
||||
g.Price,
|
||||
g.Stock,
|
||||
|
|
@ -454,6 +455,7 @@ public class GoodsService : IGoodsService
|
|||
{
|
||||
Id = goods.Id,
|
||||
Title = goods.Title,
|
||||
ImgUrl = FormatImageUrl(goods.ImgUrl),
|
||||
ImgUrlDetail = FormatImageUrl(goods.ImgUrlDetail),
|
||||
Price = goods.Price.ToString("0.##"),
|
||||
Stock = goods.Stock,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user