Commit aec557e9 authored by Junling Bu's avatar Junling Bu
Browse files

chore[litemall-vue]: 参考litemall-admin结构,重新调整litemall-vue的src结构

parent 8d262f8b
import axios from 'axios'
import { Dialog, Toast } from 'vant';
// create an axios instance
const service = axios.create({
baseURL: process.env.BASE_API, // api 的 base_url
timeout: 5000 // request timeout
})
// request interceptor
service.interceptors.request.use(
config => {
if (!config.headers['X-Litemall-Token']) {
config.headers['X-Litemall-Token'] = `${window.localStorage.getItem(
'Authorization'
) || ''}`;
}
return config;
},
err => Promise.reject(err)
)
// response interceptor
service.interceptors.response.use(
response => {
const res = response.data
if (res.errno === 501) {
Toast.fail('请登录');
setTimeout(() => {
window.location = '#/login/'
}, 1500)
return Promise.reject('error')
} else if (res.errno === 502) {
Toast.alert('网站内部错误,请联系网站维护人员')
return Promise.reject('error')
} else if (res.errno !== 0) {
// 非5xx的错误属于业务错误,留给具体页面处理
return Promise.reject(response)
} else {
return response
}
}, error => {
console.log('err' + error)// for debug
Dialog.alert({
title: '警告',
message: '登录连接超时'
});
return Promise.reject(error)
})
export default service
export default { export default {
isAttached(element) { isAttached(element) {
let currentNode = element.parentNode; let currentNode = element.parentNode;
while (currentNode) { while (currentNode) {
if (currentNode.tagName === 'HTML') { if (currentNode.tagName === 'HTML') {
return true; return true;
} }
if (currentNode.nodeType === 11) { if (currentNode.nodeType === 11) {
return false; return false;
} }
currentNode = currentNode.parentNode; currentNode = currentNode.parentNode;
} }
return false; return false;
}, },
getScrollLeft(element) { getScrollLeft(element) {
return 'scrollLeft' in element ? element.scrollLeft : element.pageXOffset; return 'scrollLeft' in element ? element.scrollLeft : element.pageXOffset;
}, },
getVisibleHeight(element) { getVisibleHeight(element) {
return element === window return element === window
? element.innerHeight ? element.innerHeight
: element.getBoundingClientRect().height; : element.getBoundingClientRect().height;
}, },
getVisibleWidth(element) { getVisibleWidth(element) {
return element === window return element === window
? element.innerWidth ? element.innerWidth
: element.getBoundingClientRect().width; : element.getBoundingClientRect().width;
} }
}; };
export const idCard = /^[1-9]{1}[0-9]{14}$|^[1-9]{1}[0-9]{16}([0-9]|[xX])$/; export const idCard = /^[1-9]{1}[0-9]{14}$|^[1-9]{1}[0-9]{16}([0-9]|[xX])$/;
export const mobileReg = /^1[0-9]{10}$/; export const mobileReg = /^1[0-9]{10}$/;
export const address = val => { export const address = val => {
const value = val.trim(); const value = val.trim();
return value.length >= 5 && value.length <= 100; return value.length >= 5 && value.length <= 100;
}; };
export const userName = /^[a-zA-Z0-9_\u4e00-\u9fa5]{3,20}$/; export const userName = /^[a-zA-Z0-9_\u4e00-\u9fa5]{3,20}$/;
export const emailReg = /^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/; export const emailReg = /^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/;
<template> <template>
<div class="tab_home"> <div class="tab_home">
<div class="tal_class_searchBox"> <div class="tal_class_searchBox">
<van-search placeholder="点击前往搜索" @click="$router.push({ name: 'search' })"/> <van-search placeholder="点击前往搜索" @click="$router.push({ name: 'search' })"/>
<div class="tal_class_searchMask"></div> <div class="tal_class_searchMask"></div>
</div> </div>
<van-swipe :autoplay="3000" indicator-color="white"> <van-swipe :autoplay="3000" indicator-color="white">
<van-swipe-item v-for="(image, index) in brandList" :key="index"> <van-swipe-item v-for="(image, index) in brandList" :key="index">
<img :src="image" style="height:230px"> <img :src="image" style="height:230px">
</van-swipe-item> </van-swipe-item>
</van-swipe> </van-swipe>
<van-tabbar active-color="#7d7e80" v-model="active" class="goods-channel"> <div class="goods-channel">
<van-tabbar-item <div class="item"
@click="changeTabbar(iconJson)" @click="changeTabbar(iconJson)"
style="font-size:14px" v-for="(iconJson, index) in shopInfos.channel"
v-if="index < 5" :key="index">
v-for="(iconJson, index) in shopInfos.channel" <img :src="iconJson.iconUrl" background-size="cover"/>
:key="index" <span>{{iconJson.name}}</span>
:icon="iconJson.iconUrl" </div>
>{{iconJson.name}}</van-tabbar-item> </div>
</van-tabbar>
<van-tabbar active-color="#7d7e80" v-model="active" class="goods-channel"> <van-panel title="优惠券" style=" padding-bottom: 10px;">
<van-tabbar-item <div
@click="changeTabbar(iconJson)" class="van-coupon-item"
style="font-size:14px" v-for="(coupon,index) in shopInfos.couponList"
v-if="index >= 5" :key="index"
v-for="(iconJson, index) in shopInfos.channel" @click="getCoupon(coupon.id)"
:key="index" >
:icon="iconJson.iconUrl" <div class="van-coupon-item__content">
>{{iconJson.name}}</van-tabbar-item> <div class="van-coupon-item__head">
<van-tabbar-item></van-tabbar-item> <h2>
</van-tabbar> <span>¥</span>
{{coupon.discount}}
<!-- <van-panel title="优惠券" style=" padding-bottom: 10px;"> </h2>
<div <p>{{coupon.desc }} - {{coupon.tag}}</p>
class="van-coupon-item" </div>
v-for="(coupon,index) in shopInfos.couponList" <div class="van-coupon-item__body">
:key="index" <h2>{{coupon.name}}</h2>
@click="getCoupon(coupon.id)" <p>有效期:{{coupon.days}}</p>
>
<div class="van-coupon-item__content"> </div>
<div class="van-coupon-item__head"> </div>
<h2>
<span>¥</span> </div>
{{coupon.discount}} </van-panel>
</h2>
<p>{{coupon.desc }} - {{coupon.tag}}</p> <van-panel title="团购专区">
</div> <!-- {{shopInfos.grouponList}} -->
<div class="van-coupon-item__body"> <van-card
<h2>{{coupon.name}}</h2> :thumb-link="goDetail(groupGood.goods.id)"
<p>有效期:{{coupon.days}}</p> v-for="(groupGood ,index) in shopInfos.grouponList"
:key="index"
</div> :title="groupGood.goods.name"
</div> :desc="groupGood.goods.brief"
:num="groupGood.groupon_member"
</div> :origin-price="groupGood.goods.counterPrice"
</van-panel>--> :price="groupGood.goods.retailPrice +'.00'"
<van-panel title="团购专区"> :thumb="groupGood.goods.picUrl"
<!-- {{shopInfos.grouponList}} --> @native-click="goDetail(groupGood.goods.id)"
<van-card >
:thumb-link="goDetail(groupGood.goods.id)" <!-- <div slot="footer">添加日期 {{item.addTime}}</div> -->
v-for="(groupGood ,index) in shopInfos.grouponList" </van-card>
:key="index" </van-panel>
:title="groupGood.goods.name"
:desc="groupGood.goods.brief" <van-panel title="新品首发">
:num="groupGood.groupon_member" <!-- {{shopInfos.grouponList}} -->
:origin-price="groupGood.goods.counterPrice" <van-row gutter>
:price="groupGood.goods.retailPrice +'.00'" <van-col span="12" v-for="(newGood ,index) in shopInfos.newGoodsList" :key="index">
:thumb="groupGood.goods.picUrl" <router-link :to="{ path: `/items/detail/${newGood.id}`}">
@native-click="goDetail(groupGood.goods.id)" <img :src="newGood.picUrl" style="width:180px;height:180px;">
> </router-link>
<!-- <div slot="footer">添加日期 {{item.addTime}}</div> --> <span
</van-card> style="padding-left: 20px;position: relative;bottom: 10px; color: rgb(123, 116, 116);white-space: nowrap;"
</van-panel> >{{newGood.name}}</span>
<span
<van-panel title="新品首发"> style="padding-left: 80px;position: relative;bottom: 10px; color:#ab956d"
<!-- {{shopInfos.grouponList}} --> >{{newGood.retailPrice}}</span>
<van-row gutter> </van-col>
<van-col span="12" v-for="(newGood ,index) in shopInfos.newGoodsList" :key="index"> </van-row>
<router-link :to="{ path: `/items/detail/${newGood.id}`}"> </van-panel>
<img :src="newGood.picUrl" style="width:180px;height:180px;">
</router-link> <van-panel title="人气推荐">
<span <!-- {{shopInfos.grouponList}} -->
style="padding-left: 20px;position: relative;bottom: 10px; color: rgb(123, 116, 116);white-space: nowrap;" <van-card
>{{newGood.name}}</span> :thumb-link="goDetail(groupGood.id)"
<span v-for="(groupGood ,index) in shopInfos.hotGoodsList"
style="padding-left: 80px;position: relative;bottom: 10px; color:#ab956d" :key="index"
>{{newGood.retailPrice}}</span> :title="groupGood.name"
</van-col> :desc="groupGood.brief"
</van-row> :origin-price="groupGood.counterPrice"
</van-panel> :price="groupGood.retailPrice +'.00'"
:thumb="groupGood.picUrl"
<van-panel title="人气推荐"> @native-click="goDetail(groupGood.id)"
<!-- {{shopInfos.grouponList}} --> >
<van-card <!-- <div slot="footer">添加日期 {{item.addTime}}</div> -->
:thumb-link="goDetail(groupGood.id)" </van-card>
v-for="(groupGood ,index) in shopInfos.hotGoodsList" </van-panel>
:key="index" <!-- <van-list
:title="groupGood.name" v-model="loading"
:desc="groupGood.brief" class="scroll-load"
:origin-price="groupGood.counterPrice" :finished="finished"
:price="groupGood.retailPrice +'.00'" :immediate-check="false"
:thumb="groupGood.picUrl" :offset="100"
@native-click="goDetail(groupGood.id)" @load="loadMore"
> >
<!-- <div slot="footer">添加日期 {{item.addTime}}</div> --> <item-group
</van-card> v-for="( group, key ) in itemGroup"
</van-panel> v-if="group"
<!-- <van-list :key="key"
v-model="loading" class="interval_bot"
class="scroll-load" :setting="group.setting"
:finished="finished" >
:immediate-check="false" <component
:offset="100" v-for="item in group.items"
@load="loadMore" :goods="item"
> :key="item.id"
<item-group :is="getStyle(group.setting.style)"
v-for="( group, key ) in itemGroup" @click="toGoods(item)"
v-if="group" >
:key="key" <div slot="mask" v-if="lootAll(item)">
class="interval_bot" <img src="../../assets/images/not_enough.png" alt="已抢光">
:setting="group.setting" </div>
> <div slot="leftTopIcon" v-if="item.as_status < 2">
<component <img :src="mxStatus(item.as_status)" alt="秒杀">
v-for="item in group.items" </div>
:goods="item" </component>
:key="item.id" </item-group>
:is="getStyle(group.setting.style)" </van-list>-->
@click="toGoods(item)" </div>
> </template>
<div slot="mask" v-if="lootAll(item)">
<img src="../../assets/images/not_enough.png" alt="已抢光"> <script>
</div> import { HOME_module, ALL_GOODS } from '@/api/shop';
<div slot="leftTopIcon" v-if="item.as_status < 2"> import getLocationParam from '@/utils/location-param';
<img :src="mxStatus(item.as_status)" alt="秒杀">
</div> import mx_be_to from '@/assets/images/mx_be_to.png';
</component> import mx_start from '@/assets/images/mx_start.png';
</item-group>
</van-list>--> import SignBoard from './tabbar-home-sign-board';
</div> import ShopInfoGroup from './tabbar-home-shop-info';
</template> import ItemGroup from '@/components/item-group/';
import ItemCardVert from '@/components/item-card-vert/';
<script> import ItemCardHori from '@/components/item-card-hori/';
import { HOME_module, ALL_GOODS } from '@/api/shop';
import getLocationParam from 'core/utils/location-param'; import loadMore from '@/mixin/list-load-more';
import scrollFixed from '@/mixin/scroll-fixed';
import mx_be_to from '@/assets/images/mx_be_to.png'; import _ from 'lodash';
import mx_start from '@/assets/images/mx_start.png';
const coupon = {
import SignBoard from './tabbar-home-sign-board'; available: 1,
import ShopInfoGroup from './tabbar-home-shop-info'; discount: 0,
import ItemGroup from '@/vue/components/item-group/'; denominations: 150,
import ItemCardVert from '@/vue/components/item-card-vert/'; originCondition: 0,
import ItemCardHori from '@/vue/components/item-card-hori/'; reason: '',
value: 150,
import loadMore from '@/vue/mixin/list-load-more'; name: '优惠券名称',
import scrollFixed from '@/vue/mixin/scroll-fixed'; startAt: 1489104000,
import _ from 'lodash'; endAt: 1514592000
};
const coupon = {
available: 1, import {
discount: 0, List,
denominations: 150, Swipe,
originCondition: 0, SwipeItem,
reason: '', Tabbar,
value: 150, TabbarItem,
name: '优惠券名称', Search,
startAt: 1489104000, Panel,
endAt: 1514592000 CouponCell,
}; CouponList,
Toast,
import { Card,
List, Row,
Swipe, Col
SwipeItem, } from 'vant';
Tabbar,
TabbarItem, export default {
Search, mixins: [loadMore, scrollFixed],
Panel,
CouponCell, data() {
CouponList, const shop_id = getLocationParam('shop_id');
Toast, return {
Card, shop_id,
Row, brandList: [],
Col shopInfos: [],
} from 'vant'; shopInfo: null,
coupons: [coupon],
export default { itemGroup: {
mixins: [loadMore, scrollFixed], mx_goods: null,
activity_seckill: null,
data() { shop_recommend: null,
const shop_id = getLocationParam('shop_id'); goods: null
return { },
shop_id, mx_be_to,
brandList: [], mx_start,
shopInfos: [], isLoading: false
shopInfo: null, };
coupons: [coupon], },
itemGroup: {
mx_goods: null, computed: {
activity_seckill: null, location() {
shop_recommend: null, const shopInfo = this.shopInfo;
goods: null const local = {
}, name: shopInfo.shop_name,
mx_be_to, lat: shopInfo.lat,
mx_start, lng: shopInfo.lng
isLoading: false };
}; return local.lat && local.lng ? local : null;
}, }
},
computed: {
location() { created() {
const shopInfo = this.shopInfo; // this.initViews();
const local = { this.initNewViews();
name: shopInfo.shop_name, },
lat: shopInfo.lat,
lng: shopInfo.lng methods: {
}; goDetail(id) {
return local.lat && local.lng ? local : null; return `#/items/detail/${id}`;
} },
}, async getCoupon(id) {
let errmsg = await this.$reqPost('/wx/coupon/receive', {
created() { couponId: id
// this.initViews(); });
this.initNewViews(); Toast.success('领取成功');
}, },
async changeTabbar(o) {
methods: { let { data } = await this.$reqGet(
goDetail(id) { `/wx/goods/category?id=${o.id}`
return `#/items/detail/${id}`; );
}, let categoryId = data.data.currentCategory.id;
async getCoupon(id) { this.$router.push({
let errmsg = await this.$reqPost('/wx/coupon/receive', { path: `items/list?keyword=&itemClass=${categoryId}`
couponId: id });
}); },
Toast.success('领取成功'); initViews() {
}, this.$reqGet(HOME_module, {
async changeTabbar(o) { shop_id: this.shop_id,
let { data } = await this.$reqGet( 'per-page': this.pages.perPage,
`/wx/goods/category?id=${o.id}` page: 1
); }).then(res => {
let categoryId = data.data.currentCategory.id; const { shop_info, page } = res.data.data;
this.$router.push({ const {
path: `items/list?keyword=&itemClass=${categoryId}` mx_goods,
}); shop_recommend,
}, activity_seckill,
initViews() { goods
this.$reqGet(HOME_module, { } = this.decorate(res.data.data);
shop_id: this.shop_id, this.shopInfo = shop_info;
'per-page': this.pages.perPage, this.itemGroup.mx_goods = mx_goods;
page: 1 this.itemGroup.shop_recommend = shop_recommend;
}).then(res => { this.itemGroup.activity_seckill = activity_seckill;
const { shop_info, page } = res.data.data; this.itemGroup.goods = goods;
const { this.setPages(page);
mx_goods, });
shop_recommend, },
activity_seckill, initNewViews() {
goods this.$reqGet('/wx/home/index').then(res => {
} = this.decorate(res.data.data); this.shopInfos = res.data.data;
this.shopInfo = shop_info; this.brandList = [];
this.itemGroup.mx_goods = mx_goods; _.each(res.data.data.brandList, v => {
this.itemGroup.shop_recommend = shop_recommend; this.brandList.push(v.picUrl);
this.itemGroup.activity_seckill = activity_seckill; });
this.itemGroup.goods = goods; });
this.setPages(page); },
});
}, initData() {
initNewViews() { // return this.$reqGet(ALL_GOODS, {
this.$reqGet('/wx/home/index').then(res => { // shop_id: this.shop_id,
this.shopInfos = res.data.data; // 'per-page': this.pages.perPage,
this.brandList = []; // page: this.pages.currPage
_.each(res.data.data.brandList, v => { // }).then(res => {
this.brandList.push(v.picUrl); // const { items, page } = res.data.data;
}); // this.itemGroup.goods && this.itemGroup.goods.items.push(...items);
}); // return page;
}, // });
},
initData() {
// return this.$reqGet(ALL_GOODS, { toGoods(item) {
// shop_id: this.shop_id, // 如果是秒杀商品, 并且已经抢光
// 'per-page': this.pages.perPage, if (this.lootAll(item)) {
// page: this.pages.currPage this.$dialog.alert({ message: '该秒杀商品已抢光,看看别的吧!' });
// }).then(res => { return;
// const { items, page } = res.data.data; }
// this.itemGroup.goods && this.itemGroup.goods.items.push(...items); this.$router.push({ path: `/items/detail/${item.id}` });
// return page; },
// });
}, groupIcon(key) {
const iconGroup = {
toGoods(item) { activity_seckill: 'naozhong',
// 如果是秒杀商品, 并且已经抢光 goods: 'list',
if (this.lootAll(item)) { mx_goods: 'n4',
this.$dialog.alert({ message: '该秒杀商品已抢光,看看别的吧!' }); shop_recommend: 'good'
return; };
} return iconGroup[key] || '';
this.$router.push({ path: `/items/detail/${item.id}` }); },
},
getStyle(style) {
groupIcon(key) { return style ? 'item-card-vert' : 'item-card-hori';
const iconGroup = { },
activity_seckill: 'naozhong',
goods: 'list', decorate({ mx_goods, shop_recommend, activity_seckill, goods }) {
mx_goods: 'n4', if (mx_goods) {
shop_recommend: 'good' mx_goods.setting.icon = 'n4';
}; mx_goods.setting.title_desc = '分享得金豆';
return iconGroup[key] || ''; mx_goods.setting.title_color = '#db3d3c';
}, mx_goods.setting.item_len = mx_goods.items.length;
}
getStyle(style) { if (shop_recommend) {
return style ? 'item-card-vert' : 'item-card-hori'; shop_recommend.setting.icon = 'good';
}, shop_recommend.setting.item_len = shop_recommend.items.length;
}
decorate({ mx_goods, shop_recommend, activity_seckill, goods }) { if (activity_seckill) {
if (mx_goods) { activity_seckill.setting.icon = 'naozhong';
mx_goods.setting.icon = 'n4'; activity_seckill.setting.title_color = '#db3d3c';
mx_goods.setting.title_desc = '分享得金豆'; activity_seckill.setting.item_len = activity_seckill.items.length;
mx_goods.setting.title_color = '#db3d3c'; }
mx_goods.setting.item_len = mx_goods.items.length; if (goods) {
} goods.setting.icon = 'list';
if (shop_recommend) { goods.setting.item_len = goods.items.length;
shop_recommend.setting.icon = 'good'; }
shop_recommend.setting.item_len = shop_recommend.items.length; return {
} mx_goods,
if (activity_seckill) { shop_recommend,
activity_seckill.setting.icon = 'naozhong'; activity_seckill,
activity_seckill.setting.title_color = '#db3d3c'; goods
activity_seckill.setting.item_len = activity_seckill.items.length; };
} },
if (goods) {
goods.setting.icon = 'list'; lootAll(item) {
goods.setting.item_len = goods.items.length; return (
} typeof item.as_status !== 'undefined' && item.sold_num == item.total
return { );
mx_goods, },
shop_recommend,
activity_seckill, mxStatus(as_status) {
goods return as_status ? this.mx_start : this.mx_be_to;
}; }
}, },
lootAll(item) { components: {
return ( // Vue.use(Tabbar).use(TabbarItem);,
typeof item.as_status !== 'undefined' && item.sold_num == item.total [Row.name]: Row,
); [Col.name]: Col,
}, [Card.name]: Card,
[Toast.name]: Toast,
mxStatus(as_status) { [CouponCell.name]: CouponCell,
return as_status ? this.mx_start : this.mx_be_to; [CouponList.name]: CouponList,
} [Search.name]: Search,
}, [Panel.name]: Panel,
[List.name]: List,
components: { [Swipe.name]: Swipe,
// Vue.use(Tabbar).use(TabbarItem);, [SwipeItem.name]: SwipeItem,
[Row.name]: Row, [Tabbar.name]: Tabbar,
[Col.name]: Col, [TabbarItem.name]: TabbarItem,
[Card.name]: Card, [SignBoard.name]: SignBoard,
[Toast.name]: Toast, [ShopInfoGroup.name]: ShopInfoGroup,
[CouponCell.name]: CouponCell, [ItemGroup.name]: ItemGroup,
[CouponList.name]: CouponList, [ItemCardVert.name]: ItemCardVert,
[Search.name]: Search, [ItemCardHori.name]: ItemCardHori
[Panel.name]: Panel, }
[List.name]: List, };
[Swipe.name]: Swipe, </script>
[SwipeItem.name]: SwipeItem,
[Tabbar.name]: Tabbar,
[TabbarItem.name]: TabbarItem, <style lang="scss" scoped>
[SignBoard.name]: SignBoard, .interval_bot {
[ShopInfoGroup.name]: ShopInfoGroup, margin-bottom: 10px;
[ItemGroup.name]: ItemGroup, }
[ItemCardVert.name]: ItemCardVert,
[ItemCardHori.name]: ItemCardHori .goods-channel {
} background: #fff;
}; display: flex;
</script> align-items: center;
flex-wrap: wrap;
padding-bottom: 0px;
<style lang="scss" scoped> padding-top: 10px;
.interval_bot { }
margin-bottom: 10px;
} .goods-channel .item {
.goods-channel { width: 50px;
position: sticky; height: 50px;
border-bottom-width: 0px; margin-left: 10px;
} }
.van-coupon-cell--selected {
color: #323233; .goods-channel img {
} display: block;
.van-coupon-list { width: 30px;
height: 100%; height: 30px;
position: relative; margin: 0 auto;
background-color: #f8f8f8; }
}
.van-coupon-list__field { .goods-channel span {
padding: 7px 15px; display: block;
} font-size: 15px;
.van-coupon-list__exchange { text-align: center;
height: 32px; margin: 0 auto;
line-height: 30px; line-height: 1;
} color: #333;
.van-coupon-list__list { }
overflow-y: auto; van-tabbar-item
padding: 15px 0; .van-coupon-cell--selected {
-webkit-box-sizing: border-box; color: #323233;
box-sizing: border-box; }
-webkit-overflow-scrolling: touch; .van-coupon-list {
} height: 100%;
.van-coupon-list__close { position: relative;
left: 0; background-color: #f8f8f8;
bottom: 0; }
position: absolute; .van-coupon-list__field {
font-weight: 500; padding: 7px 15px;
} }
.van-coupon-list__empty { .van-coupon-list__exchange {
padding-top: 100px; height: 32px;
text-align: center; line-height: 30px;
} }
.van-coupon-list__empty p { .van-coupon-list__list {
color: #969799; overflow-y: auto;
margin: 15px 0; padding: 15px 0;
font-size: 14px; -webkit-box-sizing: border-box;
line-height: 20px; box-sizing: border-box;
} -webkit-overflow-scrolling: touch;
.van-coupon-list__empty img { }
width: 80px; .van-coupon-list__close {
height: 84px; left: 0;
} bottom: 0;
.van-coupon-item { position: absolute;
overflow: hidden; font-weight: 500;
border-radius: 4px; }
margin: 0 15px 15px; .van-coupon-list__empty {
background-color: #fff; padding-top: 100px;
-webkit-box-shadow: 0 0 4px rgba(0, 0, 0, 0.1); text-align: center;
box-shadow: 0 0 4px rgba(0, 0, 0, 0.1); }
} .van-coupon-list__empty p {
.van-coupon-item:active { color: #969799;
background-color: #e8e8e8; margin: 15px 0;
} font-size: 14px;
.van-coupon-item__content { line-height: 20px;
display: -webkit-box; }
display: -ms-flexbox; .van-coupon-list__empty img {
display: flex; width: 80px;
height: 100px; height: 84px;
padding: 24px 0 0 15px; }
-webkit-box-sizing: border-box; .van-coupon-item {
box-sizing: border-box; overflow: hidden;
} border-radius: 4px;
.van-coupon-item h2, margin: 0 15px 15px;
.van-coupon-item p { background-color: #fff;
margin: 0; -webkit-box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
overflow: hidden; box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
white-space: nowrap; }
text-overflow: ellipsis; .van-coupon-item:active {
} background-color: #e8e8e8;
.van-coupon-item h2 { }
height: 34px; .van-coupon-item__content {
font-weight: 500; display: -webkit-box;
line-height: 34px; display: -ms-flexbox;
} display: flex;
.van-coupon-item p { height: 100px;
font-size: 12px; padding: 24px 0 0 15px;
line-height: 16px; -webkit-box-sizing: border-box;
color: #969799; box-sizing: border-box;
} border:1px solid red;
.van-coupon-item__head {
min-width: 90px; }
} .van-coupon-item h2,
.van-coupon-item__head h2 { .van-coupon-item p {
color: #f44; margin: 0;
font-size: 24px; overflow: hidden;
} white-space: nowrap;
.van-coupon-item__head h2 span { text-overflow: ellipsis;
font-size: 50%; }
} .van-coupon-item h2 {
.van-coupon-item__body { height: 34px;
-webkit-box-flex: 1; font-weight: 500;
-ms-flex: 1; line-height: 34px;
flex: 1; }
position: relative; .van-coupon-item p {
border-radius: 0 4px 4px 0; font-size: 12px;
} line-height: 16px;
.van-coupon-item__body h2 { color: #969799;
font-size: 16px; }
} .van-coupon-item__head {
.van-coupon-item__corner { min-width: 90px;
top: 16px; }
right: 15px; .van-coupon-item__head h2 {
position: absolute; color: #f44;
} font-size: 24px;
.van-coupon-item__corner .van-icon { }
border-color: #f44; .van-coupon-item__head h2 span {
background-color: #f44; font-size: 50%;
} }
.van-coupon-item__reason { .van-coupon-item__body {
padding: 7px 15px; -webkit-box-flex: 1;
border-top: 1px dashed #ebedf0; -ms-flex: 1;
background-color: #fafafa; flex: 1;
} position: relative;
.van-coupon-item--disabled:active { border-radius: 0 4px 4px 0;
background-color: #fff; }
} .van-coupon-item__body h2 {
.van-coupon-item--disabled .van-coupon-item__content { font-size: 16px;
height: 90px; }
} .van-coupon-item__corner {
.van-coupon-item--disabled h2, top: 16px;
.van-coupon-item--disabled p, right: 15px;
.van-coupon-item--disabled span { position: absolute;
color: #969799; }
} .van-coupon-item__corner .van-icon {
</style> border-color: #f44;
background-color: #f44;
}
.van-coupon-item__reason {
padding: 7px 15px;
border-top: 1px dashed #ebedf0;
background-color: #fafafa;
}
.van-coupon-item--disabled:active {
background-color: #fff;
}
.van-coupon-item--disabled .van-coupon-item__content {
height: 90px;
}
.van-coupon-item--disabled h2,
.van-coupon-item--disabled p,
.van-coupon-item--disabled span {
color: #969799;
}
</style>
...@@ -63,11 +63,11 @@ ...@@ -63,11 +63,11 @@
<script> <script>
import { GOODS_SEARCH } from '@/api/goods'; import { GOODS_SEARCH } from '@/api/goods';
import ItemGroup from '@/vue/components/item-group'; import ItemGroup from '@/components/item-group';
import ItemCardHori from '@/vue/components/item-card-hori/'; import ItemCardHori from '@/components/item-card-hori/';
import { Search, Tab, Tabs, Popup } from 'vant'; import { Search, Tab, Tabs, Popup } from 'vant';
// import { throttle } from 'lodash'; // import { throttle } from 'lodash';
import InfinityScroll from '@/vue/components/infinity-scroll'; import InfinityScroll from '@/components/infinity-scroll';
export default { export default {
name: 'Item-list', name: 'Item-list',
......
...@@ -32,14 +32,14 @@ ...@@ -32,14 +32,14 @@
<script> <script>
import { GOODS_SEARCH } from '@/api/goods'; import { GOODS_SEARCH } from '@/api/goods';
import ItemGroup from '@/vue/components/item-group/'; import ItemGroup from '@/components/item-group/';
import IsEmpty from '@/vue/components/is-empty/'; import IsEmpty from '@/components/is-empty/';
import ItemCardHori from '@/vue/components/item-card-hori/'; import ItemCardHori from '@/components/item-card-hori/';
import { Search, List } from 'vant'; import { Search, List } from 'vant';
import _ from 'lodash'; import _ from 'lodash';
import loadMore from '@/vue/mixin/list-load-more'; import loadMore from '@/mixin/list-load-more';
import scrollFixed from '@/vue/mixin/scroll-fixed'; import scrollFixed from '@/mixin/scroll-fixed';
export default { export default {
name: 'Item-list', name: 'Item-list',
......
<template> <template>
<div class="tab_class"> <div class="tab_class">
<div class="tal_class_searchBox"> <div class="tal_class_searchBox">
<van-search placeholder="点击前往搜索"/> <van-search placeholder="点击前往搜索"/>
<div class="tal_class_searchMask" @click="$router.push({ name: 'search' })"></div> <div class="tal_class_searchMask" @click="$router.push({ name: 'search' })"></div>
</div> </div>
<class-tree <class-tree
ref="classTree" ref="classTree"
class="height-fix42" class="height-fix42"
@nav-click="changeCatalog" @nav-click="changeCatalog"
@class-click="toItemList" @class-click="toItemList"
@all-click="toItemList" @all-click="toItemList"
:list="list" :list="list"
></class-tree> ></class-tree>
<is-empty v-if="isEmpty">抱歉,店主还未上架商品</is-empty> <is-empty v-if="isEmpty">抱歉,店主还未上架商品</is-empty>
</div> </div>
</template> </template>
<script> <script>
import { GOODS_CATEGORY, GOODS_CHANNGE_CATEGORY } from '@/api/goods'; import { GOODS_CATEGORY, GOODS_CHANNGE_CATEGORY } from '@/api/goods';
import getLocationParam from 'core/utils/location-param'; import getLocationParam from '@/utils/location-param';
import { Search } from 'vant'; import { Search } from 'vant';
import classTree from './tabbar-class-tree'; import classTree from './tabbar-class-tree';
import IsEmpty from '@/vue/components/is-empty'; import IsEmpty from '@/components/is-empty';
import _ from 'lodash'; import _ from 'lodash';
import { async } from 'q'; import { async } from 'q';
function getIndex(arr, keyWord) { function getIndex(arr, keyWord) {
let index = 0; let index = 0;
_.each(arr, (v, k) => { _.each(arr, (v, k) => {
if (v.id === keyWord) { if (v.id === keyWord) {
index = k; index = k;
return false; return false;
} }
}); });
return index; return index;
} }
export default { export default {
data() { data() {
return { return {
list: [], list: [],
subCategory: [], subCategory: [],
isEmpty: false isEmpty: false
}; };
}, },
created() { created() {
this.initData(); this.initData();
}, },
methods: { methods: {
initData() { initData() {
const shop_id = getLocationParam('shop_id'); const shop_id = getLocationParam('shop_id');
this.$reqGet(`${GOODS_CATEGORY}`).then(res => { this.$reqGet(`${GOODS_CATEGORY}`).then(res => {
this.list = res.data.data.categoryList; this.list = res.data.data.categoryList;
this.$refs.classTree.changeList(res.data.data); this.$refs.classTree.changeList(res.data.data);
this.subCategory = res.data.data.currentSubCategory; this.subCategory = res.data.data.currentSubCategory;
if (this.subCategory.length === 0) this.isEmpty = true; if (this.subCategory.length === 0) this.isEmpty = true;
}); });
}, },
removeNoChild(data) { removeNoChild(data) {
return data.filter(item => item.children && item.children.length); return data.filter(item => item.children && item.children.length);
}, },
changeCatalog(id) { changeCatalog(id) {
this.$reqGet(`${GOODS_CHANNGE_CATEGORY}${id}`).then(res => { this.$reqGet(`${GOODS_CHANNGE_CATEGORY}${id}`).then(res => {
let index = getIndex(this.list, res.data.data.currentCategory.id); let index = getIndex(this.list, res.data.data.currentCategory.id);
this.$refs.classTree.changeList(res.data.data); this.$refs.classTree.changeList(res.data.data);
this.subCategory = res.data.data.currentSubCategory; this.subCategory = res.data.data.currentSubCategory;
if (this.subCategory.length === 0) this.isEmpty = true; if (this.subCategory.length === 0) this.isEmpty = true;
}); });
}, },
toItemList(id) { toItemList(id) {
this.$router.push({ this.$router.push({
name: 'list', name: 'list',
query: { keyword: '', itemClass: id } query: { keyword: '', itemClass: id }
}); });
} }
}, },
components: { components: {
[Search.name]: Search, [Search.name]: Search,
[classTree.name]: classTree, [classTree.name]: classTree,
[IsEmpty.name]: IsEmpty [IsEmpty.name]: IsEmpty
} }
}; };
</script> </script>
<style scoped> <style scoped>
.tab_class { .tab_class {
overflow: hidden; overflow: hidden;
background-color: #fff; background-color: #fff;
} }
.height-fix { .height-fix {
padding-bottom: 42px; padding-bottom: 42px;
} }
.tal_class_searchBox { .tal_class_searchBox {
position: relative; position: relative;
} }
.tal_class_searchMask { .tal_class_searchMask {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
z-index: 9; z-index: 9;
} }
</style> </style>
<template> <template>
<md-field-group class="foget_view"> <md-field-group class="foget_view">
<md-field <md-field
v-model="password" v-model="password"
icon="lock" icon="lock"
:is-error="isErrow" :is-error="isErrow"
placeholder="请输入新密码"/> placeholder="请输入新密码"/>
<md-field <md-field
v-model="passwordRepeat" v-model="passwordRepeat"
type="password" type="password"
icon="lock" icon="lock"
:is-error="isErrow" :is-error="isErrow"
placeholder="请再次输入密码" /> placeholder="请再次输入密码" />
<div class="red" v-show="isErrow">两次密码输入不一致</div> <div class="red" v-show="isErrow">两次密码输入不一致</div>
<div class="foget_submit"> <div class="foget_submit">
<van-button size="large" type="danger" @click="submitCode">重置</van-button> <van-button size="large" type="danger" @click="submitCode">重置</van-button>
</div> </div>
</md-field-group> </md-field-group>
</template> </template>
<script> <script>
import field from '@/vue/components/field/'; import field from '@/components/field/';
import fieldGroup from '@/vue/components/field-group/'; import fieldGroup from '@/components/field-group/';
export default { export default {
data() { data() {
return { return {
isErrow: true, isErrow: true,
password: '', password: '',
passwordRepeat: '' passwordRepeat: ''
}; };
}, },
methods: { methods: {
submitCode() {} submitCode() {}
}, },
components: { components: {
[field.name]: field, [field.name]: field,
[fieldGroup.name]: fieldGroup [fieldGroup.name]: fieldGroup
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
div.foget_view { div.foget_view {
background-color: #fff; background-color: #fff;
padding-top: 30px; padding-top: 30px;
} }
div.foget_submit { div.foget_submit {
padding-top: 30px; padding-top: 30px;
padding-bottom: 20px; padding-bottom: 20px;
} }
</style> </style>
<template> <template>
<md-field-group class="foget_view"> <md-field-group class="foget_view">
<md-field <md-field
v-model="mobile" v-model="mobile"
icon="mobile" icon="mobile"
placeholder="请输入手机号"/> placeholder="请输入手机号"/>
<md-field <md-field
v-model="code" v-model="code"
icon="lock" icon="lock"
placeholder="请输入短信验证码" placeholder="请输入短信验证码"
> >
<div slot="rightIcon" @click="getCode" class="getCode red"> <div slot="rightIcon" @click="getCode" class="getCode red">
<countdown v-if="counting" :time="60000" @countdownend="countdownend"> <countdown v-if="counting" :time="60000" @countdownend="countdownend">
<template slot-scope="props">{{ +props.seconds || 60 }}秒后获取</template> <template slot-scope="props">{{ +props.seconds || 60 }}秒后获取</template>
</countdown> </countdown>
<span v-else>获取验证码</span> <span v-else>获取验证码</span>
</div> </div>
</md-field > </md-field >
<div class="foget_submit"> <div class="foget_submit">
<van-button size="large" type="danger" @click="submitCode">下一步</van-button> <van-button size="large" type="danger" @click="submitCode">下一步</van-button>
</div> </div>
</md-field-group> </md-field-group>
</template> </template>
<script> <script>
import field from '@/vue/components/field/'; import field from '@/components/field/';
import fieldGroup from '@/vue/components/field-group/'; import fieldGroup from '@/components/field-group/';
export default { export default {
data() { data() {
return { return {
counting: false, counting: false,
mobile: '', mobile: '',
code: '' code: ''
}; };
}, },
methods: { methods: {
submitCode() { submitCode() {
this.$router.push({ name: 'forgetReset' }); this.$router.push({ name: 'forgetReset' });
}, },
getCode() { getCode() {
this.counting = true; this.counting = true;
}, },
countdownend() { countdownend() {
this.counting = false; this.counting = false;
} }
}, },
components: { components: {
[field.name]: field, [field.name]: field,
[fieldGroup.name]: fieldGroup [fieldGroup.name]: fieldGroup
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '../../../assets/scss/mixin'; @import '../../../assets/scss/mixin';
div.foget_view { div.foget_view {
background-color: #fff; background-color: #fff;
padding-top: 30px; padding-top: 30px;
} }
div.foget_submit { div.foget_submit {
padding-top: 30px; padding-top: 30px;
padding-bottom: 20px; padding-bottom: 20px;
} }
.getCode { .getCode {
@include one-border(left); @include one-border(left);
text-align: center; text-align: center;
} }
.time_down { .time_down {
color: $red; color: $red;
} }
</style> </style>
...@@ -50,12 +50,12 @@ ...@@ -50,12 +50,12 @@
</template> </template>
<script> <script>
import field from '@/vue/components/field/'; import field from '@/components/field/';
import fieldGroup from '@/vue/components/field-group/'; import fieldGroup from '@/components/field-group/';
import { USER_LOGIN, USER_PROFILE } from '@/api/user'; import { loginByUsername, USER_LOGIN, USER_PROFILE } from '@/api/user';
import { setLocalStorage } from 'core/utils/local-storage'; import { setLocalStorage } from '@/utils/local-storage';
import { emailReg, mobileReg } from '@/core/regexp'; import { emailReg, mobileReg } from '@/utils/validate';
import { Toast } from 'vant'; import { Toast } from 'vant';
...@@ -93,6 +93,7 @@ export default { ...@@ -93,6 +93,7 @@ export default {
async login() { async login() {
let loginData = this.getLoginData(); let loginData = this.getLoginData();
loginByUsername(loginData)
let { data } = await this.$reqPost(USER_LOGIN, loginData); let { data } = await this.$reqPost(USER_LOGIN, loginData);
this.userInfo = data.data.userInfo; this.userInfo = data.data.userInfo;
console.log(this.userInfo); console.log(this.userInfo);
...@@ -139,9 +140,9 @@ export default { ...@@ -139,9 +140,9 @@ export default {
getLoginData() { getLoginData() {
const password = this.password; const password = this.password;
const username = this.getUserType(this.account); const account = this.getUserType(this.account);
return { return {
username: this.account, [account]: this.account,
password: password password: password
}; };
}, },
......
<template> <template>
<md-field-group class="register_view"> <md-field-group class="register_view">
<div>我们将发送验证码到您的手机</div> <div>我们将发送验证码到您的手机</div>
<md-field <md-field
v-model="mobile" v-model="mobile"
icon="mobile" icon="mobile"
placeholder="请输入手机号"/> placeholder="请输入手机号"/>
<div class="register_submit"> <div class="register_submit">
<van-button size="large" type="danger" @click="submitCode">下一步</van-button> <van-button size="large" type="danger" @click="submitCode">下一步</van-button>
</div> </div>
<div class="register_footer"> <div class="register_footer">
已有账号? 已有账号?
<router-link to="/login" class="red">登录</router-link> <router-link to="/login" class="red">登录</router-link>
</div> </div>
</md-field-group> </md-field-group>
</template> </template>
<script> <script>
import field from '@/vue/components/field/'; import field from '@/components/field/';
import fieldGroup from '@/vue/components/field-group/'; import fieldGroup from '@/components/field-group/';
export default { export default {
data() { data() {
return { return {
mobile: '' mobile: ''
}; };
}, },
methods: { methods: {
submitCode() { submitCode() {
this.$router.push({ name: 'registerSubmit' }); this.$router.push({ name: 'registerSubmit' });
} }
}, },
components: { components: {
[field.name]: field, [field.name]: field,
[fieldGroup.name]: fieldGroup [fieldGroup.name]: fieldGroup
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
div.register_view { div.register_view {
background-color: #fff; background-color: #fff;
padding-top: 30px; padding-top: 30px;
} }
div.register_submit { div.register_submit {
padding-top: 30px; padding-top: 30px;
padding-bottom: 20px; padding-bottom: 20px;
} }
.register_footer { .register_footer {
text-align: right; text-align: right;
color: $font-color-gray; color: $font-color-gray;
} }
</style> </style>
<template> <template>
<md-field-group class="register_submit"> <md-field-group class="register_submit">
<md-field v-model="code" icon="mobile" placeholder="请输入验证码"> <md-field v-model="code" icon="mobile" placeholder="请输入验证码">
<div slot="rightIcon" @click="getCode" class="getCode red"> <div slot="rightIcon" @click="getCode" class="getCode red">
<countdown v-if="counting" :time="60000" @countdownend="countdownend"> <countdown v-if="counting" :time="60000" @countdownend="countdownend">
<template slot-scope="props">{{ +props.seconds || 60 }}秒后获取</template> <template slot-scope="props">{{ +props.seconds || 60 }}秒后获取</template>
</countdown> </countdown>
<span v-else>获取验证码</span> <span v-else>获取验证码</span>
</div> </div>
</md-field> </md-field>
<md-field v-model="password" icon="lock" placeholder="请输入密码"/> <md-field v-model="password" icon="lock" placeholder="请输入密码"/>
<md-field v-model="repeatPassword" icon="lock" placeholder="请再次确认密码"/> <md-field v-model="repeatPassword" icon="lock" placeholder="请再次确认密码"/>
<div class="register_submit_btn"> <div class="register_submit_btn">
<van-button type="danger" size="large" @click="registerSubmit">确定</van-button> <van-button type="danger" size="large" @click="registerSubmit">确定</van-button>
</div> </div>
</md-field-group> </md-field-group>
</template> </template>
<script> <script>
import field from '@/vue/components/field/'; import field from '@/components/field/';
import fieldGroup from '@/vue/components/field-group/'; import fieldGroup from '@/components/field-group/';
export default { export default {
data() { data() {
return { return {
counting: true, counting: true,
code: '', code: '',
password: '', password: '',
repeatPassword: '' repeatPassword: ''
}; };
}, },
methods: { methods: {
registerSubmit() { registerSubmit() {
this.$router.push({ this.$router.push({
name: 'registerStatus', name: 'registerStatus',
params: { status: 'success' } params: { status: 'success' }
}); });
}, },
getCode() { getCode() {
this.counting = true; this.counting = true;
}, },
countdownend() { countdownend() {
this.counting = false; this.counting = false;
} }
}, },
components: { components: {
[field.name]: field, [field.name]: field,
[fieldGroup.name]: fieldGroup [fieldGroup.name]: fieldGroup
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '../../../assets/scss/mixin'; @import '../../../assets/scss/mixin';
.register_submit { .register_submit {
padding-top: 40px; padding-top: 40px;
background-color: #fff; background-color: #fff;
} }
.register_submit_btn { .register_submit_btn {
padding-top: 30px; padding-top: 30px;
} }
.getCode { .getCode {
@include one-border(left); @include one-border(left);
text-align: center; text-align: center;
} }
.time_down { .time_down {
color: $red; color: $red;
} }
</style> </style>
<template> <template>
<div class="tab-cart"> <div class="tab-cart">
<div class="editor_head" v-show="goods.length"> <div class="editor_head" v-show="goods.length">
<van-icon :name="isEditor ? 'success' : 'editor'"/> <van-icon :name="isEditor ? 'success' : 'editor'"/>
<span @click="isEditor = !isEditor">{{isEditor ? '完成' : '编辑'}}</span> <span @click="isEditor = !isEditor">{{isEditor ? '完成' : '编辑'}}</span>
</div> </div>
<van-checkbox-group @change="toggle" class="card-goods" v-model="checkedGoods"> <van-checkbox-group @change="toggle" class="card-goods" v-model="checkedGoods">
<div v-for="(item, i) in goods" :key="i" class="card-goods__item"> <div v-for="(item, i) in goods" :key="i" class="card-goods__item">
<van-checkbox :key="item.id" :name="item.id" v-model="item.checked"></van-checkbox> <van-checkbox :key="item.id" :name="item.id" v-model="item.checked"></van-checkbox>
<van-card desc="暂无描述" :num="item.number" :thumb="item.picUrl"> <van-card desc="暂无描述" :num="item.number" :thumb="item.picUrl">
<div class="van-card__row" slot="title"> <div class="van-card__row" slot="title">
<div class="van-card__title"> <div class="van-card__title">
<!-- <van-tag plain type="danger">海淘</van-tag> --> <!-- <van-tag plain type="danger">海淘</van-tag> -->
{{item.goodsName}} {{item.goodsName}}
</div> </div>
<div class="van-card__price">{{item.price * 100 | yuan}}</div> <div class="van-card__price">{{item.price * 100 | yuan}}</div>
</div> </div>
<div slot="footer" v-if="isEditor"> <div slot="footer" v-if="isEditor">
<van-stepper v-model="item.number" @change="stepperEvent(item,arguments)" disableInput/> <van-stepper v-model="item.number" @change="stepperEvent(item,arguments)" disableInput/>
</div> </div>
<div slot="footer" v-else>添加日期 {{item.addTime}}</div> <div slot="footer" v-else>添加日期 {{item.addTime}}</div>
</van-card> </van-card>
<div class="cart_delete" v-if="isEditor" @click="deleteCart(i)">删除</div> <div class="cart_delete" v-if="isEditor" @click="deleteCart(i)">删除</div>
</div> </div>
</van-checkbox-group> </van-checkbox-group>
<div class="clear_invalid" v-if="goods.length" @click="clearInvalid"> <div class="clear_invalid" v-if="goods.length" @click="clearInvalid">
<van-icon name="lajitong"/>清除失效商品 <van-icon name="lajitong"/>清除失效商品
</div> </div>
<is-empty v-if="!goods.length">您的购物车空空如也~</is-empty> <is-empty v-if="!goods.length">您的购物车空空如也~</is-empty>
<van-submit-bar <van-submit-bar
style="bottom: 50px" style="bottom: 50px"
:price="totalPrice" :price="totalPrice"
:disabled="!checkedGoods.length" :disabled="!checkedGoods.length"
:buttonText="submitBarText" :buttonText="submitBarText"
:loading="isSubmit" :loading="isSubmit"
label="总计" label="总计"
@submit="cartSubmit" @submit="cartSubmit"
> >
<van-checkbox v-model="allCheckedStatus" @change="setCheckAll" style="padding: 0 10px;">全选</van-checkbox> <van-checkbox v-model="allCheckedStatus" @change="setCheckAll" style="padding: 0 10px;">全选</van-checkbox>
</van-submit-bar> </van-submit-bar>
</div> </div>
</template> </template>
<script> <script>
import { Checkbox, CheckboxGroup, Card, SubmitBar, Stepper, Tag } from 'vant'; import { Checkbox, CheckboxGroup, Card, SubmitBar, Stepper, Tag } from 'vant';
import isEmpty from '@/vue/components/is-empty/'; import isEmpty from '@/components/is-empty/';
import _ from 'lodash'; import _ from 'lodash';
import { debug } from 'util'; import { debug } from 'util';
export default { export default {
data() { data() {
return { return {
isEditor: false, isEditor: false,
checkedAll: false, checkedAll: false,
isSubmit: false, isSubmit: false,
checkedGoods: [], checkedGoods: [],
AllGoods: [], AllGoods: [],
allCheckedStatus: false, allCheckedStatus: false,
goods: [], goods: [],
count: 0 count: 0
}; };
}, },
activated() { activated() {
this.checkedAll = false; this.checkedAll = false;
this.isEditor = false; this.isEditor = false;
this.isSubmit = false; this.isSubmit = false;
}, },
created() { created() {
this.init(); this.init();
}, },
computed: { computed: {
submitBarText() { submitBarText() {
const count = this.count; const count = this.count;
return this.isEditor ? '删除' : `结算${count ? `(${count})` : ''}`; return this.isEditor ? '删除' : `结算${count ? `(${count})` : ''}`;
}, },
totalPrice() { totalPrice() {
return this.goods.reduce( return this.goods.reduce(
(total, item) => (total, item) =>
total + total +
(this.checkedGoods.indexOf(item.id) !== -1 (this.checkedGoods.indexOf(item.id) !== -1
? item.price * item.number * 100 ? item.price * item.number * 100
: 0), : 0),
0 0
); );
} }
}, },
methods: { methods: {
async stepperEvent(item, arg) { async stepperEvent(item, arg) {
let number = arg[0]; let number = arg[0];
await this.$reqPost('/wx/cart/update', { await this.$reqPost('/wx/cart/update', {
number: number, number: number,
goodsId: item.goodsId, goodsId: item.goodsId,
id: item.id, id: item.id,
productId: item.productId productId: item.productId
}); });
}, },
async init() { async init() {
let { data } = await this.$reqGet('/wx/cart/index'); let { data } = await this.$reqGet('/wx/cart/index');
this.goods = data.data.cartList; this.goods = data.data.cartList;
this.AllGoods = this.getAllList(); this.AllGoods = this.getAllList();
this.checkedGoods = this.getCheckedList(this.goods); this.checkedGoods = this.getCheckedList(this.goods);
this.count = this.checkedGoods.length; this.count = this.checkedGoods.length;
}, },
getAllList() { getAllList() {
let result = []; let result = [];
_.each(this.goods, v => { _.each(this.goods, v => {
result.push(v.id); result.push(v.id);
}); });
return result; return result;
}, },
getCheckedList(goods) { getCheckedList(goods) {
let result = []; let result = [];
_.each(goods, v => { _.each(goods, v => {
if (v.checked) { if (v.checked) {
result.push(v.id); result.push(v.id);
} }
}); });
return result; return result;
}, },
async cartSubmit(data) { async cartSubmit(data) {
let productIds = []; let productIds = [];
let checkedGoods = this.checkedGoods; let checkedGoods = this.checkedGoods;
_.each(checkedGoods, id => { _.each(checkedGoods, id => {
productIds.push( productIds.push(
_.find(this.goods, vv => { _.find(this.goods, vv => {
return id === vv.id; return id === vv.id;
}).productId }).productId
); );
}); });
console.log(this.goods); console.log(this.goods);
if (this.isEditor) { if (this.isEditor) {
this.$dialog this.$dialog
.confirm({ .confirm({
message: '确定删除所选商品吗?', message: '确定删除所选商品吗?',
cancelButtonText: '再想想' cancelButtonText: '再想想'
}) })
.then(() => { .then(() => {
this.deleteNext(productIds); this.deleteNext(productIds);
}); });
} else { } else {
// for (check in checkedGoods){ // for (check in checkedGoods){
// await this.doCheck(productIds); // await this.doCheck(productIds);
// } // }
let { data } = await this.$reqGet( let { data } = await this.$reqGet(
'/wx/cart/checkout?cartId=0&addressId=0&couponId=0&grouponRulesId=0' '/wx/cart/checkout?cartId=0&addressId=0&couponId=0&grouponRulesId=0'
); );
this.isSubmit = true; this.isSubmit = true;
this.$router.push({ name: 'placeOrderEntity' }); this.$router.push({ name: 'placeOrderEntity' });
} }
}, },
async doCheck(productIds, isChecked) { async doCheck(productIds, isChecked) {
// let good = _.find(this.goods, vv => { // let good = _.find(this.goods, vv => {
// return id === vv.id; // return id === vv.id;
// }) // })
// let productId = good.productId; // let productId = good.productId;
let { data } = await this.$reqPost('/wx/cart/checked', { let { data } = await this.$reqPost('/wx/cart/checked', {
productIds: productIds, productIds: productIds,
isChecked: isChecked isChecked: isChecked
}); });
// if (this.checkedGoods.length == this.AllGoods.length) { // if (this.checkedGoods.length == this.AllGoods.length) {
// this.allCheckedStatus = true; // this.allCheckedStatus = true;
// } // }
}, },
formatPrice(price) { formatPrice(price) {
return (price / 100).toFixed(2); return (price / 100).toFixed(2);
}, },
setCheckAll(val) { setCheckAll(val) {
if (this.checkedGoods.length === this.AllGoods.length) { if (this.checkedGoods.length === this.AllGoods.length) {
this.checkedGoods = []; this.checkedGoods = [];
} else { } else {
this.checkedGoods = this.AllGoods; this.checkedGoods = this.AllGoods;
} }
}, },
deleteCart(o) { deleteCart(o) {
let productId = this.goods[o].productId; let productId = this.goods[o].productId;
this.$dialog this.$dialog
.confirm({ message: '确定删除所选商品吗', cancelButtonText: '再想想' }) .confirm({ message: '确定删除所选商品吗', cancelButtonText: '再想想' })
.then(() => { .then(() => {
// const goodsId = this.goods.splice(i, 1)[0].id; // const goodsId = this.goods.splice(i, 1)[0].id;
this.$nextTick(() => { this.$nextTick(() => {
this.deleteNext(productId); this.deleteNext(productId);
}); });
}); });
}, },
toggle(index) { toggle(index) {
let addProductIds = []; let addProductIds = [];
_.each(index, v => { _.each(index, v => {
let productId = _.find(this.goods, result => { let productId = _.find(this.goods, result => {
return result.id === v; return result.id === v;
}).productId; }).productId;
addProductIds.push(productId); addProductIds.push(productId);
}); });
let delProductIds = []; let delProductIds = [];
_.each(_.difference(this.AllGoods, index), v => { _.each(_.difference(this.AllGoods, index), v => {
let productId = _.find(this.goods, result => { let productId = _.find(this.goods, result => {
return result.id === v; return result.id === v;
}).productId; }).productId;
delProductIds.push(productId); delProductIds.push(productId);
}); });
//没选中的不掉接口 //没选中的不掉接口
if (delProductIds.length > 0) { if (delProductIds.length > 0) {
this.doCheck(delProductIds, 0); this.doCheck(delProductIds, 0);
} }
if (addProductIds.length > 0) { if (addProductIds.length > 0) {
this.doCheck(addProductIds, 1); this.doCheck(addProductIds, 1);
} }
}, },
async deleteNext(o) { async deleteNext(o) {
let productIds = []; let productIds = [];
if (o instanceof Array) { if (o instanceof Array) {
productIds = o; productIds = o;
} else { } else {
productIds.push(o); productIds.push(o);
} }
let { data } = await this.$reqPost('/wx/cart/delete', { let { data } = await this.$reqPost('/wx/cart/delete', {
productIds: productIds productIds: productIds
}); });
this.count = this.count - productIds.length; this.count = this.count - productIds.length;
this.goods = data.data.cartList; this.goods = data.data.cartList;
// this.isEditor = !!this.goods.length; // this.isEditor = !!this.goods.length;
// this.checkedGoods.forEach((goods, i) => { // this.checkedGoods.forEach((goods, i) => {
// if (goods.id == goodsId) { // if (goods.id == goodsId) {
// this.checkedGoods.splice(i, 1); // this.checkedGoods.splice(i, 1);
// return false; // return false;
// } // }
// }); // });
}, },
clearInvalid() { clearInvalid() {
this.$dialog this.$dialog
.confirm({ .confirm({
message: '确定清除所有失效商品吗?', message: '确定清除所有失效商品吗?',
cancelButtonText: '再想想' cancelButtonText: '再想想'
}) })
.then(() => { .then(() => {
this.goods = this.goods.filter(goods => goods.checked); this.goods = this.goods.filter(goods => goods.checked);
}); });
} }
}, },
components: { components: {
[Card.name]: Card, [Card.name]: Card,
[Tag.name]: Tag, [Tag.name]: Tag,
[Stepper.name]: Stepper, [Stepper.name]: Stepper,
[isEmpty.name]: isEmpty, [isEmpty.name]: isEmpty,
[Checkbox.name]: Checkbox, [Checkbox.name]: Checkbox,
[SubmitBar.name]: SubmitBar, [SubmitBar.name]: SubmitBar,
[CheckboxGroup.name]: CheckboxGroup [CheckboxGroup.name]: CheckboxGroup
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '../../assets/scss/mixin'; @import '../../assets/scss/mixin';
.tab-cart { .tab-cart {
padding-bottom: 50px; padding-bottom: 50px;
box-sizing: border-box; box-sizing: border-box;
} }
.editor_head { .editor_head {
@include one-border; @include one-border;
text-align: right; text-align: right;
padding: 10px; padding: 10px;
font-size: $font-size-normal; font-size: $font-size-normal;
background-color: #fff; background-color: #fff;
} }
.card-goods { .card-goods {
background-color: $bg-color; background-color: $bg-color;
.card-goods__item { .card-goods__item {
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 10px; margin-bottom: 10px;
background-color: #fff; background-color: #fff;
} }
.cart_delete { .cart_delete {
line-height: 100px; line-height: 100px;
padding: 0 10px; padding: 0 10px;
color: #fff; color: #fff;
background-color: $red; background-color: $red;
} }
.card-goods__footer { .card-goods__footer {
font-size: $font-size-normal; font-size: $font-size-normal;
color: $font-color-gray; color: $font-color-gray;
} }
} }
.clear_invalid { .clear_invalid {
width: 120px; width: 120px;
color: $font-color-gray; color: $font-color-gray;
border: 1px solid $font-color-gray; border: 1px solid $font-color-gray;
margin: 0 auto; margin: 0 auto;
text-align: center; text-align: center;
padding: 5px 3px; padding: 5px 3px;
margin-top: 20px; margin-top: 20px;
border-radius: 3px; border-radius: 3px;
} }
</style> </style>
...@@ -40,13 +40,13 @@ ...@@ -40,13 +40,13 @@
<script> <script>
import { GOODS_COLLECT_LIST } from '@/api/user'; import { GOODS_COLLECT_LIST } from '@/api/user';
import ItemGroup from '@/vue/components/item-group/'; import ItemGroup from '@/components/item-group/';
import ItemCardHori from '@/vue/components/item-card-hori/'; import ItemCardHori from '@/components/item-card-hori/';
import IsEmpty from '@/vue/components/is-empty/'; import IsEmpty from '@/components/is-empty/';
import { Search, List } from 'vant'; import { Search, List } from 'vant';
import loadMore from '@/vue/mixin/list-load-more'; import loadMore from '@/mixin/list-load-more';
import scrollFixed from '@/vue/mixin/scroll-fixed'; import scrollFixed from '@/mixin/scroll-fixed';
export default { export default {
mixins: [loadMore, scrollFixed], mixins: [loadMore, scrollFixed],
......
<template> <template>
<div class="order_list no-pad-bottom over-hide"> <div class="order_list no-pad-bottom over-hide">
<van-tabs v-model="activeIndex" :swipe-threshold="5" @click="handleTabClick"> <van-tabs v-model="activeIndex" :swipe-threshold="5" @click="handleTabClick">
<van-tab v-for="(tab, tabIndex) in tabsItem" :title="tab.name" :key="tab.type"> <van-tab v-for="(tab, tabIndex) in tabsItem" :title="tab.name" :key="tab.type">
<InfinityScroll <InfinityScroll
class="full-page scroll-wrap height-fix42" class="full-page scroll-wrap height-fix42"
:beforeRequest="beforeRequest" :beforeRequest="beforeRequest"
:apiUrl="listApi" :apiUrl="listApi"
@onLoad="onLoad(tabIndex, $event)" @onLoad="onLoad(tabIndex, $event)"
> >
<van-panel <van-panel
v-for="(el, i) in tab.items" v-for="(el, i) in tab.items"
class="order_list--panel" class="order_list--panel"
:key="el.id" :key="el.id"
:title="'订单编号: ' + el.id" :title="'订单编号: ' + el.id"
:status="getStatusText(el.status)" :status="getStatusText(el.status)"
> >
<div> <div>
<van-card <van-card
v-for="(goods, i) in el.serviceItems" v-for="(goods, i) in el.serviceItems"
class="order_list--van-card" class="order_list--van-card"
:key="i" :key="i"
:title="goods.item_name" :title="goods.item_name"
:desc="goods.sku_props_str" :desc="goods.sku_props_str"
:num="10000" :num="10000"
:price="(goods.price / 100).toFixed(2)" :price="(goods.price / 100).toFixed(2)"
:thumb="goods.pic_url" :thumb="goods.pic_url"
/> />
<div class="order_list--total">合计: {{el.total_fee | yuan}}(含运费{{el.post_fee | yuan}}</div> <div class="order_list--total">合计: {{el.total_fee | yuan}}(含运费{{el.post_fee | yuan}}</div>
</div> </div>
<component <component
slot="footer" slot="footer"
:is="'status' + el.status" :is="'status' + el.status"
@delete-order="delOrder(i)" @delete-order="delOrder(i)"
@pay="toPay(el.id)" @pay="toPay(el.id)"
@cancel="cancelOrder(i)" @cancel="cancelOrder(i)"
/> />
</van-panel> </van-panel>
</InfinityScroll> </InfinityScroll>
</van-tab> </van-tab>
</van-tabs> </van-tabs>
</div> </div>
</template> </template>
<script> <script>
import { ELE_COUPON_LIST } from '@/api/order'; import { ELE_COUPON_LIST } from '@/api/order';
import { Tab, Tabs, Panel, Card, List } from 'vant'; import { Tab, Tabs, Panel, Card, List } from 'vant';
import status10 from './handle-status-10'; import status10 from './handle-status-10';
import status40 from './handle-status-40'; import status40 from './handle-status-40';
import status60 from './handle-status-60'; import status60 from './handle-status-60';
import status70 from './handle-status-70'; import status70 from './handle-status-70';
import status100 from './handle-status-100'; import status100 from './handle-status-100';
import status110 from './handle-status-110'; import status110 from './handle-status-110';
import status120 from './handle-status-120'; import status120 from './handle-status-120';
import _ from 'lodash'; import _ from 'lodash';
import InfinityScroll from '@/vue/components/infinity-scroll'; import InfinityScroll from '@/components/infinity-scroll';
const STATUS_TEXT = { const STATUS_TEXT = {
10: '待付款', 10: '待付款',
40: '已完成', 40: '已完成',
60: '已关闭', 60: '已关闭',
70: '已关闭', 70: '已关闭',
100: '未使用', 100: '未使用',
110: '已使用', 110: '已使用',
120: '已退款' 120: '已退款'
}; };
export default { export default {
name: 'order-list', name: 'order-list',
props: { props: {
active: { active: {
type: [String, Number], type: [String, Number],
default: 0 default: 0
} }
}, },
data() { data() {
const activeIndex = this.active; const activeIndex = this.active;
return { return {
listApi: ELE_COUPON_LIST, listApi: ELE_COUPON_LIST,
shop_id: 1, shop_id: 1,
activeIndex, activeIndex,
tabsItem: [ tabsItem: [
{ {
name: '全部', name: '全部',
status: 0, status: 0,
items: [] items: []
}, },
{ {
name: '待付款', name: '待付款',
status: 10, status: 10,
items: [] items: []
}, },
{ {
name: '待使用', name: '待使用',
status: 100, status: 100,
items: [] items: []
}, },
{ {
name: '已使用', name: '已使用',
status: 110, status: 110,
items: [] items: []
}, },
{ {
name: '退款成功', name: '退款成功',
status: 120, status: 120,
items: [] items: []
} }
] ]
}; };
}, },
methods: { methods: {
onLoad(i, items) { onLoad(i, items) {
new Array(10).fill(1).forEach(() => { new Array(10).fill(1).forEach(() => {
items.push(_.cloneDeep(_.last(items))); items.push(_.cloneDeep(_.last(items)));
}); });
this.tabsItem[i].items.push(...items); this.tabsItem[i].items.push(...items);
}, },
beforeRequest() { beforeRequest() {
const i = this.activeIndex; const i = this.activeIndex;
const status = this.tabsItem[i].status; const status = this.tabsItem[i].status;
const { shop_id } = this; const { shop_id } = this;
return { return {
params: { params: {
status, status,
shop_id shop_id
} }
}; };
}, },
delOrder(i) { delOrder(i) {
this.$dialog.confirm({ message: '确定删除订单?' }).then(() => { this.$dialog.confirm({ message: '确定删除订单?' }).then(() => {
this.items.splice(i, 1); this.items.splice(i, 1);
this.$toast('已删除'); this.$toast('已删除');
}); });
}, },
async cancelOrder(i) { async cancelOrder(i) {
this.$dialog this.$dialog
.confirm({ message: '确定要取消该订单吗?' }) .confirm({ message: '确定要取消该订单吗?' })
.then(() => { .then(() => {
this.items.splice(i, 1); this.items.splice(i, 1);
this.$toast('已取消该订单'); this.$toast('已取消该订单');
}) })
.catch(() => {}); .catch(() => {});
}, },
toPay(id) { toPay(id) {
this.$router.push({ name: 'payment', params: { order_id: id } }); this.$router.push({ name: 'payment', params: { order_id: id } });
}, },
handleTabClick(index) { handleTabClick(index) {
this.$router.replace({ this.$router.replace({
name: 'user-order-ele-list', name: 'user-order-ele-list',
params: { status: index } params: { status: index }
}); });
}, },
getStatusText(status) { getStatusText(status) {
return STATUS_TEXT[status] || ''; return STATUS_TEXT[status] || '';
} }
}, },
components: { components: {
[Tab.name]: Tab, [Tab.name]: Tab,
[Tabs.name]: Tabs, [Tabs.name]: Tabs,
[Panel.name]: Panel, [Panel.name]: Panel,
[Card.name]: Card, [Card.name]: Card,
[List.name]: List, [List.name]: List,
InfinityScroll, InfinityScroll,
status10, status10,
status40, status40,
status60, status60,
status70, status70,
status100, status100,
status110, status110,
status120 status120
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.order_list { .order_list {
&--footer_btn { &--footer_btn {
text-align: right; text-align: right;
} }
&--panel { &--panel {
margin-bottom: 10px; margin-bottom: 10px;
} }
&--van-card { &--van-card {
background-color: #fafafa; background-color: #fafafa;
} }
&--total { &--total {
text-align: right; text-align: right;
padding: 10px; padding: 10px;
} }
} }
</style> </style>
<template> <template>
<div class="order_list over-hide"> <div class="order_list over-hide">
<van-tabs v-model="activeIndex" :swipe-threshold="5" @click="handleTabClick"> <van-tabs v-model="activeIndex" :swipe-threshold="5" @click="handleTabClick">
<van-tab <van-tab
v-for="(tab, tabIndex) in tabsItem" v-for="(tab, tabIndex) in tabsItem"
:title="tab.name" :title="tab.name"
@click="changeTab" @click="changeTab"
:key="tab.type" :key="tab.type"
> >
<InfinityScroll <InfinityScroll
class="full-page scroll-wrap height-fix42" class="full-page scroll-wrap height-fix42"
:beforeRequest="beforeRequest" :beforeRequest="beforeRequest"
:apiUrl="listApi" :apiUrl="listApi"
@onLoad="onLoad(tabIndex, $event)" @onLoad="onLoad(tabIndex, $event)"
> >
<van-panel <van-panel
v-for="(el, i) in orderArr" v-for="(el, i) in orderArr"
class="order_list--panel" class="order_list--panel"
:key="i" :key="i"
:title="'订单编号: ' + el.orderSn" :title="'订单编号: ' + el.orderSn"
:status="el.orderStatusText" :status="el.orderStatusText"
> >
<div> <div>
<van-card <van-card
v-for="(goods, goodsI) in el.goodsList" v-for="(goods, goodsI) in el.goodsList"
class="order_list--van-card" class="order_list--van-card"
:key="goodsI" :key="goodsI"
:title="goods.goodsName" :title="goods.goodsName"
:desc="goods.goodsName" :desc="goods.goodsName"
:num="goods.number" :num="goods.number"
:thumb="goods.picUrl" :thumb="goods.picUrl"
@click.native="toOrderDetail(el.id)" @click.native="toOrderDetail(el.id)"
/> />
<div <div
class="order_list--total" class="order_list--total"
>合计: {{el.actualPrice * 100 | yuan}}(含运费{{el.post_fee | yuan}}</div> >合计: {{el.actualPrice * 100 | yuan}}(含运费{{el.post_fee | yuan}}</div>
</div> </div>
<component <component
slot="footer" slot="footer"
:is="'status' + el.status" :is="'status' + el.status"
:reminder="el.is_can_reminder" :reminder="el.is_can_reminder"
@handle="actionHandle($event, i)" @handle="actionHandle($event, i)"
/> />
</van-panel> </van-panel>
</InfinityScroll> </InfinityScroll>
</van-tab> </van-tab>
</van-tabs> </van-tabs>
</div> </div>
</template> </template>
<script> <script>
import { ORDER_LIST } from '@/api/order'; import { ORDER_LIST } from '@/api/order';
import { Tab, Tabs, Panel, Card, List } from 'vant'; import { Tab, Tabs, Panel, Card, List } from 'vant';
import status10 from './handle-status-10'; import status10 from './handle-status-10';
import status20 from './handle-status-20'; import status20 from './handle-status-20';
import status25 from './handle-status-25'; import status25 from './handle-status-25';
import status30 from './handle-status-30'; import status30 from './handle-status-30';
import status40 from './handle-status-40'; import status40 from './handle-status-40';
import status50 from './handle-status-50'; import status50 from './handle-status-50';
import status60 from './handle-status-60'; import status60 from './handle-status-60';
import status70 from './handle-status-70'; import status70 from './handle-status-70';
import InfinityScroll from '@/vue/components/infinity-scroll'; import InfinityScroll from '@/components/infinity-scroll';
const STATUS_TEXT = { const STATUS_TEXT = {
10: '待付款', 10: '待付款',
20: '待发货', 20: '待发货',
25: '部分发货', 25: '部分发货',
30: '待收货', 30: '待收货',
40: '已完成', 40: '已完成',
50: '退款成功', 50: '退款成功',
60: '交易关闭', 60: '交易关闭',
70: '交易关闭' 70: '交易关闭'
}; };
export default { export default {
name: 'order-list', name: 'order-list',
props: { props: {
active: { active: {
type: [String, Number], type: [String, Number],
default: 0 default: 0
} }
}, },
created() { created() {
this.init(); this.init();
}, },
data() { data() {
const activeIndex = this.active; const activeIndex = this.active;
return { return {
listApi: ORDER_LIST, listApi: ORDER_LIST,
shop_id: 1, shop_id: 1,
activeIndex, activeIndex,
tabsItem: [ tabsItem: [
{ {
name: '全部', name: '全部',
status: 0, status: 0,
items: [] items: []
}, },
{ {
name: '待付款', name: '待付款',
status: 10, status: 10,
items: [] items: []
}, },
{ {
name: '待发货', name: '待发货',
status: 20, status: 20,
items: [] items: []
}, },
{ {
name: '待收货', name: '待收货',
status: 30, status: 30,
items: [] items: []
}, },
{ {
name: '已完成', name: '已完成',
status: 40, status: 40,
items: [] items: []
} }
], ],
orderArr: [] orderArr: []
}; };
}, },
methods: { methods: {
async init(i) { async init(i) {
let { data } = await this.$reqGet( let { data } = await this.$reqGet(
`/wx/order/list?showType=${i || this.active || '0'}` `/wx/order/list?showType=${i || this.active || '0'}`
); );
this.orderArr = data.data.data; this.orderArr = data.data.data;
}, },
onLoad(i, items) { onLoad(i, items) {
this.tabsItem[i].items.push(...items); this.tabsItem[i].items.push(...items);
}, },
beforeRequest() { beforeRequest() {
const i = this.activeIndex; const i = this.activeIndex;
const status = this.tabsItem[i].status; const status = this.tabsItem[i].status;
const { shop_id } = this; const { shop_id } = this;
return { return {
params: { params: {
status, status,
shop_id shop_id
} }
}; };
}, },
async delOrder(i) { async delOrder(i) {
await this.$dialog.confirm({ message: '确定要删除该订单吗?' }); await this.$dialog.confirm({ message: '确定要删除该订单吗?' });
this.items.splice(i, 1); this.items.splice(i, 1);
this.$toast('已删除该订单'); this.$toast('已删除该订单');
}, },
async cancelOrder(i) { async cancelOrder(i) {
await this.$dialog.confirm({ message: '确定要取消该订单吗?' }); await this.$dialog.confirm({ message: '确定要取消该订单吗?' });
if (this.activeIndex == 0) { if (this.activeIndex == 0) {
this.items[i].status = 60; this.items[i].status = 60;
} else { } else {
this.items.splice(i, 1); this.items.splice(i, 1);
} }
this.$toast('已取消该订单'); this.$toast('已取消该订单');
}, },
async receiptOrder(i) { async receiptOrder(i) {
await this.$dialog.confirm({ await this.$dialog.confirm({
message: '请确认收到货物, 确认收货后无法撤销!' message: '请确认收到货物, 确认收货后无法撤销!'
}); });
this.items[i].status = 40; this.items[i].status = 40;
this.$toast('已确认收货'); this.$toast('已确认收货');
}, },
reminderOrder(i) { reminderOrder(i) {
this.items[i].is_can_reminder = false; this.items[i].is_can_reminder = false;
this.$toast('已提醒卖家发货, 请耐心等待哦~'); this.$toast('已提醒卖家发货, 请耐心等待哦~');
}, },
toPay(i) { toPay(i) {
const id = this.items[i].id; const id = this.items[i].id;
this.$router.push({ name: 'payment', params: { order_id: id } }); this.$router.push({ name: 'payment', params: { order_id: id } });
}, },
handleTabClick(index) { handleTabClick(index) {
console.log(6666666); console.log(6666666);
// console.log(index); // console.log(index);
// await this.init(i); // await this.init(i);
this.$router.replace({ this.$router.replace({
name: 'user-order-list', name: 'user-order-list',
params: { active: index } params: { active: index }
}); });
}, },
getStatusText(status) { getStatusText(status) {
return STATUS_TEXT[status] || ''; return STATUS_TEXT[status] || '';
}, },
toOrderDetail(id) { toOrderDetail(id) {
this.$router.push({ this.$router.push({
name: `orderDetail`, name: `orderDetail`,
query: { cartId: 0, orderId: id } query: { cartId: 0, orderId: id }
}); });
}, },
actionHandle(handle, i) { actionHandle(handle, i) {
this[handle] && this[handle](i); this[handle] && this[handle](i);
} }
}, },
watch: { watch: {
active(val) { active(val) {
this.init(val); this.init(val);
val && !this.address_list.length && this.getAddress(); val && !this.address_list.length && this.getAddress();
} }
}, },
components: { components: {
InfinityScroll, InfinityScroll,
[Tab.name]: Tab, [Tab.name]: Tab,
[Tabs.name]: Tabs, [Tabs.name]: Tabs,
[Panel.name]: Panel, [Panel.name]: Panel,
[Card.name]: Card, [Card.name]: Card,
[List.name]: List, [List.name]: List,
status10, status10,
status20, status20,
status25, status25,
status30, status30,
status40, status40,
status50, status50,
status60, status60,
status70 status70
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.order_list { .order_list {
padding-bottom: 0; padding-bottom: 0;
overflow-y: hidden; overflow-y: hidden;
&--footer_btn { &--footer_btn {
text-align: right; text-align: right;
} }
&--panel { &--panel {
margin-bottom: 10px; margin-bottom: 10px;
} }
&--van-card { &--van-card {
background-color: #fafafa; background-color: #fafafa;
} }
&--total { &--total {
text-align: right; text-align: right;
padding: 10px; padding: 10px;
} }
} }
</style> </style>
<template> <template>
<div class="order_list"> <div class="order_list">
<van-tabs sticky :active="activeIndex" :swipe-threshold="5" @click="handleTabClick"> <van-tabs sticky :active="activeIndex" :swipe-threshold="5" @click="handleTabClick">
<van-tab v-for="(tab, tabIndex) in tabsItem" :title="tab.name" :key="tab.type"> <van-tab v-for="(tab, tabIndex) in tabsItem" :title="tab.name" :key="tab.type">
<InfinityScroll <InfinityScroll
class="full-page scroll-wrap" class="full-page scroll-wrap"
:beforeRequest="beforeRequest" :beforeRequest="beforeRequest"
:apiUrl="listApi" :apiUrl="listApi"
@onLoad="onLoad(tabIndex, $event)" @onLoad="onLoad(tabIndex, $event)"
> >
<van-panel <van-panel
v-for="(el, i) in tab.items" v-for="(el, i) in tab.items"
class="order_list--panel" class="order_list--panel"
:key="i" :key="i"
:title="'订单编号: ' + el.id" :title="'订单编号: ' + el.id"
:status="getStatusText(el.status)" :status="getStatusText(el.status)"
> >
<div> <div>
<van-card <van-card
class="order_list--van-card" class="order_list--van-card"
:key="i" :key="i"
:title="el.orderItem.item_name" :title="el.orderItem.item_name"
:desc="el.orderItem.sku_props_str" :desc="el.orderItem.sku_props_str"
:num="10000" :num="10000"
:price="(el.orderItem.price / 100).toFixed(2)" :price="(el.orderItem.price / 100).toFixed(2)"
:thumb="el.orderItem.pic_url" :thumb="el.orderItem.pic_url"
/> />
<div <div
class="order_list--total" class="order_list--total"
>合计: {{el.refund_fee | yuan}}(含运费{{el.refund_post_fee | yuan}}</div> >合计: {{el.refund_fee | yuan}}(含运费{{el.refund_post_fee | yuan}}</div>
</div> </div>
<div slot="footer" style="text-align: right;"> <div slot="footer" style="text-align: right;">
<van-button <van-button
size="small" size="small"
@click="refund_handle(i)" @click="refund_handle(i)"
>{{ el.status == 10 ? "撤销申请" : "查看详情"}}</van-button> >{{ el.status == 10 ? "撤销申请" : "查看详情"}}</van-button>
</div> </div>
</van-panel> </van-panel>
</InfinityScroll> </InfinityScroll>
</van-tab> </van-tab>
</van-tabs> </van-tabs>
</div> </div>
</template> </template>
<script> <script>
import { REFUND_LIST } from '@/api/order'; import { REFUND_LIST } from '@/api/order';
import { Tab, Tabs, Panel, Card, List } from 'vant'; import { Tab, Tabs, Panel, Card, List } from 'vant';
import InfinityScroll from '@/vue/components/infinity-scroll'; import InfinityScroll from '@/components/infinity-scroll';
const STATUS_TEXT = { const STATUS_TEXT = {
10: '退款中', 10: '退款中',
50: '退款关闭', 50: '退款关闭',
60: '退款成功' 60: '退款成功'
}; };
export default { export default {
name: 'order-list', name: 'order-list',
data() { data() {
return { return {
listApi: REFUND_LIST, listApi: REFUND_LIST,
shop_id: 1, shop_id: 1,
activeIndex: 0, activeIndex: 0,
items: [], items: [],
tabsItem: [ tabsItem: [
{ {
name: '全部', name: '全部',
status: 0, status: 0,
items: [] items: []
}, },
{ {
name: '退款中', name: '退款中',
status: 10, status: 10,
items: [] items: []
}, },
{ {
name: '退款成功', name: '退款成功',
status: 60, status: 60,
items: [] items: []
} }
] ]
}; };
}, },
methods: { methods: {
onLoad(i, items) { onLoad(i, items) {
this.tabsItem[i].items.push(...items); this.tabsItem[i].items.push(...items);
}, },
beforeRequest() { beforeRequest() {
const i = this.activeIndex; const i = this.activeIndex;
const status = this.tabsItem[i].status; const status = this.tabsItem[i].status;
const { shop_id } = this; const { shop_id } = this;
return { return {
params: { params: {
status, status,
shop_id shop_id
} }
}; };
}, },
refund_handle(i) { refund_handle(i) {
const item = this.items[i]; const item = this.items[i];
if (item.status == 10) { if (item.status == 10) {
this.$dialog this.$dialog
.confirm({ .confirm({
message: '撤销后将不能再次发起申请,确定要撤销该申请吗?' message: '撤销后将不能再次发起申请,确定要撤销该申请吗?'
}) })
.then(() => { .then(() => {
this.$toast('已撤销该退款申请'); this.$toast('已撤销该退款申请');
this.items[i].status = 50; this.items[i].status = 50;
}); });
} else { } else {
// 跳转退款详情 // 跳转退款详情
} }
}, },
handleTabClick(index) { handleTabClick(index) {
if (this.activeIndex != index) { if (this.activeIndex != index) {
this.activeIndex = index; this.activeIndex = index;
} }
}, },
getStatusText(status) { getStatusText(status) {
return STATUS_TEXT[status] || ''; return STATUS_TEXT[status] || '';
} }
}, },
components: { components: {
[Tab.name]: Tab, [Tab.name]: Tab,
[Tabs.name]: Tabs, [Tabs.name]: Tabs,
[Panel.name]: Panel, [Panel.name]: Panel,
[Card.name]: Card, [Card.name]: Card,
[List.name]: List, [List.name]: List,
InfinityScroll InfinityScroll
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.order_list { .order_list {
padding-bottom: 0; padding-bottom: 0;
&--footer_btn { &--footer_btn {
text-align: right; text-align: right;
} }
&--panel { &--panel {
margin-bottom: 10px; margin-bottom: 10px;
} }
&--van-card { &--van-card {
background-color: #fafafa; background-color: #fafafa;
} }
&--total { &--total {
text-align: right; text-align: right;
padding: 10px; padding: 10px;
} }
} }
</style> </style>
<template> <template>
<div class="user_header" :style="{backgroundImage: `url(${background_image})`}"> <div class="user_header" :style="{backgroundImage: `url(${background_image})`}">
<van-icon name="set" class="user_set" @click="toSetting"/> <van-icon name="set" class="user_set" @click="toSetting"/>
<div class="user_avatar"> <div class="user_avatar">
<img :src="avatar" alt="头像" width="55" height="55"> <img :src="avatar" alt="头像" width="55" height="55">
</div> </div>
<div>{{nickName}}</div> <div>{{nickName}}</div>
</div> </div>
</template> </template>
<script> <script>
import avatar_default from '../../assets/images/avatar_default.png'; import avatar_default from '@/assets/images/avatar_default.png';
import bg_default from '../../assets/images/user_head_bg.png'; import bg_default from '@/assets/images/user_head_bg.png';
import { getLocalStorage } from 'core/utils/local-storage'; import { getLocalStorage } from '@/utils/local-storage';
import _ from 'lodash'; import _ from 'lodash';
export default { export default {
name: 'user-header', name: 'user-header',
props: { props: {
isLogin: { isLogin: {
type: Boolean, type: Boolean,
default: false default: false
} }
}, },
data() { data() {
return { return {
nickName: '昵称', nickName: '昵称',
avatar: avatar_default, avatar: avatar_default,
background_image: bg_default background_image: bg_default
}; };
}, },
activated() { activated() {
this.getUserInfo(); this.getUserInfo();
}, },
methods: { methods: {
getUserInfo() { getUserInfo() {
const infoData = getLocalStorage( const infoData = getLocalStorage(
'nickName', 'nickName',
'background_image', 'background_image',
'avatar' 'avatar'
); );
this.avatar = avatar_default; this.avatar = avatar_default;
this.nickName = infoData.nickName || '昵称'; this.nickName = infoData.nickName || '昵称';
if (!_.isEmpty(infoData.avatar)) { if (!_.isEmpty(infoData.avatar)) {
this.avatar = `http://www.qmenhu.com${infoData.avatar}`; this.avatar = `http://www.qmenhu.com${infoData.avatar}`;
} }
console.log(this.avatar); console.log(this.avatar);
console.log('-----------'); console.log('-----------');
console.log(infoData); console.log(infoData);
this.background_image = infoData.background_image || bg_default; this.background_image = infoData.background_image || bg_default;
}, },
toSetting() { toSetting() {
this.$router.push({ name: 'user-information' }); this.$router.push({ name: 'user-information' });
} }
// toLogin() { // toLogin() {
// !this.isLogin && // !this.isLogin &&
// this.$router.push({ name: 'login', query: { redirect: 'user' } }); // this.$router.push({ name: 'login', query: { redirect: 'user' } });
// } // }
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.user_header { .user_header {
position: relative; position: relative;
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: cover; background-size: cover;
height: 130px; height: 130px;
box-sizing: border-box; box-sizing: border-box;
text-align: center; text-align: center;
color: #fff; color: #fff;
padding-top: 30px; padding-top: 30px;
} }
i.user_set { i.user_set {
position: absolute; position: absolute;
top: 10px; top: 10px;
right: 10px; right: 10px;
font-size: 24px; font-size: 24px;
} }
.user_avatar { .user_avatar {
margin-bottom: 10px; margin-bottom: 10px;
img { img {
border: 0; border: 0;
border-radius: 50%; border-radius: 50%;
} }
} }
</style> </style>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment