feat: finish home and product page

dev_1.0.1
hu-qi 5 months ago
parent 2b98bdd90c
commit a2b4cf369e
Signed by: huqi
GPG Key ID: B66F8F763A3A3251

@ -21,3 +21,10 @@ export function fetchProductDetail(id) {
url: '/product/detail/'+id url: '/product/detail/'+id
}) })
} }
export function fetchProductLuooDetail(id) {
return request({
method: 'GET',
url: '/product/luoo/detail/'+id
})
}

@ -48,8 +48,10 @@
"titleNView": { "titleNView": {
"type": "transparent" "type": "transparent"
} }
} },
"navigationStyle": "custom"
} }
}, { }, {
"path": "pages/set/set", "path": "pages/set/set",
"style": { "style": {

@ -1,17 +1,17 @@
<template> <template>
<view class="content"> <view class="content">
<view class="row b-b"> <view class="row b-b">
<text class="tit">姓名</text> <text class="tit">收货姓名</text>
<input class="input" type="text" v-model="addressData.name" placeholder="收货人姓名" placeholder-class="placeholder" /> <input class="input" type="text" v-model="addressData.name" placeholder="收货人姓名" placeholder-class="placeholder" />
</view> </view>
<view class="row b-b"> <view class="row b-b">
<text class="tit">手机号码</text> <text class="tit">手机号码</text>
<input class="input" type="number" v-model="addressData.phoneNumber" placeholder="收货人手机号码" placeholder-class="placeholder" /> <input class="input" type="number" v-model="addressData.phoneNumber" placeholder="收货人手机号码" placeholder-class="placeholder" />
</view> </view>
<view class="row b-b"> <!-- <view class="row b-b">
<text class="tit">邮政编码</text> <text class="tit">邮政编码</text>
<input class="input" type="number" v-model="addressData.postCode" placeholder="收货人邮政编码" placeholder-class="placeholder" /> <input class="input" type="number" v-model="addressData.postCode" placeholder="收货人邮政编码" placeholder-class="placeholder" />
</view> </view> -->
<!-- <view class="row b-b"> <!-- <view class="row b-b">
<text class="tit">所在区域</text> <text class="tit">所在区域</text>
<text @click="chooseLocation" class="input"> <text @click="chooseLocation" class="input">
@ -20,19 +20,19 @@
<text class="yticon icon-shouhuodizhi" @click="chooseLocation"></text> <text class="yticon icon-shouhuodizhi" @click="chooseLocation"></text>
</view> --> </view> -->
<view class="row b-b"> <view class="row b-b">
<text class="tit">所在区域</text> <text class="tit">收货地区</text>
<input class="input" type="text" v-model="addressData.prefixAddress" placeholder="所在区域" placeholder-class="placeholder" /> <input class="input" type="text" v-model="addressData.prefixAddress" placeholder="省市区县 乡镇" placeholder-class="placeholder" />
</view> </view>
<view class="row b-b"> <view class="row b-b">
<text class="tit">详细地址</text> <text class="tit">详细地址</text>
<input class="input" type="text" v-model="addressData.detailAddress" placeholder="详细地址" placeholder-class="placeholder" /> <input class="input" type="text" v-model="addressData.detailAddress" placeholder="街道 楼牌号" placeholder-class="placeholder" />
</view> </view>
<view class="row default-row"> <view class="row default-row">
<text class="tit">设为默认</text> <text class="tit">设为默认</text>
<switch :checked="addressData.defaultStatus==1" color="#fa436a" @change="switchChange" /> <switch :checked="addressData.defaultStatus==1" color="#fa436a" @change="switchChange" />
</view> </view>
<button class="add-btn" @click="confirm"></button> <button class="add-btn" @click="confirm"></button>
</view> </view>
</template> </template>
@ -60,9 +60,9 @@
} }
}, },
onLoad(option) { onLoad(option) {
let title = '新增收货地址'; let title = '新增地址';
if (option.type === 'edit') { if (option.type === 'edit') {
title = '编辑收货地址' title = '编辑地址'
fetchAddressDetail(option.id).then(response=>{ fetchAddressDetail(option.id).then(response=>{
this.addressData = response.data; this.addressData = response.data;
this.addressData.prefixAddress = this.addressData.province+this.addressData.city+this.addressData.region; this.addressData.prefixAddress = this.addressData.province+this.addressData.city+this.addressData.region;

@ -2,8 +2,8 @@
<view class="container"> <view class="container">
<!-- 搜索框 --> <!-- 搜索框 -->
<view class="search-box" customStyle="background-color: #ffffff;padding: 24upx;"> <view class="search-box" customStyle="background-color: #ffffff;padding: 24upx;">
<u-search class="search" v-model="keyword" :clearabled="true" :showAction="false" <u-search class="search" v-model="keyword" :clearabled="true" :showAction="false" bgColor="#ffffff"
bgColor="#ffffff"></u-search> @search="search" @clear="search"></u-search>
<navigator url="/pages/cart/cart" open-type="switchTab" class="icon-box"> <navigator url="/pages/cart/cart" open-type="switchTab" class="icon-box">
<image class="cart-icon" src="../../static/index/cart.svg" mode=""></image> <image class="cart-icon" src="../../static/index/cart.svg" mode=""></image>
@ -106,7 +106,9 @@
hotProductList: [], hotProductList: [],
recommendParams: { recommendParams: {
pageNum: 1, pageNum: 1,
pageSize: 4 pageSize: 4,
categoryId: '',
searchStr: '',
}, },
loadingType: 'more', loadingType: 'more',
tagCurrent: 0, tagCurrent: 0,
@ -124,7 +126,14 @@
}, },
// //
onPullDownRefresh() { onPullDownRefresh() {
this.recommendParams.pageNum = 1; this.recommendParams = {
pageNum: 1,
pageSize: 4,
searchStr: '',
categoryId: ''
};
this.tagCurrent = 0
this.keyword = ''
this.loadData(); this.loadData();
}, },
// //
@ -167,7 +176,7 @@
}); });
fetchContentV2().then(response => { fetchContentV2().then(response => {
this.categoryList = [{ this.categoryList = [{
id: 0, id: '',
name: "全部" name: "全部"
}].concat(response.data.categoryList) }].concat(response.data.categoryList)
}); });
@ -220,8 +229,31 @@
} }
}, },
changeTag(index) { changeTag(index) {
console.log('index', index) console.log('index', index, this.categoryList[index])
this.tagCurrent = index this.tagCurrent = index
const currentTag = this.categoryList[index]
this.recommendParams.pageNum = 1
this.recommendParams.pageSize = 4
this.recommendParams.categoryId = currentTag.id
this.getProductList()
},
search() {
this.recommendParams.searchStr = this.keyword
this.recommendParams.pageNum = 1
this.recommendParams.pageSize = 4
this.getProductList()
},
getProductList() {
fetchRecommendProductList(this.recommendParams).then(response => {
this.recommendProductList = response.data;
if (response.data.length === 0) {
this.loadingType = 'nomore';
} else {
this.loadingType = 'more';
}
uni.stopPullDownRefresh();
})
} }
}, },
} }
@ -330,6 +362,7 @@
/* 标签列表 */ /* 标签列表 */
.tag-list { .tag-list {
// padding: 0 36upx; // padding: 0 36upx;
.u-scroll-box { .u-scroll-box {
view { view {

@ -1,33 +1,39 @@
<template> <template>
<view class="container"> <view class="container">
<view class="carousel"> <view class="carousel">
<swiper indicator-dots circular=true duration="400"> <u-swiper :list="imgList" :autoplay="false" indicatorStyle="right: 20px" duration="400" mode="number"
<swiper-item class="swiper-item" v-for="(item,index) in imgList" :key="index"> height="750" indicator-pos="bottomRight" class="swiper">
<view class="image-wrapper"> </u-swiper>
<image :src="item.src" class="loaded" mode="aspectFill"></image> <view class="btn-box">
</view> <view class="goback" @click="goBack">
</swiper-item> <image src="@/static/icons/icon_back.png" mode=""></image>
</swiper> </view>
<view class="share" @click="share">
<image src="@/static/icons/icon_share.png" mode=""></image>
</view>
</view>
</view> </view>
<view class="introduce-section"> <view class="introduce-section">
<text class="title">{{product.name}}</text><br>
<text class="title2">{{product.subTitle}}</text>
<view class="price-box"> <view class="price-box">
<text class="price-tip">¥</text> <text class="price-tip">¥</text>
<text class="price">{{product.price}}</text> <text class="price">{{product.price}}</text>
<text class="m-price">¥{{product.originalPrice}}</text> <text class="m-price">¥{{product.originalPrice}}</text>
<!-- <text class="coupon-tip">7</text> --> <!-- <text class="coupon-tip">7</text> -->
</view> </view>
<view class="bot-row"> <text class="title">{{product.name}}</text><br>
<text class="title2">{{product.subTitle}}</text>
<!-- <view class="bot-row">
<text>销量: {{product.sale}}</text> <text>销量: {{product.sale}}</text>
<text>库存: {{product.stock}}</text> <text>库存: {{product.stock}}</text>
<text>浏览量: 768</text> <text>浏览量: 768</text>
</view> </view> -->
</view> </view>
<!-- 分享 --> <!-- 分享 -->
<view class="share-section" @click="share"> <!-- <view class="share-section" @click="share">
<view class="share-icon"> <view class="share-icon">
<text class="yticon icon-xingxing"></text> <text class="yticon icon-xingxing"></text>
@ -39,7 +45,7 @@
<text class="yticon icon-you"></text> <text class="yticon icon-you"></text>
</view> </view>
</view> </view> -->
<view class="c-list"> <view class="c-list">
<view class="c-row b-b" @click="toggleSpec"> <view class="c-row b-b" @click="toggleSpec">
@ -78,7 +84,7 @@
</view> </view>
<!-- 评价 --> <!-- 评价 -->
<view class="eva-section"> <!-- <view class="eva-section">
<view class="e-header"> <view class="e-header">
<text class="tit">评价</text> <text class="tit">评价</text>
<text>(86)</text> <text>(86)</text>
@ -86,7 +92,8 @@
<text class="yticon icon-you"></text> <text class="yticon icon-you"></text>
</view> </view>
<view class="eva-box"> <view class="eva-box">
<image class="portrait" src="http://img3.imgtn.bdimg.com/it/u=1150341365,1327279810&fm=26&gp=0.jpg" mode="aspectFill"></image> <image class="portrait" src="http://img3.imgtn.bdimg.com/it/u=1150341365,1327279810&fm=26&gp=0.jpg"
mode="aspectFill"></image>
<view class="right"> <view class="right">
<text class="name">Leo yo</text> <text class="name">Leo yo</text>
<text class="con">商品收到了79元两件质量不错试了一下有点瘦但是加个外罩很漂亮我很喜欢</text> <text class="con">商品收到了79元两件质量不错试了一下有点瘦但是加个外罩很漂亮我很喜欢</text>
@ -96,7 +103,7 @@
</view> </view>
</view> </view>
</view> </view>
</view> </view> -->
<!-- 品牌信息 --> <!-- 品牌信息 -->
<view class="brand-info"> <view class="brand-info">
@ -123,22 +130,29 @@
<!-- 底部操作菜单 --> <!-- 底部操作菜单 -->
<view class="page-bottom"> <view class="page-bottom">
<navigator url="/pages/index/index" open-type="switchTab" class="p-b-btn">
<text class="yticon icon-xiatubiao--copy"></text>
<text>首页</text>
</navigator>
<navigator url="/pages/cart/cart" open-type="switchTab" class="p-b-btn"> <navigator url="/pages/cart/cart" open-type="switchTab" class="p-b-btn">
<text class="yticon icon-gouwuche"></text> <!-- <text class="yticon icon-gouwuche"></text> -->
<text>购物车</text> <!-- <text>购物车</text> -->
<image class="pdicon" src="@/static/index/cart.svg"></image>
<u-badge type="error" class="cart-badge" :overflow-count="9" :count="cartNum"></u-badge>
</navigator>
<navigator url="/pages/index/index" open-type="switchTab" class="p-b-btn">
<!-- <text class="yticon icon-xiatubiao--copy"></text> -->
<!-- <text>首页</text> -->
<image class="pdicon" src="@/static/index/serverCenter.svg"></image>
</navigator> </navigator>
<view class="p-b-btn" :class="{active: favorite}" @click="toFavorite"> <view class="p-b-btn" :class="{active: favorite}" @click="toFavorite">
<text class="yticon icon-shoucang"></text> <!-- <text class="yticon icon-shoucang"></text> -->
<text>收藏</text> <!-- <text>收藏</text> -->
<image v-if="favorite" class="pdicon" src="@/static/index/collections-active.svg"></image>
<image v-else class="pdicon" src="@/static/index/collections.svg"></image>
</view> </view>
<view class="action-btn-group"> <view class="action-btn-group">
<button type="primary" class=" action-btn no-border buy-now-btn" @click="buy"></button>
<button type="primary" class=" action-btn no-border add-cart-btn" @click="addToCart"></button> <button type="primary" class=" action-btn no-border add-cart-btn" @click="addToCart"></button>
<button type="primary" class=" action-btn no-border buy-now-btn" @click="buy"></button>
</view> </view>
</view> </view>
@ -164,8 +178,9 @@
<view v-for="(item,index) in specList" :key="index" class="attr-list"> <view v-for="(item,index) in specList" :key="index" class="attr-list">
<text>{{item.name}}</text> <text>{{item.name}}</text>
<view class="item-list"> <view class="item-list">
<text v-for="(childItem, childIndex) in specChildList" v-if="childItem.pid === item.id" :key="childIndex" class="tit" <text v-for="(childItem, childIndex) in specChildList" v-if="childItem.pid === item.id"
:class="{selected: childItem.selected}" @click="selectSpec(childIndex, childItem.pid)"> :key="childIndex" class="tit" :class="{selected: childItem.selected}"
@click="selectSpec(childIndex, childItem.pid)">
{{childItem.name}} {{childItem.name}}
</text> </text>
</view> </view>
@ -218,7 +233,8 @@
<script> <script>
import share from '@/components/share.vue'; import share from '@/components/share.vue';
import { import {
fetchProductDetail fetchProductDetail,
fetchProductLuooDetail
} from '@/api/product.js'; } from '@/api/product.js';
import { import {
addCartItem addCartItem
@ -235,6 +251,9 @@
deleteProductCollection, deleteProductCollection,
productCollectionDetail productCollectionDetail
} from '@/api/memberProductCollection.js'; } from '@/api/memberProductCollection.js';
import {
fetchCartList
} from '@/api/cart.js';
import { import {
mapState mapState
} from 'vuex'; } from 'vuex';
@ -294,7 +313,8 @@
attrList: [], attrList: [],
promotionTipList: [], promotionTipList: [],
couponState: 0, couponState: 0,
couponList: [] couponList: [],
cartNum: 0,
}; };
}, },
async onLoad(options) { async onLoad(options) {
@ -326,7 +346,11 @@
}, },
methods: { methods: {
async loadData(id) { async loadData(id) {
fetchProductDetail(id).then(response => { // fetchProductLuooDetail(id).then(response => {
// console.log(response)
// this.product = response;
// });
await fetchProductDetail(id).then(async response => {
this.product = response.data.product; this.product = response.data.product;
this.skuStockList = response.data.skuStockList; this.skuStockList = response.data.skuStockList;
this.brand = response.data.brand; this.brand = response.data.brand;
@ -336,9 +360,10 @@
this.initAttrList(response.data); this.initAttrList(response.data);
this.initPromotionTipList(response.data); this.initPromotionTipList(response.data);
this.initProductDesc(); this.initProductDesc();
this.handleReadHistory(); await this.handleReadHistory();
this.initProductCollection(); this.initProductCollection();
}); });
this.getCartNum()
}, },
// //
toggleSpec() { toggleSpec() {
@ -366,10 +391,10 @@
toggleCoupon(type) { toggleCoupon(type) {
fetchProductCouponList(this.product.id).then(response => { fetchProductCouponList(this.product.id).then(response => {
this.couponList = response.data; this.couponList = response.data;
if(this.couponList==null||this.couponList.length==0){ if (this.couponList == null || this.couponList.length == 0) {
uni.showToast({ uni.showToast({
title:"暂无可领优惠券", title: "暂无可领优惠券",
icon:"none" icon: "none"
}) })
return; return;
} }
@ -468,7 +493,9 @@
for (let item of tempPics) { for (let item of tempPics) {
if (item != null && item != '') { if (item != null && item != '') {
this.imgList.push({ this.imgList.push({
src: item "src": item,
"image": item,
"type": 'image'
}); });
} }
} }
@ -578,6 +605,7 @@
// //
initProductDesc() { initProductDesc() {
let rawhtml = this.product.detailMobileHtml; let rawhtml = this.product.detailMobileHtml;
if(!rawhtml){ return}
let tempNode = document.createElement('div'); let tempNode = document.createElement('div');
tempNode.innerHTML = rawhtml; tempNode.innerHTML = rawhtml;
let imgs = tempNode.getElementsByTagName('img'); let imgs = tempNode.getElementsByTagName('img');
@ -590,6 +618,7 @@
}, },
// //
handleReadHistory() { handleReadHistory() {
console.log('handleReadHistory')
if (this.hasLogin) { if (this.hasLogin) {
let data = { let data = {
productId: this.product.id, productId: this.product.id,
@ -661,6 +690,7 @@
title: response.message, title: response.message,
duration: 1500 duration: 1500
}) })
this.getCartNum()
}); });
}, },
// //
@ -688,6 +718,7 @@
}, },
// //
initProductCollection() { initProductCollection() {
console.log('this.hasLogin', this.hasLogin)
if (this.hasLogin) { if (this.hasLogin) {
productCollectionDetail({ productCollectionDetail({
productId: this.product.id productId: this.product.id
@ -697,12 +728,22 @@
} }
}, },
// //
navToBrandDetail(){ navToBrandDetail() {
let id = this.brand.id; let id = this.brand.id;
uni.navigateTo({ uni.navigateTo({
url: `/pages/brand/brandDetail?id=${id}` url: `/pages/brand/brandDetail?id=${id}`
}) })
}, },
//
goBack() {
uni.navigateBack()
},
//
getCartNum() {
fetchCartList().then(response => {
this.cartNum = response.data.reduce((sum, item) => sum + item.quantity, 0);
})
}
}, },
} }
@ -712,6 +753,7 @@
page { page {
background: $page-color-base; background: $page-color-base;
padding-bottom: 160upx; padding-bottom: 160upx;
padding-top: var(--status-bar-height);
} }
.icon-you { .icon-you {
@ -722,9 +764,26 @@
.carousel { .carousel {
height: 722upx; height: 722upx;
position: relative; position: relative;
.btn-box {
width: 100vw;
position: absolute;
top: calc(var(--status-bar-height) + 38upx);
left: 0upx;
padding: 38upx;
@include flex(x, center, center);
justify-content: space-between;
/* align-self: ; */
view image {
width: 60upx;
height: 60upx;
}
}
swiper { .swiper {
height: 100%; height: 100%;
.u-swiper-indicator {
bottom: 36upx!important;
}
} }
.image-wrapper { .image-wrapper {
@ -750,7 +809,7 @@
/* 标题简介 */ /* 标题简介 */
.introduce-section { .introduce-section {
background: #fff; background: #fff;
padding: 20upx 30upx; padding: 36upx;
.title { .title {
font-size: 32upx; font-size: 32upx;
@ -996,6 +1055,9 @@
.detail-desc { .detail-desc {
background: #fff; background: #fff;
margin-top: 16upx; margin-top: 16upx;
/* margin-bottom: 60upx; */
margin-bottom: constant(safe-area-inset-bottom);
margin-bottom: env(safe-area-inset-bottom);
.d-header { .d-header {
display: flex; display: flex;
@ -1215,17 +1277,18 @@
/* 底部操作菜单 */ /* 底部操作菜单 */
.page-bottom { .page-bottom {
position: fixed; position: fixed;
left: 30upx; left: 0;
bottom: 30upx; bottom: 0;
z-index: 95; z-index: 95;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
width: 690upx; width: 100vw;
height: 100upx; height: 144upx;
background: rgba(255, 255, 255, .9); background: #ffffff;
box-shadow: 0 0 20upx 0 rgba(0, 0, 0, .5); box-sizing: content-box;
border-radius: 16upx; padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
.p-b-btn { .p-b-btn {
display: flex; display: flex;
@ -1236,6 +1299,11 @@
color: $font-color-base; color: $font-color-base;
width: 96upx; width: 96upx;
height: 80upx; height: 80upx;
position: relative;
.cart-badge>view {
top: 0upx !important;
right: 0upx !important;
}
.yticon { .yticon {
font-size: 40upx; font-size: 40upx;
@ -1243,6 +1311,11 @@
color: $font-color-light; color: $font-color-light;
} }
.pdicon {
width: 48upx;
height: 48upx;
}
&.active, &.active,
&.active .yticon { &.active .yticon {
color: $uni-color-primary; color: $uni-color-primary;
@ -1261,25 +1334,10 @@
.action-btn-group { .action-btn-group {
display: flex; display: flex;
height: 76upx; height: 76upx;
border-radius: 100px;
overflow: hidden; overflow: hidden;
box-shadow: 0 20upx 40upx -16upx #fa436a;
box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
background: linear-gradient(to right, #ffac30, #fa436a, #F56C6C);
margin-left: 20upx; margin-left: 20upx;
position: relative; position: relative;
&:after {
content: '';
position: absolute;
top: 50%;
right: 50%;
transform: translateY(-50%);
height: 28upx;
width: 0;
border-right: 1px solid rgba(255, 255, 255, .5);
}
.action-btn { .action-btn {
display: flex; display: flex;
align-items: center; align-items: center;
@ -1288,9 +1346,19 @@
height: 100%; height: 100%;
font-size: $font-base; font-size: $font-base;
padding: 0; padding: 0;
border-radius: 0; border-radius: 60upx;
background: transparent;
} }
.action-btn.add-cart-btn {
background-color: rgba(0, 0, 0, 0.05);
color: rgba(0, 0, 0, 0.95);
margin-right: 10upx;
}
.action-btn.buy-now-btn {
background-color: #CC342D;
}
} }
} }
@ -1469,14 +1537,14 @@
font-size: $font-base + 2upx; font-size: $font-base + 2upx;
color: $font-color-dark; color: $font-color-dark;
position: relative; position: relative;
text { text {
padding: 0 20upx; padding: 0 20upx;
background: #fff; background: #fff;
position: relative; position: relative;
z-index: 1; z-index: 1;
} }
&:after { &:after {
position: absolute; position: absolute;
left: 50%; left: 50%;
@ -1489,4 +1557,4 @@
} }
} }
} }
</style> </style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 7.1 KiB

@ -24,7 +24,7 @@ $border-color-light: #EBEEF5;
/* 图片加载中颜色 */ /* 图片加载中颜色 */
$image-bg-color: #eee; $image-bg-color: #eee;
/* 行为相关颜色 */ /* 行为相关颜色 */
$uni-color-primary:#fa436a; $uni-color-primary:#CC342D;
$uni-color-success: #4cd964; $uni-color-success: #4cd964;
$uni-color-warning: #f0ad4e; $uni-color-warning: #f0ad4e;
$uni-color-error: #dd524d; $uni-color-error: #dd524d;

Loading…
Cancel
Save