main
RIceWqy 2 years ago
parent c0a2dc6eab
commit e4f86ae640

File diff suppressed because it is too large Load Diff

@ -50,7 +50,11 @@
</slot> </slot>
</view> </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> </view>
</template> </template>
@ -68,7 +72,12 @@
* @property {Array} tagTextList - 活动标签 * @property {Array} tagTextList - 活动标签
* @event {Function} click 商品被点击 * @event {Function} click 商品被点击
*/ */
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex'; import {
mapMutations,
mapActions,
mapState,
mapGetters
} from 'vuex';
export default { export default {
components: {}, components: {},
data() { data() {
@ -184,7 +193,10 @@
confirmColor: '#f0c785', confirmColor: '#f0c785',
content: `是否确认从购物车中删除此商品?`, content: `是否确认从购物车中删除此商品?`,
success: res => { 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) { async selSku(info) {
console.log("selSku")
if (this.detail.activity_type) { 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; return;
} }
this.goodsInfo = {}; this.goodsInfo = {};
@ -229,14 +247,21 @@
// //
addCart(sku) { addCart(sku) {
console.log("cart ")
if (sku.stock <= 0) { if (sku.stock <= 0) {
this.$u.toast('库存不足'); this.$u.toast('库存不足');
return; return;
} }
if (this.detail.activity_type) { 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; return;
} }
let confirmGoodsList = { let confirmGoodsList = {
list: [{ list: [{
goods_id: sku.goods_id, goods_id: sku.goods_id,
@ -244,7 +269,7 @@
sku_price_id: sku.id, sku_price_id: sku.id,
goods_price: sku.price goods_price: sku.price
}], }],
from: 'goods' // from: 'goods'
}; };
this.addCartGoods(confirmGoodsList).then(res => { this.addCartGoods(confirmGoodsList).then(res => {
if (res.code === 1) { if (res.code === 1) {

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

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

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

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

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

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

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

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

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

@ -81,6 +81,7 @@
*/ */
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex'; import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
import wechat from '@/shopro/wechat/wechat'; import wechat from '@/shopro/wechat/wechat';
import jsonrpc from '@/shopro/request/indexJson.js'
export default { export default {
components: {}, components: {},
data() { data() {
@ -126,7 +127,7 @@ export default {
} }
}, },
methods: { methods: {
...mapActions(['getUserInfo', 'showAuthModal']), ...mapActions(['getUserInfoJson','getUserInfo', 'showAuthModal']),
jump(path, query) { jump(path, query) {
this.$Router.push({ this.$Router.push({
path: path, path: path,
@ -141,7 +142,8 @@ export default {
async refreshWechatUser() { async refreshWechatUser() {
this.showModal = false; this.showModal = false;
let token = await wechat.refresh(); let token = await wechat.refresh();
token && this.getUserInfo(token); token && this.getUserInfoJson(token);
// token && this.getUserInfo(token);
}, },
// //
goStore() { 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-list" v-for="order in orderDetail.item" :key="order.id">
<view class="order-card" @tap="jump('/pages/goods/detail', { id: order.goods_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> <template #describe>
<view class="order-sku u-ellipsis-1"> <view class="order-sku u-ellipsis-1">
<text class="order-num">数量:{{ order.goods_num || 0 }};</text> <text class="order-num">数量:{{ order.goods_num || 0 }};</text>
@ -33,7 +33,7 @@
</template> </template>
<template #cardBottom> <template #cardBottom>
<view class="card-price-box u-flex"> <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> <button class="u-reset-button status-btn" v-if="order.status_name">{{ order.status_name }}</button>
</view> </view>
</template> </template>
@ -180,6 +180,7 @@
</template> </template>
<script> <script>
import jsonrpc from "@/shopro/request/indexJson.js"
export default { export default {
components: {}, components: {},
data() { data() {
@ -237,6 +238,17 @@ export default {
// //
getOrderDetail() { getOrderDetail() {
let that = this; 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', { that.$http('order.detail', {
id: that.$Route.query.id id: that.$Route.query.id
}).then(res => { }).then(res => {
@ -245,7 +257,7 @@ export default {
that.orderDetail.createtime = that.$u.timeFormat(res.data.createtime, 'yyyy-mm-dd hh:MM'); 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'); that.orderDetail.paytime = that.$u.timeFormat(res.data.paytime, 'yyyy-mm-dd hh:MM');
} }
}); }); */
}, },
// //
onCopy(code) { onCopy(code) {

@ -22,7 +22,7 @@
</view> </view>
<view class="goods-order" v-for="goods in order.item" :key="goods.id"> <view class="goods-order" v-for="goods in order.item" :key="goods.id">
<view class="order-content"> <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> <template #describe>
<view class="order-sku u-ellipsis-1"> <view class="order-sku u-ellipsis-1">
<text class="order-num">数量:{{ goods.goods_num || 0 }};</text> <text class="order-num">数量:{{ goods.goods_num || 0 }};</text>
@ -31,7 +31,7 @@
</template> </template>
<template #cardBottom> <template #cardBottom>
<view class="order-price-box u-flex "> <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" <button class="u-reset-button status-btn"
v-if="goods.status_name">{{ goods.status_name }}</button> v-if="goods.status_name">{{ goods.status_name }}</button>
</view> </view>
@ -82,6 +82,7 @@
</template> </template>
<script> <script>
import jsonrpc from "@/shopro/request/indexJson.js"
export default { export default {
components: {}, components: {},
data() { data() {
@ -152,7 +153,18 @@
getOrderList() { getOrderList() {
let that = this; let that = this;
that.loadStatus = 'loading'; 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, type: that.orderType,
page: that.currentPage page: that.currentPage
}, '加载中...').then(res => { }, '加载中...').then(res => {
@ -162,7 +174,7 @@
that.lastPage = res.data.last_page; that.lastPage = res.data.last_page;
that.loadStatus = that.currentPage < res.data.last_page ? 'loadmore' : 'nomore'; that.loadStatus = that.currentPage < res.data.last_page ? 'loadmore' : 'nomore';
} }
}); }); */
}, },
// //

@ -55,6 +55,7 @@
/** /**
* 接收商品订单orderType:goods充值订单orderType:recharge * 接收商品订单orderType:goods充值订单orderType:recharge
*/ */
import jsonrpc from "@/shopro/request/indexJson.js"
import Pay from '@/shopro/pay'; import Pay from '@/shopro/pay';
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex'; import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
let timer; let timer;
@ -165,6 +166,21 @@
// //
getGoodsOrderDetail() { getGoodsOrderDetail() {
let that = this; 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', { that.$http('order.detail', {
id: that.$Route.query.orderId id: that.$Route.query.orderId
}).then(res => { }).then(res => {
@ -176,7 +192,7 @@
that.isCountDown = false; that.isCountDown = false;
} }
} }
}); }); */
}, },
// //

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

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

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

@ -1,6 +1,6 @@
// 购物车模块 // 购物车模块
import http from '@/shopro/request/index' import http from '@/shopro/request/index'
import jsonrpc from '@/shopro/request/indexJson.js'
const state = { const state = {
cartList: [], //购物车列表 cartList: [], //购物车列表
checkCart: {}, //检测是否是购物车数据的对象 checkCart: {}, //检测是否是购物车数据的对象
@ -114,10 +114,32 @@ const mutations = {
} }
const actions = { 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({ getCartList({
commit commit
}) { }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
http('cart.index').then(res => { http('cart.index').then(res => {
if (res.code === 1) { 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({ addCartGoods({
dispatch 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({ changeCartList({
commit, commit,

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

Loading…
Cancel
Save