main
RIceWqy 2 years ago
parent c0a2dc6eab
commit e4f86ae640

File diff suppressed because it is too large Load Diff

@ -50,7 +50,11 @@
</slot>
</view>
<!-- 规格弹窗 -->
<shopro-sku v-if="showSku && goodsInfo.id" v-model="showSku" :goodsInfo="goodsInfo" buyType="cart"></shopro-sku>
<shopro-sku v-if="showSku && goodsInfo && goodsInfo.id" v-model="showSku" :goodsInfo="goodsInfo"
buyType="cart"></shopro-sku>
</view>
</template>
@ -68,7 +72,12 @@
* @property {Array} tagTextList - 活动标签
* @event {Function} click 商品被点击
*/
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
import {
mapMutations,
mapActions,
mapState,
mapGetters
} from 'vuex';
export default {
components: {},
data() {
@ -184,7 +193,10 @@
confirmColor: '#f0c785',
content: `是否确认从购物车中删除此商品?`,
success: res => {
res.confirm && this.changeCartList({ ids: [cartGoodId], art: 'delete' });
res.confirm && this.changeCartList({
ids: [cartGoodId],
art: 'delete'
});
}
});
},
@ -206,8 +218,14 @@
// ,
async selSku(info) {
console.log("selSku")
if (this.detail.activity_type) {
this.$Router.push({ path: '/pages/goods/detail', query: { id: this.detail.id } });
this.$Router.push({
path: '/pages/goods/detail',
query: {
id: this.detail.id
}
});
return;
}
this.goodsInfo = {};
@ -229,14 +247,21 @@
//
addCart(sku) {
console.log("cart ")
if (sku.stock <= 0) {
this.$u.toast('库存不足');
return;
}
if (this.detail.activity_type) {
this.$Router.push({ path: '/pages/goods/detail', query: { id: this.detail.id } });
this.$Router.push({
path: '/pages/goods/detail',
query: {
id: this.detail.id
}
});
return;
}
let confirmGoodsList = {
list: [{
goods_id: sku.goods_id,
@ -244,7 +269,7 @@
sku_price_id: sku.id,
goods_price: sku.price
}],
from: 'goods'
// from: 'goods'
};
this.addCartGoods(confirmGoodsList).then(res => {
if (res.code === 1) {
@ -345,4 +370,4 @@
}
}
}
</style>
</style>

@ -160,7 +160,7 @@
},
methods: {
...mapActions(['addCartGoods', 'getCartList']),
...mapActions(['addCartGoodsJson','addCartGoods', 'getCartList']),
jump(path, parmas) {
this.$Router.push({
path: path,
@ -343,10 +343,11 @@
list: [that.confirmGoodsInfo],
from: 'goods'
};
that.addCartGoods(confirmGoodsList).then(res => {
if (res.code === 1) {
that.addCartGoodsJson(confirmGoodsList).then(res => {
console.log(res)
if (res.error.code === 200) {
that.showModal = false;
that.$u.toast(res.msg);
that.$u.toast(res.error.msg);
}
});
}
@ -369,6 +370,7 @@
},
//
confirm() {
console.log("confirm")
if (this.confirmSku()) {
switch (this.buyType) {
case 'cart':

@ -17,7 +17,7 @@ async function bootstrap() {
Vue.use(uView);
// 加载shopro
Vue.use(shopro);
Vue.use(jsonrpc);
Vue.use(jsonrpc);
const app = new Vue({
store,
...App

@ -210,6 +210,7 @@ import shComment from './components/sh-comment.vue';
import share from '@/shopro/share';
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
import jsonrpc from "@/shopro/request/indexJson.js"
export default {
components: {
shServe,
@ -361,7 +362,7 @@ export default {
getGoodsDetail() {
let that = this;
return new Promise((resolve, reject) => {
that.$jsonrpc('goods.detail',{id: that.$Route.query.id},'',
jsonrpc('goods.detail',{id: that.$Route.query.id},'',
false).then(res=>{
console.log(res)
if (res.error.code === 200) {

@ -15,7 +15,7 @@
<view class="u-waterfall u-p-16" v-if="!isEmpty">
<view id="u-left-column" class="u-column">
<view class="goods-item u-m-b-16 u-flex u-row-center u-col-center" v-for="leftGoods in leftList" :key="leftGoods.id">
<shopro-goods-card
<shopro-goods-card v-if="leftGoods"
:detail="leftGoods"
:type="leftGoods.activity_type"
:image="leftGoods.image"
@ -31,7 +31,7 @@
</view>
<view id="u-right-column" class="u-column">
<view class="goods-item u-m-b-16 u-flex u-row-center u-col-center" v-for="rightGoods in rightList" :key="rightGoods.id">
<shopro-goods-card
<shopro-goods-card v-if="rightGoods"
:detail="rightGoods"
:type="rightGoods.activity_type"
:image="rightGoods.image"
@ -58,6 +58,7 @@
<script>
import shFilter from './components/sh-filter.vue';
import jsonrpc from '@/shopro/request/indexJson.js';
import { mapMutations, mapActions, mapState } from 'vuex';
let systemInfo = uni.getSystemInfoSync();
let historyTag = uni.getStorageSync('searchHistoryArr') ? JSON.parse(uni.getStorageSync('searchHistoryArr')) : [];
@ -181,7 +182,7 @@ export default {
let that = this;
that.loadStatus = 'loading';
console.log("good list ")
this.$jsonrpc('goods.list2',this.listParams,'加载中...').then(res=>{
jsonrpc('goods.list2',this.listParams,'加载中...').then(res=>{
console.log(res)
if (this.searchVal && !historyTag.includes(this.searchVal)) {
let searchHistoryArr = JSON.stringify(this.getArr(historyTag, this.searchVal));

@ -40,8 +40,9 @@
<text
class="order-price font-OPPOSANS">{{ g.sku_price ? g.sku_price.price : 0 }}</text>
<u-number-box :value="g.goods_num" :long-press="false" :min="0" :step="1"
:index="index" :max="!g.sku_price ? 0: (g.sku_price.stock > 999 ? 999 : g.sku_price.stock)" @min="onMin(g)"
@minus="changeNum($event, g)" @plus="changeNum($event, g)"
:index="index"
:max="!g.sku_price ? 0: (g.sku_price.stock > 999 ? 999 : g.sku_price.stock)"
@min="onMin(g)" @minus="changeNum($event, g)" @plus="changeNum($event, g)"
@change="changeNum($event, g)">
</u-number-box>
</view>
@ -73,7 +74,12 @@
</template>
<script>
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
import {
mapMutations,
mapActions,
mapState,
mapGetters
} from 'vuex';
let timer = null;
export default {
components: {},
@ -90,13 +96,13 @@
}
},
onShow() {
this.isLogin && this.getCartList();
this.isLogin && this.getCartListJson();
},
onHide() {
this.isTool = false;
},
methods: {
...mapActions(['getCartList', 'changeCartList']),
...mapActions(['getCartListJson', 'getCartList', 'changeCartList', 'changeCartListJson']),
//
onMin(g) {
@ -105,7 +111,10 @@
confirmColor: '#f0c785',
content: `是否确认从购物车中删除此商品?`,
success: res => {
res.confirm && this.changeCartList({ ids: [g.id], art: 'delete' });
res.confirm && this.changeCartListJson({
ids: [g.id],
art: 'delete'
});
}
});
},
@ -114,9 +123,13 @@
uni.showLoading({
mask: true
});
e.value > 0 && this.changeCartList({ ids: [g.id], goodsNum: e.value, art: 'change' });
e.value > 0 && this.changeCartListJson({
ids: [g.id],
goodsNum: e.value,
art: 'change'
});
uni.hideLoading();
await this.getCartList();
await this.getCartListJson();
},
//
@ -142,7 +155,9 @@
//
onPay() {
let that = this;
let { cartList } = this;
let {
cartList
} = this;
if (this.isSel) {
let confirmcartList = [];
let isActivity = false;
@ -155,11 +170,14 @@
if (item.cart_type === 'activity') {
isActivity = true;
}
console.log(item)
confirmcartList.push({
goods_id: item.goods_id,
sku_price_id: item.sku_price_id,
goods_price: item.sku_price ? item.sku_price.price : 0,
goods_num: item.goods_num
goods_num: item.goods_num,
cart_id: item.id
});
}
}
@ -167,20 +185,28 @@
this.$u.toast('活动商品只能单独购买');
return false;
}
that.jump('/pages/order/confirm', { goodsList: confirmcartList, from: 'cart' });
that.jump('/pages/order/confirm', {
goodsList: confirmcartList,
from: 'cart'
});
}
},
//
goodsDelete() {
let that = this;
let { cartList } = this;
let {
cartList
} = this;
let selectedIdsArray = [];
cartList.map(item => {
if (item.checked) {
selectedIdsArray.push(item.id);
}
});
this.changeCartList({ ids: selectedIdsArray, art: 'delete' });
this.changeCartListJson({
ids: selectedIdsArray,
art: 'delete'
});
}
}
};
@ -368,4 +394,4 @@
color: rgba(#fff, 0.9);
}
}
</style>
</style>

@ -16,69 +16,76 @@
</template>
<script>
import takeoutCatgory from './category/takeout-catgory.vue';
import threeCatgory from './category/three-catgory.vue';
import twoCatgory from './category/two-catgory.vue';
import oneCatgory from './category/one-catgory.vue';
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
import jsonrpc from "@/shopro/jsonrpc/jsonrpc2.0.js"
export default {
components: {
takeoutCatgory,
threeCatgory,
twoCatgory,
oneCatgory
},
data() {
return {
categoryType: 0, //1:,2:3:4:
categoryStyleId: 0 //Id
};
},
computed: {
...mapGetters(['authType'])
},
onLoad() {
this.getCategory();
},
methods: {
/**
* 获取分类数据
* type4:三级分类 type3:二级分类 ,type2:一级分类,type1:快速购买
*/
getCategory() {
this.$jsonrpc('category.info',{id: this.$Route.query.id ? this.$Route.query.id : 0}).then(res =>{
if (res.result?.type) {
this.categoryType = Number(res.result.type);
this.categoryStyleId = Number(res.result.id);
uni.setNavigationBarTitle({
title: res.result?.name
});
}
})
/* this.$http('category.info', { id: this.$Route.query.id ? this.$Route.query.id : 0}).then(res => {
if (res.code === 1) {
if (res.data?.type) {
this.categoryType = Number(res.data.type);
this.categoryStyleId = Number(res.data.id);
import takeoutCatgory from './category/takeout-catgory.vue';
import threeCatgory from './category/three-catgory.vue';
import twoCatgory from './category/two-catgory.vue';
import oneCatgory from './category/one-catgory.vue';
import {
mapMutations,
mapActions,
mapState,
mapGetters
} from 'vuex';
import jsonrpc from "@/shopro/request/indexJson.js"
export default {
components: {
takeoutCatgory,
threeCatgory,
twoCatgory,
oneCatgory
},
data() {
return {
categoryType: 0, //1:,2:3:4:
categoryStyleId: 0 //Id
};
},
computed: {
...mapGetters(['authType'])
},
onLoad() {
this.getCategory();
},
methods: {
/**
* 获取分类数据
* type4:三级分类 type3:二级分类 ,type2:一级分类,type1:快速购买
*/
getCategory() {
jsonrpc('category.info', {
id: this.$Route.query.id ? this.$Route.query.id : 0
}).then(res => {
if (res.result?.type) {
this.categoryType = Number(res.result.type);
this.categoryStyleId = Number(res.result.id);
uni.setNavigationBarTitle({
title: res.data?.name
title: res.result?.name
});
}
}
}); */
})
/* this.$http('category.info', { id: this.$Route.query.id ? this.$Route.query.id : 0}).then(res => {
if (res.code === 1) {
if (res.data?.type) {
this.categoryType = Number(res.data.type);
this.categoryStyleId = Number(res.data.id);
uni.setNavigationBarTitle({
title: res.data?.name
});
}
}
}); */
}
}
}
};
};
</script>
<style lang="scss">
.category-box {
height: 100%;
flex: 1;
overflow: hidden;
}
</style>
.category-box {
height: 100%;
flex: 1;
overflow: hidden;
}
</style>

@ -2,8 +2,7 @@
<view class="catgory-wrap">
<view class="u-flex wrapper-box">
<!-- 左侧分类列表 -->
<scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view"
:scroll-top="scrollLeftTop">
<scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view" :scroll-top="scrollLeftTop">
<view v-for="(item, index) in tabbarList" :key="index" class="u-tab-item u-ellipsis-1"
:class="[currentTab == index ? 'u-tab-item-active' : '']" :data-current="index"
@tap.stop="swichMenu(index)">
@ -103,7 +102,13 @@
</template>
<script>
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
import {
mapMutations,
mapActions,
mapState,
mapGetters
} from 'vuex';
import jsonrpc from '@/shopro/request/indexJson.js';
export default {
components: {},
data() {
@ -171,7 +176,12 @@
...mapActions(['getCartList', 'changeCartList', 'addCartGoods']),
//
toGoodDetail(id) {
this.$Router.push({ path: '/pages/goods/detail', query: { id: id } });
this.$Router.push({
path: '/pages/goods/detail',
query: {
id: id
}
});
},
//
@ -197,10 +207,10 @@
//
async getCategory() {
console.log("getCategory#@#@")
const tabbarData = await this.$jsonrpc('category.detail', {
const tabbarData = await jsonrpc('category.detail', {
id: this.categoryStyleId
});
/* const tabbarData = await this.$http('category.detail', {
id: this.categoryStyleId
}); */
@ -260,7 +270,9 @@
const query = uni.createSelectorQuery().in(this);
query
.select('.' + elClass)
.fields({ size: true }, res => {
.fields({
size: true
}, res => {
// resnull
if (!res) {
setTimeout(() => {
@ -313,7 +325,10 @@
confirmColor: '#f0c785',
content: `是否确认从购物车中删除此商品?`,
success: res => {
res.confirm && this.changeCartList({ ids: [cartGoodId], art: 'delete' });
res.confirm && this.changeCartList({
ids: [cartGoodId],
art: 'delete'
});
}
});
},
@ -407,8 +422,8 @@
flex: 1;
display: flex;
overflow: hidden;
// menu
// menu
.u-tab-view {
width: 200rpx;
height: 100%;
@ -605,4 +620,4 @@
}
}
}
</style>
</style>

@ -3,7 +3,8 @@
<view class="u-flex u-col-center wrapper-box">
<view class="scroll-box" style="background-color: #F6F6F6;">
<scroll-view class="left u-flex-col u-col-center" enable-back-to-top scroll-y>
<view class="type-list u-ellipsis-1" :class="[{ 'list-active': listId == index }]" v-for="(item, index) in categoryData" :key="index" @tap="onType(index)">
<view class="type-list u-ellipsis-1" :class="[{ 'list-active': listId == index }]"
v-for="(item, index) in categoryData" :key="index" @tap="onType(index)">
<view class="line" :class="[{ 'line-active': listId == index }]"></view>
{{ item.name }}
</view>
@ -13,18 +14,22 @@
<view style="height: 100%;width: 100%;">
<scroll-view scroll-y class="scroll-box" enable-back-to-top scroll-with-animation>
<view class="right" v-if="categoryData.length">
<image class="type-img" v-if="categoryData[listId].image" :src="categoryData[listId].image" mode="aspectFill"></image>
<image class="type-img" v-if="categoryData[listId].image" :src="categoryData[listId].image"
mode="aspectFill"></image>
<view class="item-list" v-for="(list, index1) in categoryData[listId].children" :key="index1">
<view class="type-box u-flex u-row-between u-col-center">
<text class="type-title">{{ list.name }}</text>
<view class="more u-flex u-col-center" @tap="jump('/pages/goods/list', { id: list.id })">
<view class="more u-flex u-col-center"
@tap="jump('/pages/goods/list', { id: list.id })">
<text>查看更多</text>
<view class="u-iconfont uicon-arrow-right" style="color: #999;font-size: 28rpx;"></view>
<view class="u-iconfont uicon-arrow-right" style="color: #999;font-size: 28rpx;">
</view>
</view>
</view>
<view class="item-box u-flex">
<view class="u-flex-col goods-item" @tap="jump('/pages/goods/list', { id: mlist.id })" v-for="(mlist, index2) in list.children" :key="index2">
<view class="u-flex-col goods-item" @tap="jump('/pages/goods/list', { id: mlist.id })"
v-for="(mlist, index2) in list.children" :key="index2">
<image class="item-img" lazy-load :src="mlist.image" mode="aspectFill"></image>
<view class="item-title u-ellipsis-1 ">{{ mlist.name }}</view>
</view>
@ -32,11 +37,9 @@
</view>
<!-- 缺省页 -->
<shopro-empty
v-show="!categoryData[listId].children.length"
<shopro-empty v-show="!categoryData[listId].children.length"
:image="$IMG_URL + '/imgs/empty/empty_goods.png'"
tipText="暂无该商品,还有更多好货等着你噢~"
></shopro-empty>
tipText="暂无该商品,还有更多好货等着你噢~"></shopro-empty>
<view class="hack-tabbar"></view>
</view>
</scroll-view>
@ -46,173 +49,179 @@
</template>
<script>
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
export default {
components: {},
data() {
return {
listId: 0,
categoryData: {}
};
},
computed: {},
props: {
categoryStyleId: {
type: Number,
default: 0
}
},
async created() {
console.log('%c当前分类三级分类', 'color:green;background:yellow');
await this.getCategory();
},
methods: {
getCategory() {
this.$jsonrpc('category.info', {
id: this.categoryStyleId
}).then(res => {
this.categoryData = res.result.children;
});
/* this.$http('category.detail', {
id: this.categoryStyleId
}).then(res => {
if (res.code === 1) {
this.categoryData = res.data.children;
}
}); */
import jsonrpc from "@/shopro/request/indexJson.js"
import {
mapMutations,
mapActions,
mapState,
mapGetters
} from 'vuex';
export default {
components: {},
data() {
return {
listId: 0,
categoryData: {}
};
},
onType(id) {
this.listId = id;
computed: {},
props: {
categoryStyleId: {
type: Number,
default: 0
}
},
async created() {
console.log('%c当前分类三级分类', 'color:green;background:yellow');
await this.getCategory();
},
//
jump(path, parmas) {
this.$Router.push({
path: path,
query: parmas
});
methods: {
getCategory() {
jsonrpc('category.info', {
id: this.categoryStyleId
}).then(res => {
this.categoryData = res.result.children;
});
/* this.$http('category.detail', {
id: this.categoryStyleId
}).then(res => {
if (res.code === 1) {
this.categoryData = res.data.children;
}
}); */
},
onType(id) {
this.listId = id;
},
//
jump(path, parmas) {
this.$Router.push({
path: path,
query: parmas
});
}
}
}
};
};
</script>
<style lang="scss">
.hack-tabbar {
height: calc(100rpx + env(safe-area-inset-bottom) / 2);
width: 100%;
}
.content_box {
margin-top: 1upx;
display: flex;
flex-direction: column;
overflow: hidden;
height: 100%;
}
.wrapper-box {
flex: 1;
margin-top: 1upx;
height: 100%;
}
.scroll-box {
height: 100%;
flex: 1;
background: #fff;
}
.left {
width: 200upx;
height: 100%;
flex: 1;
.list-active {
background: #fff;
color: #333333 !important;
font-weight: bold !important;
.hack-tabbar {
height: calc(100rpx + env(safe-area-inset-bottom) / 2);
width: 100%;
}
.line-active {
background: #e6b873;
.content_box {
margin-top: 1upx;
display: flex;
flex-direction: column;
overflow: hidden;
height: 100%;
}
.type-list {
height: 84upx;
position: relative;
width: 200rpx;
padding-left: 16rpx;
line-height: 84rpx;
font-size: 28upx;
font-weight: 400;
color: rgba(102, 102, 102, 1);
.line {
width: 10upx;
height: 100%;
position: absolute;
left: 0;
}
.wrapper-box {
flex: 1;
margin-top: 1upx;
height: 100%;
}
}
.right {
padding: 0 30upx;
flex: 1;
height: 100%;
.type-img {
width: 505rpx;
height: 150rpx;
background: #ccc;
border-radius: 10rpx;
margin-top: 30rpx;
.scroll-box {
height: 100%;
flex: 1;
background: #fff;
}
.item-list {
.type-box {
height: 84rpx;
.left {
width: 200upx;
height: 100%;
flex: 1;
.type-title {
font-size: 28rpx;
font-weight: bold;
}
.list-active {
background: #fff;
color: #333333 !important;
font-weight: bold !important;
}
.more {
font-size: 26rpx;
color: #999;
.line-active {
background: #e6b873;
}
.type-list {
height: 84upx;
position: relative;
width: 200rpx;
padding-left: 16rpx;
line-height: 84rpx;
font-size: 28upx;
font-weight: 400;
color: rgba(102, 102, 102, 1);
.line {
width: 10upx;
height: 100%;
position: absolute;
left: 0;
}
}
}
.item-box {
flex-wrap: wrap;
.right {
padding: 0 30upx;
flex: 1;
height: 100%;
.type-img {
width: 505rpx;
height: 150rpx;
background: #ccc;
border-radius: 10rpx;
margin-top: 30rpx;
}
.goods-item {
margin-right: 20rpx;
margin-bottom: 20rpx;
.item-list {
.type-box {
height: 84rpx;
&:nth-child(3n) {
margin-right: 0;
.type-title {
font-size: 28rpx;
font-weight: bold;
}
.item-img {
width: 150rpx;
height: 150rpx;
background: #f5f5f5;
border-radius: 6rpx;
.more {
font-size: 26rpx;
color: #999;
}
}
.item-title {
font-size: 24rpx;
line-height: 24rpx;
margin-top: 10rpx;
width: 150rpx;
text-align: center;
.item-box {
flex-wrap: wrap;
.goods-item {
margin-right: 20rpx;
margin-bottom: 20rpx;
&:nth-child(3n) {
margin-right: 0;
}
.item-img {
width: 150rpx;
height: 150rpx;
background: #f5f5f5;
border-radius: 6rpx;
}
.item-title {
font-size: 24rpx;
line-height: 24rpx;
margin-top: 10rpx;
width: 150rpx;
text-align: center;
}
}
}
}
}
}
</style>
</style>

@ -3,14 +3,10 @@
<view class="u-flex u-col-center wrapper-box">
<view class="scroll-box" style="background-color: #F6F6F6;">
<scroll-view class="left u-flex-col u-col-center" enable-back-to-top scroll-y>
<view
class="type-list u-flex u-col-center"
:class="[{ 'list-active': listId == index }]"
v-for="(item, index) in categoryData"
:key="index"
@tap="onType(index)"
>
<view class="u-ellipsis-1 list-item" :class="[{ 'line-active': listId == index }]">{{ item.name }}</view>
<view class="type-list u-flex u-col-center" :class="[{ 'list-active': listId == index }]"
v-for="(item, index) in categoryData" :key="index" @tap="onType(index)">
<view class="u-ellipsis-1 list-item" :class="[{ 'line-active': listId == index }]">
{{ item.name }}</view>
</view>
<view class="hack-tabbar"></view>
</scroll-view>
@ -18,7 +14,8 @@
<view style="height: 100%;width: 100%;">
<scroll-view scroll-y class="scroll-box" enable-back-to-top scroll-with-animation>
<view class="right" v-if="categoryData.length">
<image class="type-img" v-if="categoryData[listId].image" :src="categoryData[listId].image" lazy-load mode="aspectFill"></image>
<image class="type-img" v-if="categoryData[listId].image" :src="categoryData[listId].image"
lazy-load mode="aspectFill"></image>
<view class="type-box u-flex u-col-center u-row-center">
<view class="u-iconfont uicon-minus" style="color: #d3d3d3;font-size: 28rpx;"></view>
<text class="type-title">{{ categoryData[listId].name }}</text>
@ -26,24 +23,18 @@
</view>
<view class="item-list">
<view class="item-box u-flex">
<view
class="u-flex-col u-col-center goods-item"
<view class="u-flex-col u-col-center goods-item"
@tap="jump('/pages/goods/list', { id: list.id })"
v-for="(list, index1) in categoryData[listId].children"
:key="index1"
>
v-for="(list, index1) in categoryData[listId].children" :key="index1">
<image class="item-img" lazy-load :src="list.image" mode="aspectFill"></image>
<view class="item-title u-ellipsis-1 ">{{ list.name }}</view>
</view>
</view>
<!-- 缺省页 -->
<shopro-empty
v-show="!categoryData[listId].children.length"
:image="$IMG_URL + '/imgs/empty/empty_goods.png'"
marginTop="200rpx"
tipText="暂无该商品,还有更多好货等着你噢~"
></shopro-empty>
<shopro-empty v-show="!categoryData[listId].children.length"
:image="$IMG_URL + '/imgs/empty/empty_goods.png'" marginTop="200rpx"
tipText="暂无该商品,还有更多好货等着你噢~"></shopro-empty>
<view class="hack-tabbar"></view>
</view>
</view>
@ -54,168 +45,179 @@
</template>
<script>
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
export default {
components: {},
data() {
return {
listId: 0,
categoryData: {}
};
},
computed: {},
props: {
categoryStyleId: {
type: Number,
default: 0
}
},
created() {
console.log('%c当前分类二级分类', 'color:green;background:yellow');
this.getCategory();
},
methods: {
getCategory() {
console.log("getCategory333")
this.$jsonrpc('category.detail', {
id: this.categoryStyleId
}).then(res => {
this.categoryData = res.result.children;
});
/* this.$http('category.detail', {
id: this.categoryStyleId
}).then(res => {
if (res.code === 1) {
this.categoryData = res.data.children;
}
}); */
import {
mapMutations,
mapActions,
mapState,
mapGetters
} from 'vuex';
import jsonrpc from '@/shopro/request/indexJson.js';
export default {
components: {},
data() {
return {
listId: 0,
categoryData: {}
};
},
onType(id) {
this.listId = id;
computed: {},
props: {
categoryStyleId: {
type: Number,
default: 0
}
},
//
jump(path, parmas) {
this.$Router.push({
path: path,
query: parmas
});
created() {
console.log('%c当前分类二级分类', 'color:green;background:yellow');
this.getCategory();
},
methods: {
getCategory() {
jsonrpc('category.detail', {
id: this.categoryStyleId
}).then(res => {
this.categoryData = res.result.children;
});
/* this.$http('category.detail', {
id: this.categoryStyleId
}).then(res => {
if (res.code === 1) {
this.categoryData = res.data.children;
}
}); */
},
onType(id) {
this.listId = id;
},
//
jump(path, parmas) {
this.$Router.push({
path: path,
query: parmas
});
}
}
}
};
};
</script>
<style lang="scss">
.hack-tabbar {
height: calc(100rpx + env(safe-area-inset-bottom) / 2);
width: 100%;
}
.content_box {
display: flex;
flex-direction: column;
overflow: hidden;
height: 100%;
}
.wrapper-box {
flex: 1;
margin-top: 1upx;
height: 100%;
}
.scroll-box {
height: 100%;
flex: 1;
background: #fff;
}
.left {
width: 200upx;
height: 100%;
flex: 1;
.list-active {
background: #fff;
color: #ffff !important;
}
.list-item {
width: 180rpx;
height: 64rpx;
line-height: 64rpx;
padding-left: 14rpx;
.hack-tabbar {
height: calc(100rpx + env(safe-area-inset-bottom) / 2);
width: 100%;
}
.line-active {
width: 180rpx;
height: 64rpx;
background: #e6b873;
border-radius: 0rpx 32rpx 32rpx 0rpx;
color: #fff;
.content_box {
display: flex;
flex-direction: column;
overflow: hidden;
height: 100%;
}
.type-list {
height: 100rpx;
position: relative;
width: 200rpx;
font-size: 28upx;
font-weight: 400;
color: rgba(102, 102, 102, 1);
.wrapper-box {
flex: 1;
margin-top: 1upx;
height: 100%;
}
}
.right {
padding: 0 30upx;
flex: 1;
height: 100%;
.type-img {
width: 505rpx;
height: 150rpx;
background: #ccc;
margin-top: 30rpx;
border-radius: 10rpx;
.scroll-box {
height: 100%;
flex: 1;
background: #fff;
}
.type-box {
height: 84rpx;
.type-title {
font-size: 28rpx;
font-weight: bold;
padding: 0 16rpx;
.left {
width: 200upx;
height: 100%;
flex: 1;
.list-active {
background: #fff;
color: #ffff !important;
}
.list-item {
width: 180rpx;
height: 64rpx;
line-height: 64rpx;
padding-left: 14rpx;
}
.line-active {
width: 180rpx;
height: 64rpx;
background: #e6b873;
border-radius: 0rpx 32rpx 32rpx 0rpx;
color: #fff;
}
.more {
font-size: 26rpx;
color: #999;
.type-list {
height: 100rpx;
position: relative;
width: 200rpx;
font-size: 28upx;
font-weight: 400;
color: rgba(102, 102, 102, 1);
}
}
.item-list {
.item-box {
flex-wrap: wrap;
.right {
padding: 0 30upx;
flex: 1;
height: 100%;
.type-img {
width: 505rpx;
height: 150rpx;
background: #ccc;
margin-top: 30rpx;
border-radius: 10rpx;
}
.goods-item {
margin-right: 20rpx;
margin-bottom: 20rpx;
.type-box {
height: 84rpx;
&:nth-child(3n) {
margin-right: 0;
}
.type-title {
font-size: 28rpx;
font-weight: bold;
padding: 0 16rpx;
}
.item-img {
width: 150rpx;
height: 150rpx;
border-radius: 6rpx;
background: #f5f5f5;
}
.more {
font-size: 26rpx;
color: #999;
}
}
.item-title {
font-size: 24rpx;
margin-top: 10rpx;
width: 150rpx;
text-align: center;
.item-list {
.item-box {
flex-wrap: wrap;
.goods-item {
margin-right: 20rpx;
margin-bottom: 20rpx;
&:nth-child(3n) {
margin-right: 0;
}
.item-img {
width: 150rpx;
height: 150rpx;
border-radius: 6rpx;
background: #f5f5f5;
}
.item-title {
font-size: 24rpx;
margin-top: 10rpx;
width: 150rpx;
text-align: center;
}
}
}
}
}
}
</style>
</style>

@ -154,7 +154,7 @@ export default {
};
},
computed: {
...mapGetters(['initShop', 'homeTemplate', 'hasTemplate', 'isLogin']),
...mapGetters(['getCartListJson','initShop', 'homeTemplate', 'hasTemplate', 'isLogin']),
//
headSwiperList() {
if (this.homeTemplate?.length) {
@ -177,7 +177,8 @@ export default {
onShow() {
let that = this;
this.enable = true;
this.isLogin && this.getCartList();
// this.isLogin && this.getCartList();
this.isLogin && this.getCartListJson();
//
uni.onNetworkStatusChange(res => {
this.isConnected = res.isConnected;

@ -107,21 +107,23 @@ export default {
onShow() {
if (this.isLogin) {
this.init();
this.getUserData();
// this.getUserData();
}
this.enable = true;
},
methods: {
...mapActions(['getUserInfo', 'showAuthModal', 'getUserData']),
...mapActions(['getUserInfoJson','getUserInfo', 'showAuthModal', 'getUserData']),
onShare() {
this.showShare = true;
uni.hideTabBar();
},
//
init() {
this.getUserInfo()
this.getUserInfoJson()
// this.getUserInfo()
.then(res => {
uni.stopPullDownRefresh();
})
.catch(e => {

@ -81,6 +81,7 @@
*/
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
import wechat from '@/shopro/wechat/wechat';
import jsonrpc from '@/shopro/request/indexJson.js'
export default {
components: {},
data() {
@ -126,7 +127,7 @@ export default {
}
},
methods: {
...mapActions(['getUserInfo', 'showAuthModal']),
...mapActions(['getUserInfoJson','getUserInfo', 'showAuthModal']),
jump(path, query) {
this.$Router.push({
path: path,
@ -141,7 +142,8 @@ export default {
async refreshWechatUser() {
this.showModal = false;
let token = await wechat.refresh();
token && this.getUserInfo(token);
token && this.getUserInfoJson(token);
// token && this.getUserInfo(token);
},
//
goStore() {

File diff suppressed because it is too large Load Diff

@ -24,7 +24,7 @@
<!-- 订单信息 -->
<view class="order-list" v-for="order in orderDetail.item" :key="order.id">
<view class="order-card" @tap="jump('/pages/goods/detail', { id: order.goods_id })">
<shopro-mini-card :title="order.goods_title" :image="order.goods_image">
<shopro-mini-card :title="order.goods.title" :image="order.goods.image">
<template #describe>
<view class="order-sku u-ellipsis-1">
<text class="order-num">数量:{{ order.goods_num || 0 }};</text>
@ -33,7 +33,7 @@
</template>
<template #cardBottom>
<view class="card-price-box u-flex">
<text class="order-price font-OPPOSANS">{{ order.goods_price || 0 }}</text>
<text class="order-price font-OPPOSANS">{{ order.goods.total_sales || 0 }}</text>
<button class="u-reset-button status-btn" v-if="order.status_name">{{ order.status_name }}</button>
</view>
</template>
@ -180,6 +180,7 @@
</template>
<script>
import jsonrpc from "@/shopro/request/indexJson.js"
export default {
components: {},
data() {
@ -237,6 +238,17 @@ export default {
//
getOrderDetail() {
let that = this;
jsonrpc('order.detail', {
id: that.$Route.query.id
}).then(res => {
if (res.error.code === 200) {
that.orderDetail = res.result;
that.orderDetail.createtime = that.$u.timeFormat(res.result.createtime, 'yyyy-mm-dd hh:MM');
that.orderDetail.paytime = that.$u.timeFormat(res.result.paytime, 'yyyy-mm-dd hh:MM');
}
});
/*
that.$http('order.detail', {
id: that.$Route.query.id
}).then(res => {
@ -245,7 +257,7 @@ export default {
that.orderDetail.createtime = that.$u.timeFormat(res.data.createtime, 'yyyy-mm-dd hh:MM');
that.orderDetail.paytime = that.$u.timeFormat(res.data.paytime, 'yyyy-mm-dd hh:MM');
}
});
}); */
},
//
onCopy(code) {

@ -22,7 +22,7 @@
</view>
<view class="goods-order" v-for="goods in order.item" :key="goods.id">
<view class="order-content">
<shopro-mini-card :title="goods.goods_title" :image="goods.goods_image">
<shopro-mini-card :title="goods.goods.title" :image="goods.goods.image">
<template #describe>
<view class="order-sku u-ellipsis-1">
<text class="order-num">数量:{{ goods.goods_num || 0 }};</text>
@ -31,7 +31,7 @@
</template>
<template #cardBottom>
<view class="order-price-box u-flex ">
<text class="order-price font-OPPOSANS">{{ goods.goods_price || 0 }}</text>
<text class="order-price font-OPPOSANS">{{ goods.goods.total_sales || 0 }}</text>
<button class="u-reset-button status-btn"
v-if="goods.status_name">{{ goods.status_name }}</button>
</view>
@ -82,6 +82,7 @@
</template>
<script>
import jsonrpc from "@/shopro/request/indexJson.js"
export default {
components: {},
data() {
@ -152,7 +153,18 @@
getOrderList() {
let that = this;
that.loadStatus = 'loading';
that.$http('order.index', {
jsonrpc('order.index', {
type: that.orderType,
page: that.currentPage
}, '加载中...').then(res => {
if (res.error.code === 200) {
that.orderList = [...that.orderList, ...res.result.result_order];
that.isEmpty = !that.orderList.length;
that.lastPage = res.result.last_page;
that.loadStatus = that.currentPage < res.result.last_page ? 'loadmore' : 'nomore';
}
});
/* that.$http('order.index', {
type: that.orderType,
page: that.currentPage
}, '加载中...').then(res => {
@ -162,7 +174,7 @@
that.lastPage = res.data.last_page;
that.loadStatus = that.currentPage < res.data.last_page ? 'loadmore' : 'nomore';
}
});
}); */
},
//

@ -55,6 +55,7 @@
/**
* 接收商品订单orderType:goods充值订单orderType:recharge
*/
import jsonrpc from "@/shopro/request/indexJson.js"
import Pay from '@/shopro/pay';
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
let timer;
@ -165,6 +166,21 @@
//
getGoodsOrderDetail() {
let that = this;
jsonrpc('order.detail', {
id: that.$Route.query.orderId
}).then(res => {
if (res.error.code === 200) {
that.orderDetail = res.result;
if (res.data.ext_arr !== null) {
that.countDown();
} else {
that.isCountDown = false;
}
}
});
/*
that.$http('order.detail', {
id: that.$Route.query.orderId
}).then(res => {
@ -176,7 +192,7 @@
that.isCountDown = false;
}
}
});
}); */
},
//

@ -77,6 +77,7 @@ export default {
method: "POST",
// desc: '发送短信',
},
},
/** 分类 ↓ **/
@ -257,14 +258,24 @@ export default {
/** 用户 ↓ **/
user: {
smsJson: {
url: "user/getLoginOrRegSMSVerificationCode",
auth: false,
method: "POST",
// desc: '账号密码登录',
},
accountLogin: {
url: "user/accountLogin",
auth: false,
method: "POST",
// desc: '账号密码登录',
},
smsLoginJson: {
url: "user/loginOrRegByMobile",
auth: false,
method: "POST",
// desc: '短信登录',
},
smsLogin: {
url: "user/smsLogin",
auth: false,
@ -299,7 +310,12 @@ export default {
method: "POST",
// desc: '修改密码',
},
infoJson: {
url: "user/myinfo",
auth: true,
method: "GET",
// desc: '用户信息'
},
info: {
url: "user",
auth: true,
@ -486,6 +502,12 @@ export default {
/** 购物车 ↓ **/
cart: {
mycart: {
url: "cart/mycart",
auth: true,
method: "POST",
// desc: '购物车商品列表',
},
index: {
url: "cart",
auth: true,
@ -498,7 +520,6 @@ export default {
method: "POST",
// desc: '添加购物车',
},
edit: {
url: "cart/edit",
auth: true,
@ -670,7 +691,7 @@ export default {
// desc: '充值'
},
rechargeLog: {
url: "trade_order/index",
url: "trade_order/index",
auth: true,
method: "GET",
// desc: '充值记录'
@ -788,4 +809,4 @@ export default {
}
};
};

@ -1,82 +1,79 @@
import Request from './request'
import apiList from './apis.js'
import store from '@/shopro/store/index.js'
const shoproRequest = new Request();
export default {
install(Vue) {
Vue.prototype.$jsonrpc = function (
url,
data = {},
toastBefore = '', // 请求前加载提示
toastAfter = true, // 请求后错误提示
) {
if (typeof url !== "string") {
return;
}
let api = getApiPath(url);
/* 请求之前拦截器 */
shoproRequest.interceptor.request((config, cancel) => {
let token = uni.getStorageSync('token');
if (api.auth && !token) {
store.dispatch('showAuthModal',"smsLogin");
uni.hideLoading();
throw (`暂未登录,已阻止此次API请求: '${api.url}'`);
}
token && shoproRequest.setConfig(config => {
config.header.token = token;
});
if (toastBefore !== '') {
uni.showLoading({
title: toastBefore,
mask: true
});
}
return config;
});
export default function jsonrpc(
url,
data = {},
toastBefore = '', // 请求前加载提示
toastAfter = true, // 请求后错误提示
) {
if (typeof url !== "string") {
return;
}
let api = getApiPath(url);
/* 请求之前拦截器 */
shoproRequest.interceptor.request((config, cancel) => {
let token = uni.getStorageSync('token');
if (api.auth && !token) {
console.log(token)
store.dispatch('showAuthModal', "smsLogin");
uni.hideLoading();
throw (`暂未登录,已阻止此次API请求: '${api.url}'`);
}
token && shoproRequest.setConfig(config => {
config.header.token = token;
});
if (toastBefore !== '') {
uni.showLoading({
title: toastBefore,
mask: true
});
}
return config;
});
/* 请求之后拦截器 */
shoproRequest.interceptor.response((response) => {
uni.hideLoading();
if (response.code === 0) {
if (toastAfter) {
uni.showToast({
title: response.msg || '请求出错,稍后重试',
icon: 'none',
duration: 1000,
mask: true
});
}
}
/* 请求之后拦截器 */
shoproRequest.interceptor.response((response) => {
uni.hideLoading();
if (response.code === 0) {
if (toastAfter) {
uni.showToast({
title: response.msg || '请求出错,稍后重试',
icon: 'none',
duration: 1000,
mask: true
});
}
}
// token过期注销
if (response.code === 401) {
store.dispatch('logout');
store.dispatch('showAuthModal');
throw (`登录已过期或注销,已阻止此次API请求: '${api.url}'`);
}
return response;
});
// token过期注销
if (response.code === 401) {
store.dispatch('logout');
store.dispatch('showAuthModal');
throw (`登录已过期或注销,已阻止此次API请求: '${api.url}'`);
}
return response;
});
return shoproRequest.requestJson({
url: api.url,
data,
method: api.method
});
}
}
};
return shoproRequest.requestJson({
url: api.url,
data,
method: api.method
});
}
;
// 组装接口路径
function getApiPath(url) {
let apiArray = url.split(".");
let api = apiList;
apiArray.forEach(v => {
api = api[v];
});
return api;
}
let apiArray = url.split(".");
let api = apiList;
apiArray.forEach(v => {
api = api[v];
});
return api;
}

@ -139,7 +139,9 @@ async requestJson(options = {}) {
return new Promise((resolve, reject) => {
let createJsonRpc ={
method: '/'+options.url
jsonrpc:"2.0",
method: '/'+options.url,
session:localStorage.getItem('token')
}
createJsonRpc.params ={
...options.data

@ -1,6 +1,6 @@
// 购物车模块
import http from '@/shopro/request/index'
import jsonrpc from '@/shopro/request/indexJson.js'
const state = {
cartList: [], //购物车列表
checkCart: {}, //检测是否是购物车数据的对象
@ -114,10 +114,32 @@ const mutations = {
}
const actions = {
getCartListJson({
commit
}) {
return new Promise((resolve, reject) => {
jsonrpc('cart.mycart').then(res => {
console.log(res)
if (res.error.code === 200) {
let cartData = res.result;
cartData.length && cartData.map(item => {
item.checked = true;
})
commit('CART_LIST', cartData);
commit('checkCartList');
commit('getCheckCart')
}
}).catch(e => {
reject(e)
})
})
},
// 购物车数据(查)
getCartList({
commit
}) {
return new Promise((resolve, reject) => {
http('cart.index').then(res => {
if (res.code === 1) {
@ -135,6 +157,22 @@ const actions = {
})
})
},
addCartGoodsJson({
dispatch
}, data) {
return new Promise((resolve, reject) => {
jsonrpc('cart.add', {
goods_list: data.list,
from: data.from
}).then(res => {
// console.log(res)
res.error.code === 200 && dispatch('getCartList');
resolve(res)
}).catch(e => {
reject(e)
})
})
},
// 添加到购物车(增)
addCartGoods({
dispatch
@ -151,6 +189,26 @@ const actions = {
})
})
},
changeCartListJson({
commit,
dispatch
}, param) {
return new Promise((resolve, reject) => {
jsonrpc('cart.edit', {
cart_list: param.ids,
value: param.goodsNum || null,
act: param.art
}).then(res => {
if (param.art === 'delete' && res.error.code === 200) {
dispatch('getCartListJson');
}
commit('checkCartList');
resolve(res)
}).catch(e => {
reject(e)
})
})
},
// 修改购物车商品数量(改)|| 删除购物车商品(删)
changeCartList({
commit,
@ -179,4 +237,4 @@ export default {
mutations,
actions,
getters
}
}

@ -1,5 +1,6 @@
// 用户数据模块
import http from '@/shopro/request/index'
import jsonrpc from '@/shopro/request/indexJson.js'
import store from '@/shopro/store'
import tools from '@/shopro/utils/tools'
import wechat from '@/shopro/wechat/wechat'
@ -26,6 +27,46 @@ const getters = {
}
const actions = {
getUserInfoJson({
commit,
dispatch,
getters,
state
}, token = '') {
return new Promise((resolve, reject) => {
token && uni.setStorageSync('token', token);
console.log("get user info json")
jsonrpc('user.infoJson').then(res => {
console.log(res)
if (res.error.code === 200) {
let lastLoginStatus = getters.isLogin;
commit('userInfo', res.result);
commit('isLogin', true);
dispatch('showAuthModal', '');
!lastLoginStatus && share.setShareInfo();
// 存在分享信息 添加分享记录
let spm = uni.getStorageSync('spm');
if (spm) {
http('common.shareAdd', {
spm: spm
});
uni.removeStorageSync('spm');
}
resolve(res.result)
}
}).then(
/* () => {
// 只有在登录的时候请求购物车信息,订单信息,获取登录信息之后。
token && dispatch('getCartList');
token && dispatch('getUserData');
} */
)
.catch(e => {
reject(e)
})
})
},
// 获取用户信息
getUserInfo({
commit,
@ -33,31 +74,33 @@ const actions = {
getters,
state
}, token = '') {
return new Promise((resolve, reject) => {
token && uni.setStorageSync('token', token);
http('user.info').then(res => {
if (res.code === 1) {
let lastLoginStatus = getters.isLogin;
commit('userInfo', res.data);
commit('isLogin', true);
dispatch('showAuthModal', '');
!lastLoginStatus && share.setShareInfo();
// 存在分享信息 添加分享记录
let spm = uni.getStorageSync('spm');
if (spm) {
http('common.shareAdd', {
spm: spm
});
uni.removeStorageSync('spm');
if (res.code === 1) {
let lastLoginStatus = getters.isLogin;
commit('userInfo', res.data);
commit('isLogin', true);
dispatch('showAuthModal', '');
!lastLoginStatus && share.setShareInfo();
// 存在分享信息 添加分享记录
let spm = uni.getStorageSync('spm');
if (spm) {
http('common.shareAdd', {
spm: spm
});
uni.removeStorageSync('spm');
}
resolve(res.data)
}
resolve(res.data)
}
}).then(() => {
// 只有在登录的时候请求购物车信息,订单信息,获取登录信息之后。
token && dispatch('getCartList');
token && dispatch('getUserData');
})
}).then(() => {
// 只有在登录的时候请求购物车信息,订单信息,获取登录信息之后。
token && dispatch('getCartList');
token && dispatch('getUserData');
})
.catch(e => {
reject(e)
})
@ -163,8 +206,8 @@ const actions = {
const mutations = {
setAuthType(state, authType) {
state.authType = authType;
},
state.authType = authType;
},
token(state, payload) {
state.token = payload;
uni.setStorageSync("token", payload);
@ -225,9 +268,9 @@ const mutations = {
Object.keys(typeMap).forEach(key => {
idsMap[key] = []
typeMap[key].forEach(item => {
if (messageIdsObj[item]) {
idsMap[key].push(messageIdsObj[item])
}
if (messageIdsObj[item]) {
idsMap[key].push(messageIdsObj[item])
}
})
})
state.subscribeMessageIdsMap = idsMap
@ -241,4 +284,4 @@ export default {
mutations,
actions,
getters
}
}
Loading…
Cancel
Save