Commit 4c23005f by 张成

update

parent 48673cc2
......@@ -3,8 +3,11 @@
@import "uview-ui/index.scss";
</style>
<script>
import Store from '@/store';
export default {
onLaunch: function () {
Store.commit('setAuthorization', uni.getStorageSync('Authorization'))
Store.commit('setUserInfo', uni.getStorageSync('userInfo'))
// uni.showLoading({
// title: '加载中...',
// mask:true
......@@ -15,11 +18,7 @@ export default {
},
onHide: function () {
},
methods: {
unilogin() {
}
}
}
</script>
......@@ -27,7 +26,7 @@ export default {
/*每个页面公共css */
.pages {
background: #F2F2F2;
min-height: calc(100vh - 100rpx);
min-height: 100vh;
}
* {
......
<template>
<div>
<u-popup :show="show" :round="10" closeable mode="bottom" @close="close">
<div class="order_flow">
<div class="code">取单码 {{ orderInfo.orderNum }}</div>
<image mode="scaleToFill" :src="qrCode" 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="flow_describe">
<h3>注意事项</h3>
<view class="text">
<view>*热饮温度高,推荐使用纸吸管,纸吸管体验更佳。拿到后请小心饮用,吸入时请注意烫口喔</view>
<view>*冷饮如选择冰块分装,冰块分装后饮品将不满杯,敬请谅解。</view>
<view>*冷饮去冰如选择椰椰雪糕,默认分装椰椰雪糕,敬请谅解</view>
</view>
</div>
</div>
</u-popup>
</div>
</template>
<script>
export default {
data() {
return {
orderInfo: {},
qrCode: '',
show: false,
}
},
onLoad() {
},
methods: {
close() {
this.show = false
},
open(data, path) {
this.show = true
this.orderInfo = data;
this.qrCode = path
},
jsonParse(json) {
return JSON.parse(json)
},
}
}
</script>
<style lang="scss" scoped>
.pages {
padding-top: 1rpx;
padding-bottom: 30rpx;
}
.text {
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #333333;
line-height: 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;
}
.btns {
text-align: center;
display: flex;
align-items: center;
justify-content: center;
}
.btn {
width: 160rpx;
height: 52rpx;
background: #006ECF;
border-radius: 6rpx;
display: inline-block;
margin: 20rpx;
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: 308rpx;
height: 310rpx;
display: block;
margin: 25rpx auto;
background-color: #ccc;
}
.flow_describe {
width: 686rpx;
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;
}
}
}
.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
......@@ -30,9 +30,9 @@
<view class="size">
<text style="font-size: 28rpx;color: #000000;">{{ item.name }}</text>
<text style="font-size:20rpx;color:#666666">
<text v-for="(rl, index) in item.skus[0].rules" :key="rl.ruleName">
<text v-for="(rl, index) in item.sku.rules" :key="rl.ruleName">
{{ rl.ruleName }}
<text v-if="index != item.skus.rules.length - 1">/</text>
<text v-if="index != item.sku.rules.length - 1">/</text>
</text>
</text>
<text>
......@@ -56,9 +56,9 @@
</u-popup>
<view class="end" v-if="goods.length">
<view class="end-left">
<view @click.stop="openShopCar" class="end-left">
<view style="display:flex">
<view class="car-img" @click.stop="openShopCar">
<view class="car-img">
<text class="badge" v-if="totalNum">{{ totalNum }}</text>
</view>
<text class="shopClassStyle">{{ totalPrice.toFixed(2) }}</text>
......@@ -143,7 +143,7 @@ export default {
uni.showToast({ title: '已拒绝手机号授权', icon: 'error' })
}
},
change(e) { console.log(e) },
change(e) { },
selected(item) {
item.flag = !item.flag
if (!item.flag) {
......@@ -183,7 +183,7 @@ export default {
add(item) {
let s = 0;
this.goods.forEach(function (val) {
s += val.num;
s += Number(val.num);
}, 0);
if (s >= 9) {
uni.showToast({
......@@ -192,7 +192,7 @@ export default {
});
return;
}
let num = item.num
let num = Number(item.num)
item.num = num + 1
uni.setStorageSync('shopCarInfo', this.goods);
}
......@@ -384,7 +384,7 @@ export default {
height: 92rpx;
background-color: rgb(253, 253, 253);
position: fixed;
bottom: 50px;
bottom: 0;
left: 0;
display: flex;
z-index: 10075;
......
<template>
<!-- Tab -->
<u-tabbar zIndex="10075" v-model="selectedTabbar" :border="false" inactive-color="#000000" height="50" active-color="#006ECF" :fixed="true" :safeAreaInsetBottom="true" @change="beforeSwitch">
<u-tabbar-item v-for="(item,index) in list" :key="item.text" :text="item.text" :icon="selectedTabbar==index?item.activeIcon:item.icon"></u-tabbar-item>
</u-tabbar>
<u-tabbar zIndex="10075" v-model="selectedTabbar" :border="false" inactive-color="#000000" height="50"
active-color="#006ECF" :fixed="true" :safeAreaInsetBottom="true" @change="beforeSwitch">
<u-tabbar-item v-for="(item, index) in list" :key="item.text" :text="item.text"
:icon="selectedTabbar == index ? item.activeIcon : item.icon"></u-tabbar-item>
</u-tabbar>
</template>
<script>
export default {
data() {
return {
}
return {}
},
props: ['selectedTabbar'],
computed: {
......@@ -21,7 +21,9 @@ export default {
},
methods: {
//点击tab
beforeSwitch(index) {
uni.switchTab({ url: this.list[index].pagePath });
return true;
}
......
import App from './App'
import App from './App';
//引入vuex
import store from './store'
import utils from './utils/utils'
import store from './store';
import utils from './utils/utils';
// console.log(Vue.$u,22)
// 需要在Vue.use(uView)之后执行
// #ifndef VUE3
import Vue from 'vue'
import Vue from 'vue';
import uView from 'uview-ui';
import User from '@/request/user';
Vue.use(uView);
Vue.prototype.$utils = utils
Vue.config.productionTip = false
App.mpType = 'app'
Vue.prototype.$utils = utils;
Vue.prototype.setPrice = (price) => price && Number(price).toFixed(2);
Vue.prototype.loginByPhoneNumber = (e) => {
if (e.detail.errMsg == 'getPhoneNumber:ok') {
User.getPhoneNumber(e);
} else if (e.detail.errMsg == 'getPhoneNumber:fail user deny') {
uni.showToast({ title: '已拒绝手机号授权', icon: 'error' });
}
};
Vue.config.productionTip = false;
App.mpType = 'app';
const app = new Vue({
...App,
store
})
app.$mount()
require('./request/index')(app);
...App,
store,
});
app.$mount();
require('./request/index')(app);
// #endif
// #ifdef VUE3
import { createSSRApp } from 'vue'
import { createSSRApp } from 'vue';
export function createApp() {
const app = createSSRApp(App)
const app = createSSRApp(App);
return {
app
}
app,
};
}
// #endif
\ No newline at end of file
// #endif
<template>
<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 ew class="product-list">
<div v-for="item in list" :key="item.id" @click="selectedShop(item)" class="shop_item">
<div class="header">
<h3>{{ item.name }}</h3>
<span>距离 {{ item.distance }}</span>
</div>
<div class="dec">
<div class="address">{{ item.address }}</div>
<a class="xaidan">去下单</a>
</div>
<div class="time">
<u-icon name="clock" color="#2979ff" size="16"></u-icon>
<div>营业时间:{{ item.startTime }} - {{ item.endTime }}</div>
</div>
</div>
</view>
</template>
<script>
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)
}
import { $EventBus } from '@/utils/EventBus';
export default {
data() {
return {
show: true,
columns: [],
list: []
}
}
},
onShow() {
this.list = uni.getStorageSync('shops');
},
methods: {
selectedShop(item) {
uni.setStorage({ key: 'shopData', data: item });
uni.switchTab({ url: '/pages/menu/menu' })
$EventBus.$emit('getMenuList', item);
}
},
}
</script>
<style lang="scss" scoped>
.product-list{
.shop_item {
width: 90%;
height: 264rpx;
background: #FFFFFF;
border-radius: 10rpx;
border: 2rpx solid #006ECF;
padding: 32rpx;
box-sizing: border-box;
margin: 30rpx auto;
.header {
display: flex;
align-items: center;
justify-content: space-between;
h3 {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #000000;
}
span {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
}
.dec {
display: flex;
justify-content: space-between;
margin-top: 22rpx;
.address {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFa
}
.xaidan {
font-size: 24rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFFFFF;
width: 188rpx;
text-align: center;
height: 40rpx;
line-height: 40rpx;
background: #006ECF;
border-radius: 6px;
display: block;
margin-left: 20rpx;
}
}
.time {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #333333;
margin-top: 30rpx;
}
}
</style>
\ No newline at end of file
......@@ -2,30 +2,44 @@
<view class="spec-content">
<view v-if="goodInfo">
<view class="uni-margin-wrap">
<swiper class="swiper">
<swiper v-if="goodInfo.pics.introImagesApplet" class="swiper">
<swiper-item v-for="item in goodInfo.pics.introImagesApplet" :key="item">
<image :src="item" class="swiper_img" mode="scaleToFill"></image>
</swiper-item>
</swiper>
<swiper v-else class="swiper">
<swiper-item v-for="item in goodInfo.pics.introImages" :key="item">
<image :src="item" class="swiper_img" mode="aspectFit"></image>
<image :src="item" class="swiper_img" mode="scaleToFill"></image>
</swiper-item>
</swiper>
</view>
<view class="good spec-info-left">
<text class="good-name">{{ goodInfo.name }}</text>
<view class="specs">
<!-- 规格 -->
<view v-for="specItem in goodInfo.specs" :key="specItem.specId">
<view class="good-spec-name">{{ specItem.specName }}</view>
<view class="good-spec-rule">
<view class="good-spec-rule-item" v-for="specItemRule in specItem.rules"
@click="selectRoles(specItemRule, specItem)" :class="{ active: isActvie(specItemRule) }"
:key="specItemRule.ruleId">
<view>{{ specItemRule.ruleName }}</view>
</view>
<div v-for="specItemRule in specItem.rules" class="div_item" :key="specItemRule.ruleId">
<div v-if="setDefaultStyle(specItemRule.ruleId)" class="default"></div>
<button class="good-spec-rule-item" :disabled="UseIt(specItemRule.ruleId)"
@click="selectRoles(specItemRule, specItem)"
:class="{ active: isActvie(specItemRule) }">
<view>{{ specItemRule.ruleName }}</view>
</button>
</div>
</view>
</view>
</view>
</view>
<view class="spec-detail">
<view class="spec-detail-title spec-info-left">商品详情</view>
<view class="spec-detail-img" v-for="item in goodInfo.pics.detailImages" :key="item">
<view v-if="goodInfo.pics.detailImagesApplet">
<view class="spec-detail-img" v-for="item in goodInfo.pics.detailImagesApplet" :key="item">
<image class="spec-detail-img-item" :src="item" mode="scaleToFill"></image>
</view>
</view>
<view v-else class="spec-detail-img" v-for="item in goodInfo.pics.detailImages" :key="item">
<image class="spec-detail-img-item" :src="item" mode="scaleToFill"></image>
</view>
<!-- 底部空白 -->
......@@ -34,18 +48,27 @@
<view class="good-select good-select-height">
<view class="good-select-price">
<text class="good-select-price-normal">¥100</text>
<text class="good-select-price-small">¥10</text>
<div>
<text class="good-select-price-normal">{{ priceTotal.discount }}</text>
<text class="good-select-price-small">{{ priceTotal.price }}</text>
</div>
<div v-if="!size > 0">已售罄</div>
<div v-else class="set_size">
<u-icon name="minus-circle" @click="reduceGood" color="#2979ff" size="22">
</u-icon>
<span>{{ size }}</span>
<u-icon name="plus-circle-fill" color="#2979ff" @click="addGood" size="22"></u-icon>
</div>
</view>
<view class="good-select-cont">
<span class="good-select-btn1" @click="getallNum('buyNow')" v-if="userms">
<view v-if="size > 0" class="good-select-cont">
<a class="good-select-btn1" @click="getallNum()" v-if="userms">
立即购买
</span>
</a>
<button v-if="!userms" class="good-select-btn1" style="border-radius: 0;" open-type="getPhoneNumber"
@getphonenumber="getallNum">
立即购买
</button>
<span class="good-select-btn2" @click="getallNum" type="default">加入购物袋</span>
<span class="good-select-btn2" @click="shoppingCart" type="default">加入购物袋</span>
</view>
</view>
</view>
......@@ -61,15 +84,59 @@ export default {
title: 'Hello1',
imglist: [{ img: "/static/logo.png" }, { img: "/static/ggxz01.png" }],
goodInfo: null,
selected: []
selected: [],
available: [],
goods: {},
skusDefault: [],
pirce: 0,
size: 0,
}
},
onLoad(option) {
const goodsInfo = uni.getStorageSync('goodsInfo')
this.goodInfo = JSON.parse(goodsInfo)
onShow() {
uni.removeStorageSync('goodsList');
},
onLoad() {
uni.removeStorageSync('goodsList');
const goodsInfo = JSON.parse(uni.getStorageSync('goodsInfo'));
this.goodInfo = goodsInfo;
const skus = goodsInfo.skus;
if (skus) {
const sku = skus.find(v => v.isDefault == 1 && v.state == 1) || skus.find(v => v.isDefault == 0 && v.state == 1);
this.skusDefault = skus.find(v => v.isDefault == 1);
if (!sku) return;
this.selected.push(...sku.rules)
skus.forEach(item => {
if (item.state == 1) {
item.rules.forEach(rule => {
this.available.push(rule.ruleId)
})
}
})
}
this.$nextTick(() => {
this.buildGoods(e => {
if (e) {
this.size = 1
} else {
this.size = 0
}
})
})
},
methods: {
setDefaultStyle(id) {
let selected = false;
if (this.skusDefault && this.skusDefault.rules) {
this.skusDefault.rules.forEach(item => {
if (item.ruleId == id) {
selected = true
}
});
}
return selected
},
selectRoles(specItemRule, parent) {
const { selected } = this;
selected.forEach((item, index) => {
......@@ -78,19 +145,12 @@ export default {
}
});
this.selected.push({ ...specItemRule, specId: parent.specId })
this.buildGoods()
},
isActvie(data) {
return this.selected.filter(item => item.ruleId == data.ruleId).length > 0
},
getallNum(type) {
let Authorization = uni.getStorageSync('Authorization');
if (!Authorization) {
this.loginByPhoneNumber(e);
return
}
buildGoods(callback) {
const skusObj = {};
let selectedSku = null
const skus = this.goodInfo.skus;
......@@ -102,31 +162,58 @@ export default {
for (let item in skusObj) {
const selStr = selectedrules.toString()
const itemStr = skusObj[item].toString()
if (selStr === itemStr) {
selectedSku = item
}
if (selStr === itemStr) selectedSku = item;
}
const [sku] = skus.filter(item => item.skuId == selectedSku);
if (skus.state == 2) {
if (!sku || skus.state == 2) {
uni.showToast({ title: '本商品已经售罄', icon: 'none' });
return;
callback && callback()
} else {
const { category, ...goods } = this.goodInfo;
goods.skus = [sku];
goods.sku = sku
goods.num = 1;
goods.flag = true;
goods.skuId = selectedSku
goods.categoryId = category.id;
goods.goodsName = category.name;
Utils.getallNum(goods);
if (type == 'buyNow') {
uni.navigateTo({ url: `/orderSubPackage/pages/settlement/index?buyType=1` })
} else {
uni.switchTab({ url: '/pages/menu/menu' })
this.goods = goods
callback && callback(true)
}
},
addGood() {
if (this.size < 9) {
this.size = this.size + 1;
} else {
uni.showToast({
title: '最多可一次购买9杯',
icon: 'none',
});
}
}
},
reduceGood() {
const { size } = this
if (size > 1) {
this.size = size - 1;
}
},
shoppingCart() {
const { goods } = this;
goods.num = this.size;
Utils.getallNum(goods)
uni.switchTab({ url: '/pages/menu/menu' })
},
getallNum(e) {
let Authorization = uni.getStorageSync('Authorization');
if (!Authorization) {
this.loginByPhoneNumber(e);
return
}
const { goods } = this;
goods.num = this.size
Utils.addGoods(goods)
uni.navigateTo({ url: `/orderSubPackage/pages/settlement/index?buyType=1&goodsList=1` })
},
// 付款前未登录发起授权
loginByPhoneNumber(e) {
......@@ -136,13 +223,28 @@ export default {
uni.showToast({ title: '已拒绝手机号授权', icon: 'error' })
}
},
UseIt(ruleId) {
return this.available.indexOf(ruleId) == -1
}
},
computed: {
userms() {
return this.$store.getters.Authorization;
},
priceTotal() {
let discount = 0;
let price = 0;
const { goods } = this;
if (goods.sku) {
discount = goods.sku.discount * this.size
price = goods.sku.price * this.size
}
return { discount: discount.toFixed(2), price: price.toFixed(2) }
}
},
}
</script>
......@@ -162,7 +264,10 @@ export default {
height: 100% !important;
}
.spec-content {}
.spec-content {
width: 100%;
overflow-x: hidden;
}
.spec-info-left {
padding: 22rpx 34rpx;
......@@ -203,20 +308,46 @@ export default {
margin-left: 8rpx;
margin-top: 24rpx;
flex-wrap: wrap;
.div_item {
position: relative;
width: 120rpx;
height: 48rpx;
margin-right: 10rpx;
margin-top: 10rpx;
line-height: 48rpx;
margin-left: 10rpx;
.default {
width: 15rpx;
height: 15rpx;
background-color: red;
border-radius: 50%;
position: absolute;
left: -5rpx;
top: -5rpx;
z-index: 9
}
}
}
}
.good-spec-rule-item {
width: 120rpx;
height: 48rpx;
width: 100%;
height: 100%;
border-radius: 6rpx;
font-size: 24rpx;
margin-right: 10rpx;
margin-top: 10rpx;
color: #000;
line-height: 48rpx;
text-align: center;
display: inline-block;
margin: 0;
margin: 0;
padding: 0;
line-height: 50rpx;
&.active {
background: #006ECF;
......@@ -253,6 +384,8 @@ export default {
bottom: 0rpx;
text-align: center;
background-color: #fff;
height: auto;
padding-bottom: 20rpx;
}
.good-select-price {
......@@ -260,6 +393,8 @@ export default {
align-items: center;
height: 58rpx;
background: #FFFFFF;
justify-content: space-between;
padding: 10rpx 34rpx;
}
.good-select-price-normal {
......@@ -306,4 +441,12 @@ export default {
text-align: center;
color: #fff;
}
.set_size {
display: flex;
span {
margin: 0 20rpx
}
}
</style>
<!-- 本页面如果不是从购物车发起的则获取到的数据需要存到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 {
buyType:0,//发起支付的页面标识//// 从购物车发起:buyType=1;// 立即购买:buyType=2;// 扫码进入:buyType=3;
orderId:null,//扫码进来的orderId
viewData:{},//预支付数据订单数据
totalPrice:0,//总金额
totalNum:0,//总数量
}
},
onLoad(options) {
if(options.buyType){
this.buyType = options.buyType;
}
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.buyType==3){
this.getOrderInfo()
}
},
onUnload(event){
if(this.orderId && this.buyType==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.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>
</style>
<template>
<scroll-view class="msg" scroll-y>
<view class="msg_item" v-for="item in list" @click="toRead(item)" :key="item.id">
<view class="msg_item_title_time">
<view v-if="item.isRead == 1" class="sign"></view>
<h3 class="title">{{ item.title || 'HOOLOO' }}</h3>
<view class="time">{{ item.createdAt }}</view>
</view>
<view class="msg_content">{{ item.message }}</view>
</view>
</scroll-view>
</template>
<script>
import Mine from '@/request/mine'
export default {
data() {
return {
list: []
}
},
onShow() {
this.getList()
},
methods: {
async getList() {
const { data } = await Mine.getMsg();
this.list = data.rows
},
async toRead(item) {
const { id } = item
const res = await Mine.read({ id, isRead: 2 })
if (res) {
this.getList()
}
}
}
}
</script>
<style lang="scss" scoped>
.msg_item {
width: 100%;
height: 116rpx;
background: #FFFFFF;
padding: 24rpx 62rpx;
box-sizing: border-box;
.msg_item_title_time {
display: flex;
align-items: center;
justify-content: space-between;
position: relative;
.sign {
width: 16rpx;
height: 16rpx;
background: #006ECF;
border-radius: 50%;
position: absolute;
left: -30rpx;
top: 30%
}
.title {
font-size: 24rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #000000;
line-height: 34rpx
}
.time {
font-size: 20rpx;
font-family: PingFangSC-Regular,
PingFang SC;
font-weight: 400;
color: #333333;
line-height: 28rpx;
}
}
.msg_content {
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #333333;
line-height: 28rpx;
}
}
</style>
\ No newline at end of file
<template>
</template>
<script>
......@@ -9,5 +9,4 @@ export default {
</script>
<style>
</style>
\ No newline at end of file
......@@ -3,26 +3,32 @@
<div class="shop_info">
<h3>门店确认</h3>
<div class="address">
<div class="address_1">北京朝阳建外SOHO东区A座店</div>
<div class="address_2">距您132m,请确定门店后下单</div>
<div class="address_1">{{ shopData.name }}</div>
<div class="address_2">距您{{ shopData.distance }},请确定门店后下单</div>
</div>
<div class="take_order">
<div class="title">取单时间</div>
<div class="time">现在下单,预计 <span class="min">5</span> 分钟后取餐</div>
<div class="time">现在下单,预计 <span class="min">{{ duration }}</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>
<image mode="aspectFit" v-if="item.pics.thumbnailApplet" class="goods_img"
:src="item.pics.thumbnailApplet"></image>
<image v-else class="goods_img" :src="item.pics.thumbnail"></image>
<div class="goods_text">
<div class="goods_name">
<div class="name">{{ item.name }}</div>
<div class="price">¥{{ item.sku.price }}</div>
<div class="price">¥{{ setPrice(item.sku.price) }}</div>
</div>
<div class="goods_psce">
<div class="psce_name">/</div>
<div class="psce_name">
<span v-for="rule in item.sku.rules" :key="rule.ruleId">{{ rule.ruleName }}/</span>
</div>
<div class="size">x {{ item.num }}</div>
</div>
</div>
......@@ -30,11 +36,11 @@
<div class="discount">
<div class="discount_1">
<div class="name">优惠免减</div>
<div class="price">- ¥{{ itemReduction(item.sku.discount, item.sku.price) }}</div>
<div class="price">- ¥{{ itemReduction(item.sku.discount, item.sku.price, item.num) }}</div>
</div>
<div class="concessional_rate">
<div class="name">特惠价</div>
<div class="price">¥{{ item.sku.discount }}</div>
<div class="price">¥{{ setPrice(item.sku.discount * item.num) }}</div>
</div>
</div>
</div>
......@@ -54,7 +60,7 @@
<span>微信支付</span>
</div>
</div>
<div style="height:150rpx"></div>
<div class="footer">
<div class="total">
<div class="the_sum">
......@@ -65,11 +71,11 @@
<div class="price">总优惠¥{{ reduction }}</div>
</div>
</div>
<view class="payment" @click="saveReserve" v-if="userms">
<view class="payment" @click="messageAndSave" v-if="userms">
付款
</view>
<button v-if="!userms" class="payment" style="border-radius: 0;" open-type="getPhoneNumber"
@getphonenumber="saveReserve">
@getphonenumber="getPhoneNumber">
付款
</button>
......@@ -78,25 +84,80 @@
</template>
<script>
import { $EventBus } from "../../../utils/EventBus";
import { $EventBus } from "@/utils/EventBus";
import Utils from '@/utils/utils'
import Menu from '@/request/menu'
import User from '@/request/user'
import Order from '@/request/order'
export default {
onShow() {
if (this.goods) {
Order.getWaitTine({
shopId: uni.getStorageSync('shopData').id,
goods: this.goods
}).then(({ data }) => {
this.duration = data.data
})
}
},
onLoad(option) {
this.buyType = option.buyType;
console.log(uni.getStorageSync('shopCarInfo'));
this.goods = uni.getStorageSync('shopCarInfo') || [];
$EventBus.$on('updateCar', () => {
this.goods = uni.getStorageSync('shopCarInfo') || [];
});
// 商品详情页点击立即支付进入
if (option.goodsList) {
const shopData = uni.getStorageSync('shopData');
this.shopData = shopData
this.buyType = 3;
console.log(uni.getStorageSync('goodsList'));
this.goods = uni.getStorageSync('goodsList') || [];
this.payType = '2'
return
}
// 微信扫码进入
this.option = JSON.stringify(option)
const { q } = option;
if (q) {
User.getLocation((location) => {
uni.removeStorageSync('shopCarInfo');
$EventBus.$emit('updateCar');
this.buyType = 'A';
let id = decodeURIComponent(q).split('?')[1].split('=')[1];
Menu.getScreenShopCar(id, location).then(res => {
const data = JSON.parse(res.data.data);
this.shopData = data.shop;
this.goods = data.goods.map(item => {
const data = { ...item, skuId: item.sku.skuId, flag: true }
Utils.getallNum(data)
return data
})
})
})
return
}
// 购物车点击进入
const shopData = uni.getStorageSync('shopData');
this.shopData = shopData
this.buyType = 3;
const shopCarInfo = uni.getStorageSync('shopCarInfo') || []
this.goods = shopCarInfo.filter(item => item.flag);
Order.getWaitTine({
shopId: uni.getStorageSync('shopData').id,
goods: this.goods
}).then(({ data }) => {
this.duration = data.data
})
},
data() {
return {
goods: [],
buyType: ''
buyType: '',
shopData: {},
option: '',
payType: '1',
duration: ''
}
},
computed: {
userms() {
return this.$store.getters.Authorization;
......@@ -108,7 +169,6 @@ export default {
})
return totalNum
},
reduction() {
let price = 0;
let discountNum = 0;
......@@ -118,7 +178,7 @@ export default {
discountNum += item.num * sku.discount
price += item.num * sku.price
} else {
totalPrice += 0
discountNum += 0
price += 0
}
})
......@@ -126,27 +186,56 @@ export default {
},
totalPrice() {
let totalPrice = 0;
this.goods.forEach(item => {
const sku = item.sku;
item.flag ? totalPrice += item.num * sku.discount : totalPrice += 0
item.flag ? totalPrice += (item.num * sku.discount) : (totalPrice += 0)
})
return totalPrice
return totalPrice.toFixed(2)
}
},
methods: {
itemReduction(discount, price) {
return (price - discount).toFixed(2)
itemReduction(discount, price, num) {
return ((price - discount) * num).toFixed(2)
},
// 手机号授权登录
getPhoneNumber(e) {
if (e.detail.errMsg == 'getPhoneNumber:ok') {
User.getPhoneNumber(e);
} else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
uni.showToast({ title: '已拒绝手机号授权', icon: 'error' })
}
},
messageAndSave() {
wx.requestSubscribeMessage({
tmplIds: ['1uErx-15S-3vuopXSvvsxCeM_Jd-1iZC-nXzd2yW3QU', 'Q4HDwBEvpTXpwtZktqWm4SZOTEuQK1x48xjqjD2GqyM', 'Fu_CPIXa0cnJ4EDdVKqFQ3qqKJccMqt2oorI5mfNq74'],
success: () => {
uni.setStorageSync('isMessage', 'true')
User.setAllow(1)
this.saveReserve()
},
fail: () => {
User.setAllow(2)
this.saveReserve()
}
})
},
//结算组装数据发起订单
async saveReserve() {
// 组装购物车数据或者立即支付数据
let res = await Utils.AssemblyOrder(this.totalPrice, this.totalNum, this.buyType);
let list = [];
if (this.payType == '1') {
list = uni.getStorageSync('shopCarInfo').filter((v) => v.flag == true);
} else {
list = uni.getStorageSync('goodsList').filter((v) => v.flag == true);
}
let res = await Utils.AssemblyOrder(this.totalPrice, this.totalNum, this.buyType, list);
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);
await Menu.requestPayment(orderInfo.data.data, res, this.buyType);
}
}
}
......
......@@ -3,13 +3,6 @@
"^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": {
......@@ -76,7 +69,22 @@
},
{
"root": "mineSubPackage",
"pages": []
"pages": [
{
"path": "pages/msg/index",
"style": {
"navigationBarTitleText": "消息列表",
"enablePullDownRefresh": false
}
},
{
"path": "pages/msgInfo/index",
"style": {
"navigationBarTitleText": "消息详情",
"enablePullDownRefresh": false
}
}
]
}
],
"globalStyle": {
......@@ -86,16 +94,28 @@
"backgroundColor": "#ffffff"
},
"tabBar": {
"custom": true,
"custom": false,
"color": "#000000",
"selectedColor": "#006ECF",
"iconWidth": "32px",
"list": [
{
"pagePath": "pages/menu/menu"
"iconPath": "/static/imgs/icon-unselect-menu.png",
"selectedIconPath": "/static/imgs/icon-selected-menu.png",
"pagePath": "pages/menu/menu",
"text": "菜单"
},
{
"pagePath": "pages/order/order"
"iconPath": "/static/imgs/icon-unselect-order.png",
"selectedIconPath": "/static/imgs/icon-selected-order.png",
"pagePath": "pages/order/order",
"text": "订单"
},
{
"pagePath": "pages/mine/mine"
"iconPath": "/static/imgs/icon-unselect-mine.png",
"selectedIconPath": "/static/imgs/icon-selected-mine.png",
"pagePath": "pages/mine/mine",
"text": "我的"
}
]
}
......
......@@ -15,59 +15,59 @@ export default {
}
},
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);
}
uni.reLaunch({url: '/pages/menu/menu'})
// 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',
success() {
setTimeout(() => {
uni.reLaunch({
url: '/pages/menu/menu?orderId=' + _this.id
})
}, 1500)
}
})
} else {
uni.reLaunch({
url: '/pages/menu/menu'
})
}
// async onShow() {
// // let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
// // let curRoute = routes[routes.length - 1].route //获取当前页面路由
// //   let curParam = routes[routes.length - 1].options;
// 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(() => {
// uni.reLaunch({
// url: '/pages/menu/menu?orderId=' + _this.id
// })
// }, 1500)
// }
// })
// } else {
// uni.reLaunch({
// url: '/pages/menu/menu'
// })
// }
}
},
// }
// },
methods: {
}
}
......
......@@ -7,16 +7,16 @@
</view>
<image src="../../static/imgs/banner.png"></image>
</view>
<view class="mod11 flex-col">
<view v-if="userms" class="mod11 flex-col">
<view class="box16 flex-col"></view>
<text class="txt6">小黑山羊</text>
<text class="txt6">{{ userInfo.customerName || '我是谁' }}</text>
<view class="right_arrow">
<u-icon name="arrow-right" color="#fff" size="14"></u-icon>
</view>
</view>
<button class="mod11 flex-col" v-else open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">立刻登录</button>
<view class="contents">
<view class="myOrder">
<view class="myOrder" @click="goToPage('order')">
<view class="order1">我的订单</view>
<view class="order2">点击查看订单</view>
<view>
......@@ -25,7 +25,7 @@
</view>
</view>
<view class="right_box">
<view class="box">
<view class="box" @click.stop="goToPage('coupon')">
<view class="left">
<h3>HOOLOO券</h3>
<view class="dec">优惠多多不要错过</view>
......@@ -35,11 +35,13 @@
</view>
</view>
<view class="box two">
<view class="left">
<button v-if="!userms" class="payment" open-type="getPhoneNumber" @getphonenumber.stop="goToPage">
</button>
<view @click="goToPage('msg')" class="left">
<h3>我的消息</h3>
<view class="dec">点击查看我的消息</view>
</view>
<view class="right">
<view @click="goToPage('msg')" class="right">
<image class="right_img" src="../../static/imgs/myMail.png"></image>
</view>
</view>
......@@ -49,30 +51,64 @@
<h3>常用功能</h3>
<view class="function_item">
<u-icon name="server-fill" color="#000000" size="16"></u-icon>
<text class="function_item_text">联系客服</text>
<button class="function_item_text" open-type="contact" bindcontact="handleContact"
session-from="sessionFrom">联系客服</button>
<u-icon name="arrow-right" class="function_item_icon" color="#000000" size="16"></u-icon>
</view>
</view>
<tabBar :selectedTabbar="selectedTabbar"></tabBar>
</view>
</template>
<script>
import User from '@/request/user'
export default {
data() {
return {
selectedTabbar: 2,//选中的tab
}
},
computed: {
userms() {
return this.$store.getters.Authorization;
},
userInfo() {
return this.$store.state.user.userInfo;
},
},
methods: {
// 手机号授权登录
getPhoneNumber(e) {
if (e.detail.errMsg == 'getPhoneNumber:ok') {
User.getPhoneNumber(e);
} else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
uni.showToast({ title: '已拒绝手机号授权', icon: 'error' })
}
},
goToPage(page) {
if (!this.userms) {
this.loginByPhoneNumber(page)
return
}
page == 'order' && uni.switchTab({ url: '/pages/order/order' })
page == 'coupon' && uni.showToast({ title: '功能未开放!', icon: 'none' });
page == 'msg' && uni.navigateTo({ url: '/mineSubPackage/pages/msg/index' })
}
}
}
</script>
<style lang="scss" scoped>
.payment {
border-radius: 0;
display: block;
position: absolute;
width: 100%;
height: 100%;
opacity: 0;
left: 0;
}
.menu-box {}
.menu-banner {
......@@ -191,6 +227,7 @@ export default {
align-items: center;
justify-content: space-between;
padding: 0 36rpx;
position: relative;
&.two {
margin-top: 15rpx;
......@@ -252,9 +289,21 @@ export default {
margin-top: 20rpx;
.function_item_text {
margin: 0;
margin-left: 10rpx;
padding: 10rpx;
line-height: 1;
background-color: #FFFFFF;
font-size: 24rpx;
border-radius: 0px;
}
.function_item_text::after {
position: unset !important;
border: unset;
}
.function_item_icon {
margin-left: auto;
}
......
......@@ -5,76 +5,137 @@
<view class="order_header">
<view>
<h3 class="order_adrass">{{ item.shop.name }}</h3>
<text class="order_time">{{ item.shop.payTime }}</text>
<text class="order_time">{{ item.createdAt }}</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 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 class=" order_status" v-if="item.state == 13">退款失败</view>
<view class=" order_status" v-if="item.state == 14">部分退款</view>
<view class=" order_status" v-if="item.state == 15">已退款</view>
<view class=" order_status" v-if="item.state == 50">其他人工干预状态</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>
<div class="order_content">
<view>
<view class="goods_item" v-for="good in item.orderDetails" :key="good.id">
<image class="goods_img" v-if="jsonParse(good.goods.pics).thumbnailApplet"
:src="jsonParse(good.goods.pics).thumbnailApplet"></image>
<image v-else 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>
<view v-if="item.state == 4 || item.state == 5 || item.state == 6 || item.state == 7"
class="qr_code">
<image class="qr_code_img" src="/static/imgs/icon-barcode.png"></image>
<view class="qr_text">点击二维码取单</view>
</view>
</div>
<view class="order_footer">
<view class="total">
1件商品 合计: <text class="price">¥10.00</text>
{{ orderDetailsSize(item.orderDetails) }}件商品 合计: <text class="price">{{ item.amount }}</text>
</view>
<!-- <a class="btn" type="primary">再来一单</a> -->
<a class="btn" @click.stop="PayNow(item)" v-if="item.state == 1" type="primary">立刻支付</a>
<a class="btn" v-else @click.stop="oneMoreOrder(item)" type="primary">再来一单</a>
</view>
</view>
</view>
<tabBar :selectedTabbar="selectedTabbar"></tabBar>
</view>
</template>
<script>
import order from '@/request/order'
import Menu from '@/request/menu';
import Utils from '@/utils/utils'
import { $EventBus } from "@/utils/EventBus";
export default {
name: 'order',
data() {
return {
selectedTabbar: 1,//选中的tab
list: []
}
},
async onLoad() {
const { data } = await order.getMyOrder();
this.list = data.rows
onShow() {
this.getList()
},
async onShow() {
const { data } = await order.getMyOrder();
this.list = data.rows
computed: {
userms() {
return this.$store.getters.Authorization;
},
},
methods: {
async oneMoreOrder(item) {
uni.removeStorageSync('shopCarInfo');
$EventBus.$emit('updateCar');
const numObj = {}
const { id, shopId, orderDetails } = item;
orderDetails.forEach(item => {
orderDetails[item.skuId] = item.num
})
const { data } = await order.moreOrder({ orderId: id, shopId });
data.data.forEach(item => {
const skuId = item.skus[0].skuId
const nextData = { ...item, skuId, num: orderDetails[skuId], flag: true, sku: item.skus[0] }
if (nextData.sku.state == 1) {
Utils.getallNum(nextData)
}
});
uni.switchTab({ url: '/pages/menu/menu' })
},
async getList() {
if (!this.userms) return
const { data } = await order.getMyOrder();
if (data) {
this.list = data.rows
} else {
uni.showToast({ title: '请登录!', icon: 'error' })
}
},
async PayNow({ id }) {
const orderInfo = await order.payOrder({ orderId: id })
if (orderInfo) {
if (orderInfo && orderInfo.data.code == 200) {
await Menu.requestPayment(orderInfo.data.data);
this.getList()
}
}
},
openInfo(data) {
uni.setStorageSync('orderInfo', data);
let url = '/orderSubPackage/pages/orderInfo/index'
// : '/orderSubPackage/pages/settlement/index'
uni.navigateTo({ url })
},
jsonParse(json) {
return JSON.parse(json)
const data = json || {}
return JSON.parse(data)
},
orderDetailsSize(orderDetails) {
let size = 0;
orderDetails.forEach(item => {
const { num } = item;
size += Number(num)
});
return size
}
......@@ -124,6 +185,26 @@ export default {
.order_content {
margin-top: 38rpx;
display: flex;
justify-content: space-between;
align-items: center;
.qr_code {
font-size: 16rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #666666;
line-height: 22rpx;
text-align: center;
margin-right: 15rpx;
margin-top: 30rpx;
.qr_code_img {
width: 76rpx;
height: 76rpx;
}
}
.goods_item {
display: flex;
......
import appConfig from '@/static/config/index.js';
import User from '@/request/user';
export function getBaseUrl() {
if (process.env.NODE_ENV === 'development') {
return appConfig.devApi;
......@@ -34,16 +35,11 @@ module.exports = (vm) => {
'/weixin/getShop',
'/weixin/infoByShop',
'/application/getData',
'/weixin/getArea',
];
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) => {
......@@ -55,9 +51,13 @@ module.exports = (vm) => {
uni.$u.http.interceptors.response.use(
(response) => {
uni.hideLoading();
/* 对响应成功做点什么 可使用async await 做异步操作*/
if (response.data.code !== 200) {
// 服务端返回的状态码不等于200,则reject()
const phoneNumber = uni.getStorageSync('phoneNumber');
if (response.data.code == 401 && phoneNumber) {
User.getAuthorization(phoneNumber);
}
uni.showToast({
title: response.data.msg,
icon: 'none',
......@@ -65,12 +65,12 @@ module.exports = (vm) => {
});
return Promise.reject(response);
} // return Promise.reject 可使promise状态进入catch
return response;
},
(response) => {
uni.hideLoading();
/* 对响应错误做点什么 (statusCode !== 200)*/
console.log(response);
return Promise.reject(response);
}
);
......
import Utils from '@/utils/utils'
import { $EventBus } from '@/utils/EventBus';
export default {
// 获取菜单列表
getMenuList(id) {
return uni.$u.http.get('/weixin/infoByShop', {
params:{
shopId: id
}
}).then(res => {
return res;
}).catch(err => {
uni.showToast({title:'服务器错误',icon:'none'})
})
},
// 获取点单屏幕的订单信息
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 为业务接口
requestPayment(data, oldData, buyType) {
// res为调起微信支付所需参数
// 调起微信支付
uni.requestPayment({
provider: 'wxpay', // 服务提提供商微信支付
timeStamp: data.timeStamp, // 时间戳
nonceStr: data.nonceStr, // 随机字符串
package: data.package,
signType: data.signType || 'MD5', // 签名算法
paySign: data.paySign, // 签名
success: function (res) {
if (res.errMsg == 'requestPayment:ok'){
uni.showToast({
title: '支付成功'
});
if (buyType==1){
let shopCarInfo = uni.getStorageSync('shopCarInfo');
for (let i = 0; i < oldData.length; i++){
let element = oldData[i];
for (let y = 0; y < shopCarInfo.length; y++) {
let item = shopCarInfo[y];
if (item.skus[0].skuId === element.skus[0].skuId) {
shopCarInfo.splice(index, 1);
}
}
}
// 删除购物车数据后重新放回购物车
uni.setStorageSync('shopCarInfo', shopCarInfo);
$EventBus.$emit('updateCar');
uni.navigateTo({
url:'/page/menu/menu'
})
}
}
// 获取菜单列表
getMenuList(id) {
return uni.$u.http
.get('/weixin/infoByShop', {
params: {
shopId: id,
},
})
.then((res) => {
return res;
})
.catch((err) => {
uni.showToast({ title: '服务器错误', icon: 'none' });
});
},
// 获取点单屏幕的订单信息
getScreenShopCar(key, location) {
return uni.$u.http
.post('/application/getData', {
key,
location,
})
.then((res) => {
return res;
})
.catch((err) => {
uni.showToast({
title: '服务器错误',
icon: 'none',
});
return err;
});
},
// 下单获取预支付订单
saveReserve(data) {
return uni.$u.http
.post('/order', data)
.then((res) => {
return res;
})
.catch((err) => { });
},
// saveReserve 为业务接口
requestPayment(data, oldData, buyType) {
// res为调起微信支付所需参数
// 调起微信支付
uni.requestPayment({
provider: 'wxpay', // 服务提提供商微信支付
timeStamp: data.timeStamp, // 时间戳
nonceStr: data.nonceStr, // 随机字符串
package: data.package,
signType: data.signType || 'MD5', // 签名算法
paySign: data.paySign, // 签名
success: function (res) {
if (res.errMsg == 'requestPayment:ok') {
// 删除购物车数据后重新放回购物车
uni.setStorageSync('shopCarInfo', []);
$EventBus.$emit('updateCar');
uni.switchTab({ url: '/pages/order/order' });
}
// 业务逻辑。。。
},
fail: function (err) {
uni.showToast({
title:'支付失败',
icon:'error'
})
}
});
}
}
\ No newline at end of file
// 业务逻辑。。。
},
fail: function (err) {
uni.showToast({
title: '支付失败',
icon: 'error',
});
uni.setStorageSync('shopCarInfo', []);
$EventBus.$emit('updateCar');
uni.switchTab({ url: '/pages/order/order' });
},
});
},
};
export default {
getList(id) {
}
}
\ No newline at end of file
getList(id) {},
getMsg() {
return uni.$u.http
.get('/system/message/list', {})
.then((res) => {
return res;
})
.catch((err) => {
uni.showToast({ title: '服务器错误', icon: 'none' });
});
},
read(data) {
return uni.$u.http
.put('/system/message', data)
.then((res) => {
return res;
})
.catch((err) => {
uni.showToast({ title: '服务器错误', icon: 'none' });
});
},
};
......@@ -5,12 +5,95 @@ export default {
params: {},
})
.then((res) => res)
.catch((err) => uni.showToast({ title: '服务器错误', icon: 'none' }));
.catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' })
console.log('服务器错误');
});
},
orderRefund(data) {
return uni.$u.http
.post('/system/refund', data)
.then((res) => res)
.catch((err) => uni.showToast({ title: '服务器错误', icon: 'none' }));
.catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' })
console.log('服务器错误');
});
},
getShop(params) {
return uni.$u.http
.get('/weixin/getArea', {
params,
})
.then((res) => res)
.catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' })
console.log('服务器错误');
});
},
// 校验sku是否可用
chekSku(params) {
return uni.$u.http
.get('/application/checkSku', {
params,
})
.then((res) => res)
.catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' })
console.log('服务器错误');
});
},
cancelOrder(params) {
return uni.$u.http
.get('order/cancel', {
params,
})
.then((res) => res)
.catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' })
console.log('服务器错误');
});
},
// 立刻支付
payOrder(params) {
return uni.$u.http
.get('order/payOrder', {
params,
})
.then((res) => res)
.catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' })
console.log('服务器错误');
});
},
getHomeOrder(params) {
return uni.$u.http
.get('/app/getHomeOrder', {
params: {},
})
.then((res) => res)
.catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' })
console.log('服务器错误');
});
},
getWaitTine(data) {
return uni.$u.http
.post('app/getWaitTine', data)
.then((res) => res)
.catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' })
console.log('服务器错误');
});
},
moreOrder(params) {
return uni.$u.http
.get('/app/getNextOrder', {
params,
})
.then((res) => res)
.catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' })
console.log('服务器错误');
});
},
};
import Store from '@/store';
import { $EventBus } from '../../utils/EventBus';
import { $EventBus } from '@/utils/EventBus';
export default {
getLocation() {
getLocation(callback) {
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);
uni.setStorage({ key: 'location', data: params });
callback && callback(params);
// return params;
_this.getAddress(params);
},
fail: function (res) {
console.log(res, 3333);
uni.showToast({
title: '获取地址失败,将导致部分功能不可用',
icon: 'none',
......@@ -24,7 +24,7 @@ export default {
},
});
},
// 获取具体位置店铺/weixin/getShop
// 获取默认店铺
getAddress(params) {
return uni.$u.http
.get('/weixin/getShop', {
......@@ -32,10 +32,11 @@ export default {
})
.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]);
uni.setStorage({ key: 'shopData', data: res.data.data });
if (res.data.data) {
$EventBus.$emit('getMenuList', res.data.data);
}
}
return res;
......@@ -44,21 +45,7 @@ export default {
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) {
uniLogin(res) {
uni.login({
provider: 'weixin',
success: function (data) {
......@@ -66,28 +53,19 @@ export default {
uni.$u.http
.post('/weixin/login', {
code: data.code,
source: 3, //默认是3,扫码进来是2
source: 3,
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);
},
});
.then((res) => {
const { statusCode, data } = res;
const { code, token, phoneNumber } = data;
if (statusCode == 200 && data && code == 200) {
uni.setStorage({ key: 'Authorization', data: token });
uni.setStorage({ key: 'phoneNumber', data: phoneNumber });
uni.setStorage({ key: 'userInfo', data: data });
Store.commit('setUserInfo', data);
Store.commit('setAuthorization', token);
}
})
.catch((err) => {
......@@ -98,25 +76,33 @@ export default {
},
});
},
// 手机号授权登录
getPhoneNumber(res, orderId) {
uni.setStorage({
key: 'userPhoneInfo',
data: res,
getAuthorization(phoneNumber) {
uni.$u.http.post('/weixin/refreshToken ', { phoneNumber }).then((res) => {
const { data } = res;
uni.setStorage({ key: 'Authorization', data: data.token });
Store.commit('setAuthorization', data.token);
uni.showToast({ title: '登录成功!' });
});
},
// 手机号授权登录
getPhoneNumber(res) {
uni.setStorage({ key: 'userPhoneInfo', data: res });
Store.commit('setUserPhoneInfo', res);
this.uniLogin(res.detail, orderId);
uni.setStorage({ key: 'phoneInfo', data: res });
this.uniLogin(res.detail);
},
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);
},
});
setAllow(allow) {
uni.$u.http
.get('/system/customer/allow', {
params: {
allow,
},
})
.then((res) => {
return res;
})
.catch((err) => {
uni.showToast({ title: '服务器错误', icon: 'none' });
});
},
};
import Vue from 'vue'
import Vuex from 'vuex'
import user from './modules/user'
import menu from './modules/menu'
import getters from './getters'
Vue.use(Vuex)
import Vue from 'vue';
import Vuex from 'vuex';
import user from './modules/user';
import menu from './modules/menu';
import getters from './getters';
Vue.use(Vuex);
const store = new Vuex.Store({
modules: {
user,
menu
},
state: {
list: [
{
icon: "/static/imgs/icon-unselect-menu.png",
activeIcon: '/static/imgs/icon-selected-menu.png',
customIcon: false,
pagePath: "/pages/menu/menu",
text: '菜单'
},
{
icon: "/static/imgs/icon-unselect-order.png",
activeIcon: '/static/imgs/icon-selected-order.png',
pagePath: "/pages/order/order",
text: '订单',
customIcon: false
},
{
icon: "/static/imgs/icon-unselect-mine.png",
activeIcon: '/static/imgs/icon-selected-mine.png',
pagePath: "/pages/mine/mine",
text: '我的'
}
],
orderId:''//外部扫码进入的商品id
},
mutations: {
// 设置扫码进入的商品id
setOrderId(state, orderId) {
state.orderId = orderId;
}
},
getters,
actions: {}
})
export default store
\ No newline at end of file
modules: {
user,
menu,
},
state: {
list: [],
orderId: '', //外部扫码进入的商品id
},
mutations: {
// 设置扫码进入的商品id
setOrderId(state, orderId) {
state.orderId = orderId;
},
},
getters,
actions: {},
});
export default store;
const user = {
state: {
userInfo: null, //授权信息
Authorization: null, //是否授权
location:null,//用户经纬度
userPhoneInfo:null,
shopInfo:null,//店铺信息
orderId:null//扫码进入时携带的订单id
state: {
userInfo: {}, //授权信息
Authorization: null, //是否授权
location: null, //用户经纬度
userPhoneInfo: null,
shopInfo: null, //店铺信息
orderId: null, //扫码进入时携带的订单id
},
mutations: {
// 保存扫码进入时携带的订单id
setOrderId(state, orderId) {
state.orderId = orderId;
},
// 设置是否授权
setAuthorization(state, data) {
state.Authorization = data;
},
// 设置用户允许昵称头像授权时的信息
setUserInfo(state, userInfo) {
state.userInfo = userInfo;
},
// 授权手机号时允许后的信息
setUserPhoneInfo(state, userPhoneInfo) {
state.userPhoneInfo = userPhoneInfo;
},
// 保存经纬度
saveLocation(state, location) {
state.location = location;
},
mutations: {
// 保存扫码进入时携带的订单id
setOrderId(state, orderId) {
state.orderId = orderId;
},
// 设置是否授权
setAuthorization(state, data) {
console.log(data,665)
state.Authorization = data;
},
// 设置用户允许昵称头像授权时的信息
setUserInfo(state, userInfo) {
state.userInfo = userInfo;
},
// 授权手机号时允许后的信息
setUserPhoneInfo(state, userPhoneInfo) {
state.userPhoneInfo = userPhoneInfo;
},
// 保存经纬度
saveLocation(state, location) {
state.location = location;
},
// 当前店铺信息
saveShopInfo(state, shopInfo) {
state.shopInfo = shopInfo;
}
// 当前店铺信息
saveShopInfo(state, shopInfo) {
state.shopInfo = shopInfo;
},
},
actions: {
}
}
actions: {},
};
export default user
export default user;
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);
AssemblyOrder(totalPrice, totalNum, buyType, shopCarInfo) {
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, //实付金额
amount: item.sku.price * item.num, //总价格
specRuleDetail: JSON.stringify(item.sku.rules), //规格选项详情
specRuleIds: item.sku.rules.map((item) => item.ruleId).join(','), //规格选项详情
skuId: item.skuId, //"sku ID"
......@@ -24,12 +25,13 @@ export default {
orderDetails.push(res);
}
const shopData = uni.getStorageSync('shopData');
let DAta = {
amount: totalPrice, //商品总金额
goodsNum: totalNum, //商品总数量
shopId: '12', //店铺
shopId: shopData.id, //店铺f
machineId: undefined, //机器ID
source: 3, //小程序固定传3
source: buyType, //小程序固定传3
orderDetails: orderDetails,
};
return DAta;
......@@ -40,17 +42,19 @@ export default {
}
},
// 加入购物车数据
getallNum(Obj) {
async getallNum(Obj, callback) {
console.log(Obj);
let shopCarInfo = uni.getStorageSync('shopCarInfo') || [];
let size = 0;
shopCarInfo.forEach((item) => (size += item.num), 0);
shopCarInfo.forEach((item) => (size += item.num));
if (size >= 9) {
uni.showToast({
title: '最多可一次购买9杯',
icon: 'none',
});
return;
return false;
}
if (shopCarInfo) {
let currentGoods = shopCarInfo.find((v) => v.goodsId == Obj.goodsId && v.skuId == Obj.skuId);
if (currentGoods) {
......@@ -61,9 +65,38 @@ export default {
} else {
shopCarInfo = [Obj];
}
console.log(Obj);
uni.setStorageSync('shopCarInfo', shopCarInfo);
console.log(shopCarInfo);
$EventBus.$emit('updateCar');
if (callback) {
callback();
}
},
// 商品详情立即购买
async addGoods(Obj) {
let goodsList = [];
let size = 0;
goodsList.forEach((item) => (size += item.num));
if (size >= 9) {
uni.showToast({
title: '最多可一次购买9杯',
icon: 'none',
});
return false;
}
if (goodsList) {
let currentGoods = goodsList.find(
(item) => item.goodsId == Obj.goodsId && item.skuId == Obj.skuId
);
if (currentGoods) {
currentGoods.num += 1;
} else {
goodsList.push(Obj);
}
} else {
goodsList = [Obj];
}
uni.setStorageSync('goodsList', goodsList);
},
// 解密手机
......
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