Commit dcb6db3a by zhangcheng

调整购物车调试订单

parent 465520c3
......@@ -4,7 +4,7 @@
<view class="shop-car">
<view class="header">
<text class="left">购物袋</text>
<text class="right" @click="clearCar">清空购物车</text>
<text class="right" @click="clearCar"><text class="delete-icon"></text>清空购物车</text>
</view>
<view class="container">
<view>
......@@ -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>
</view>
</view>
<view class="end-right">
<view class="end-right" @click="saveReserve">
付款
<!-- ({{totalNum}}) -->
</view>
......@@ -69,6 +69,7 @@
<script>
import { $EventBus } from "../../utils/EventBus";
import Menu from '@/request/menu';
export default{
data(){
return{
......@@ -81,7 +82,6 @@
},
created() {
$EventBus.$off('updateCar');
// this.getallNum();
},
mounted() {
this.goods = uni.getStorageSync('shopCarInfo')||[];
......@@ -90,47 +90,6 @@
});
},
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() {
this.$nextTick(()=>{
......@@ -138,14 +97,55 @@
})
},
// 清空购物车
clearCar() {
uni.removeStorageSync('shopCarInfo');
$EventBus.$emit('updateCar');
},
// 购物车为空时点击去购物,收起购物袋
goshopping(){
uni.navigateTo({
url:'../contact/contact'
})
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({
url:`/menuSubPackage/pages/settlement/settlement?totalPrice=${this.totalPrice}&totalNum=${this.totalNum}&payType=1`
})
}else{
}
}
return;
},
change(e){
console.log(e)
......@@ -242,6 +242,14 @@
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
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{
......@@ -336,7 +344,7 @@
.end{
width: 100%;
height: 92rpx;
background-color:#fff;
background-color:rgb(253, 253, 253);
position: fixed;
bottom: 50px;
left: 0;
......@@ -356,14 +364,15 @@
width:40rpx;
height: 48rpx;
display: inline-block;
border:1px solid #006ECF;
background:url('../../static/imgs/icon-shop-package.png') center center no-repeat;
background-size:cover;
position: relative;
.badge{
position: absolute;
height: 24rpx;
background: #006ECF;
right:-16rpx;
top: -12rpx;
top: -4rpx;
min-width: 24rpx;
font-size: 16rpx;
font-family: Arial-BoldMT, Arial;
......
<template>
<view>
</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>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
export default {
data() {
return {
swiperCurrent: 0,
current: 0,
tabs:[
{value:'111111111111'},
{value:'222222222222'},
{value:'333333333333'},
{value:'444444444444'},
],
list1: [{
name: '国家',
}, {
name: '城市',
}, {
name: '全部地区'
}]
}
},
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>
<style>
</style>
<style lang="scss" scoped>
.product-list{
}
</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 @@
}
,{
"path" : "areaSelect/areaSelect",
"path" : "pages/areaSelect/areaSelect",
"style" :
{
"navigationBarTitleText": "",
......@@ -59,6 +59,15 @@
}
}
,{
"path" : "pages/settlement/settlement",
"style" :
{
"navigationBarTitleText": "订单结算",
"enablePullDownRefresh": false
}
}
]
},
{
......@@ -93,7 +102,7 @@
}
],
"globalStyle": {
"navigationBarTextStyle": "white",
"navigationBarTextStyle": "black",
"navigationBarTitleText": "HOOLOO",
"navigationBarBackgroundColor": "#ffffff",
"backgroundColor": "#ffffff"
......
......@@ -7,6 +7,7 @@
import config from '../../static/config/index.js'
import Order from '../../request/order/index'
import User from '@/request/user'
import Menu from '@/request/menu'
export default {
data() {
return {
......@@ -21,6 +22,7 @@
this.id=url.split('/')[url.split('/').length-1];
this.$store.commit('setOrderId',this.id);
}
// this.id=1;
},
async onShow() {
// let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
......@@ -28,20 +30,42 @@
//   let curParam = routes[routes.length - 1].options;
//  console.log(curParam)
let Authorization=uni.getStorageSync(`Authorization`);
let userInfo=uni.getStorageSync(`userInfo`);
if(Authorization){ //
if(userInfo){
this.$store.commit('setUserInfo',userInfo);
}
uni.reLaunch({
url:'/pages/menu/menu'
})
let userPhoneInfo=uni.getStorageSync(`userPhoneInfo`);
if(Authorization && userPhoneInfo){ //
this.$store.commit('setUserPhoneInfo',userPhoneInfo);
this.$store.commit('setAuthorization',Authorization);
if(this.id!=''){
uni.navigateTo({
url:`/menuSubPackage/pages/settlement/settlement?orderId=${this.id}&payType=3`
})
}else{
uni.reLaunch({
url:'/pages/menu/menu'
})
}
}else{
uni.removeStorageSync('Authorization');
uni.removeStorageSync('userInfo');
uni.reLaunch({
url:'/pages/menu/menu'
})
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({
url:'/pages/menu/menu'
})
}
}
},
methods: {
......
{
"images": {
"left": [
"http://baidu.com",
"http://baidu.com"
],
"right": [
{
"code": 1,
"url": "http://baidu.com"
},
{
"code": 1,
"url": "http://baidu.com"
},
{
"code": 1,
"url": "http://baidu.com"
},
{
"code": 1,
"url": "http://baidu.com"
}
]
},
"tips": "http://baidu.com",
"countOfOrder": 9,
"categorys": [
{
"id": 1,
"name": "今日特惠",
"goods": [
{
[
{
"categoryId":1,
"goodId": 100,
"name": "冰茶咖啡",
"price": 29.9,
"discount": 19.9,
"flag":true,
"num":4,
"pics": {
"thumbnail": "http://baidu.com",
"introImages": [
......@@ -48,7 +20,7 @@
"http://baidu.com"
]
},
"desc": "比利时进口巧克力也挺丝滑",
"desc": "",
"remark": "",
"tags": [
"YYDS",
......@@ -118,620 +90,7 @@
"price": 0.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 2,
"ruleName": "冰",
"price": 2.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "无糖",
"price": 0.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "常温",
"price": 0.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "加糖",
"price": 2.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "冰",
"price": 2.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "加糖",
"price": 4.00
}
]
}
]
}
]
},
{
"id": 2,
"name": "今日特惠2",
"goods": [
{
"goodId": 101,
"name": "冰茶咖啡2",
"price": 29.9,
"discount": 19.9,
"pics": {
"thumbnail": "http://baidu.com",
"introImages": [
"http://baidu.com",
"http://baidu.com",
"http://baidu.com"
],
"detailImages": [
"http://baidu.com",
"http://baidu.com",
"http://baidu.com"
]
},
"desc": "比利时进口巧克力也挺丝滑",
"remark": "",
"tags": [
"YYDS",
"杨幂同款"
],
"specs": [
{
"specId": 1,
"specName": "温度",
"rules": [
{
"ruleId": 1,
"ruleName": "常温",
"price": 0
},
{
"ruleId": 2,
"ruleName": "加冰",
"price": 2
},
{
"ruleId": 3,
"ruleName": "加热",
"price": 3
}
]
},
{
"specId": 2,
"specName": "糖度",
"rules": [
{
"ruleId": 4,
"ruleName": "无糖",
"price": 0
},
{
"ruleId": 5,
"ruleName": "少糖",
"price": 1
},
{
"ruleId": 6,
"ruleName": "多糖",
"price": 2
}
]
}
],
"skus": [
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "常温",
"price": 0.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "无糖",
"price": 0.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 2,
"ruleName": "冰",
"price": 2.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "无糖",
"price": 0.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "常温",
"price": 0.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "加糖",
"price": 2.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "冰",
"price": 2.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "加糖",
"price": 4.00
}
]
}
]
}
]
},
{
"id": 3,
"name": "今日特惠3",
"goods": [
{
"goodId": 102,
"name": "冰茶咖啡3",
"price": 29.9,
"discount": 19.9,
"pics": {
"thumbnail": "http://baidu.com",
"introImages": [
"http://baidu.com",
"http://baidu.com",
"http://baidu.com"
],
"detailImages": [
"http://baidu.com",
"http://baidu.com",
"http://baidu.com"
]
},
"desc": "比利时进口巧克力也挺丝滑",
"remark": "",
"tags": [
"YYDS",
"杨幂同款"
],
"specs": [
{
"specId": 1,
"specName": "温度",
"rules": [
{
"ruleId": 1,
"ruleName": "常温",
"price": 0
},
{
"ruleId": 2,
"ruleName": "加冰",
"price": 2
},
{
"ruleId": 3,
"ruleName": "加热",
"price": 3
}
]
},
{
"specId": 2,
"specName": "糖度",
"rules": [
{
"ruleId": 4,
"ruleName": "无糖",
"price": 0
},
{
"ruleId": 5,
"ruleName": "少糖",
"price": 1
},
{
"ruleId": 6,
"ruleName": "多糖",
"price": 2
}
]
}
],
"skus": [
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "常温",
"price": 0.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "无糖",
"price": 0.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 2,
"ruleName": "冰",
"price": 2.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "无糖",
"price": 0.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "常温",
"price": 0.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "加糖",
"price": 2.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "冰",
"price": 2.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "加糖",
"price": 4.00
}
]
}
]
}
]
},
{
"id": 4,
"name": "今日特惠4",
"goods": [
{
"goodId": 103,
"name": "冰茶咖啡4",
"price": 29.9,
"discount": 19.9,
"pics": {
"thumbnail": "http://baidu.com",
"introImages": [
"http://baidu.com",
"http://baidu.com",
"http://baidu.com"
],
"detailImages": [
"http://baidu.com",
"http://baidu.com",
"http://baidu.com"
]
},
"desc": "比利时进口巧克力也挺丝滑",
"remark": "",
"tags": [
"YYDS",
"杨幂同款"
],
"specs": [
{
"specId": 1,
"specName": "温度",
"rules": [
{
"ruleId": 1,
"ruleName": "常温",
"price": 0
},
{
"ruleId": 2,
"ruleName": "加冰",
"price": 2
},
{
"ruleId": 3,
"ruleName": "加热",
"price": 3
}
]
},
{
"specId": 2,
"specName": "糖度",
"rules": [
{
"ruleId": 4,
"ruleName": "无糖",
"price": 0
},
{
"ruleId": 5,
"ruleName": "少糖",
"price": 1
},
{
"ruleId": 6,
"ruleName": "多糖",
"price": 2
}
]
}
],
"skus": [
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "常温",
"price": 0.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "无糖",
"price": 0.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 2,
"ruleName": "冰",
"price": 2.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "无糖",
"price": 0.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "常温",
"price": 0.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "加糖",
"price": 2.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "冰",
"price": 2.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "加糖",
"price": 4.00
}
]
}
]
}
]
}
],
"recommends": [
{
"goodsName": "推荐名称",
"pic": "http://baidu.com",
"desc": "推荐描述",
"goods": [
{
"goodId": 100,
"name": "冰茶咖啡",
"price": 29.9,
"discount": 19.9,
"pics": {
"thumbnail": "http://baidu.com",
"introImages": [
"http://baidu.com",
"http://baidu.com",
"http://baidu.com"
],
"detailImages": [
"http://baidu.com",
"http://baidu.com",
"http://baidu.com"
]
},
"desc": "比利时进口巧克力也挺丝滑",
"remark": "",
"tags": [
"YYDS",
"杨幂同款"
],
"specs": [
{
"specId": 1,
"specName": "温度",
"rules": [
{
"ruleId": 1,
"ruleName": "常温",
"price": 0
},
{
"ruleId": 2,
"ruleName": "加冰",
"price": 2
},
{
"ruleId": 3,
"ruleName": "加热",
"price": 3
}
]
}
],
"skus": [
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "常温",
"price": 0.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "无糖",
"price": 0.00
}
]
}
]
}
]
}
]
}
\ No newline at end of file
]
\ No newline at end of file
......@@ -3,7 +3,7 @@
<view class="menu-banner">
<image src="../../static/imgs/banner.png"></image>
<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>
<u-icon name="arrow-right" class="arrow-right-select" color="#FFFFFF"></u-icon>
</view>
......@@ -63,7 +63,7 @@
</view>
<view class="dis-box">
<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 class="mon">
<view class="discount">{{item.discount}}</view>
......@@ -88,9 +88,10 @@ import { $EventBus } from '@/utils/EventBus';
export default {
data() {
return {
orderId:null,// 如果有扫码进来的支付orderId则存入
shopInfo:{name:'请选择'},// 店铺信息
menuINfo:{},
buied: true,
buied: false,//控制首页取单码区域显隐
orderBannerh: 0,
bannerh: 0,
name: "wkiwi",
......@@ -125,8 +126,7 @@ import { $EventBus } from '@/utils/EventBus';
},
async onShow() {
console.log(1243)
// 获取首页菜单数据
await this.getMenuList(6);
let _this = this;
uni.createSelectorQuery()
.select(".menu-banner")
......@@ -146,7 +146,17 @@ import { $EventBus } from '@/utils/EventBus';
}
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.$on('getMenuList',(data)=>{
this.shopInfo=data;
......@@ -163,11 +173,12 @@ import { $EventBus } from '@/utils/EventBus';
uniGetUserInfo() {
User.uniGetUserInfo();
},
// 手机号授权登录
getPhoneNumber(e) {
// uni.exitMiniProgram({success: (res) => {}})
if(e.detail.errMsg=='getPhoneNumber:ok'){
User.getPhoneNumber(e);
User.getPhoneNumber(e,this.orderId);
}else if( e.detail.errMsg=="getPhoneNumber:fail user deny"){
uni.showToast({title:'已拒绝手机号授权',icon:'error'})
}
......@@ -175,6 +186,13 @@ import { $EventBus } from '@/utils/EventBus';
// console.log(e,333)
},
changeLocaltion() {
console.log(22345)
uni.navigateTo({
url:'/menuSubPackage/pages/areaSelect/areaSelect'
})
},
// 获取定位授权
getLocation() {
let _this = this;
uni.getSetting({
......@@ -232,17 +250,19 @@ import { $EventBus } from '@/utils/EventBus';
}
},
// 加入购物车数据
getallNum(item) {
getallNum(item,category) {
let itemCopy = JSON.parse(JSON.stringify(item));
console.log(this.classifyData,998877)
itemCopy.skus = [itemCopy.skus.find(v=>v.state!=2)];
itemCopy.skus = itemCopy.skus.find(v=>v.isDefault==1&&v.state!=2) || itemCopy.skus.find(v=>v.isDefault==0&&v.state!=2);
if(!itemCopy.skus){
uni.showToast({title:'本商品已经售罄',icon:'none'});
return;
}else{
console.log(category,'77777777777777yyyyyyyyyyyyy')
itemCopy.skus=[itemCopy.skus];
itemCopy.num=1;
itemCopy.flag=true;
itemCopy.categoryId=category.id;
itemCopy.goodsName=category.name;
console.log(itemCopy,'mmmmmmm')
Utils.getallNum(itemCopy);
}
......
......@@ -30,9 +30,9 @@ uni.$u.http.interceptors.request.use((config) => { // å¯ä½¿ç”¨async await åšå¼
mask: true,
});
let Authorization = uni.getStorageSync(`Authorization`);
// if (Authorization) {
// config.header.Authorization = Authorization;
// }
if (Authorization && config.url == '/order') {
config.header.Authorization = Authorization;
}
console.log(config,4444)
if (!Authorization) { // 如果token不存在,return Promise.reject(config) 会取消本次请求
// return Promise.reject(config);
......
import Utils from '@/utils/utils'
export default {
// 获取菜单列表
getMenuList(id) {
......@@ -11,14 +12,29 @@ export default {
uni.showToast({title:'服务器错误',icon:'none'})
})
},
// 下单获取预支付订单
saveReserve() {
uni.$u.http.post('/erer/erer', {
// 获取点单屏幕的订单信息
getScreenShopCar(key) {
return uni.$u.http.get('/application/getData', {
params:{
key: key
}
}).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 => {
})
},
// saveReserve 为业务接口
......
......@@ -57,7 +57,7 @@ export default{
// return err;
// });
// },
uniLogin(res) {
uniLogin(res,orderId) {
uni.login({
provider: 'weixin',
success: function (data) {
......@@ -72,7 +72,17 @@ export default{
uni.setStorage({key:'Authorization',data:response.data.token});
Store.commit('setAuthorization', response.data.token);
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{
})
},
// 手机号授权登录
getPhoneNumber(res) {
console.log(res,12321)
getPhoneNumber(res,orderId) {
console.log(res,'还是手机号参数吗')
uni.setStorage({
key: 'userPhoneInfo',
data: res
})
Store.commit("setUserPhoneInfo", res);
this.uniLogin(res.detail);
this.uniLogin(res.detail,orderId);
},
async uniGetUserInfo(e) {
uni.getUserProfile({ //授权后可以通过uni.getUserProfile得到用户信息
......
const getters = {
userInfo: state => state.user.userInfo.userInfo,
nickName: state => state.user.userInfo.userInfo.nickName,
Authorization: state => state.user.Authorization,
menuAllInfo: state => state.menu.menuAllInfo,
userPhoneInfo: state => state.user.userPhoneInfo,
location: state => state.user.location,
shopInfo: state => state.user.shopInfo,
userInfo: state => state.user.userInfo.userInfo,//用户授权允许时的信息
nickName: state => state.user.userInfo.userInfo.nickName,//用户授权后昵称
Authorization: state => state.user.Authorization,//用户授权成功后的token
menuAllInfo: state => state.menu.menuAllInfo,//所有的菜单数据
userPhoneInfo: state => state.user.userPhoneInfo,//用户授权手机号时的数据
location: state => state.user.location,//用户的定位数据
shopInfo: state => state.user.shopInfo,//获取到的当前的店铺数据
orderId: state => state.user.orderId, //扫码进入时取到的orderId
orderPrePayInfo: state => state.menu.orderPrePayInfo, //扫码进入结算面后和立即购买进入结算页的数据,等待支付下单
}
export default getters
\ No newline at end of file
......@@ -12,22 +12,22 @@ const store = new Vuex.Store({
state: {
list: [
{
icon: "/static/logo.png",
activeIcon: '/static/logo.png',
icon: "/static/imgs/icon-unselect-menu.png",
activeIcon: '/static/imgs/icon-selected-menu.png',
customIcon: false,
pagePath: "/pages/menu/menu",
text: '菜单'
},
{
icon: "/static/logo.png",
activeIcon: '/static/logo.png',
icon: "/static/imgs/icon-unselect-order.png",
activeIcon: '/static/imgs/icon-selected-order.png',
pagePath: "/pages/order/order",
text: '订单',
customIcon: false
},
{
icon: "/static/logo.png",
activeIcon: '/static/logo.png',
icon: "/static/imgs/icon-unselect-mine.png",
activeIcon: '/static/imgs/icon-selected-mine.png',
pagePath: "/pages/mine/mine",
text: '我的'
}
......
......@@ -2,12 +2,17 @@
const menu = {
state: {
menuAllInfo: null, //菜单信息
orderPrePayInfo: null, //(需要和购物车数据格式一致)
},
mutations: {
// 设置用户菜单信息
setMenuAllInfo(state, menuAllInfo) {
state.menuAllInfo = menuAllInfo;
},
// 立即购买按钮取到的数据和扫码进入结算页的数据统一使用次方法存储(需要和购物车数据格式一致)
saveOrderPrePayInfo(state, orderPrePayInfo) {
state.orderPrePayInfo = orderPrePayInfo;
},
},
actions: {
......
......@@ -5,9 +5,14 @@ const user = {
Authorization: null, //是否授权
location:null,//用户经纬度
userPhoneInfo:null,
shopInfo:null//店铺信息
shopInfo:null,//店铺信息
orderId:null//扫码进入时携带的订单id
},
mutations: {
// 保存扫码进入时携带的订单id
setOrderId(state, orderId) {
state.orderId = orderId;
},
// 设置是否授权
setAuthorization(state, data) {
console.log(data,665)
......
import Config from '../static/config/index.js';
import WXBizDataCrypt from "./WXBizDataCrypt.js";
import {$EventBus} from './EventBus'
import Store from '@/store'
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){
let shopCarInfo = uni.getStorageSync('shopCarInfo');
console.log(shopCarInfo,'oooooo')
......@@ -21,49 +57,6 @@ export default{
uni.setStorageSync('shopCarInfo', shopCarInfo);
$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) {
let pc = await new WXBizDataCrypt(appid,session_key);
......@@ -72,33 +65,33 @@ export default{
},
// 扫码方法
scanCode() {
uni.scanCode({
success:(res)=> {
this.scaninfo=res;
if(res.result){//res.result
if(res.result.includes(Config.AVScanUrl)){
uni.reLaunch({
url:`/pages/index/index?q=${res.result}`
})
}else{
uni.showToast({
title:'二维码错误',
icon:'none'
})
}
// '0016429'||
// `../pages/index/index`
// console.log(res.result,'内部扫码')
}
},
fail() {
uni.showToast({
icon:'none',
title:'扫码失败'
})
}
});
uni.scanCode({
success:(res)=> {
this.scaninfo=res;
if(res.result){//res.result
if(res.result.includes(Config.AVScanUrl)){
uni.reLaunch({
url:`/pages/index/index?q=${res.result}`
})
}else{
uni.showToast({
title:'二维码错误',
icon:'none'
})
}
// '0016429'||
// `../pages/index/index`
// console.log(res.result,'内部扫码')
}
},
fail() {
uni.showToast({
icon:'none',
title:'扫码失败'
})
}
});
},
formatDate(value) {
var date = new Date();
......
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