商品详情

msb_beta
ch 3 years ago
parent 39d7c5a2d5
commit 92014b93cc

@ -2,19 +2,19 @@
* @Author: ch
* @Date: 2022-03-17 16:38:39
* @LastEditors: ch
* @LastEditTime: 2022-03-30 17:58:33
* @LastEditTime: 2022-04-02 09:58:50
* @Description: file content
*/
import {ToAsyncAwait, Request} from '@/common/utils';
import {ToAsyncAwait, MsbRequest} from '@/common/utils';
import orderList from '@/mock/orderList'
const ApiGetCurrentUser = () =>
ToAsyncAwait(Request.get('/user/current'));
ToAsyncAwait(MsbRequest.get('/user/current'));
const ApiPutUser = (data) =>
ToAsyncAwait(Request.put('/user/', data))
ToAsyncAwait(MsbRequest.put('/user/', data))
export {
// 获取当前登录用户信息
ApiGetCurrentUser,

@ -0,0 +1,27 @@
/*
* @Author: ch
* @Date: 2022-04-02 09:54:53
* @LastEditors: ch
* @LastEditTime: 2022-04-02 15:17:20
* @Description: file content
*/
import {ToAsyncAwait, MsbRequest} from '@/common/utils';
/**
* 获取商品瀑布流
* @param {*} params
*/
export const ApiGetGoodsList = (params) =>
ToAsyncAwait(MsbRequest.get('/app/product/page', params));
/**
* 获取商品详情
* @param {*} params
*/
export const ApiGetGoodsDetail = (params) =>
ToAsyncAwait(MsbRequest.get(`/app/product/${params.id}`));
/**
* 获取商品sku信息
* @param {*} productId
*/
export const ApiGetGoodsSkus = (params) =>
ToAsyncAwait(MsbRequest.get('/app/product/sku',params));

@ -2,29 +2,28 @@
* @Author: ch
* @Date: 2022-03-17 16:37:45
* @LastEditors: ch
* @LastEditTime: 2022-03-28 18:09:39
* @LastEditTime: 2022-04-02 09:58:40
* @Description: file content
*/
import {Request, ToAsyncAwait} from '@/common/utils';
import {MsbRequest, ToAsyncAwait} from '@/common/utils';
/**
* 获取测试信息
* @param {*} params
*/
const ApiGetBannerData = (params) =>
ToAsyncAwait(Request.get('/edu-course/carousel/app',params));
const ApiPostLogin = (data) => ToAsyncAwait(Request.post('/user/login', data));
const ApiGetCode = (params) => ToAsyncAwait(Request.get('/user/login/verificationCode', params));
export const ApiGetBannerData = (params) =>
ToAsyncAwait(MsbRequest.get('/edu-course/carousel/app',params));
/**
* 登录
* @param {*} data
*/
export const ApiPostLogin = (data) => ToAsyncAwait(MsbRequest.post('/user/login', data));
/**
* 获取手机验证码
* @param {*} params
*/
export const ApiGetCode = (params) => ToAsyncAwait(MsbRequest.get('/user/login/verificationCode', params));
export {
ApiGetBannerData,
// 登录
ApiPostLogin,
// 获取短信验证码
ApiGetCode
}

@ -2,49 +2,49 @@
* @Author: ch
* @Date: 2022-03-29 17:38:17
* @LastEditors: ch
* @LastEditTime: 2022-03-31 20:43:09
* @LastEditTime: 2022-04-02 09:58:29
* @Description: file content
*/
import {ToAsyncAwait, Request} from '@/common/utils';
import {ToAsyncAwait, MsbRequest} from '@/common/utils';
/**
* 获取订单
* @param {*} params
*/
export const ApiGetOrderList = (params) =>
ToAsyncAwait(Request.get('/app/tradeOrder/page', params));
ToAsyncAwait(MsbRequest.get('/app/tradeOrder/page', params));
/**
* 获取预订单
* @param {*} data
*/
export const ApiGetBeforeOrder = (data) =>
ToAsyncAwait(Request.get('/app/tradeOrder/buyAdvanceOrder', data));
ToAsyncAwait(MsbRequest.get('/app/tradeOrder/buyAdvanceOrder', data));
/**
* 订单详情
* @param {*} id
*/
export const ApiGetOrderDetail = (id) =>
ToAsyncAwait(Request.get(`/app/tradeOrder/${id}`));
ToAsyncAwait(MsbRequest.get(`/app/tradeOrder/${id}`));
/**
* 提交订单
* @param {*} data
*/
export const ApiPostSubmitOrder = (data) =>
ToAsyncAwait(Request.post('/app/tradeOrder/submitOrder', data));
ToAsyncAwait(MsbRequest.post('/app/tradeOrder/submitOrder', data));
/**
* 取消订单
* @param {*} data
*/
export const ApiPutCancelOrder = (data) =>
ToAsyncAwait(Request.post('/app/tradeOrder/cancel', data));
ToAsyncAwait(MsbRequest.post('/app/tradeOrder/cancel', data));
/**
* 获取支付参数
* @param {*} data
*/
export const ApiPostWxPay = (data) =>
ToAsyncAwait(Request.post('/pay/wxPay/app', data));
ToAsyncAwait(MsbRequest.post('/pay/wxPay/app', data));

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-17 17:42:32
* @LastEditors: ch
* @LastEditTime: 2022-03-30 10:22:01
* @LastEditTime: 2022-04-02 09:58:14
* @Description: 项目接口请求统一处理器返回一个需要token和不需要token的请求封装方法
*/
@ -34,30 +34,18 @@ const errorIntercept = (error) =>{
return Promise.reject({message:error.errMsg,code:error.statusCode})
}
// 不需要token的接口封装
const Request = new MsbUniRequest();
Request.baseUrl = BASE_URL[ENV];
const MsbRequest = new MsbUniRequest();
MsbRequest.baseUrl = BASE_URL[ENV];
Request.use('request', (option) => {
MsbRequest.use('request', (option) => {
$store.state.token && (option.header = {...option.header, Authorization:$store.state.token});
return option;
})
Request.use('success', successIntercept);
Request.use('error', errorIntercept);
// 需要token的接口
const RequestTk = new MsbUniRequest();
RequestTk.baseUrl = BASE_URL[ENV];
RequestTk.use('request', (option) => {
return option;
})
RequestTk.use('success', successIntercept);
RequestTk.use('error', errorIntercept);
MsbRequest.use('success', successIntercept);
MsbRequest.use('error', errorIntercept);
export {
// 不需要Token的接口请求用这个实例
Request,
// 需要token的请求
RequestTk
MsbRequest
}

@ -2,102 +2,116 @@
* @Author: ch
* @Date: 2022-03-20 16:45:27
* @LastEditors: ch
* @LastEditTime: 2022-03-28 16:17:12
* @LastEditTime: 2022-04-02 11:15:46
* @Description: file content
-->
<template>
<view class="goods">
<view class="goods--column">
<view class="goods-item" @click="$Router.push('/pages/goods/detail')">
<image class="goods-item--img" src="@/static/testImg/2.png" mode="widthFix"></image>
<view class="goods-item--title"><text>JAVA语言程序员必备的技术书籍</text></view>
<view class="goods-item--pirce-box">
<view>
<text class="goods-item--pirce">29</text>
<text class="goods-item--original-pirce">50</text>
<view>
<view class="goods">
<view class="goods--column">
<view class="goods-item" v-for="item in goodsLeftData" :key="item.id"
@click="$Router.push(`/goodsDetail?id=${item.id}`)">
<image class="goods-item--img" :src="item.mainPicture" mode="widthFix"></image>
<view class="goods-item--title"><text>{{item.name}}</text></view>
<view class="goods-item--pirce-box">
<view>
<text class="goods-item--pirce">{{item.startingPrice}}</text>
<text class="goods-item--original-pirce">50</text>
</view>
<view>
<image class="goods-item--icon" src='@/static/index/bz.png'></image>
</view>
</view>
<view>
<image class="goods-item--icon" src='@/static/index/bz.png'></image>
<view class="goods-item--activity">
<text class="goods-item--activity-title">秒杀</text>
<text class="goods-item--activity-desc">正在抢购中</text>
</view>
</view>
<view class="goods-item--activity">
<text class="goods-item--activity-title">秒杀</text>
<text class="goods-item--activity-desc">正在抢购中</text>
</view>
</view>
<view class="goods-item">
<image class="goods-item--img" src="@/static/testImg/3.png" mode="widthFix"></image>
<view class="goods-item--title"><text>JAVA语言程序员必备的技术书籍</text></view>
<view class="goods-item--pirce-box">
<view>
<text class="goods-item--pirce">29</text>
<text class="goods-item--original-pirce">50</text>
</view>
<view>
<image class="goods-item--icon" src='@/static/index/bz.png'></image>
</view>
</view>
<view class="goods-item--activity">
<text class="goods-item--activity-title">秒杀</text>
<text class="goods-item--activity-desc">正在抢购中</text>
</view>
</view>
<view class="goods-item">
<image class="goods-item--img" src="@/static/testImg/2.png" mode="widthFix"></image>
<view class="goods-item--title"><text>JAVA语言程序员必备的技术书籍</text></view>
<view class="goods-item--pirce-box">
<view>
<text class="goods-item--pirce">29</text>
<text class="goods-item--original-pirce">50</text>
</view>
<view>
<image class="goods-item--icon" src='@/static/index/bz.png'></image>
</view>
</view>
<view class="goods-item--activity">
<text class="goods-item--activity-title">秒杀</text>
<text class="goods-item--activity-desc">正在抢购中</text>
</view>
</view>
</view>
<view class="goods--column">
<view class="goods-item">
<image class="goods-item--img" src="@/static/testImg/3.png" mode="widthFix"></image>
<view class="goods-item--title"><text>JAVA语言程序员必备的技术书籍</text></view>
<view class="goods-item--pirce-box">
<view>
<text class="goods-item--pirce">29</text>
<text class="goods-item--original-pirce">50</text>
</view>
<view>
<image class="goods-item--icon" src='@/static/index/bz.png'></image>
</view>
</view>
<view class="goods-item--activity">
<text class="goods-item--activity-title">秒杀</text>
<text class="goods-item--activity-desc">正在抢购中</text>
</view>
</view>
<view class="goods-item">
<image class="goods-item--img" src="@/static/testImg/2.png" mode="widthFix"></image>
<view class="goods-item--title"><text>JAVA语言程序员必备的技术书籍</text></view>
<view class="goods-item--pirce-box">
<view>
<text class="goods-item--pirce">29</text>
<text class="goods-item--original-pirce">50</text>
<view class="goods--column">
<view class="goods-item" v-for="item in goodsRightData" :key="item.id"
@click="$Router.push(`/goodsDetail?id=${item.id}`)">
<image class="goods-item--img" :src="item.mainPicture" mode="widthFix"></image>
<view class="goods-item--title"><text>{{item.name}}</text></view>
<view class="goods-item--pirce-box">
<view>
<text class="goods-item--pirce">{{item.startingPrice}}</text>
<text class="goods-item--original-pirce">50</text>
</view>
<view>
<image class="goods-item--icon" src='@/static/index/bz.png'></image>
</view>
</view>
<view>
<image class="goods-item--icon" src='@/static/index/bz.png'></image>
<view class="goods-item--activity">
<text class="goods-item--activity-title">秒杀</text>
<text class="goods-item--activity-desc">正在抢购中</text>
</view>
</view>
<view class="goods-item--activity">
<text class="goods-item--activity-title">秒杀</text>
<text class="goods-item--activity-desc">正在抢购中</text>
</view>
</view>
</view>
<u-loadmore :status="loadingStatus" />
</view>
</template>
<script>
import {ApiGetGoodsList} from '@/common/api/goods';
export default {
data(){
return {
loadingStatus : 'loading',
goodsLeftData : [],
goodsRightData : [],
params : {
length : 10,
pageIndex : 1
}
}
},
mounted(){
this.getGoodsList();
},
methods : {
async getGoodsList(){
this.loadingStatus = 'loading';
const {error, result} = await ApiGetGoodsList({
...this.params
});
const abs = this.goodsLeftData.length - this.goodsRightData.length;
const newLeftData = [];
const newRightData = [];
if(abs < 1){
result.records.forEach((item, index) => {
if(index % 2 === 0){
newLeftData.push(item);
}else{
newRightData.push(item);
}
})
}else{
result.records.forEach((item, index) => {
if(index % 2 !== 0){
newLeftData.push(item);
}else{
newRightData.push(item);
}
})
}
this.goodsLeftData = this.goodsLeftData.concat(newLeftData);
this.goodsRightData = this.goodsRightData.concat(newRightData);
//
if(!result.records.length){
this.loadingStatus = 'nomore';
}
},
next(){
if(this.loadingStatus === 'nomore'){
return false
}
this.params.pageIndex++;
this.getGoodsList();
}
}
}
</script>
<style lang="scss" scoped>
.goods{

@ -78,11 +78,14 @@
"/user/" : {
"target": "http://192.168.10.251:4500/"
},
"/app/" : {
"/app/tradeOrder/" : {
"target": "http://192.168.10.109:4001/"
},
"/pay/" : {
"target": "http://192.168.10.109:4001/"
},
"/app/product/" : {
"target" : "http://192.168.10.67:4002/"
}
}
}

@ -10,10 +10,10 @@
"image_id": 10185,
"status": 1,
"sort": 50,
"children": [
"productList": [
{
"name" : "上班必备",
"children" : [
"productList" : [
{
"category_id": 10010,
"name": "小米",
@ -234,7 +234,7 @@
},
{
"name" : "办公必备",
"children": [
"productList": [
{
"category_id": 10010,
"name": "小米",
@ -483,9 +483,9 @@
"image_id": 0,
"status": 1,
"sort": 55,
"children": [{
"productList": [{
"name" : "子分类或按标签分组",
"children" : [
"productList" : [
{
"category_id": 10025,
"name": "多用途锅",
@ -714,7 +714,7 @@
"image_id": 0,
"status": 1,
"sort": 60,
"children": [
"productList": [
{
"category_id": 10027,
"name": "游戏本",
@ -968,7 +968,7 @@
"image_id": 0,
"status": 1,
"sort": 65,
"children": [
"productList": [
{
"category_id": 10044,
"name": "挂件",
@ -1222,7 +1222,7 @@
"image_id": 0,
"status": 1,
"sort": 70,
"children": [
"productList": [
{
"category_id": 10053,
"name": "自营男装",
@ -1476,7 +1476,7 @@
"image_id": 0,
"status": 1,
"sort": 75,
"children": [
"productList": [
{
"category_id": 10058,
"name": "牛仔裤",
@ -1730,7 +1730,7 @@
"image_id": 0,
"status": 1,
"sort": 80,
"children": [
"productList": [
{
"category_id": 10074,
"name": "欧美表",
@ -1903,7 +1903,7 @@
"image_id": 0,
"status": 1,
"sort": 90,
"children": [
"productList": [
{
"category_id": 10079,
"name": "自营女包",
@ -2076,7 +2076,7 @@
"image_id": 0,
"status": 1,
"sort": 100,
"children": [
"productList": [
{
"category_id": 10086,
"name": "抱枕靠垫",
@ -2141,7 +2141,7 @@
"image_id": 0,
"status": 1,
"sort": 100,
"children": [
"productList": [
{
"category_id": 10089,
"name": "运动鞋",

File diff suppressed because one or more lines are too long

@ -56,6 +56,7 @@
},
{
"path": "pages/goods/detail/index",
"aliasPath" : "/goodsDetail",
"style": {
"navigationStyle" : "custom",
"navigationBarTitleText": "uni-app"

@ -14,12 +14,13 @@
<!-- 右侧 二级分类 -->
<scroll-view class="cate-right" :scroll-top="scrollTop" :scroll-y="true">
<image class="cate-tow-img" :src="list[curIndex].image ? list[curIndex].image.preview_url : ''"></image>
<view v-for="(item, idx) in list[curIndex].children"
<!-- <image class="cate-tow-img" :src="list[curIndex].image ? list[curIndex].image.preview_url : ''"></image> -->
<image class="cate-tow-img" src="@/static/goods/category_banner.jpg"></image>
<view v-for="(item, idx) in list[curIndex].productList"
:key="idx" @click="onTargetGoodsList(item.category_id)">
<view class="cate-tow-group">
<text class="cate-tow-group--title">{{item.name}}</text>
<view class="cate-tow-group--item" v-for="i in item.children" :key="i.id">
<view class="cate-tow-group--item" v-for="i in item.productList" :key="i.id">
<image class="cate-tow-group--img" mode="scaleToFill"
:src="i.image.preview_url"></image>
<text class="cate-tow-group--name">{{i.name}}</text>

@ -1,178 +1,219 @@
<!--
* @Author: ch
* @Date: 2022-03-24 11:30:55
* @LastEditors: ch
* @LastEditTime: 2022-04-02 18:10:15
* @Description: file content
-->
<template>
<goods-sku-popup :value="value" @input="onChangeValue" border-radius="20" :localdata="goodsInfo" :mode="skuMode"
:maskCloseAble="true" @open="openSkuPopup" @close="closeSkuPopup" @add-cart="addCart" @buy-now="buyNow"
buyNowText="立即购买" />
<u-popup :show="value" round="24rpx">
<view class="sku-popup">
<view class="product-info">
<image class="product-img" src="https://msb-edu-dev.oss-cn-beijing.aliyuncs.com/test/1.png"/>
<view>
<view>{{curSku.sellPrice}}</view>
<text>{{curSku.name}}</text>
<view>库存{{curSku.stock}}</view>
</view>
</view>
<view class="attr-group" v-for="(item, index) in attributeGroupList" :key="item.id">
<text class="attr-name">{{item.name}}</text>
<view class="attr-items">
<text class="attr-item" :class="{'attr-item__active' : i.active, 'attr-item__disabled' : i.disabled}"
v-for="i in item.attributes" :key="i.symbol"
@click="handleAttrItem(i, index)"
>{{i.name}}</text>
</view>
</view>
<view class="sku-num">
<view>
<text>数量</text>
<text>有货</text>
</view>
<u-number-box :min="1" :max="curSku.stock" button-size="40rpx" bgColor="#F5F6FA"
:value="curNum" >
<text slot="minus" class="cart-item--stepper-icon">-</text>
<text slot="plus" class="cart-item--stepper-icon">+</text>
</u-number-box>
</view>
<view class="footer">
<UiButton>加入购物车</UiButton>
<UiButton>立即购买</UiButton>
</view>
</view>
</u-popup>
</template>
<script>
// import { setCartTotalNum } from '@/core/app'
// import * as CartApi from '@/api/cart'
import GoodsSkuPopup from '@/components/goods-sku-popup'
export default {
components: {
GoodsSkuPopup
},
model: {
prop: 'value',
event: 'input'
},
props: {
// true false
value: {
Type: Boolean,
default: false
},
// 1: 2: 3:
skuMode: {
type: Number,
default: 1
},
//
goods: {
type: Object,
default: {}
}
},
data() {
return {
goodsInfo: {}
}
},
created() {
const app = this
const { goods } = app
app.goodsInfo = {
_id: goods.goods_id,
name: goods.goods_name,
goods_thumb: goods.goods_image,
sku_list: app.getSkuList(),
spec_list: app.getSpecList()
}
},
methods: {
//
onChangeValue(val) {
this.$emit('input', val)
},
// SKU
getSkuList() {
const app = this
const { goods: { goods_name, goods_image, skuList } } = app
const skuData = []
skuList.forEach(item => {
skuData.push({
_id: item.id,
goods_sku_id: item.goods_sku_id,
goods_id: item.goods_id,
goods_name: goods_name,
image: item.image_url ? item.image_url : goods_image,
price: item.goods_price * 100,
stock: item.stock_num,
spec_value_ids: item.spec_value_ids,
sku_name_arr: app.getSkuNameArr(item.spec_value_ids)
})
})
return skuData
},
// sku
getSkuNameArr(specValueIds) {
const app = this
const defaultData = ['默认']
const skuNameArr = []
if (specValueIds) {
specValueIds.forEach((valueId, groupIndex) => {
const specValueName = app.getSpecValueName(valueId, groupIndex)
skuNameArr.push(specValueName)
})
}
return skuNameArr.length ? skuNameArr : defaultData
},
//
getSpecValueName(valueId, groupIndex) {
const app = this
const { goods: { specList } } = app
const res = specList[groupIndex].valueList.find(specValue => {
return specValue.spec_value_id == valueId
})
return res.spec_value
},
//
getSpecList() {
const { goods: { specList } } = this
const defaultData = [{ name: '默认', list: [{ name: '默认' }] }]
const specData = []
specList.forEach(group => {
const children = []
group.valueList.forEach(specValue => {
children.push({ name: specValue.spec_value })
})
specData.push({
name: group.spec_name,
list: children
})
})
return specData.length ? specData : defaultData
},
// sku -----------------------------------------------------------
openSkuPopup() {
// console.log(" - sku")
},
closeSkuPopup() {
// console.log(" - sku")
},
//
addCart(selectShop) {
const app = this
const { goods_id, goods_sku_id, buy_num } = selectShop
// CartApi.add(goods_id, goods_sku_id, buy_num)
// .then(result => {
// //
// app.$toast(result.message)
// //
// app.onChangeValue(false)
// //
// const cartTotal = result.data.cartTotal
// //
// setCartTotalNum(cartTotal)
// //
// app.$emit('addCart', cartTotal)
// })
},
//
buyNow(selectShop) {
//
this.$Router.push({path : '/orderSubmit', query:{
mode: 'buyNow',
skuId: selectShop.goods_sku_id,
num: selectShop.buy_num
}})
// this.$navTo('pages/checkout/index', {
// mode: 'buyNow',
// goodsId: selectShop.goods_id,
// goodsSkuId: selectShop.goods_sku_id,
// goodsNum: selectShop.buy_num
// })
//
this.onChangeValue(false)
}
}
}
import UiButton from '../../../components/UiButton.vue';
export default {
components: { UiButton },
props: {
// true false
value: {
Type: Boolean,
default: false,
},
// 1: 2: 3:
mode: {
type: Number,
default: 1,
},
//
goodsInfo: {
type: Object,
default: {},
},
// sku
skuInfo : {
type : Array,
default : []
}
},
data() {
return {
// props
attributeGroupList : [],
//
curNum : 1,
};
},
watch : {
goodsInfo(newData){
if(newData.attributeGroupList){
this.attributeGroupList = newData.attributeGroupList;
//
if(this.skuInfo.length){
this.setDefaultAttr();
}
}
},
skuInfo(newData){
//
if(newData.length){
this.setDefaultAttr();
}
}
},
computed : {
/**
* 当前选中SKU根据选中规格计算
*/
curSku(){
const skuSymbolList = this.attributeGroupList.map(item => {
const activeAttr = item.attributes.find(i => i.active);
return activeAttr ? activeAttr.symbol : ''
}).filter(i => i);
return this.skuInfo.find(i => i.attributeSymbolList === skuSymbolList.join(',')) || {};
}
},
methods: {
/**
* 设置默认选中规格
*/
setDefaultAttr(){
const curSku = this.skuInfo.find(i => i.stock > 0);
this.attributeGroupList.forEach(item => {
for(let i of item.attributes){
if(curSku.attributeSymbolList.includes(i.symbol)){
this.$set(i,'active', true);
break;
}
}
})
},
/**
* 点击属性项设置选中和禁用项
*/
handleAttrItem(item, groupIndex){
//
if(item.disabled){
return false;
}
// 1
this.curNum = 1;
//
this.attributeGroupList[groupIndex].attributes.forEach(item =>{
this.$set(item,'active', false);
});
//
this.$set(item,'active', true);
// SKUsymbol ,0SKU
const symbols = this.skuInfo.filter(i => i.attributeSymbolList.includes(item.symbol) && i.stock > 0)
.map(i => i.attributeSymbolList).join(',');
this.attributeGroupList.forEach((group, index) => {
if(groupIndex === index){
return false;
}
// SKUsymbos
group.attributes.forEach(item =>{
if(!symbols.includes(item.symbol)){
this.$set(item,'disabled', true);
}else{
this.$set(item,'disabled', false);
}
})
})
}
},
};
</script>
<style lang="scss" scoped>
.sku-popup{
padding: 30rpx;
}
.product-info{
display: flex;
}
.product-img{
width: 200rpx;
height: 200rpx;
}
.attr-group{
margin-top: 40rpx;
font-size: 30rpx;
}
.attr-items{
display: flex;
flex-wrap: wrap;
padding: 10rpx 0;
}
.attr-item{
background: #F8F8F8;
line-height: 70rpx;
border-radius: 100rpx;
border: 1px solid #F8F8F8;
color: #666;
display: block;
min-width: 158rpx;
max-width: 630rpx;
text-align: center;
margin: 20rpx 28rpx 0 0;
padding: 0 20rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
&__active{
background: #FFF3EE;
border-color: #FF512B;
color: #FF875B;
}
&__disabled{
color: #ccc;
}
}
.sku-num{
display: flex;
justify-content: space-between;
margin: 40rpx 0;
}
.footer{
display: flex;
justify-content: space-between;
}
</style>

@ -2,25 +2,25 @@
* @Author: ch
* @Date: 2022-03-23 17:27:21
* @LastEditors: ch
* @LastEditTime: 2022-03-24 14:10:20
* @LastEditTime: 2022-04-02 16:21:43
* @Description: file content
-->
<template>
<view>
<SlideImage :images="goods.goods_images"></SlideImage>
<SlideImage :images="goods.images"></SlideImage>
<view class="goods-info">
<view class="pirce">
<text></text>
<text>199.9</text>
<text></text>
</view>
<view class="goods-info--title">{{goods.goods_name}}</view>
<view class="goods-info--title">{{goods.name}}</view>
</view>
<view class="select">
<Service></Service>
<u-cell label="选择" :border="false" isLink @click="onShowSkuPopup()"></u-cell>
<SkuPopup v-model="showSkuPopup" :skuMode="skuMode" :goods="goods" @addCart="onAddCart" ></SkuPopup>
<SkuPopup v-model="showSkuPopup" :mode="skuMode" :goodsInfo="goods" :skuInfo="skuInfo" @addCart="onAddCart" ></SkuPopup>
</view>
<view class="goods-desc">
<mp-html :content="goods.content"/>
@ -40,7 +40,7 @@
</template>
<script>
import goodsDetailData from '@/mock/goodsDetail.json';
import {ApiGetGoodsDetail, ApiGetGoodsSkus} from '@/common/api/goods';
import SlideImage from '@/pages/goods/detail/SlideImage.vue';
import Service from './Service.vue';
import mpHtml from 'mp-html/dist/uni-app/components/mp-html/mp-html';
@ -49,13 +49,41 @@ export default {
components: { SlideImage, mpHtml, Service, SkuPopup},
data(){
return {
goods : goodsDetailData.data.detail,
goods : {},
skuInfo : [],
showSkuPopup : false,
// sku 1: 2: 3:
skuMode : 1
}
},
onLoad(){
this.getGoodsDetail();
this.getGoodsSkus();
},
methods:{
async getGoodsDetail(){
const {query} = this.$Route;
const {error, result} = await ApiGetGoodsDetail({id : query.id});
if(error){
uin.$u.totast(error.message);
return false;
}
result.attributeGroupList[0].attributes = [...result.attributeGroupList[0].attributes, ...[
{name: "绿色", symbol: 6}
]]
this.goods = {...result,
images : result.otherPictureList || [result.mainPicture],
};
},
async getGoodsSkus(){
const {query} = this.$Route;
const {error, result} = await ApiGetGoodsSkus({productId : query.id});
if(error) {
uin.$u.totast(error.message);
return false;
}
this.skuInfo = result;
},
/**
* 显示/隐藏SKU弹窗
* @param {skuMode} 模式 1:都显示 2:只显示购物车 3:只显示立即购买

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-21 10:31:54
* @LastEditors: ch
* @LastEditTime: 2022-03-29 10:45:01
* @LastEditTime: 2022-04-02 11:12:11
* @Description: file content
-->
<template>
@ -17,7 +17,7 @@
<!-- 排序标签 -->
<Sort></Sort>
</view>
<BsGoodsGroup class="goods-group"></BsGoodsGroup>
<BsGoodsGroup class="goods-group" ref="goodsGroup" ></BsGoodsGroup>
</view>
</template>
<script>
@ -36,8 +36,11 @@ export default {
// console.log(getCurrentPages())
},
onReachBottom(){
this.$refs.goodsGroup.next()
},
onHide(){
console.log(getCurrentPages());
// console.log(getCurrentPages());
}
};
</script>

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2019-08-22 19:41:20
* @LastEditors: ch
* @LastEditTime: 2022-03-29 14:01:10
* @LastEditTime: 2022-04-02 11:12:22
* @Description: file content
-->
<template>
@ -36,7 +36,7 @@
<Pick></Pick>
<view class="title">为您推荐</view>
<BsGoodsGroup></BsGoodsGroup>
<BsGoodsGroup ref="goodsGroup" ></BsGoodsGroup>
</view>
</template>
<script>
@ -58,20 +58,22 @@ export default {
{ url : 'bz4.png', title : '数码周边'},
{ url : 'bz5.png', title : '数码周边'},
{ url : 'bz6.png', title : '数码周边'},
]
],
goodsData:[]
}
},
onLoad(){
this.getBannerList();
},
onReachBottom(){
this.$refs.goodsGroup.next()
},
onShow(){
uni.pageScrollTo({
scrollTop: 0,
duration : 0
});
this.scrollTop = 0;
console.log(this.$store.state);
},
onPageScroll({scrollTop}){
if(this.scrollTop > 36 && scrollTop > 36){
@ -82,9 +84,9 @@ export default {
},
methods : {
async getBannerList(){
const {error, result} = await ApiGetBannerData({pageIndex:1, length:999});
console.log(result)
this.bannerList = result.concat(result).map(i => i.imgUrl);
// const {error, result} = await ApiGetBannerData({pageIndex:1, length:999});
// console.log(result)
// this.bannerList = result.concat(result).map(i => i.imgUrl);
}
}
}

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-31 14:26:09
* @LastEditors: ch
* @LastEditTime: 2022-03-31 22:45:02
* @LastEditTime: 2022-04-01 11:23:13
* @Description: file content
-->
<template>
@ -84,7 +84,7 @@
import UiPageHeader from '@/components/UiPageHeader.vue'
import UiGoodsInfo from '../../../components/UiGoodsInfo.vue'
import UiWhiteBox from '../../../components/UiWhiteBox.vue'
import {ApiGetOrderDetail,ApiPutCancelOrder} from '@/common/api/order'
import {ApiGetOrderDetail, ApiPutCancelOrder} from '@/common/api/order'
import UiButton from '../../../components/UiButton.vue'
import StatusTips from './StatusTips.vue'
import UiCell from '../../../components/UiCell.vue'
@ -130,7 +130,10 @@ export default {
this.cancelValue = val;
},
async cancelOrder(){
const {error, result} = await ApiPutCancelOrder(this.$Route.query.id);
const {error, result} = await ApiPutCancelOrder({
cancelReasonType : this.cancelValue,
orderId : this.$Route.query.id
});
if(error){
uni.$u.totast(error.message);
return false;

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Loading…
Cancel
Save