【订单详情】

1. 初步接入详情 API 接口
pull/1/MERGE
YunaiV 2023-06-06 19:12:07 +08:00
parent 4a9c829d6f
commit 4e465b7e72
11 changed files with 280 additions and 97 deletions

11
api/pay/order.js Normal file
View File

@ -0,0 +1,11 @@
import request from "@/utils/request.js";
export function getOrder(id) {
return request.get("app-api/pay/order/get", {
id
});
}
export function submitOrder(data) {
return request.post("app-api/pay/order/submit", data);
}

6
api/product/category.js Normal file
View File

@ -0,0 +1,6 @@
import request from "@/utils/request.js";
// 查询分类列表
export function getCategoryList() {
return request.get('app-api/product/category/list', {});
}

15
api/product/spu.js Normal file
View File

@ -0,0 +1,15 @@
import request from "@/utils/request.js";
// 获得商品 SPU 分页
export function getSpuPage(data) {
return request.get('app-api/product/spu/page', data);
}
// 查询商品
export function getSpuDetail(id) {
return request.get('app-api/product/spu/get-detail', {
id
}, {
noAuth: true // TODO 芋艿:后续要做调整
});
}

5
api/trade/afterSale.js Normal file
View File

@ -0,0 +1,5 @@
import request from "@/utils/request.js";
export function getAfterSalePage(data) {
return request.get("app-api/trade/after-sale/page", data);
}

29
api/trade/cart.js Normal file
View File

@ -0,0 +1,29 @@
import request from "@/utils/request.js";
export function addCart(data) {
return request.post("app-api/trade/cart/add", data);
}
export function updateCart(data) {
return request.put("app-api/trade/cart/update", data);
}
export function resetCart(data) {
return request.put("app-api/trade/cart/reset", data);
}
export function getCartCount() {
return request.get("app-api/trade/cart/get-count");
}
export function getCartCountMap() {
return request.get("app-api/trade/cart/get-count-map");
}
export function getCartList() {
return request.get("app-api/trade/cart/list");
}
export function deleteCart(ids) {
return request.delete("app-api/trade/cart/delete?ids=" + ids.join(','));
}

29
api/trade/order.js Normal file
View File

@ -0,0 +1,29 @@
import request from "@/utils/request.js";
export function settlementOrder(data) {
return request.get("app-api/trade/order/settlement", data);
}
export function createOrder(data) {
return request.post("app-api/trade/order/create", data);
}
export function getOrderDetail(id) {
return request.get("app-api/trade/order/get-detail", {
id
});
}
export function getOrderCount() {
return request.get("app-api/trade/order/get-count");
}
export function getOrderPage(data) {
return request.get("app-api/trade/order/page", data);
}
export function getOrderItem(id) {
return request.get("app-api/trade/order/item/get", {
id
});
}

View File

