main
RIceWqy 2 years ago
parent c0a2dc6eab
commit e4f86ae640

@ -52,7 +52,8 @@
<view v-if="authType === 'smsLogin'"> <view v-if="authType === 'smsLogin'">
<view class="head-box u-m-b-60"> <view class="head-box u-m-b-60">
<view class="u-flex u-m-b-20"> <view class="u-flex u-m-b-20">
<view class="head-title-active u-m-r-40" @tap="showAuthModal('accountLogin')" style="display: none;"> <view class="head-title-active u-m-r-40" @tap="showAuthModal('accountLogin')"
style="display: none;">
账号登录 账号登录
</view> </view>
<view class="head-title head-title-line head-title-animation"> <view class="head-title head-title-line head-title-animation">
@ -345,9 +346,17 @@
import FormValidate from "@/shopro/validate/form"; import FormValidate from "@/shopro/validate/form";
import schema from "@/uview-ui/libs/util/async-validator"; import schema from "@/uview-ui/libs/util/async-validator";
import wechat from "@/shopro/wechat/wechat"; import wechat from "@/shopro/wechat/wechat";
import { mapMutations, mapActions, mapState, mapGetters } from "vuex"; import jsonrpc from "@/shopro/request/indexJson.js";
import {
mapMutations,
mapActions,
mapState,
mapGetters
} from "vuex";
// #ifdef APP-PLUS // #ifdef APP-PLUS
import apple from "@/shopro/apple"; import apple from "@/shopro/apple";
// #endif // #endif
export default { export default {
@ -376,8 +385,8 @@ export default {
// 2. // 2.
smsLogin: { smsLogin: {
data: { data: {
mobile: "", // mobile: "1336943778", //
code: "", // code: "666666", //
isMobileEnd: false // isMobileEnd: false //
}, },
rules: { rules: {
@ -392,8 +401,8 @@ export default {
// 3. // 3.
register: { register: {
data: { data: {
mobile: "", // mobile: "1336943778", //
code: "", // code: "666666", //
password: "", // password: "", //
isMobileEnd: false // isMobileEnd: false //
}, },
@ -454,8 +463,7 @@ export default {
rules: { rules: {
oldPassword: FormValidate.password, oldPassword: FormValidate.password,
newPassword: FormValidate.password, newPassword: FormValidate.password,
reNewPassword: [ reNewPassword: [{
{
required: true, required: true,
message: "请重新输入密码", message: "请重新输入密码",
trigger: ["change", "blur"] trigger: ["change", "blur"]
@ -509,7 +517,47 @@ export default {
}, },
methods: { methods: {
...mapActions(["getUserInfo", "showAuthModal"]), ...mapActions(["getUserInfoJson", "getUserInfo", "showAuthModal"]),
//
getSmsCode(type) {
const that = this;
if (that.form[this.authType].data.isMobileEnd && !that.disabledCode) {
jsonrpc("user.smsJson", {
mobile: that.form[this.authType].data.mobile,
event: type
},
"获取验证码中..."
).then(res => {
console.log(res)
if (res.error.code === 200) {
that.codeChange();
that.$u.toast("验证码已发送,请注意查收短信");
} else {
that.$u.toast(res.msg);
}
});
} else {
that.$u.toast("请稍后再试");
}
/* if (that.form[this.authType].data.isMobileEnd && !that.disabledCode) {
that.$http(
"common.smsSend", {
mobile: that.form[this.authType].data.mobile,
event: type
},
"获取验证码中..."
).then(res => {
if (res.code === 1) {
that.codeChange();
that.$u.toast("验证码已发送,请注意查收短信");
} else {
that.$u.toast(res.msg);
}
});
} else {
that.$u.toast("请稍后再试");
} */
},
// //
checkValue(e, key) { checkValue(e, key) {
@ -536,11 +584,9 @@ export default {
[key]: rules [key]: rules
}); });
// //
validator.validate( validator.validate({
{
[key]: fieldValue [key]: fieldValue
}, }, {
{
firstFields: true firstFields: true
}, },
(errors, fields) => { (errors, fields) => {
@ -593,29 +639,6 @@ export default {
this.$store.dispatch("showAuthModal", ""); this.$store.dispatch("showAuthModal", "");
}, },
//
getSmsCode(type) {
const that = this;
if (that.form[this.authType].data.isMobileEnd && !that.disabledCode) {
that.$http(
"common.smsSend",
{
mobile: that.form[this.authType].data.mobile,
event: type
},
"获取验证码中..."
).then(res => {
if (res.code === 1) {
that.codeChange();
that.$u.toast("验证码已发送,请注意查收短信");
} else {
that.$u.toast(res.msg);
}
});
} else {
that.$u.toast("请稍后再试");
}
},
// //
codeChange() { codeChange() {
@ -681,8 +704,7 @@ export default {
(await that.validateSubmit()) && (await that.validateSubmit()) &&
that that
.$http( .$http(
"user.accountLogin", "user.accountLogin", {
{
account: that.form["accountLogin"].data.account, account: that.form["accountLogin"].data.account,
password: that.form["accountLogin"].data.password password: that.form["accountLogin"].data.password
}, },
@ -700,23 +722,37 @@ export default {
// 2. // 2.
async smsLoginSubmit() { async smsLoginSubmit() {
let that = this; let that = this;
(await that.validateSubmit()) && (await that.validateSubmit()) &&
that jsonrpc("user.smsLoginJson", {
.$http( mobile: that.form["smsLogin"].data.mobile,
"user.smsLogin", verification_code: that.form["smsLogin"].data.code
{ },
"登录中..."
).then(res => {
console.log(res)
if (res.error.code === 200) {
// that.getUserInfo(res.result.token);
that.getUserInfoJson(res.result.token);
that.closeAuthModal();
that.$u.toast(res.error.message);
} else {
that.$u.toast(res.error.message);
}
});
/* (await that.validateSubmit()) &&
that.$http("user.smsLogin", {
mobile: that.form["smsLogin"].data.mobile, mobile: that.form["smsLogin"].data.mobile,
code: that.form["smsLogin"].data.code code: that.form["smsLogin"].data.code
}, },
"登录中..." "登录中..."
) ).then(res => {
.then(res => {
if (res.code === 1) { if (res.code === 1) {
that.closeAuthModal(); that.closeAuthModal();
that.getUserInfo(res.data.token); that.getUserInfo(res.data.token);
that.$u.toast(res.msg); that.$u.toast(res.msg);
} }
}); }); */
}, },
// 3. // 3.
@ -725,8 +761,7 @@ export default {
(await that.validateSubmit()) && (await that.validateSubmit()) &&
that that
.$http( .$http(
"user.register", "user.register", {
{
mobile: that.form["register"].data.mobile, mobile: that.form["register"].data.mobile,
code: that.form["register"].data.code, code: that.form["register"].data.code,
password: that.form["register"].data.password password: that.form["register"].data.password
@ -748,8 +783,7 @@ export default {
(await that.validateSubmit()) && (await that.validateSubmit()) &&
that that
.$http( .$http(
"user.forgotPwd", "user.forgotPwd", {
{
mobile: that.form["forgotPwd"].data.mobile, mobile: that.form["forgotPwd"].data.mobile,
code: that.form["forgotPwd"].data.code, code: that.form["forgotPwd"].data.code,
password: that.form["forgotPwd"].data.password password: that.form["forgotPwd"].data.password
@ -774,8 +808,7 @@ export default {
(await that.validateSubmit()) && (await that.validateSubmit()) &&
that that
.$http( .$http(
"user.bindMobile", "user.bindMobile", {
{
mobile: that.form["bindMobile"].data.mobile, mobile: that.form["bindMobile"].data.mobile,
code: that.form["bindMobile"].data.code, code: that.form["bindMobile"].data.code,
password: that.form["bindMobile"].data.password password: that.form["bindMobile"].data.password
@ -797,8 +830,7 @@ export default {
(await that.validateSubmit()) && (await that.validateSubmit()) &&
that that
.$http( .$http(
"user.changePwd", "user.changePwd", {
{
oldpassword: that.form["changePwd"].data.oldPassword, oldpassword: that.form["changePwd"].data.oldPassword,
newpassword: that.form["changePwd"].data.newPassword newpassword: that.form["changePwd"].data.newPassword
}, },

@ -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':

@ -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'
});
} }
} }
}; };

@ -20,8 +20,13 @@ 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,
mapActions,
mapState,
mapGetters
} from 'vuex';
import jsonrpc from "@/shopro/request/indexJson.js"
export default { export default {
components: { components: {
takeoutCatgory, takeoutCatgory,
@ -48,7 +53,9 @@ export default {
*/ */
getCategory() { 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);

@ -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'
});
} }
}); });
}, },

@ -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,7 +49,13 @@
</template> </template>
<script> <script>
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex'; import jsonrpc from "@/shopro/request/indexJson.js"
import {
mapMutations,
mapActions,
mapState,
mapGetters
} from 'vuex';
export default { export default {
components: {}, components: {},
data() { data() {
@ -69,11 +78,10 @@ export default {
methods: { methods: {
getCategory() { getCategory() {
this.$jsonrpc('category.info', { jsonrpc('category.info', {
id: this.categoryStyleId id: this.categoryStyleId
}).then(res => { }).then(res => {
this.categoryData = res.result.children; this.categoryData = res.result.children;
}); });
@ -104,6 +112,7 @@ export default {
height: calc(100rpx + env(safe-area-inset-bottom) / 2); height: calc(100rpx + env(safe-area-inset-bottom) / 2);
width: 100%; width: 100%;
} }
.content_box { .content_box {
margin-top: 1upx; margin-top: 1upx;
display: flex; display: flex;

@ -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,7 +45,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() {
@ -76,8 +73,8 @@ export default {
}, },
methods: { methods: {
getCategory() { getCategory() {
console.log("getCategory333")
this.$jsonrpc('category.detail', { jsonrpc('category.detail', {
id: this.categoryStyleId id: this.categoryStyleId
}).then(res => { }).then(res => {
@ -111,6 +108,7 @@ export default {
height: calc(100rpx + env(safe-area-inset-bottom) / 2); height: calc(100rpx + env(safe-area-inset-bottom) / 2);
width: 100%; width: 100%;
} }
.content_box { .content_box {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -139,12 +137,14 @@ export default {
background: #fff; background: #fff;
color: #ffff !important; color: #ffff !important;
} }
.list-item { .list-item {
width: 180rpx; width: 180rpx;
height: 64rpx; height: 64rpx;
line-height: 64rpx; line-height: 64rpx;
padding-left: 14rpx; padding-left: 14rpx;
} }
.line-active { .line-active {
width: 180rpx; width: 180rpx;
height: 64rpx; height: 64rpx;
@ -175,6 +175,7 @@ export default {
margin-top: 30rpx; margin-top: 30rpx;
border-radius: 10rpx; border-radius: 10rpx;
} }
.type-box { .type-box {
height: 84rpx; height: 84rpx;
@ -183,6 +184,7 @@ export default {
font-weight: bold; font-weight: bold;
padding: 0 16rpx; padding: 0 16rpx;
} }
.more { .more {
font-size: 26rpx; font-size: 26rpx;
color: #999; color: #999;

@ -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,14 +1,10 @@
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) {
Vue.prototype.$jsonrpc = function (
url, url,
data = {}, data = {},
toastBefore = '', // 请求前加载提示 toastBefore = '', // 请求前加载提示
@ -23,6 +19,7 @@ export default {
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) {
console.log(token)
store.dispatch('showAuthModal', "smsLogin"); store.dispatch('showAuthModal', "smsLogin");
uni.hideLoading(); uni.hideLoading();
throw (`暂未登录,已阻止此次API请求: '${api.url}'`); throw (`暂未登录,已阻止此次API请求: '${api.url}'`);
@ -68,8 +65,8 @@ export default {
method: api.method method: api.method
}); });
} }
}
}; ;
// 组装接口路径 // 组装接口路径
function getApiPath(url) { function getApiPath(url) {

@ -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,8 +74,10 @@ 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;

Loading…
Cancel
Save