Commit ae118994 by 张成

up[date

parent 4c9ddc05
<style lang="scss">
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
@import "uview-ui/index.scss";
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
@import "uview-ui/index.scss";
</style>
<script>
export default {
onLaunch: function() {
// uni.showLoading({
// title: '加载中...',
// mask:true
// });
// uni.clearStorageSync();
},
onShow: function() {
},
onHide: function() {
},
methods:{
unilogin(){
}
export default {
onLaunch: function () {
// uni.showLoading({
// title: '加载中...',
// mask:true
// });
// uni.clearStorageSync();
},
onShow: function () {
},
onHide: function () {
},
methods: {
unilogin() {
}
}
}
</script>
<style>
/*每个页面公共css */
/*每个页面公共css */
.pages {
background: #F2F2F2;
min-height: calc(100vh - 100rpx);
}
* {
box-sizing: border-box;
}
image {
width: 100%;
height: auto;
}
</style>
<template>
</template>
<script>
export default {
}
</script>
<style>
</style>
\ No newline at end of file
<template>
<div class="pages">
<div class="order_status">
<view class="status_text" v-if="orderInfo.state == 0">订单状态:创建未校验</view>
<view class="status_text" v-if="orderInfo.state == 1">订单状态:未支付</view>
<view class="status_text" v-if="orderInfo.state == 2">订单状态:排队中</view>
<view class="status_text" v-if="orderInfo.state == 3">订单状态:制作中</view>
<view class="status_text" v-if="orderInfo.state == 4">订单状态:制作完成</view>
<view class="status_text" v-if="orderInfo.state == 5">订单状态:待取超时</view>
<view class="status_text" v-if="orderInfo.state == 6">订单状态:完成</view>
<view class="status_text" v-if="orderInfo.state == 7">订单状态:取消</view>
<view class="status_text" v-if="orderInfo.state == 8">订单状态:取消</view>
<view class="status_text" v-if="orderInfo.state == 9">订单状态:取消</view>
<view class="status_text" v-if="orderInfo.state == 10">订单状态:取消</view>
<view class="status_text" v-if="orderInfo.state == 11">订单状态:已退款</view>
<view class="status_text" v-if="orderInfo.state == 12">订单状态:部分退款</view>
<div>
<a type="primary" @click="toRefund" v-if="orderInfo.state == 1" class="btn">申请退款</a>
<a type="primary" @click="toRefund" v-if="orderInfo.state == 2" class="btn">申请退款</a>
</div>
</div>
<div class="order_flow">
<div class="code">取单码 Mon999</div>
<image mode="aspectFit" :src="orderInfo.pickCode" class="qr_code"></image>
<div class="flow_describe">
<h3>扫码流程 </h3>
<image :mode="'aspectFit'" width="600px" class="flow_img" src="../../../static/imgs/order_flow.png">
</image>
</div>
<div class="shop_info">
<div class="address">
<div class="address_1">北京朝阳建外SOHO东区A座店</div>
<div class="address_2">距您132m,请确定门店后下单</div>
</div>
<div v-for="item in orderInfo.orderDetails" :key="item.id">
<div class="goods">
<div class="goods_item">
<image mode="aspectFit" :src="jsonParse(item.goods.pics).thumbnail" class="goods_img">
</image>
<div class="goods_text">
<div class="goods_name">
<div class="name">{{ item.goodsName }}</div>
<div class="price">¥{{ item.realAmount }}</div>
</div>
<div class="goods_psce">
<div class="psce_name">
<span v-for="rule in jsonParse(item.specRuleDetail)" :key="rule.specId">
{{ rule.ruleName }}/
</span>
</div>
<div class="size">*{{ item.num }}</div>
</div>
</div>
</div>
</div>
<div class="discount">
<div class="discount_1">
<div class="name">优惠免减</div>
<div class="price">- ¥5</div>
</div>
<div class="concessional_rate">
<div class="name">优惠免减</div>
<div class="price">- ¥5</div>
</div>
</div>
</div>
<div class="total">
<div class="size">共一件商品</div>
<div>
<span class="paid_in">实付</span>
<span class="money">¥10</span>
</div>
</div>
</div>
</div>
<div class="order_describe">
<h3>订单信息</h3>
<div class="item">
<span class="label">下单时间:</span>
<span class="value">2022-11-12 10:20:20</span>
</div>
<div class="item">
<span class="label">取单码号:</span>
<span class="value">2022-11-12 10:20:20</span>
</div>
<div class="item">
<span class="label">订单编号:</span>
<span class="value">2022-11-12 10:20:20</span>
</div>
</div>
<div class="customer_service">
<span>有疑问,联系客服</span>
<u-icon name="arrow-right" color="#000" size="20"></u-icon>
</div>
</div>
</template>
<script>
import Order from '@/request/order'
export default {
onLoad() {
this.orderInfo = uni.getStorageSync('orderInfo');
},
data() {
return {
orderInfo: {}
}
},
methods: {
toRefund() {
Order.orderRefund({ orderId: this.orderInfo.id, refundAmount: this.orderInfo.amount }).then(res => {
console.log(res);
uni.switchTab({ url: '/pages/menu/menu' })
})
},
jsonParse(json) {
return JSON.parse(json)
}
}
}
</script>
<style lang="scss" scoped>
.pages {
padding-top: 1rpx;
padding-bottom: 30rpx;
}
.order_status {
width: 686rpx;
height: 174rpx;
background: #FFFFFF;
border-radius: 10rpx;
margin: 32rpx auto 0;
padding: 14px;
.status_text {
font-size: 32rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #000000;
text-align: center;
}
.btn {
width: 160rpx;
height: 52rpx;
background: #006ECF;
border-radius: 6rpx;
display: block;
margin: 20rpx auto;
padding: 0;
line-height: 52rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFFFFF;
font-size: 20rpx;
text-align: center;
}
}
.order_flow {
background: #FFFFFF;
border-radius: 10rpx;
margin-top: 32rpx;
padding-top: 65rpx;
.code {
font-size: 36rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #000000;
text-align: center;
}
.qr_code {
width: 508rpx;
height: 510rpx;
display: block;
margin: 25rpx auto;
background-color: #ccc;
}
.flow_describe {
width: 686rpx;
height: 340rpx;
background: #FFFFFF;
box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(166, 166, 166, 0.5);
border-radius: 10rpx;
margin: 0 auto;
padding: 30rpx;
h3 {
font-size: 28rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #000000;
}
.flow_img {
width: 600rpx;
height: 214rpx;
display: block;
margin: 24rpx auto;
}
}
}
.shop_info {
width: 686rpx;
background: #FFFFFF;
border-radius: 10rpx;
margin: 0 auto;
margin-top: 32rpx;
padding: 24rpx 32rpx;
box-sizing: border-box;
h3 {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #000000;
}
.address {
margin-top: 16rpx;
.address_1 {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #333333;
}
.address_2 {
margin-top: 5rpx;
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
}
.goods {
margin-top: 35rpx;
padding-top: 35rpx;
.goods_item {
display: flex;
align-items: center;
margin-top: 20rpx;
}
.goods_img {
height: 80rpx;
width: 80rpx;
background-color: #eee;
margin-right: 50rpx;
}
.goods_text {
flex: 1;
.goods_psce,
.goods_name {
display: flex;
justify-content: space-between;
align-items: center;
.name {
font-size: 24rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #333333;
}
.price {
font-size: 28rpx;
font-family: Arial-BoldMT, Arial;
font-weight: normal;
color: #000000;
}
.psce_name {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
.size {
font-size: 24rpx;
font-family: ArialMT;
color: #666666;
}
}
.goods_psce {
margin-top: 10rpx;
}
}
}
.discount {
margin-top: 24rpx;
padding-bottom: 24rpx;
border-bottom: 1rpx solid #666;
.discount_1 {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #333333;
.price {
font-family: Arial-BoldMT, Arial;
font-weight: normal;
color: #EB5F17;
}
}
.concessional_rate {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
margin-top: 18rpx;
.price {
font-family: Arial-BoldMT, Arial;
font-weight: 700;
color: #000;
}
}
}
.total {
display: flex;
align-items: center;
display: flex;
justify-content: space-between;
margin-top: 52rpx;
.size {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
.paid_in {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 600;
color: #000000;
}
.money {
font-weight: 600;
font-size: 32rpx;
color: #000000;
vertical-align: middle;
}
}
}
.order_describe {
background: #fff;
border-radius: 10rpx;
padding: 0 62rpx 24rpx;
margin-top: 32rpx;
h3 {
padding: 24rpx 0;
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #000000;
border-bottom: 1rpx solid #666;
}
.item {
margin-top: 20rpx;
.label {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
.value {
font-size: 24rpx;
font-family: ArialMT;
color: #333333;
}
}
}
.customer_service {
height: 90rpx;
line-height: 90rpx;
background: #FFFFFF;
border-radius: 10rpx;
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #000000;
padding: 0 64rpx;
margin: 32rpx 0;
display: flex;
justify-content: space-between;
}
</style>
\ No newline at end of file
<template>
<view class="pages">
<div class="shop_info">
<h3>门店确认</h3>
<div class="address">
<div class="address_1">北京朝阳建外SOHO东区A座店</div>
<div class="address_2">距您132m,请确定门店后下单</div>
</div>
<div class="take_order">
<div class="title">取单时间</div>
<div class="time">现在下单,预计 <span class="min">5</span> 分钟后取餐</div>
</div>
</div>
<div class="goods_info">
<h3>商品详情</h3>
<div class="goods" v-for="item in goods" :key="item.goodsId">
<div class="goods_item">
<image mode="aspectFit" class="goods_img" src=""></image>
<div class="goods_text">
<div class="goods_name">
<div class="name">{{ item.name }}</div>
<div class="price">¥{{ item.sku.price }}</div>
</div>
<div class="goods_psce">
<div class="psce_name">/</div>
<div class="size">x {{ item.num }}</div>
</div>
</div>
</div>
<div class="discount">
<div class="discount_1">
<div class="name">优惠免减</div>
<div class="price">- ¥{{ itemReduction(item.sku.discount, item.sku.price) }}</div>
</div>
<div class="concessional_rate">
<div class="name">特惠价</div>
<div class="price">¥{{ item.sku.discount }}</div>
</div>
</div>
</div>
<div class="total">
<div class="size">{{ totalNum }}件商品</div>
<div>
<span class="paid_in">实付</span>
<span class="money">{{ totalPrice }}</span>
</div>
</div>
</div>
<div class="Payment_method">
<div>支付方式</div>
<div class="type">
<image mode="aspectFit" src="../../../static/imgs/weixin-3.png" class="icon"></image>
<span>微信支付</span>
</div>
</div>
<div class="footer">
<div class="total">
<div class="the_sum">
<span class="name">合计</span>
<span class="price">{{ totalPrice }}</span>
</div>
<div class="sun">
<div class="price">总优惠¥{{ reduction }}</div>
</div>
</div>
<view class="payment" @click="saveReserve" v-if="userms">
付款
</view>
<button v-if="!userms" class="payment" style="border-radius: 0;" open-type="getPhoneNumber"
@getphonenumber="saveReserve">
付款
</button>
</div>
</view>
</template>
<script>
import { $EventBus } from "../../../utils/EventBus";
import Utils from '@/utils/utils'
import Menu from '@/request/menu'
export default {
onLoad(option) {
this.buyType = option.buyType;
console.log(uni.getStorageSync('shopCarInfo'));
this.goods = uni.getStorageSync('shopCarInfo') || [];
$EventBus.$on('updateCar', () => {
this.goods = uni.getStorageSync('shopCarInfo') || [];
});
},
data() {
return {
goods: [],
buyType: ''
}
},
computed: {
userms() {
return this.$store.getters.Authorization;
},
totalNum() {
let totalNum = 0;
this.goods.map(item => {
item.flag ? totalNum += item.num : totalNum += 0
})
return totalNum
},
reduction() {
let price = 0;
let discountNum = 0;
this.goods.forEach(item => {
const sku = item.sku;
if (item.flag) {
discountNum += item.num * sku.discount
price += item.num * sku.price
} else {
totalPrice += 0
price += 0
}
})
return (price - discountNum).toFixed(2)
},
totalPrice() {
let totalPrice = 0;
this.goods.forEach(item => {
const sku = item.sku;
item.flag ? totalPrice += item.num * sku.discount : totalPrice += 0
})
return totalPrice
}
},
methods: {
itemReduction(discount, price) {
return (price - discount).toFixed(2)
},
//结算组装数据发起订单
async saveReserve() {
// 组装购物车数据或者立即支付数据
let res = await Utils.AssemblyOrder(this.totalPrice, this.totalNum, this.buyType);
if (res) {
// 发起订单
let orderInfo = await Menu.saveReserve(res);
if (orderInfo && orderInfo.data.code == 200) {
let payMent = await Menu.requestPayment(orderInfo.data.data, res, this.buyType);
}
}
}
}
}
</script>
<style lang="scss" scoped>
.pages {
padding-top: 1rpx;
}
.shop_info {
width: 686rpx;
height: 306rpx;
background: #FFFFFF;
border-radius: 10rpx;
margin: 0 auto;
margin-top: 32rpx;
padding: 24rpx 32rpx;
box-sizing: border-box;
h3 {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #000000;
}
.address {
margin-top: 16rpx;
.address_1 {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #333333;
}
.address_2 {
margin-top: 5rpx;
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
}
.take_order {
margin-top: 28rpx;
padding-top: 28rpx;
border-top: 1rpx solid #666;
.title {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #000000;
}
.time {
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #333333;
.min {
color: #006ECF;
font-size: 28rpx;
font-weight: 700;
margin: 0 5rpx;
display: inline-block;
}
}
}
}
.goods_info {
width: 686rpx;
background: #FFFFFF;
border-radius: 10rpx;
margin: 0 auto;
margin-top: 32rpx;
padding: 24rpx 32rpx;
box-sizing: border-box;
h3 {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #000000;
}
.goods {
margin-top: 42rpx;
border-bottom: 1rpx solid #666;
padding-bottom: 20rpx;
.goods_item {
display: flex;
align-items: center;
}
.goods_img {
height: 80rpx;
width: 80rpx;
background-color: #eee;
margin-right: 50rpx;
}
.goods_text {
flex: 1;
.goods_psce,
.goods_name {
display: flex;
justify-content: space-between;
align-items: center;
.name {
font-size: 24rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #333333;
}
.price {
font-size: 28rpx;
font-family: Arial-BoldMT, Arial;
font-weight: normal;
color: #000000;
}
.psce_name {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
.size {
font-size: 24rpx;
font-family: ArialMT;
color: #666666;
}
}
.goods_psce {
margin-top: 10rpx;
}
}
}
.discount {
margin-top: 15rpx;
padding-top: 15rpx;
.discount_1 {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #333333;
.price {
font-family: Arial-BoldMT, Arial;
font-weight: normal;
color: #EB5F17;
}
}
.concessional_rate {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
margin-top: 18rpx;
.price {
font-family: Arial-BoldMT, Arial;
font-weight: 700;
color: #000;
}
}
}
.total {
display: flex;
align-items: center;
display: flex;
justify-content: space-between;
margin-top: 52rpx;
.size {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
.paid_in {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 600;
color: #000000;
}
.money {
font-weight: 600;
font-size: 32rpx;
color: #000000;
vertical-align: middle;
}
}
}
.Payment_method {
width: 686rpx;
height: 86rpx;
margin: 32rpx auto 0;
padding: 0 32rpx;
background: #FFFFFF;
border-radius: 10rpx;
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #333333;
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
.type {
display: flex;
align-items: center;
font-weight: 600;
.icon {
width: 32rpx;
height: 32rpx;
margin-right: 10rpx;
}
}
}
.footer {
height: 92rpx;
background: #fff;
position: fixed;
bottom: 0;
display: flex;
width: 100%;
.total {
flex: 1;
padding-left: 32rpx;
.the_sum {
.name {
font-size: 24rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #000000;
}
.price {
font-size: 28rpx;
font-family: Arial-BoldMT, Arial;
font-weight: normal;
color: #000000;
}
}
.sun {
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #FF0E00;
margin-top: 10rpx;
}
}
.payment {
width: 170rpx;
height: 100%;
background: #006ECF;
text-align: center;
line-height: 92rpx;
font-size: 32rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFFFFF;
}
}
</style>
\ No newline at end of file
{ "easycom": {
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
},
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": ""
}
}
,{
"path" : "pages/menu/menu",
"style" :
{
"navigationBarTitleText": "菜单",
"navigationStyle":"custom",
"enablePullDownRefresh": false
}
},{
"path" : "pages/order/order",
"style" :
{
"navigationBarTitleText": "订单",
"enablePullDownRefresh": false
}
{
"easycom": {
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
},
"pages": [
//pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "pages/menu/menu",
"style": {
"navigationBarTitleText": "菜单",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/order/order",
"style": {
"navigationBarTitleText": "订单",
"enablePullDownRefresh": false
}
},
{
"path": "pages/mine/mine",
"style": {
"navigationBarTitleText": "我的",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
}
],
"subPackages": [
{
"root": "menuSubPackage",
"pages": [
{
"path": "pages/goodsDetail/goodsDetail",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/areaSelect/areaSelect",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
,{
"path" : "pages/mine/mine",
"style" :
{
"navigationBarTitleText": "我的",
"navigationStyle":"custom",
"enablePullDownRefresh": false
}
]
},
{
"root": "orderSubPackage",
"pages": [
{
"path": "pages/settlement/index",
"style": {
"navigationBarTitleText": "订单结算",
"enablePullDownRefresh": false
}
},
{
"path": "pages/orderInfo/index",
"style": {
"navigationBarTitleText": "订单详情",
"enablePullDownRefresh": false
}
}
],
"subPackages": [
{
"root": "menuSubPackage",
"pages": [
{
"path" : "pages/goodsDetail/goodsDetail",
"style" :
{
"navigationBarTitleText": "",
"navigationStyle":"custom",
"enablePullDownRefresh": false
}
}
,{
"path" : "pages/areaSelect/areaSelect",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
,{
"path" : "pages/settlement/settlement",
"style" :
{
"navigationBarTitleText": "订单结算",
"enablePullDownRefresh": false
}
}
]
},
{
"root": "orderSubPackage",
"pages": [
{
"path": "pages/demo/demo",
"style": {
// "navigationBarBackgroundColor": "",
// "navigationBarTitleText": "",
"enablePullDownRefresh": false
// "navigationStyle":"custom"
}
}
]
},
{
"root": "mineSubPackage",
"pages": [
{
"path": "pages/demo/demo",
"style": {
// "navigationBarBackgroundColor": "",
// "navigationBarTitleText": "",
"enablePullDownRefresh": false
// "navigationStyle":"custom"
}
}
]
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "HOOLOO",
"navigationBarBackgroundColor": "#ffffff",
"backgroundColor": "#ffffff"
},
"tabBar": {
"custom":true,
"list": [
{
"pagePath": "pages/menu/menu"
},{
"pagePath": "pages/order/order"
}, {
"pagePath": "pages/mine/mine"
}
]
}
]
},
{
"root": "mineSubPackage",
"pages": []
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "HOOLOO",
"navigationBarBackgroundColor": "#ffffff",
"backgroundColor": "#ffffff"
},
"tabBar": {
"custom": true,
"list": [
{
"pagePath": "pages/menu/menu"
},
{
"pagePath": "pages/order/order"
},
{
"pagePath": "pages/mine/mine"
}
]
}
}
......@@ -4,99 +4,99 @@
</template>
<script>
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 {
id:''
}
},
onLoad(options) {
this.id='';
this.$store.commit('setOrderId','');
if(options.q){
let url=decodeURIComponent(options.q);
this.id=url.split('/')[url.split('/').length-1];
this.$store.commit('setOrderId',this.id);
}
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 {
id: ''
}
},
onLoad(options) {
this.id = '';
this.$store.commit('setOrderId', '');
if (options.q) {
let url = decodeURIComponent(options.q);
this.id = url.split('/')[url.split('/').length - 1];
this.$store.commit('setOrderId', this.id);
}
// this.id=1;
},
async onShow() {
// let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
// let curRoute = routes[routes.length - 1].route //获取当前页面路由
//   let curParam = routes[routes.length - 1].options;
//  console.log(curParam)
let Authorization=uni.getStorageSync(`Authorization`);
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}&buyType=3`
})
}else{
uni.reLaunch({
url:'/pages/menu/menu'
})
}
}else{
uni.removeStorageSync('Authorization');
uni.removeStorageSync('userPhoneInfo');
if(this.id!=''){
let _this = this;
uni.showToast({
title:'请授权登录',
icon:'error',
},
async onShow() {
// let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
// let curRoute = routes[routes.length - 1].route //获取当前页面路由
//   let curParam = routes[routes.length - 1].options;
//  console.log(curParam)
let Authorization = uni.getStorageSync(`Authorization`);
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}&buyType=3`
})
} else {
uni.reLaunch({
url: '/pages/menu/menu'
})
}
} else {
uni.removeStorageSync('Authorization');
uni.removeStorageSync('userPhoneInfo');
if (this.id != '') {
let _this = this;
uni.showToast({
title: '请授权登录',
icon: 'error',
success() {
setTimeout(()=>{
setTimeout(() => {
uni.reLaunch({
url:'/pages/menu/menu?orderId='+_this.id
url: '/pages/menu/menu?orderId=' + _this.id
})
},1500)
}, 1500)
}
})
}else{
uni.reLaunch({
url:'/pages/menu/menu'
})
}
})
} else {
uni.reLaunch({
url: '/pages/menu/menu'
})
}
},
methods: {
}
},
methods: {
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>
<template>
<view>
<view class="pages">
<view class="menu-banner">
<view class="log">
<image class="logImg" src="/static/imgs/hooloo.png"></image>
<view class="logText">未 来 咖 啡</view>
</view>
<image src="../../static/imgs/banner.png"></image>
</view>
<view class="mod11 flex-col">
<view class="box16 flex-col"></view>
<text class="txt6">小黑山羊</text>
<view class="right_arrow">
<u-icon name="arrow-right" color="#fff" size="14"></u-icon>
</view>
</view>
<view class="contents">
<view class="myOrder">
<view class="order1">我的订单</view>
<view class="order2">点击查看订单</view>
<view>
<image class="orderImg" src="../../static/imgs/myOrder.png">
</image>
</view>
</view>
<view class="right_box">
<view class="box">
<view class="left">
<h3>HOOLOO券</h3>
<view class="dec">优惠多多不要错过</view>
</view>
<view class="right">
<image class="right_img" src="../../static/imgs/my3.png"></image>
</view>
</view>
<view class="box two">
<view class="left">
<h3>我的消息</h3>
<view class="dec">点击查看我的消息</view>
</view>
<view class="right">
<image class="right_img" src="../../static/imgs/myMail.png"></image>
</view>
</view>
</view>
</view>
<view class="function">
<h3>常用功能</h3>
<view class="function_item">
<u-icon name="server-fill" color="#000000" size="16"></u-icon>
<text class="function_item_text">联系客服</text>
<u-icon name="arrow-right" class="function_item_icon" color="#000000" size="16"></u-icon>
</view>
</view>
<tabBar :selectedTabbar="selectedTabbar"></tabBar>
</view>
</template>
......@@ -36,7 +81,7 @@ export default {
.log {
position: absolute;
z-index: 99;
top: 100rpx;
left: 30rpx;
......@@ -62,4 +107,158 @@ export default {
}
}
.mod11 {
margin: 0 auto;
width: 692rpx;
height: 144rpx;
background: rgba(255, 255, 255, 0.2);
border-radius: 10rpx;
backdrop-filter: blur(10rpx);
display: flex;
align-items: center;
margin-top: -72rpx;
padding: 0 30rpx;
box-sizing: border-box;
color: #fff;
.right_arrow {
margin-left: auto;
}
.txt6 {
margin-left: 20rpx;
}
.box16 {
width: 80rpx;
height: 80rpx;
background: #FF72C1;
box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(50, 50, 50, 0.25);
border-radius: 4rpx;
}
}
.contents {
display: flex;
align-items: center;
margin: 34rpx auto;
width: 692rpx;
.myOrder {
width: 270rpx;
height: 272rpx;
background: #FFFFFF;
border-radius: 10rpx;
text-align: center;
.order1 {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #000000;
margin-top: 25rpx;
}
.order2 {
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #323232;
margin-top: 10rpx;
}
.orderImg {
width: 70rpx;
height: 80rpx;
margin: 0 auto;
margin-top: 50rpx;
}
}
.right_box {
margin-left: 20rpx;
}
.box {
width: 396rpx;
height: 128rpx;
background: #FFFFFF;
border-radius: 10rpx;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 36rpx;
&.two {
margin-top: 15rpx;
}
.left {
text-align: center;
}
h3 {
font-size: 28rpx;
font-family: Arial-BoldMT, Arial;
font-weight: 700;
color: #000000;
}
.dec {
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #323232;
margin-top: 10rpx
}
.right_img {
width: 80rpx;
height: 55rpx;
}
}
}
.function {
width: 692rpx;
background: #FFFFFF;
border-radius: 10rpx;
margin: 0 auto;
padding: 25rpx;
box-sizing: border-box;
h3 {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #000000;
}
.function_item {
font-size: 24rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #000000;
line-height: 34rpx;
display: flex;
align-items: center;
margin-top: 20rpx;
.function_item_text {
margin-left: 10rpx;
}
.function_item_icon {
margin-left: auto;
}
}
}
</style>
\ No newline at end of file
<template>
<view>
<tabBar :selectedTabbar="selectedTabbar"></tabBar>
<view class="pages">
<view class="orders">
<view class="order_item" v-for="item in list" :key="item.id" @click="openInfo(item)">
<view class="order_header">
<view>
<h3 class="order_adrass">{{ item.shop.name }}</h3>
<text class="order_time">{{ item.shop.payTime }}</text>
</view>
<view class="order_status" v-if="item.state == 0">创建未校验</view>
<view class="order_status" v-if="item.state == 1">未支付</view>
<view class="order_status" v-if="item.state == 2">排队中</view>
<view class="order_status" v-if="item.state == 3">制作中</view>
<view class="order_status" v-if="item.state == 4">制作完成</view>
<view class="order_status" v-if="item.state == 5">待取超时</view>
<view class="order_status" v-if="item.state == 6">完成</view>
<view class="order_status" v-if="item.state == 7">取消</view>
<view class="order_status" v-if="item.state == 8">取消</view>
<view class="order_status" v-if="item.state == 9">取消</view>
<view class="order_status" v-if="item.state == 10">取消</view>
<view class="order_status" v-if="item.state == 11">已退款</view>
<view class="order_status" v-if="item.state == 12">部分退款</view>
</view>
<view class="order_content">
<view class="goods_item" v-for="good in item.orderDetails" :key="good.id">
<image class="goods_img" :src="jsonParse(good.goods.pics).thumbnail"></image>
<view class="goods_text">
<view class="goods_title">{{ good.goodsName }}×{{ good.num }}</view>
<view class="goods_spce">
<span v-for="rule in jsonParse(good.specRuleDetail)" :key="rule.specId">
{{ rule.ruleName }}/
</span>
</view>
</view>
</view>
</view>
<view class="order_footer">
<view class="total">
共1件商品 合计: <text class="price">¥10.00</text>
</view>
<!-- <a class="btn" type="primary">再来一单</a> -->
</view>
</view>
</view>
<tabBar :selectedTabbar="selectedTabbar"></tabBar>
</view>
</template>
<script>
export default {
name:'order',
data() {
return {
selectedTabbar:1,//选中的tab
}
},
computed:{
import order from '@/request/order'
export default {
name: 'order',
data() {
return {
selectedTabbar: 1,//选中的tab
list: []
}
},
async onLoad() {
const { data } = await order.getMyOrder();
this.list = data.rows
},
async onShow() {
const { data } = await order.getMyOrder();
this.list = data.rows
},
methods: {
openInfo(data) {
uni.setStorageSync('orderInfo', data);
let url = '/orderSubPackage/pages/orderInfo/index'
// : '/orderSubPackage/pages/settlement/index'
uni.navigateTo({ url })
},
methods: {
jsonParse(json) {
return JSON.parse(json)
}
}
}
</script>
<style>
<style lang="scss" scoped>
.orders {
padding: 1rpx;
.order_item {
width: 686rpx;
min-height: 370rpx;
background: #FFFFFF;
border-radius: 10rpx;
margin: 15rpx auto 0;
box-sizing: border-box;
padding: 28rpx 32rpx;
.order_header {
display: flex;
justify-content: space-between;
.order_adrass {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #000000;
}
.order_time {
font-size: 20rpx;
font-family: ArialMT;
color: #666666;
}
.order_status {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 500;
color: #000000;
margin-top: 10rpx;
}
}
.order_content {
margin-top: 38rpx;
.goods_item {
display: flex;
align-items: center;
margin-top: 10rpx;
.goods_img {
height: 80rpx;
width: 80rpx;
background-color: #eee;
}
.goods_text {
margin-left: 38rpx;
.goods_title {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #000000;
}
.goods_spce {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
margin-top: 6rpx;
}
}
}
}
.order_footer {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 50rpx;
.total {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
.price {
color: #FF5200;
font-weight: 700
}
}
.btn {
width: 144rpx;
height: 48rpx;
line-height: 48rpx;
background: #006ECF;
border-radius: 6rpx;
font-size: 24rpx;
margin: 0;
color: #fff;
text-align: center;
}
}
}
</style>
}
</style>
\ No newline at end of file
import appConfig from '@/static/config/index.js';
export function getBaseUrl() {
if (process.env.NODE_ENV === 'development') {
console.log(121)
return appConfig.devApi;
} else {
return appConfig.prodApi;
}
if (process.env.NODE_ENV === 'development') {
return appConfig.devApi;
} else {
return appConfig.prodApi;
}
}
module.exports = (vm) => {
console.log(vm.$store)
uni.$u.http.setConfig((config) => {
config.baseURL= getBaseUrl();
uni.$u.http.setConfig((config) => {
config.baseURL = getBaseUrl();
// showLoading: process.env.NODE_ENV === 'development',
config.method= 'POST';
config.method = 'POST';
// 设置为json,返回后会对数据进行一次JSON.parse()
config.dataType = 'json';
config.timeout = 3000; // 在此时间内,请求还没回来的话,就显示加载中动画,单位ms
// 配置请求头信息
config.header= {
'Content-Type': 'application/json' // 'application/x-www-form-urlencoded'
}
config.header = {
'Content-Type': 'application/json', // 'application/x-www-form-urlencoded'
};
return config;
});
// 请求拦截
uni.$u.http.interceptors.request.use((config) => { // 可使用async await 做异步操作
uni.showLoading({
});
// 请求拦截
uni.$u.http.interceptors.request.use(
(config) => {
// 可使用async await 做异步操作
uni.showLoading({
title: '加载中',
mask: true,
});
let Authorization = uni.getStorageSync(`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);
});
let Authorization = uni.getStorageSync(`Authorization`);
const configUrl = [
'/weixin/login',
'/weixin/getShop',
'/weixin/infoByShop',
'/application/getData',
];
if (Authorization && configUrl.indexOf(config.url) == -1) {
config.header.Authorization = Authorization;
}
console.log(config, 4444);
if (!Authorization) {
// 如果token不存在,return Promise.reject(config) 会取消本次请求
// return Promise.reject(config);
}
return config;
},
(config) => {
// 可使用async await 做异步操作
return Promise.reject(config);
}
return config
}, config => { // 可使用async await 做异步操作
return Promise.reject(config)
});
// 响应拦截
uni.$u.http.interceptors.response.use((response) => {
uni.hideLoading();
/* 对响应成功做点什么 可使用async await 做异步操作*/
if (response.data.code !== 200) { // 服务端返回的状态码不等于200,则reject()
);
// 响应拦截
uni.$u.http.interceptors.response.use(
(response) => {
uni.hideLoading();
/* 对响应成功做点什么 可使用async await 做异步操作*/
if (response.data.code !== 200) {
// 服务端返回的状态码不等于200,则reject()
uni.showToast({
title: response.data.msg,
icon: 'none',
duration: 2000
})
return Promise.reject(response)
} // return Promise.reject 可使promise状态进入catch
console.log(response)
return response
}, (response) => {
uni.hideLoading();
/* 对响应错误做点什么 (statusCode !== 200)*/
console.log(response)
return Promise.reject(response)
});
}
\ No newline at end of file
title: response.data.msg,
icon: 'none',
duration: 2000,
});
return Promise.reject(response);
} // return Promise.reject 可使promise状态进入catch
return response;
},
(response) => {
uni.hideLoading();
/* 对响应错误做点什么 (statusCode !== 200)*/
console.log(response);
return Promise.reject(response);
}
);
};
export default{
valiFrequency(id) {
}
}
\ No newline at end of file
export default {
getMyOrder() {
return uni.$u.http
.get('/app/getMyOrder', {
params: {},
})
.then((res) => res)
.catch((err) => uni.showToast({ title: '服务器错误', icon: 'none' }));
},
orderRefund(data) {
return uni.$u.http
.post('/system/refund', data)
.then((res) => res)
.catch((err) => uni.showToast({ title: '服务器错误', icon: 'none' }));
},
};
import Store from '@/store'
import Store from '@/store';
import { $EventBus } from '../../utils/EventBus';
export default{
getLocation() {
let _this = this;
return uni.getLocation({
type: 'gcj02', //返回可以用于uni.openLocation的经纬度
success: function (res) {
console.log(res, 'res')
var params = {
lat: res.latitude,
lng: res.longitude
}
Store.commit('saveLocation',params);
// return params;
_this.getAddress(params);
},
fail: function (res) {
console.log(res,3333)
uni.showToast({
title: '获取地址失败,将导致部分功能不可用',
icon: 'none'
});
}
})
},
// 获取具体位置店铺/weixin/getShop
getAddress(params) {
return uni.$u.http.get('/weixin/getShop',{
params
}).then((res)=>{
if(res.data.code==200){
console.log(res.data.data,12345678)
Store.commit('saveShopInfo', res.data.data);
if (res.data.data.length){
$EventBus.$emit('getMenuList', res.data.data[0])
}
}
return res;
}).catch(err=>{
return err;
});
},
// 通过地址选择店铺xxxx
// getAddress(params) {
// return uni.$u.http.get('/weixin/getShop', {
// params
// }).then((res) => {
// if (res.data.code == 200) {
// console.log(res.data.data, 12345678)
// Store.commit('saveShopInfo', res.data.data);
// }
// return res;
// }).catch(err => {
// return err;
// });
// },
uniLogin(res,orderId) {
uni.login({
provider: 'weixin',
success: function (data) {
// 传给后台接口所需登录数据
uni.$u.http.post('/weixin/login', {
code: data.code,
source: 3, //默认是3,扫码进来是2
iv: res.iv,
encryptedData: res.encryptedData
}).then((response) => {
if (response.statusCode == 200 && response.data && response.data.code==200) {
uni.setStorage({key:'Authorization',data:response.data.token});
Store.commit('setAuthorization', response.data.token);
uni.showToast({
title:'登录成功',
success() {
setTimeout(()=>{
// 如果扫码进来的带有orderId则授权成功之后跳入结算页面
if (orderId) {
uni.navigateTo({
url: '/menuSubPackage/pages/settlement/settlement?orderId=' + orderId
})
}
},1500)
}
});
}
}).catch((err) => {
uni.showToast({
title: err.msg
});
})
}
})
},
// 手机号授权登录
getPhoneNumber(res,orderId) {
console.log(res,'还是手机号参数吗')
uni.setStorage({
key: 'userPhoneInfo',
data: res
})
Store.commit("setUserPhoneInfo", res);
this.uniLogin(res.detail,orderId);
},
async uniGetUserInfo(e) {
uni.getUserProfile({ //授权后可以通过uni.getUserProfile得到用户信息
lang: "zh_CN",
desc: '用于完善用户信息',
success: res => {
uni.setStorage({key:'userInfo', data:res})
Store.commit("setUserInfo",res)
// this.uniLogin(res);
export default {
getLocation() {
let _this = this;
return uni.getLocation({
type: 'gcj02', //返回可以用于uni.openLocation的经纬度
success: function (res) {
console.log(res, 'res');
var params = {
lat: res.latitude,
lng: res.longitude,
};
Store.commit('saveLocation', params);
// return params;
_this.getAddress(params);
},
fail: function (res) {
console.log(res, 3333);
uni.showToast({
title: '获取地址失败,将导致部分功能不可用',
icon: 'none',
});
},
});
},
// 获取具体位置店铺/weixin/getShop
getAddress(params) {
return uni.$u.http
.get('/weixin/getShop', {
params,
})
.then((res) => {
if (res.data.code == 200) {
console.log(res.data.data, 12345678);
Store.commit('saveShopInfo', res.data.data);
if (res.data.data.length) {
$EventBus.$emit('getMenuList', res.data.data[0]);
}
}
return res;
})
.catch((err) => {
return err;
});
},
// 通过地址选择店铺xxxx
// getAddress(params) {
// return uni.$u.http.get('/weixin/getShop', {
// params
// }).then((res) => {
// if (res.data.code == 200) {
// console.log(res.data.data, 12345678)
// Store.commit('saveShopInfo', res.data.data);
// }
// return res;
// }).catch(err => {
// return err;
// });
// },
uniLogin(res, orderId) {
uni.login({
provider: 'weixin',
success: function (data) {
// 传给后台接口所需登录数据
uni.$u.http
.post('/weixin/login', {
code: data.code,
source: 3, //默认是3,扫码进来是2
iv: res.iv,
encryptedData: res.encryptedData,
})
.then((response) => {
if (response.statusCode == 200 && response.data && response.data.code == 200) {
uni.setStorage({ key: 'Authorization', data: response.data.token });
Store.commit('setAuthorization', response.data.token);
uni.showToast({
title: '登录成功',
success() {
setTimeout(() => {
// 如果扫码进来的带有orderId则授权成功之后跳入结算页面
if (orderId) {
uni.navigateTo({
url: '/menuSubPackage/pages/settlement/settlement?orderId=' + orderId,
});
} else {
}
})
}, 1500);
},
});
}
}
\ No newline at end of file
})
.catch((err) => {
uni.showToast({
title: err.msg,
});
});
},
});
},
// 手机号授权登录
getPhoneNumber(res, orderId) {
uni.setStorage({
key: 'userPhoneInfo',
data: res,
});
Store.commit('setUserPhoneInfo', res);
this.uniLogin(res.detail, orderId);
},
async uniGetUserInfo(e) {
uni.getUserProfile({
//授权后可以通过uni.getUserProfile得到用户信息
lang: 'zh_CN',
desc: '用于完善用户信息',
success: (res) => {
uni.setStorage({ key: 'userInfo', data: res });
Store.commit('setUserInfo', res);
// this.uniLogin(res);
},
});
},
};
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');
let s = 0;
shopCarInfo.forEach(function (val) {
s += val.num;
}, 0);
if (s >= 9) {
uni.showToast({
title: '最多可一次购买9杯',
icon: 'none'
});
return;
}
console.log(shopCarInfo,'oooooo')
if (shopCarInfo){
let currentGoods = shopCarInfo.find(v => v.goodsId == Obj.goodsId && v.skuId == Obj.skuId);
if (currentGoods){
console.log(currentGoods,'pppppp')
currentGoods.num+=1;
}else{
shopCarInfo.push(Obj);
}
console.log(shopCarInfo,7777)
}else{
shopCarInfo = [Obj];
}
uni.setStorageSync('shopCarInfo', shopCarInfo);
$EventBus.$emit('updateCar');
},
// 解密手机
async onGetPhoneNumber(appid,session_key,encryptedData,iv) {
let pc = await new WXBizDataCrypt(appid,session_key);
let data = await pc.decryptData(encryptedData ,iv);
return data;
},
// 扫码方法
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:'扫码失败'
})
}
});
},
formatDate(value) {
var date = new Date();
date.setTime(value);
var month = date.getMonth() + 1;
if (month < 10)
month = "0" + month;
var cdate = date.getDate();
if (cdate < 10)
cdate = "0" + cdate;
var hours = date.getHours();
if (hours < 10)
hours = "0" + hours;
var minutes = date.getMinutes();
if (minutes < 10)
minutes = "0" + minutes;
var time = date.getFullYear() + "-" + month + "-" + cdate +
" " + hours + ":" + minutes;
return time;
},
numberFixed(data,fixed=2){
if(data==undefined){
return undefined
}else if(data == 0){
return '0'
}else{
return (Math.round(Number(data) * Math.pow(10,fixed)) / Math.pow(10,fixed)).toFixed(fixed);
}
}
}
\ No newline at end of file
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.sku.discount * item.num, //实付金额
specRuleDetail: JSON.stringify(item.sku.rules), //规格选项详情
specRuleIds: item.sku.rules.map((item) => item.ruleId).join(','), //规格选项详情
skuId: item.skuId, //"sku ID"
goodsCategory: item.categoryId, //商品分类
};
orderDetails.push(res);
}
let DAta = {
amount: totalPrice, //商品总金额
goodsNum: totalNum, //商品总数量
shopId: '12', //店铺
machineId: undefined, //机器ID
source: 3, //小程序固定传3
orderDetails: orderDetails,
};
return DAta;
} else {
uni.showToast({
title: '请选择商品',
});
}
},
// 加入购物车数据
getallNum(Obj) {
let shopCarInfo = uni.getStorageSync('shopCarInfo') || [];
let size = 0;
shopCarInfo.forEach((item) => (size += item.num), 0);
if (size >= 9) {
uni.showToast({
title: '最多可一次购买9杯',
icon: 'none',
});
return;
}
if (shopCarInfo) {
let currentGoods = shopCarInfo.find((v) => v.goodsId == Obj.goodsId && v.skuId == Obj.skuId);
if (currentGoods) {
currentGoods.num += 1;
} else {
shopCarInfo.push(Obj);
}
} else {
shopCarInfo = [Obj];
}
uni.setStorageSync('shopCarInfo', shopCarInfo);
console.log(shopCarInfo);
$EventBus.$emit('updateCar');
},
// 解密手机
async onGetPhoneNumber(appid, session_key, encryptedData, iv) {
let pc = await new WXBizDataCrypt(appid, session_key);
let data = await pc.decryptData(encryptedData, iv);
return data;
},
// 扫码方法
scanCode() {
uni.scanCode({
success: (res) => {
this.scaninfo = res;
if (res.result) {
if (res.result.includes(Config.AVScanUrl)) {
uni.reLaunch({
url: `/pages/index/index?q=${res.result}`,
});
} else {
uni.showToast({
title: '二维码错误',
icon: 'none',
});
}
}
},
fail() {
uni.showToast({
icon: 'none',
title: '扫码失败',
});
},
});
},
formatDate(value) {
var date = new Date();
date.setTime(value);
var month = date.getMonth() + 1;
if (month < 10) month = '0' + month;
var cdate = date.getDate();
if (cdate < 10) cdate = '0' + cdate;
var hours = date.getHours();
if (hours < 10) hours = '0' + hours;
var minutes = date.getMinutes();
if (minutes < 10) minutes = '0' + minutes;
var time = date.getFullYear() + '-' + month + '-' + cdate + ' ' + hours + ':' + minutes;
return time;
},
numberFixed(data, fixed = 2) {
if (data == undefined) {
return undefined;
} else if (data == 0) {
return '0';
} else {
return (Math.round(Number(data) * Math.pow(10, fixed)) / Math.pow(10, fixed)).toFixed(fixed);
}
},
};
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