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