@ -1,12 +1,12 @@
let domain = 'http://127.0.0.1:8081'
let domain = 'http://apif.java.crmeb.net'
module.exports = {
// 请求域名 格式: https://您的域名
// #ifdef MP
HTTP_REQUEST_URL: domain,
// #endif
HTTP_ADMIN_URL:'http://127.0.0.1:8080', //PC后台的API请求地址上传图片用
HTTP_ADMIN_URL:'http://apif.java.crmeb.net', //PC后台的API请求地址上传图片用
// #ifdef H5
//H5接口是浏览器地址
// HTTP_REQUEST_URL: window.location.protocol+"//"+window.location.host,

View File

@ -20,27 +20,26 @@
<scroll-view :scroll-top="scrollTop" scroll-y='true' scroll-with-animation="true"
:style='"height:"+height+"px;"' @scroll="scroll">
<view id="past0">
<productConSwiper :imgUrls="sliderImage" :videoline="productInfo.videoLink">
<productConSwiper :imgUrls="spu.sliderPicUrls" :videoline="spu.videoUrl">
</productConSwiper>
<view class="pad30">
<!-- 价格库存销量 -->
<view class='wrapper mb30 borRadius14'>
<view class='share acea-row row-between row-bottom'>
<view class='money font-color'>
<text class='num'>{{productInfo.price}}</text>
<text class='vip-money'
v-if="productInfo.vipPrice && productInfo.vipPrice > 0">{{productInfo.vipPrice}}</text>
<image v-if="productInfo.vipPrice && productInfo.vipPrice > 0"
src="../../static/images/vip.png"></image>
<text class='num'>{{ fen2yuan(spu.price) }}</text>
<text class='vip-money' v-if="spu.vipPrice && spu.vipPrice > 0">{{ fen2yuan(spu.vipPrice) }}</text>
<image v-if="spu.vipPrice && spu.vipPrice > 0" src="../../static/images/vip.png" />
</view>
<view class='iconfont icon-fenxiang' @click="listenerActionSheet"></view>
</view>
<view class='introduce'>{{productInfo.storeName}}</view>
<view class='introduce'>{{ spu.name }}</view>
<view class='label acea-row row-between-wrapper'>
<view>原价:{{productInfo.otPrice || 0}}</view>
<view>库存:{{productInfo.stock || 0}}{{productInfo.unitName || ''}}</view>
<view>原价:{{ fen2yuan(spu.marketPrice) }}</view>
<view>库存:{{ spu.stock }} {{ spu.unitName}}</view>
<view>
销量:{{Math.floor(productInfo.sales) + Math.floor(productInfo.ficti) || 0}}{{productInfo.unitName || ''}}
销量:{{ spu.salesCount}} {{ spu.unitName }}
</view>
</view>
<!-- <view class='coupon acea-row row-between-wrapper' v-if="productInfo.give_integral > 0">
@ -49,12 +48,14 @@
<view class='activity'>赠送 {{productInfo.give_integral}} 积分</view>
</view>
</view> -->
<view v-if="coupon.list.length>0 && type=='normal'"
<!-- TODO 芋艿卡在这个位置 -->
<view v-if="coupon.list.length > 0 && type==='normal'"
class='coupon acea-row row-between-wrapper' @click='couponTap'>
<view class='hide line1 acea-row'>
优惠券
<view class='activity'>
{{coupon.list[0].minPrice}}{{coupon.list[0].money}}</view>
{{ coupon.list[0].minPrice }}{{ coupon.list[0].money }}
</view>
</view>
<view class='iconfont icon-jiantou'></view>
</view>
@ -146,9 +147,8 @@
<image src="../../static/images/xyou.png"></image>
</view>
<view class='conter'>
<jyf-parser :html="description" ref="article" :tag-style="tagStyle"></jyf-parser>
<jyf-parser :html="spu.description" ref="article" :tag-style="tagStyle"></jyf-parser>
</view>
<!-- <rich-text :nodes="description" class="conter"></rich-text> -->
</view>
<view style='height:120rpx;'></view>
</scroll-view>
@ -203,9 +203,17 @@
<shareRedPackets :sharePacket="sharePacket" @listenerActionSheet="listenerActionSheet"
@closeChange="closeChange"></shareRedPackets>
<!-- 组件 -->
<productWindow :attr="attr" :isShow='1' :iSplus='1' @myevent="onMyEvent" @ChangeAttr="ChangeAttr"
@ChangeCartNum="ChangeCartNum" @attrVal="attrVal" @iptCartNum="iptCartNum" id='product-window'>
</productWindow>
<productWindow
:attr="attr"
:isShow='1'
:iSplus='1'
@myevent="onMyEvent"
@ChangeAttr="ChangeAttr"
@ChangeCartNum="ChangeCartNum"
@attrVal="attrVal"
@iptCartNum="iptCartNum"
id='product-window'
/>
<home></home>
<couponListWindow :coupon='coupon' @ChangCouponsClone="ChangCouponsClone" @ChangCoupons="ChangCoupons"
@ChangCouponsUseState="ChangCouponsUseState" @tabCouponType="tabCouponType"></couponListWindow>
@ -257,14 +265,10 @@
<script>
import uQRCode from '@/js_sdk/Sansnn-uQRCode/uqrcode.js'
// import yzf_chat from '@/plugin/chat/yzf_chat.js'
import store from '@/store';
import {
getProductDetail,
collectAdd,
collectDel,
postCartAdd,
getReplyList,
getReplyConfig,
getProductGood,
getReplyProduct
@ -292,10 +296,9 @@
import userEvaluation from '@/components/userEvaluation';
import shareRedPackets from '@/components/shareRedPackets';
import home from '@/components/home';
import {
silenceBindingSpread
} from "@/utils";
import parser from "@/components/jyf-parser/jyf-parser";
import * as ProductSpuApi from '@/api/product/spu.js';
import * as Util from '@/utils/util.js';
// #ifdef MP
import {
base64src
@ -320,7 +323,6 @@
// #endif
},
data() {
let that = this;
return {
//
coupon: {
@ -335,8 +337,9 @@
id: 0, //id
replyCount: 0, //
reply: [], //
productInfo: {}, //
productValue: [], //
productInfo: {}, // TODO
spu: {}, // SPU
skuMap: [], // SKU Map
couponList: [], //
cart_num: 1, //
isAuto: false, //
@ -362,12 +365,12 @@
isDown: true,
posters: false,
weixinStatus: false,
attr: {
cartAttr: false,
attr: { // productWindow 使
cartAttr: false, // TODO
// id = name = values[].id = values[].name = index =
productAttr: [],
productSelect: {}
productSelect: {} // SKU
},
description: '',
navActive: 0,
H5ShareBox: false, //
activityH5: [],
@ -387,7 +390,6 @@
table: 'width:100%',
video: 'width:100%'
},
sliderImage: [],
qrcodeSize: 600,
canvasStatus: false, //
imagePath: '', //
@ -405,25 +407,18 @@
isLogin: {
handler: function(newV, oldV) {
let that = this;
if (newV == true) {
if (newV === true) {
that.getCouponList();
that.getCartCount();
//that.downloadFilePromotionCode();
}
},
deep: true
},
productInfo: {
handler: function() {
this.$nextTick(() => {});
},
immediate: true
}
},
onLoad(options) {
let that = this
var pages = getCurrentPages();
that.returnShow = pages.length === 1 ? false : true;
that.returnShow = pages.length !== 1;
if (pages.length <= 1) {
that.retunTop = false
}
@ -597,7 +592,7 @@
}
}
},
/*
/**
* 去商品详情页
*/
goDetail(item) {
@ -633,7 +628,6 @@
uni.redirectTo({
url: `/pages/activity/goods_seckill_details/index?id=${item.activityH5.id}`
})
return
}
},
//
@ -651,7 +645,7 @@
ChangeCartNum: function(changeValue) {
//changeValue: |
//
let productSelect = this.productValue[this.attrValue];
let productSelect = this.skuMap[this.attrValue];
//,
if (productSelect === undefined && !this.attr.productAttr.length)
productSelect = this.attr.productSelect;
@ -682,7 +676,7 @@
*
*/
ChangeAttr: function(res) {
let productSelect = this.productValue[res];
let productSelect = this.skuMap[res];
if (productSelect) {
this.$set(this.attr.productSelect, "image", productSelect.image);
this.$set(this.attr.productSelect, "price", productSelect.price);
@ -749,26 +743,25 @@
})
});
},
/**
* 获取产品详情
*
*/
getGoodsDetails: function() {
let that = this;
getProductDetail(that.id, that.type).then(res => {
let productInfo = res.data.productInfo;
//
let arrayImg = productInfo.sliderImage;
let sliderImage = JSON.parse(arrayImg);
that.$set(that, 'sliderImage', sliderImage);
ProductSpuApi.getSpuDetail(that.id).then(res => {
let productInfo = res.data;
let spu = res.data;
that.$set(that, 'productInfo', productInfo);
that.$set(that, 'description', productInfo.content);
that.$set(that, 'userCollect', res.data.userCollect);
that.$set(that, 'spu', spu);
that.$set(that, 'userCollect', res.data.userCollect); // TODO
if (true) {
return;
}
that.$set(that.attr, 'productAttr', res.data.productAttr);
that.$set(that, 'productValue', res.data.productValue);
that.$set(that, 'skuMap', res.data.skuMap);
that.$set(that.sharePacket, 'priceName', res.data.priceName);
that.$set(that.sharePacket, 'isState', Math.floor(res.data.priceName) != 0 ?
false : true);
that.$set(that.sharePacket, 'isState', Math.floor(res.data.priceName) === 0);
that.$set(that, 'activityH5', res.data.activityAllH5 ? res.data.activityAllH5 : []);
uni.setNavigationBarTitle({
title: productInfo.storeName.substring(0, 7) + "..."
@ -794,7 +787,7 @@
// #ifdef MP
that.getQrcode();
// #endif
};
}
setTimeout(function() {
that.infoScroll();
}, 500);
@ -806,6 +799,9 @@
// #endif
that.DefaultSelect();
}).catch(err => {
if (true) {
return;
}
//
return that.$util.Tips({
title: err.toString()
@ -881,8 +877,8 @@
DefaultSelect: function() {
let productAttr = this.attr.productAttr;
let value = [];
for (let key in this.productValue) {
if (this.productValue[key].stock > 0) {
for (let key in this.skuMap) {
if (this.skuMap[key].stock > 0) {
value = this.attr.productAttr.length ? key.split(",") : [];
break;
}
@ -891,7 +887,7 @@
this.$set(productAttr[i], "index", value[i]);
}
//sort();:--
let productSelect = this.productValue[value.join(",")];
let productSelect = this.skuMap[value.join(",")];
if (productSelect && productAttr.length) {
this.$set(
this.attr.productSelect,
@ -1030,7 +1026,7 @@
*/
goCat: function(num) {
let that = this,
productSelect = that.productValue[this.attrValue];
productSelect = that.skuMap[this.attrValue];
//
if (that.attrValue) {
//
@ -1370,6 +1366,9 @@
})
}
},
fen2yuan(price) {
return Util.fen2yuan(price)
}
}
}
</script>

70
utils/product.js Normal file
View File

@ -0,0 +1,70 @@
// ========== 商品相关的 Util ==========
/**
* 从商品 SKU 数组中转换出商品属性的数组
*
* 类似结构[{
* id: // 属性的编号
* name: // 属性的名字
* values: [{
* id: // 属性值的编号
* name: // 属性值的名字
* }]
* }]
*
* @param skus 商品 SKU 数组
*/
export function convertProductPropertyList(skus) {
let result = [];
for (const sku of skus) {
if (!sku.properties) {
continue
}
for (const property of sku.properties) {
// ① 先处理属性
let resultProperty = result.find(item => item.id === property.propertyId)
if (!resultProperty) {
resultProperty = {
id: property.propertyId,
name: property.propertyName,
values: []
}
result.push(resultProperty)
}
// ② 再处理属性值
let resultValue = resultProperty.values.find(item => item.id === property.valueId)
if (!resultValue) {
resultProperty.values.push({
id: property.valueId,
name: property.valueName
})
}
}
}
return result;
}
/**
* 从商品 SKU 数组中转换出商品 SKU Map
*
* key: 属性值的拼接使用 , 间隔例如说 黑色,CH510
*
* @param skus 商品 SKU Map
*/
export function convertProductSkuMap(skus) {
let result = {};
for (const sku of skus) {
let key = '';
if (!sku.properties) {
continue
}
for (const property of sku.properties) {
if (key !== '') {
key += ','
}
key += property.valueName
}
result[key] = sku
}
return result
}

View File

@ -31,17 +31,28 @@ function baseRequest(url, method, data, {
});
}
}
// TODO 补个 header 多租户
if (url.indexOf('app-api') >= 0) {
header = {
...header
}
header['tenant-id'] = 1
header['Authorization'] = 'Bearer test247'
}
if (store.state.app.token) header[TOKENNAME] = store.state.app.token;
return new Promise((reslove, reject) => {
uni.request({
url: Url + '/api/front/' + url,
url: url.indexOf('app-api') < 0 ? Url + '/api/front/' + url
: 'http://127.0.0.1:48080/' + url, // TODO 芋艿:搞个 url 的配置
method: method || 'GET',
header: header,
data: data || {},
success: (res) => {
if (noVerify)
reslove(res.data, res);
else if (res.data.code == 200)
else if (res.data.code === 200 || res.data.code === 0)
reslove(res.data, res);
else if ([410000, 410001, 410002, 401].indexOf(res.data.code) !== -1) {
toLogin();

View File

@ -781,13 +781,21 @@ export default {
else return url.replace('http://', 'https://');
},
/**
* 姓名除了姓显示其他
*/
formatName: function(str) {
return str.substr(0, 1) + new Array(str.length).join('*');
}
},
}
/**
* 将分转成元
*
* @param price 例如说 100
* @returns {string} 例如说 1.00
*/
export function fen2yuan(price) {
return (price / 100.0).toFixed(2)
}