Commit dcb6db3a by zhangcheng

调整购物车调试订单

parent 465520c3
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<view class="shop-car"> <view class="shop-car">
<view class="header"> <view class="header">
<text class="left">购物袋</text> <text class="left">购物袋</text>
<text class="right" @click="clearCar">清空购物车</text> <text class="right" @click="clearCar"><text class="delete-icon"></text>清空购物车</text>
</view> </view>
<view class="container"> <view class="container">
<view> <view>
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
<text style="color:#000000;font-weight: bold;font-size: 28rpx;display: flex; margin-left: 30rpx; align-items: center;">{{totalPrice.toFixed(2)}}</text> <text style="color:#000000;font-weight: bold;font-size: 28rpx;display: flex; margin-left: 30rpx; align-items: center;">{{totalPrice.toFixed(2)}}</text>
</view> </view>
</view> </view>
<view class="end-right"> <view class="end-right" @click="saveReserve">
付款 付款
<!-- ({{totalNum}}) --> <!-- ({{totalNum}}) -->
</view> </view>
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
<script> <script>
import { $EventBus } from "../../utils/EventBus"; import { $EventBus } from "../../utils/EventBus";
import Menu from '@/request/menu';
export default{ export default{
data(){ data(){
return{ return{
...@@ -81,7 +82,6 @@ ...@@ -81,7 +82,6 @@
}, },
created() { created() {
$EventBus.$off('updateCar'); $EventBus.$off('updateCar');
// this.getallNum();
}, },
mounted() { mounted() {
this.goods = uni.getStorageSync('shopCarInfo')||[]; this.goods = uni.getStorageSync('shopCarInfo')||[];
...@@ -90,47 +90,6 @@ ...@@ -90,47 +90,6 @@
}); });
}, },
methods:{ methods:{
// // 获取总数
// getallNum(arrA) {
// let shopCarInfo = uni.getStorageSync('shopCarInfo');
// let shopCarInfoAdd=[]
// if(shopCarInfo){
// let ids = shopCarInfo.map(v=>v.goodId);
// console.log(ids,444)
// shopCarInfo.forEach((item)=>{
// arrA.forEach((preItem,index)=>{
// console.log(ids.includes(preItem.goodId),1234567)
// let ind=ids.indexOf(preItem.goodId);
// if(ind>-1){
// let num = 0;
// for(let i=0; i<item.rules.length; i++){
// let it = item.rules[i];
// for(let r=0; r<preItem.rules.length; r++){
// let ry = preItem.rules[r];
// if(ry.specId==it.specId && ry.ruleId==it.ruleId){
// num+=1;
// }
// }
// }
// if(num==item.rules.length){
// item.num+=1
// }else{
// shopCarInfoAdd.push(preItem)
// }
// }else{
// shopCarInfoAdd.push(preItem);
// arrA.splice(index,1)
// }
// });
// })
// }else{
// shopCarInfo=arrA
// }
// shopCarInfo = [...shopCarInfo,...shopCarInfoAdd];
// uni.setStorageSync('shopCarInfo',shopCarInfo)
// this.goods=uni.getStorageSync('shopCarInfo');
// },
// 切换购物车列表显示隐藏 // 切换购物车列表显示隐藏
openShopCar() { openShopCar() {
this.$nextTick(()=>{ this.$nextTick(()=>{
...@@ -138,14 +97,55 @@ ...@@ -138,14 +97,55 @@
}) })
}, },
// 清空购物车
clearCar() { clearCar() {
uni.removeStorageSync('shopCarInfo'); uni.removeStorageSync('shopCarInfo');
$EventBus.$emit('updateCar'); $EventBus.$emit('updateCar');
}, },
// 购物车为空时点击去购物,收起购物袋
goshopping(){ goshopping(){
this.showShopCar=false;
},
//跳转到结算
saveReserve() {
let Authorization = uni.getStorageSync('Authorization');
let shopCarInfo = uni.getStorageSync('shopCarInfo').filter(v=>v.flag==true);
if(shopCarInfo && this.totalPrice>0 && this.totalNum>0){
// let orderDetails=[];
// shopCarInfo.forEach((item)=>{
// let res = {
// goodsId:item.goodsId,//商品id
// goodsName:item.name,//商品名称
// machineId:undefined,//点单屏机器ID
// num:item.num,//当前sku数量
// realAmount:item.skus[0].price*item.num,//实付金额
// specRuleDetail:JSON.stringify(item.skus[0].rules),//规格选项详情
// skuId:item.skus[0].skuId,//"sku ID"
// goodsCategory:item.categoryId//商品分类
// };
// orderDetails.push(res);
// });
// let DAta={
// amount:this.totalPrice,//商品总金额
// goodsNum:this.totalNum,//商品总数量
// shopId:this.$store.getters.shopInfo[0].id,//店铺
// machineId:undefined,//机器ID
// source:3,//小程序固定传3
// orderDetails:orderDetails
// }
// let res = Menu.saveReserve(DAta);
if(Authorization){
// 从购物车发起:payType=1;
// 立即购买:payType=2;
// 扫码进入:payType=3;
uni.navigateTo({ uni.navigateTo({
url:'../contact/contact' url:`/menuSubPackage/pages/settlement/settlement?totalPrice=${this.totalPrice}&totalNum=${this.totalNum}&payType=1`
}) })
}else{
}
}
return;
}, },
change(e){ change(e){
console.log(e) console.log(e)
...@@ -242,6 +242,14 @@ ...@@ -242,6 +242,14 @@
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
color: #999999; color: #999999;
.delete-icon{
width:18rpx;
height: 18rpx;
background: url(../../static/imgs/icon-delete.png) center center no-repeat;
background-size: cover;
display: inline-block;
margin-right: 8rpx;
}
} }
} }
.container{ .container{
...@@ -336,7 +344,7 @@ ...@@ -336,7 +344,7 @@
.end{ .end{
width: 100%; width: 100%;
height: 92rpx; height: 92rpx;
background-color:#fff; background-color:rgb(253, 253, 253);
position: fixed; position: fixed;
bottom: 50px; bottom: 50px;
left: 0; left: 0;
...@@ -356,14 +364,15 @@ ...@@ -356,14 +364,15 @@
width:40rpx; width:40rpx;
height: 48rpx; height: 48rpx;
display: inline-block; display: inline-block;
border:1px solid #006ECF; background:url('../../static/imgs/icon-shop-package.png') center center no-repeat;
background-size:cover;
position: relative; position: relative;
.badge{ .badge{
position: absolute; position: absolute;
height: 24rpx; height: 24rpx;
background: #006ECF; background: #006ECF;
right:-16rpx; right:-16rpx;
top: -12rpx; top: -4rpx;
min-width: 24rpx; min-width: 24rpx;
font-size: 16rpx; font-size: 16rpx;
font-family: Arial-BoldMT, Arial; font-family: Arial-BoldMT, Arial;
......
<template> <template>
<view> <view class="product-list">
<u-sticky bgColor="#fff" >
<u-tabs :list="list1" ref="uTabs" :current="current" @change="tabsChange"></u-tabs>
</u-sticky>
<swiper :current="swiperCurrent" @change="transition">
<swiper-item class="swiper-item" v-for="(item, index) in tabs" :key="index">
<scroll-view scroll-y style="height:100%;width: 100%;" @scrolltolower="onreachBottom">
{{item.value}}
</scroll-view>
</swiper-item>
</swiper>
</view> </view>
</template> </template>
...@@ -8,15 +17,44 @@ ...@@ -8,15 +17,44 @@
export default { export default {
data() { data() {
return { return {
swiperCurrent: 0,
current: 0,
tabs:[
{value:'111111111111'},
{value:'222222222222'},
{value:'333333333333'},
{value:'444444444444'},
],
list1: [{
name: '国家',
}, {
name: '城市',
}, {
name: '全部地区'
}]
} }
}, },
methods: { methods:{
// tabs通知swiper切换
tabsChange(e) {
this.swiperCurrent = e.index;
},
// swiper-item左右移动,通知tabs的滑块跟随移动
transition(e) {
this.current = e.detail.current
console.log(e.detail.current,'-------')
},
// scroll-view到底部加载更多
onreachBottom() {
console.log(11111111111)
}
} }
} }
</script> </script>
<style>
<style lang="scss" scoped>
.product-list{
}
</style> </style>
\ No newline at end of file
<!-- 本页面如果不是从购物车发起的则获取到的数据需要存到vuex等待发起支付时组装数据 -->
<template>
<view>
<u-button @click="saveReserve">付款</u-button>
</view>
</template>
<script>
import Utils from '@/utils/utils'
import Menu from '@/request/menu'
export default {
data() {
return {
payType:0,//发起支付的页面标识//// 从购物车发起:payType=1;// 立即购买:payType=2;// 扫码进入:payType=3;
orderId:null,//扫码进来的orderId
viewData:{},//预支付数据订单数据
totalPrice:0,//总金额
totalNum:0,//总数量
}
},
onLoad(options) {
if(options.payType){
this.payType = options.payType;
}
if(options.orderId){
this.orderId = options.orderId;
}
if(options.totalPrice){
this.totalPrice = options.totalPrice;
}
if(options.totalNum){
this.totalNum = options.totalNum;
}
},
onShow() {
if(this.orderId!=null && this.payType==3){
this.getOrderInfo()
}
},
onUnload(event){
if(this.orderId && this.payType==3){
uni.switchTab({
url:'/pages/menu/menu'
});
}
return true;
},
methods: {
// 扫码直接进来的订单需要重新获取数据,获取到之后要存到vuex等待支付时组装数据
async getOrderInfo(){
let res = await Menu.getScreenShopCar(this.orderId);
if(res.data.code==200){
this.viewData = res.data.data;
//这里取到数据后需要计算出总价和总数量存给this.totalPrice和this.totalNum;
// 需要组装成和购物车一样的数据存进vuex等待支付。
// ###############未完成处理
this.$store.commit('saveOrderPrePayInfo',res.data.data);
}
},
//结算组装数据发起订单
async saveReserve() {
// 组装购物车数据或者立即支付数据
let res = await Utils.AssemblyOrder(this.totalPrice,this.totalNum,this.payType);
if(res){
// 发起订单
let orderInfo = await Menu.saveReserve(res);
if(orderInfo && orderInfo.data.code==200){
let payMent = await Menu.requestPayment(orderInfo.data.data);
}
}
}
}
}
</script>
<style>
</style>
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
} }
,{ ,{
"path" : "areaSelect/areaSelect", "path" : "pages/areaSelect/areaSelect",
"style" : "style" :
{ {
"navigationBarTitleText": "", "navigationBarTitleText": "",
...@@ -59,6 +59,15 @@ ...@@ -59,6 +59,15 @@
} }
} }
,{
"path" : "pages/settlement/settlement",
"style" :
{
"navigationBarTitleText": "订单结算",
"enablePullDownRefresh": false
}
}
] ]
}, },
{ {
...@@ -93,7 +102,7 @@ ...@@ -93,7 +102,7 @@
} }
], ],
"globalStyle": { "globalStyle": {
"navigationBarTextStyle": "white", "navigationBarTextStyle": "black",
"navigationBarTitleText": "HOOLOO", "navigationBarTitleText": "HOOLOO",
"navigationBarBackgroundColor": "#ffffff", "navigationBarBackgroundColor": "#ffffff",
"backgroundColor": "#ffffff" "backgroundColor": "#ffffff"
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
import config from '../../static/config/index.js' import config from '../../static/config/index.js'
import Order from '../../request/order/index' import Order from '../../request/order/index'
import User from '@/request/user' import User from '@/request/user'
import Menu from '@/request/menu'
export default { export default {
data() { data() {
return { return {
...@@ -21,6 +22,7 @@ ...@@ -21,6 +22,7 @@
this.id=url.split('/')[url.split('/').length-1]; this.id=url.split('/')[url.split('/').length-1];
this.$store.commit('setOrderId',this.id); this.$store.commit('setOrderId',this.id);
} }
// this.id=1;
}, },
async onShow() { async onShow() {
// let routes = getCurrentPages(); // 获取当前打开过的页面路由数组 // let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
...@@ -28,21 +30,43 @@ ...@@ -28,21 +30,43 @@
//   let curParam = routes[routes.length - 1].options; //   let curParam = routes[routes.length - 1].options;
//  console.log(curParam) //  console.log(curParam)
let Authorization=uni.getStorageSync(`Authorization`); let Authorization=uni.getStorageSync(`Authorization`);
let userInfo=uni.getStorageSync(`userInfo`); let userPhoneInfo=uni.getStorageSync(`userPhoneInfo`);
if(Authorization){ // if(Authorization && userPhoneInfo){ //
if(userInfo){ this.$store.commit('setUserPhoneInfo',userPhoneInfo);
this.$store.commit('setUserInfo',userInfo); this.$store.commit('setAuthorization',Authorization);
} if(this.id!=''){
uni.navigateTo({
url:`/menuSubPackage/pages/settlement/settlement?orderId=${this.id}&payType=3`
})
}else{
uni.reLaunch({ uni.reLaunch({
url:'/pages/menu/menu' url:'/pages/menu/menu'
}) })
}
}else{ }else{
uni.removeStorageSync('Authorization'); uni.removeStorageSync('Authorization');
uni.removeStorageSync('userInfo'); uni.removeStorageSync('userPhoneInfo');
if(this.id!=''){
let _this = this;
uni.showToast({
title:'请授权登录',
icon:'error',
success() {
setTimeout(()=>{
uni.reLaunch({
url:'/pages/menu/menu?orderId='+_this.id
})
},1500)
}
})
}else{
uni.reLaunch({ uni.reLaunch({
url:'/pages/menu/menu' url:'/pages/menu/menu'
}) })
} }
}
}, },
methods: { methods: {
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<view class="menu-banner"> <view class="menu-banner">
<image src="../../static/imgs/banner.png"></image> <image src="../../static/imgs/banner.png"></image>
<view class="shop-info" :style="{top: `${menuINfo.top}px`}"> <view class="shop-info" :style="{top: `${menuINfo.top}px`}">
<view class="shop-box" :style="{height: `${menuINfo.height}px`,'line-height': `${menuINfo.height}px`}"> <view class="shop-box" :style="{height: `${menuINfo.height}px`,'line-height': `${menuINfo.height}px`}" @click="changeLocaltion">
<text class="shop-name">{{shopInfo.name}}</text> <text class="shop-name">{{shopInfo.name}}</text>
<u-icon name="arrow-right" class="arrow-right-select" color="#FFFFFF"></u-icon> <u-icon name="arrow-right" class="arrow-right-select" color="#FFFFFF"></u-icon>
</view> </view>
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
</view> </view>
<view class="dis-box"> <view class="dis-box">
<view class="dis">{{item.desc}}</view> <view class="dis">{{item.desc}}</view>
<view class="add-btn" @click.stop="getallNum(item)">+</view> <view class="add-btn" @click.stop="getallNum(item,category)">+</view>
</view> </view>
<view class="mon"> <view class="mon">
<view class="discount">{{item.discount}}</view> <view class="discount">{{item.discount}}</view>
...@@ -88,9 +88,10 @@ import { $EventBus } from '@/utils/EventBus'; ...@@ -88,9 +88,10 @@ import { $EventBus } from '@/utils/EventBus';
export default { export default {
data() { data() {
return { return {
orderId:null,// 如果有扫码进来的支付orderId则存入
shopInfo:{name:'请选择'},// 店铺信息 shopInfo:{name:'请选择'},// 店铺信息
menuINfo:{}, menuINfo:{},
buied: true, buied: false,//控制首页取单码区域显隐
orderBannerh: 0, orderBannerh: 0,
bannerh: 0, bannerh: 0,
name: "wkiwi", name: "wkiwi",
...@@ -125,8 +126,7 @@ import { $EventBus } from '@/utils/EventBus'; ...@@ -125,8 +126,7 @@ import { $EventBus } from '@/utils/EventBus';
}, },
async onShow() { async onShow() {
console.log(1243) console.log(1243)
// 获取首页菜单数据
await this.getMenuList(6);
let _this = this; let _this = this;
uni.createSelectorQuery() uni.createSelectorQuery()
.select(".menu-banner") .select(".menu-banner")
...@@ -146,7 +146,17 @@ import { $EventBus } from '@/utils/EventBus'; ...@@ -146,7 +146,17 @@ import { $EventBus } from '@/utils/EventBus';
} }
this.getHeightList(); this.getHeightList();
}, },
onLoad: async function () { onLoad: async function (options) {
if(options.orderId){
this.orderId=options.orderId;
}
// 获取首页菜单数据
let shopInfo = this.$store.getters.shopInfo;
if(shopInfo && shopInfo[0].id){
await this.getMenuList(shopInfo[0].id);
}else{
await this.getMenuList(6);
}
$EventBus.$off('getMenuList') $EventBus.$off('getMenuList')
$EventBus.$on('getMenuList',(data)=>{ $EventBus.$on('getMenuList',(data)=>{
this.shopInfo=data; this.shopInfo=data;
...@@ -163,11 +173,12 @@ import { $EventBus } from '@/utils/EventBus'; ...@@ -163,11 +173,12 @@ import { $EventBus } from '@/utils/EventBus';
uniGetUserInfo() { uniGetUserInfo() {
User.uniGetUserInfo(); User.uniGetUserInfo();
}, },
// 手机号授权登录
getPhoneNumber(e) { getPhoneNumber(e) {
// uni.exitMiniProgram({success: (res) => {}}) // uni.exitMiniProgram({success: (res) => {}})
if(e.detail.errMsg=='getPhoneNumber:ok'){ if(e.detail.errMsg=='getPhoneNumber:ok'){
User.getPhoneNumber(e); User.getPhoneNumber(e,this.orderId);
}else if( e.detail.errMsg=="getPhoneNumber:fail user deny"){ }else if( e.detail.errMsg=="getPhoneNumber:fail user deny"){
uni.showToast({title:'已拒绝手机号授权',icon:'error'}) uni.showToast({title:'已拒绝手机号授权',icon:'error'})
} }
...@@ -175,6 +186,13 @@ import { $EventBus } from '@/utils/EventBus'; ...@@ -175,6 +186,13 @@ import { $EventBus } from '@/utils/EventBus';
// console.log(e,333) // console.log(e,333)
}, },
changeLocaltion() {
console.log(22345)
uni.navigateTo({
url:'/menuSubPackage/pages/areaSelect/areaSelect'
})
},
// 获取定位授权
getLocation() { getLocation() {
let _this = this; let _this = this;
uni.getSetting({ uni.getSetting({
...@@ -232,17 +250,19 @@ import { $EventBus } from '@/utils/EventBus'; ...@@ -232,17 +250,19 @@ import { $EventBus } from '@/utils/EventBus';
} }
}, },
// 加入购物车数据 // 加入购物车数据
getallNum(item) { getallNum(item,category) {
let itemCopy = JSON.parse(JSON.stringify(item)); let itemCopy = JSON.parse(JSON.stringify(item));
console.log(this.classifyData,998877) itemCopy.skus = itemCopy.skus.find(v=>v.isDefault==1&&v.state!=2) || itemCopy.skus.find(v=>v.isDefault==0&&v.state!=2);
itemCopy.skus = [itemCopy.skus.find(v=>v.state!=2)];
if(!itemCopy.skus){ if(!itemCopy.skus){
uni.showToast({title:'本商品已经售罄',icon:'none'}); uni.showToast({title:'本商品已经售罄',icon:'none'});
return; return;
}else{ }else{
console.log(category,'77777777777777yyyyyyyyyyyyy')
itemCopy.skus=[itemCopy.skus];
itemCopy.num=1; itemCopy.num=1;
itemCopy.flag=true; itemCopy.flag=true;
itemCopy.categoryId=category.id;
itemCopy.goodsName=category.name;
console.log(itemCopy,'mmmmmmm') console.log(itemCopy,'mmmmmmm')
Utils.getallNum(itemCopy); Utils.getallNum(itemCopy);
} }
......
...@@ -30,9 +30,9 @@ uni.$u.http.interceptors.request.use((config) => { // å¯ä½¿ç”¨async await åšå¼ ...@@ -30,9 +30,9 @@ uni.$u.http.interceptors.request.use((config) => { // å¯ä½¿ç”¨async await åšå¼
mask: true, mask: true,
}); });
let Authorization = uni.getStorageSync(`Authorization`); let Authorization = uni.getStorageSync(`Authorization`);
// if (Authorization) { if (Authorization && config.url == '/order') {
// config.header.Authorization = Authorization; config.header.Authorization = Authorization;
// } }
console.log(config,4444) console.log(config,4444)
if (!Authorization) { // 如果token不存在,return Promise.reject(config) 会取消本次请求 if (!Authorization) { // 如果token不存在,return Promise.reject(config) 会取消本次请求
// return Promise.reject(config); // return Promise.reject(config);
......
import Utils from '@/utils/utils'
export default { export default {
// 获取菜单列表 // 获取菜单列表
getMenuList(id) { getMenuList(id) {
...@@ -11,12 +12,27 @@ export default { ...@@ -11,12 +12,27 @@ export default {
uni.showToast({title:'服务器错误',icon:'none'}) uni.showToast({title:'服务器错误',icon:'none'})
}) })
}, },
// 下单获取预支付订单 // 获取点单屏幕的订单信息
saveReserve() { getScreenShopCar(key) {
uni.$u.http.post('/erer/erer', { return uni.$u.http.get('/application/getData', {
params:{
key: key
}
}).then(res => { }).then(res => {
return res;
}).catch(err => {
uni.showToast({
title: '服务器错误',
icon: 'none'
});
return err;
})
},
// 下单获取预支付订单
saveReserve(data) {
return uni.$u.http.post('/order', data).then(res => {
console.log(res,444411111)
return res;
}).catch(err => { }).catch(err => {
}) })
......
...@@ -57,7 +57,7 @@ export default{ ...@@ -57,7 +57,7 @@ export default{
// return err; // return err;
// }); // });
// }, // },
uniLogin(res) { uniLogin(res,orderId) {
uni.login({ uni.login({
provider: 'weixin', provider: 'weixin',
success: function (data) { success: function (data) {
...@@ -72,7 +72,17 @@ export default{ ...@@ -72,7 +72,17 @@ export default{
uni.setStorage({key:'Authorization',data:response.data.token}); uni.setStorage({key:'Authorization',data:response.data.token});
Store.commit('setAuthorization', response.data.token); Store.commit('setAuthorization', response.data.token);
uni.showToast({ uni.showToast({
title:'登录成功' title:'登录成功',
success() {
setTimeout(()=>{
// 如果扫码进来的带有orderId则授权成功之后跳入结算页面
if (orderId) {
uni.navigateTo({
url: '/menuSubPackage/pages/settlement/settlement?orderId=' + orderId
})
}
},1500)
}
}); });
} }
...@@ -85,14 +95,14 @@ export default{ ...@@ -85,14 +95,14 @@ export default{
}) })
}, },
// 手机号授权登录 // 手机号授权登录
getPhoneNumber(res) { getPhoneNumber(res,orderId) {
console.log(res,12321) console.log(res,'还是手机号参数吗')
uni.setStorage({ uni.setStorage({
key: 'userPhoneInfo', key: 'userPhoneInfo',
data: res data: res
}) })
Store.commit("setUserPhoneInfo", res); Store.commit("setUserPhoneInfo", res);
this.uniLogin(res.detail); this.uniLogin(res.detail,orderId);
}, },
async uniGetUserInfo(e) { async uniGetUserInfo(e) {
uni.getUserProfile({ //授权后可以通过uni.getUserProfile得到用户信息 uni.getUserProfile({ //授权后可以通过uni.getUserProfile得到用户信息
......
const getters = { const getters = {
userInfo: state => state.user.userInfo.userInfo, userInfo: state => state.user.userInfo.userInfo,//用户授权允许时的信息
nickName: state => state.user.userInfo.userInfo.nickName, nickName: state => state.user.userInfo.userInfo.nickName,//用户授权后昵称
Authorization: state => state.user.Authorization, Authorization: state => state.user.Authorization,//用户授权成功后的token
menuAllInfo: state => state.menu.menuAllInfo, menuAllInfo: state => state.menu.menuAllInfo,//所有的菜单数据
userPhoneInfo: state => state.user.userPhoneInfo, userPhoneInfo: state => state.user.userPhoneInfo,//用户授权手机号时的数据
location: state => state.user.location, location: state => state.user.location,//用户的定位数据
shopInfo: state => state.user.shopInfo, shopInfo: state => state.user.shopInfo,//获取到的当前的店铺数据
orderId: state => state.user.orderId, //扫码进入时取到的orderId
orderPrePayInfo: state => state.menu.orderPrePayInfo, //扫码进入结算面后和立即购买进入结算页的数据,等待支付下单
} }
export default getters export default getters
\ No newline at end of file
...@@ -12,22 +12,22 @@ const store = new Vuex.Store({ ...@@ -12,22 +12,22 @@ const store = new Vuex.Store({
state: { state: {
list: [ list: [
{ {
icon: "/static/logo.png", icon: "/static/imgs/icon-unselect-menu.png",
activeIcon: '/static/logo.png', activeIcon: '/static/imgs/icon-selected-menu.png',
customIcon: false, customIcon: false,
pagePath: "/pages/menu/menu", pagePath: "/pages/menu/menu",
text: '菜单' text: '菜单'
}, },
{ {
icon: "/static/logo.png", icon: "/static/imgs/icon-unselect-order.png",
activeIcon: '/static/logo.png', activeIcon: '/static/imgs/icon-selected-order.png',
pagePath: "/pages/order/order", pagePath: "/pages/order/order",
text: '订单', text: '订单',
customIcon: false customIcon: false
}, },
{ {
icon: "/static/logo.png", icon: "/static/imgs/icon-unselect-mine.png",
activeIcon: '/static/logo.png', activeIcon: '/static/imgs/icon-selected-mine.png',
pagePath: "/pages/mine/mine", pagePath: "/pages/mine/mine",
text: '我的' text: '我的'
} }
......
...@@ -2,12 +2,17 @@ ...@@ -2,12 +2,17 @@
const menu = { const menu = {
state: { state: {
menuAllInfo: null, //菜单信息 menuAllInfo: null, //菜单信息
orderPrePayInfo: null, //(需要和购物车数据格式一致)
}, },
mutations: { mutations: {
// 设置用户菜单信息 // 设置用户菜单信息
setMenuAllInfo(state, menuAllInfo) { setMenuAllInfo(state, menuAllInfo) {
state.menuAllInfo = menuAllInfo; state.menuAllInfo = menuAllInfo;
}, },
// 立即购买按钮取到的数据和扫码进入结算页的数据统一使用次方法存储(需要和购物车数据格式一致)
saveOrderPrePayInfo(state, orderPrePayInfo) {
state.orderPrePayInfo = orderPrePayInfo;
},
}, },
actions: { actions: {
......
...@@ -5,9 +5,14 @@ const user = { ...@@ -5,9 +5,14 @@ const user = {
Authorization: null, //是否授权 Authorization: null, //是否授权
location:null,//用户经纬度 location:null,//用户经纬度
userPhoneInfo:null, userPhoneInfo:null,
shopInfo:null//店铺信息 shopInfo:null,//店铺信息
orderId:null//扫码进入时携带的订单id
}, },
mutations: { mutations: {
// 保存扫码进入时携带的订单id
setOrderId(state, orderId) {
state.orderId = orderId;
},
// 设置是否授权 // 设置是否授权
setAuthorization(state, data) { setAuthorization(state, data) {
console.log(data,665) console.log(data,665)
......
import Config from '../static/config/index.js'; import Config from '../static/config/index.js';
import WXBizDataCrypt from "./WXBizDataCrypt.js"; import WXBizDataCrypt from "./WXBizDataCrypt.js";
import {$EventBus} from './EventBus' import {$EventBus} from './EventBus'
import Store from '@/store'
export default{ export default{
// 组装提交订单数据
AssemblyOrder(totalPrice, totalNum) {
let shopCarInfo = uni.getStorageSync('shopCarInfo').filter(v => v.flag == true);
if (shopCarInfo && totalPrice > 0 && totalNum > 0) {
let orderDetails = [];
for (let i = 0; i < shopCarInfo.length; i++) {
let item = shopCarInfo[i];
let res = {
goodsId: item.goodsId, //商品id
goodsName: item.name, //商品名称
machineId: undefined, //点单屏机器ID
num: item.num, //当前sku数量
realAmount: item.skus[0].price * item.num, //实付金额
specRuleDetail: JSON.stringify(item.skus[0].rules), //规格选项详情
skuId: item.skus[0].skuId, //"sku ID"
goodsCategory: item.categoryId //商品分类
};
orderDetails.push(res);
}
let DAta = {
amount: totalPrice, //商品总金额
goodsNum: totalNum, //商品总数量
shopId: Store.getters.shopInfo[0].id, //店铺
machineId: undefined, //机器ID
source: 3, //小程序固定传3
orderDetails: orderDetails
}
return DAta;
} else {
uni.showToast({
title: '请选择商品'
})
}
},
// 加入购物车数据
getallNum(Obj){ getallNum(Obj){
let shopCarInfo = uni.getStorageSync('shopCarInfo'); let shopCarInfo = uni.getStorageSync('shopCarInfo');
console.log(shopCarInfo,'oooooo') console.log(shopCarInfo,'oooooo')
...@@ -21,49 +57,6 @@ export default{ ...@@ -21,49 +57,6 @@ export default{
uni.setStorageSync('shopCarInfo', shopCarInfo); uni.setStorageSync('shopCarInfo', shopCarInfo);
$EventBus.$emit('updateCar'); $EventBus.$emit('updateCar');
}, },
// getallNum(arrA) {
// // arrA = []
// let shopCarInfo = uni.getStorageSync('shopCarInfo');
// let shopCarInfoAdd = []
// console.log(shopCarInfo, 55553333)
// if (shopCarInfo) {
// let ids = shopCarInfo.map(v => v.goodsId);
// console.log(ids, 444)
// shopCarInfo.forEach((item) => {
// arrA.forEach((preItem, index) => {
// console.log(ids.includes(preItem.goodsId), 1234567)
// let ind = ids.indexOf(preItem.goodsId);
// if (ind > -1) {
// let num = 0;
// for (let i = 0; i < item.rules.length; i++) {
// let it = item.rules[i];
// for (let r = 0; r < preItem.rules.length; r++) {
// let ry = preItem.rules[r];
// if (ry.specId == it.specId && ry.ruleId == it.ruleId) {
// num += 1;
// }
// }
// }
// if (num == item.rules.length) {
// item.num += 1
// } else {
// shopCarInfoAdd.push(preItem)
// }
// } else {
// shopCarInfoAdd.push(preItem);
// arrA.splice(index, 1)
// }
// });
// })
// } else {
// shopCarInfo = arrA
// }
// shopCarInfo = [...shopCarInfo, ...shopCarInfoAdd];
// uni.setStorageSync('shopCarInfo', shopCarInfo);
// $EventBus.$emit('updateCar');
// // this.goods = uni.getStorageSync('shopCarInfo');
// },
// 解密手机 // 解密手机
async onGetPhoneNumber(appid,session_key,encryptedData,iv) { async onGetPhoneNumber(appid,session_key,encryptedData,iv) {
let pc = await new WXBizDataCrypt(appid,session_key); let pc = await new WXBizDataCrypt(appid,session_key);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment