Commit acc1f2c7 authored by liumiss's avatar liumiss

订单页、详详情页

parent fdd31016
......@@ -12100,6 +12100,11 @@
"integrity": "sha1-XS/yKXcAPsaHpLhwc9+7rBRszyk=",
"dev": true
},
"weixin-js-sdk": {
"version": "1.4.0-test",
"resolved": "https://registry.npmjs.org/weixin-js-sdk/-/weixin-js-sdk-1.4.0-test.tgz",
"integrity": "sha512-Dh/TwKhaQVAlyqEXdR65aJdexsynOhCEauexY93YZ+gXcV+ITTd/qvAHdwmkGP0nwAp314v0FD4AXUqCBQFm6Q=="
},
"when": {
"version": "3.6.4",
"resolved": "https://registry.npm.taobao.org/when/download/when-3.6.4.tgz",
......
......@@ -14,7 +14,8 @@
"cube-ui": "~1.12.15",
"vant": "^2.1.3",
"vue": "^2.6.10",
"vue-router": "^3.0.3"
"vue-router": "^3.0.3",
"weixin-js-sdk": "^1.4.0-test"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.10.0",
......
......@@ -39,3 +39,61 @@ export const getShopInfo = (shop_id) => request('shop', { shop_id }, 'get');
// 获取一个商家的菜品
export const allCategoryAndGoods = (shop_id) => request('/shop/goods/shop', { shop_id}, 'get');
// 店铺订单-下单- 预下单
export const preorder = (shop_id,price, address_id, goods_list) => request('shop/order/pre', {
shop_id,
price,
address_id,
goods_list,
order_type: "take_out",
// delivery_fee: 0
});
// 店铺订单-下单
export const placeOrder = ( shop_id,price, address_id, goods_list, order_type = "take_out") => request('shop/order', {
shop_id,
price,
address_id,
goods_list,
order_type,// take_out下单 recharge充值
});
export const getOrder = (order_status, page) => request('user/order', {
order_status,
page,
'details_sign': false,
}, 'get');
// 获取订单详情
export const getOrderDetail = (order_no) => request('user/order/detail', {
order_no
}, 'get');
/******* 支付相关 ******/
export const weChatConfig = (url, js_api_list) => request('wechat/jsticket', {
url,
js_api_list: ["chooseWXPay"]
});
// 微信 JSAPI 支付
export const weChatJSAPIPay = (order_no) => request('payment/wechat/official_account', {
order_no
});
// 微信 H5支付
export const weChatH5Pay = (order_no) => request('payment/wechat/web', {
order_no
});
// 查看账号 余额
export const getBalance = () => request('shop/member/balance', {}, 'get');
// 余额支付
export const balancePay = (order_no) => request('shop/member/pay', {
order_no
});
\ No newline at end of file
......@@ -49,14 +49,23 @@
// -webkit-transform: scaleY(0.5);
// transform: scaleY(0.5);
}
.no-data{
.no-data,
.empty_tips{
height: 300px;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
font-size: 14px;
color:#999;
}
.empty_tips p{
font-size: 12px;
color: #aaa;
line-height: 1.2;
text-align: center;
}
.word-one{
overflow: hidden;
text-overflow:ellipsis;
......
var wx = require('weixin-js-sdk');
//微信内 JSApi支付
export default {
WxConfig(data) {
wx.config({
debug: false,//这里一般在测试阶段先用ture,等打包给后台的时候就改回false,
appId: data.appId,
timestamp: data.timestamp,
nonceStr: data.nonceStr,
signature: data.signature,
jsApiList: data.jsApiList
})
wx.ready(function () {
wx.checkJsApi({
jsApiList: data.jsApiList,
success: function (res) {
// console.log(res)
},
fail: function (res) {
// console.log(res)
}
})
// 分享给朋友代码
wx.error(function (res) {
// console.log("errorMSG:" + res);
});
})
},
WXJSApi(data, resolve, callback) {
function onBridgeReady() {
WeixinJSBridge.invoke(
"getBrandWCPayRequest",
{
appId: data.appId, //公众号名称,由商户传入
timeStamp: data.timestamp, //时间戳,自1970年以来的秒数
nonceStr: data.nonceStr, //随机串
package: data.package, //订单详情扩展字符串
signType: data.signType, //微信签名方式:
paySign: data.paySign, //微信签名
},
function (res) {
// WeixinJSBridge.log(JSON.stringify(res) );
if (res.err_msg == "get_brand_wcpay_request:ok") {
resolve();
} else {
callback();
console.log(res)
}
}
);
}
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
}
} else {
onBridgeReady();
}
},
}
<template>
<div class="container">
<header v-if="shopInfo.id" class="line">
<span>{{shopInfo.name}}</span>
</header>
<ul class="food_list_ul" v-if="goods_list">
<li v-for="item in goods_list" :key="item.id" class="van-cell">
<div class="thumb">
<van-image width="40" :src="$globalUrlFile +item.goods_img"></van-image>
</div>
<div class="van-cell__title">
<p class="word-one">{{item.goods_name}}</p>
</div>
<div class="num_price">
<span>x {{item.goods_quantity}}</span>
<span>¥{{item.goods_price}}</span>
</div>
</li>
</ul>
</div>
</template>
<script>
export default {
props: ["shopInfo", "goods_list"]
};
</script>
<style lang="stylus" scoped>
@import '~common/stylus/variable.styl';
@import '~common/stylus/mixin.styl';
.container {
font-size: $fontsize-medium;
header {
position: relative;
padding: 15px;
scw($fontsize-large, #3e3e3e, 600);
}
.van-cell {
.thumb {
margin-right: 10px;
}
&__title {
width: 65%;
}
.num_price {
width: 25%;
flex(space-between, center);
span:nth-of-type(1) {
font-size: $fontsize-small;
}
}
}
}
</style>
\ No newline at end of file
<template>
<div>
<div v-for="order in data" :key="order.id" class="box">
<van-panel v-if="order.order_type=='take_out'" class="margin-bt-space">
<div slot="header" class="van-cell van-panel__header" @click="onShow(77)">
<div class="van-cell__title">
<span>订单编号:</span>
<div class="van-cell__label">{{order.order_no}}</div>
</div>
<div class="van-cell__value van-panel__header-value">
<span>已送达</span>
</div>
</div>
<van-cell @click="onSelect(order.order_no)">
<div slot="title">
<p class="word-one">{{order.goods_name}}</p>
</div>
<span>
<span class="text-extra-small">¥</span>
<span class="text-base">{{order.price_final}}</span>
</span>
</van-cell>
<div slot="footer">
<van-button size="small" color="#1f81be" @click="onMore" plain>再来一单</van-button>
</div>
</van-panel>
</div>
</div>
</template>
<script>
export default {
props: {
data: {
// 订单列表
type: Array,
default: null
}
},
methods: {
onCallBack(order_no) {
this.$emit("select", order_no);
},
onMore() {
this.$emit("more");
},
onSelect(order_no) {
this.$emit("select", order_no);
},
onShow(shopId) {
this.$emit("show", shopId);
}
// onCancel(order_no,index) {
// this.$emit("cancel", order_no,index);
// },
// onPay(order_no) {
// this.$emit("pay", order_no);
// }
}
};
</script>
<style lang="stylus" scoped>
.box {
border-radius: 6px;
overflow: hidden;
}
.van-panel {
margin-bottom: 10px;
padding-bottom: 10px;
&__content {
padding-left: 12%;
}
&__header-value {
color: #606060;
}
&__content {
.van-cell {
&__title {
width: 70%;
}
&__label {
line-height: 1;
margin-top: 0;
}
&__value {
color: #2c2c2c;
font-size: 0;
}
}
}
}
.van-panel__content .van-cell__value, .van-panel__footer {
text-align: right;
}
</style>
<template>
<div>
<van-action-sheet
v-model="showActionSheet"
:actions="actions"
@select="onSelectAction"
@click-overlay="onClickOverlay"
/>
</div>
</template>
<script>
import { weChatH5Pay, weChatJSAPIPay, balancePay } from "../common/serve";
import payUtils from "../common/utils/pay"; // 支付相关接口
import { mapMutations } from "vuex";
import { setTimeout } from "timers";
export default {
data() {
return {
actions: [
{
type: "wexin",
name: "微信支付"
},
{
type: "banlence",
name: "余额支付"
},
{
type: "apliay",
name: "支付宝"
}
]
};
},
props: {
showActionSheet: {
type: Boolean,
default: false
},
order_no: {
type: String
}
},
methods: {
...mapMutations(["SAVE_COUPON"]),
// 支付
onSelectAction(item) {
this.$emit("click");
/** 余额支付 **/
if (item.type == "banlence") {
this.banlencePayFn();
return;
}
// 根据 当前运行环境 调用不同支付接口
if (this._testUserAgent() == "wechat") {
// 微信
if (item.type == "wexin") {
this.wxJSAPIPay();
} else {
this.$toast('功能未开放~')
// 跳转浏览器支付宝 H5
}
} else if (this._testUserAgent() == "alipay") {
// 支付宝
if (item.type == "wexin") {
this.wxH5Pay();
} else {
this.$toast('功能未开放~')
// 支付宝 Api
}
} else {
// 其他浏览器
if (item.type == "wexin") {
this.wxH5Pay();
} else {
this.$toast('功能未开放~')
// 支付宝 H5
}
}
},
// 微信API支付
wxJSAPIPay() {
const _this = this;
weChatJSAPIPay(this.order_no).then(res => {
if (res.code == 0) {
payUtils.WXJSApi(
res.data,
// 此为支付成功的回调
function() {
_this.paySuccess();
},
// 此为支付失败的回调
function() {
_this.payFail(res);
}
);
} else {
this.$toast(res.message);
}
});
},
// 微信H5支付
wxH5Pay() {
weChatH5Pay(this.order_no).then(res => {
if (res.code == 0) {
// 支付成功操作
window.location.replace(
res.data.mweb_url +
"&redirect_url=" +
encodeURIComponent(window.location.href + "&tip=yes")
);
// 清除当前使用优惠券的信息
this.SAVE_COUPON({ id: -1, price: 0, index: -1 });
} else {
this.$toast(res.message);
}
});
},
// 余额支付
async banlencePayFn() {
const _this = this;
this.$dialog
.confirm({
title: "确定使用余额支付?",
confirmButtonText: "付款",
cancelButtonText: "取消"
})
.then(() => {
balancePay(this.order_no).then(res => {
if (res.code == 0) {
this.paySuccess();
} else {
this.payFail(res);
}
});
});
},
paySuccess() {
// 设置返回页面层级
if (this.$route.name == "confirmOrder") {
this.$router.replace({ name: "paySuccess" });
} else {
this.$router.push({ name: "paySuccess" });
}
},
payFail(res) {
if (this.$route.name == "orderDetails") {
// 当前页面为订单详情,则仅提示
this.$toast("支付失败");
} else {
this.$toast(res.message);
setTimeout(() =>{
// 设置返回页面层级
if (this.$route.name == "confirmOrder") {
this.$router.replace({
name: "orderDetails",
params: { id: this.order_no }
});
} else {
this.$router.push({
name: "orderDetails",
params: { id: this.order_no }
});
}
}, 1000);
}
},
// 点击遮罩层
onClickOverlay() {
this.$emit("click");
this.$router.push({
name: "orderDetails",
params: { id: this.order_no }
});
},
// 检测当前运行环境
_testUserAgent() {
let shell = "none";
if (/MicroMessenger/.test(window.navigator.userAgent)) {
shell = "wechat"; // 微信
} else if (/AlipayClient/.test(window.navigator.userAgent)) {
shell = "alipay"; // 支付宝
} else {
shell = "other"; // 其他浏览器
}
return shell;
}
}
};
</script>
\ No newline at end of file
......@@ -30,13 +30,13 @@ export default {
return {};
},
props: ["options"],
props: ["options","location"],
computed: {},
methods: {
onSelect(item){
this.$router.push({name:'shop',params:{id:item.shop_id}})
this.$router.push({name:'shop',params:{id:item.shop_id},query:{geohash:this.location.lat+','+this.location.lng}})
}
}
};
......
......@@ -150,11 +150,14 @@ export default {
if (this.totalPrice < this.minPrice) {
return;
}
this.$createDialog({
/* this.$createDialog({
title: "支付",
content: `您需要支付${this.totalPrice}元`
}).show();
e.stopPropagation();
*/
let geohash = this.$route.query.geohash;
this.$router.push({name:'confirmOrder',params:{shopId:this.shopId},query:{geohash:geohash}});
},
drop(el) {
for (let i = 0; i < this.balls.length; i++) {
......
......@@ -12,9 +12,12 @@ const choiseLocation = r => require.ensure([], () => r(require('./views/location
const shop = r => require.ensure([], () => r(require('./views/shopItem/index.vue')))
const searchLocation = r => require.ensure([], () => r(require('./views/search/location-search.vue')))
// const choiseLocation = r => require.ensure([], () => r(require('./views/location/choise.vue')))
const orderDetails = r => require.ensure([], () => r(require('./views/order/order-detail.vue')))
const confirmOrder = r => require.ensure([], () => r(require('./views/confirmOrder/index.vue')))
Vue.use(Router);
export default new Router({
......@@ -82,5 +85,17 @@ export default new Router({
component: shop,
meta: { title: '', keepAlive: false }
},
{
path: '/confirmOrder/:shopId',
name: 'confirmOrder',
component: confirmOrder,
meta: { title: '外卖配送', requireAuth: true }
},
{
path: '/order/:order_no',
name: 'orderDetails',
component: orderDetails,
meta: { title: '', requireAuth: true }
},
]
});
......@@ -23,7 +23,7 @@ export default {
geolocation.getCurrentPosition();
AMap.event.addListener(geolocation, "complete", function (data) {
let location = { lat: data.position.lat, lng: data.position.lng, formattedAddress: data.formattedAddress };
commit('RECORD_ADDRESS', location)
commit('RECORD_LOCATION', location)
console.log(data)
});
AMap.event.addListener(geolocation, "error", function (data) {
......
......@@ -6,8 +6,9 @@ import actions from './actions'
Vue.use(Vuex)
const state = {
location: { lat: '', lng: '', formattedAddress: '' },
choise_position: {
location: { lat: '', lng: '', formattedAddress: '' }, // 当前地图定位
choosed_address:{lat: '', lng: '', formattedAddress: ''}, // 当前定位使用的地址信息
choise_position: { // 地图中选择的定位
id: 0,
location: {
lat: 0,
......@@ -16,7 +17,7 @@ const state = {
Q: 0
}
},
shopInfo:{},
shopInfo:{},// 当前店铺信息
edit_address: {}, // 待编辑的地址信息
cartList: {}, // 加入购物车的商品列表
}
......
......@@ -2,15 +2,19 @@ import { sessionstorage } from '../common/utils/mUtils'
export default {
// 记录当前地理位置
RECORD_ADDRESS(state, info) {
RECORD_LOCATION(state, info) {
state.location = info;
console.log(info)
},
RECORD_ADDRESS(state, info) {
state.choosed_address = info;
console.log(info)
},
// 重新定位
REFRESH_LOCATION(state, info) {
/* REFRESH_LOCATION(state, info) {
state.location = info;
console.log(info)
},
}, */
// 地图定位:确认收货地址
CHOISE_POSITION(state, info) {
state.choise_position = info
......@@ -28,7 +32,7 @@ export default {
}
},
// 记录当前地理位置
// 记录当前店铺位置
CURRENT_SHOPINFO(state, info) {
state.shopInfo = info;
},
......@@ -61,7 +65,7 @@ export default {
category[food_id]['num']++;
} else {
category[food_id] = {
"goods_category_id":category_id,
"goods_category_id": category_id,
"num": 1,
"id": food_id,
"name": name,
......@@ -91,15 +95,15 @@ export default {
let shop = (cart[shopid] || {});
let category = (shop[category_id] || {});
if (category && category[food_id]) {
if (category[food_id]['num'] > 0) {
if (category[food_id]['num'] >1) {
category[food_id]['num']--;
state.cartList = { ...cart };
//存入localStorage
sessionstorage.save('buyCart', state.cartList);
} else {
//商品数量为0,则清空当前商品的信息
category[food_id] = null;
delete category[food_id]
}
}
state.cartList = { ...cart };
//存入localStorage
sessionstorage.save('buyCart', state.cartList);
},
}
\ No newline at end of file
......@@ -7,13 +7,18 @@ import {
Grid,
GridItem,
Row, Col,
Cell, CellGroup ,
Cell, CellGroup,
Field,
Button,
Tag,
Card,
Tab, Tabs ,
Rate
Tab, Tabs,
Rate,
ContactCard, ContactList, ContactEdit,
SubmitBar ,
ActionSheet,
Panel,
List
} from 'vant'
Vue.use(Search)
Vue.use(Image)
......@@ -27,4 +32,8 @@ Vue.use(Tag)
Vue.use(Button)
Vue.use(Tab).use(Tabs);
Vue.use(Rate)
Vue.use(ContactCard).use(ContactList).use(ContactEdit);
Vue.use(SubmitBar)
Vue.use(ActionSheet)
Vue.use(Panel)
Vue.use(List)
......@@ -5,7 +5,7 @@
<div class="van-address-list">
<van-row>
<van-col span="24">
<cube-address-list :options="list" :edit="true" @edit="onEdit"></cube-address-list>
<cube-address-list :options="list" :edit="true" @edit="onEdit" @select="onSelect"></cube-address-list>
</van-col>
</van-row>
</div>
......@@ -31,7 +31,8 @@ export default {
data() {
return {
chosenAddressId: "-1", // 字符串类型!!!
list: []
list: [],
isSelect:false // 从下单页过来选择收货地址
};
},
computed: {
......@@ -69,15 +70,40 @@ export default {
this.$router.replace({ name: "addAddress" });
},
onEdit(item, index) {
onEdit(item) {
this.$store.commit("RECORD_ADDRESSINFO", item);
this.$router.replace({
name: "editAddress",
params: { id: item.location_id },
query: { position: item.position }
});
},
onSelect(item){
if(this.isSelect){
this.$store.commit("RECORD_ADDRESS", { ...item,lat: item.position[0], lng: item.position[1], formattedAddress: item.address_detail });
this.$router.go(-1)
}
}
},
// 允许切换地址
beforeRouteEnter(to, from, next) {
console.log(from)
next(vm => {
if (from.name == "confirmOrder") {
vm.isSelect = true;
}else{
vm.isSelect = false;
}
});
},
// 清除 允许切换地址的标记
/* beforeRouteLeave(to, from, next) {
if (to.name == "confirmOrder") {
this.SAVE_ADDRESS_SWITCHABLE(false);
this.RECORD_ORDER_ADDRESS(false)
}
}
next();
} */
};
</script>
......
......@@ -23,7 +23,7 @@
<!-- 地址列表 -->
<van-row>
<van-col span="22" offset="2">
<cube-address-list :options="addressList" @select="setDefaultAddress"></cube-address-list>
<cube-address-list :options="addressList" @select="setCurAddress"></cube-address-list>
</van-col>
</van-row>
......@@ -81,7 +81,8 @@ export default {
let _data = res.data;
_data.forEach(el => {
let _obj = {
// id: el.id.toString(),
lat:el.location.lat,
lng:el.location.lng,
name: el.name,
tel: el.phone,
label: el.label, // 地址类型:例:家
......@@ -94,24 +95,14 @@ export default {
});
},
// 选择收货地址
async setDefaultAddress(item) {
// this.$router.push({ name: "home" });
// return;
Object.assign(item, { is_default: 1 });
let res = await editReceivingAddress(item);
if (res.code == 0) {
this.$router.push({ name: "home" });
} else {
this.$createToast({
txt: res.message,
type: "error"
}).show();
}
async setCurAddress(item) {
this.$store.commit("RECORD_ADDRESS", { ...item,lat: item.lat, lng: item.lng, formattedAddress: item.address_detail });
this.$router.push({name:'home'})
},
onSelect() {},
onRefreshLocation() {
// 重新定位后,调用定位api
this.$store.commit("REFRESH_LOCATION", "定位中...");
this.$store.commit("RECORD_LOCATION", "定位中...");
this.$store.dispatch("GET_LOCATION", map);
},
onLink(route) {
......
<template>
<div class="confirm-order-container">
<section v-if="!showLoading">
<!-- 添加地址卡片 -->
<van-contact-card
v-if="!choosed_address.id"
type="add"
add-text="选择收货地址"
@click="selectAddress"
/>
<div v-else class="van-contact-card van-cell margin-bt-space">
<van-cell is-link @click="selectAddress">
<div slot="title">
<van-tag v-if="choosed_address.label==1" color="#ffe1e1" text-color="#f44">家</van-tag>
<van-tag v-else-if="choosed_address.label==2" color="#3ca0e629" text-color="#3ca0e6">公司</van-tag>
<strong>{{addressTitle}}</strong>
</div>
<div
slot="label"
>{{choosed_address.name}}({{choosed_address.gender==0?'':(choosed_address.gender==1?'男士':'女士')}}) {{this.choosed_address.tel}}</div>
</van-cell>
</div>
<section class="section">
<confirm-foods-list :shopInfo="shopInfo" :goods_list="checkoutData.goods_list"></confirm-foods-list>
</section>
<van-row class="order-box">
<van-cell :value="'¥'+checkoutData.delivery_fee || 0">
<div slot="title">
<van-tag color="#1f9af8">配送费</van-tag>
</div>
</van-cell>
<van-cell class="total">
<div slot="title">订单</div>
<span>
小计 ¥
<strong class="text-medium">{{checkoutData.price_final}}</strong>
</span>
</van-cell>
</van-row>
<van-row>
<van-cell title="订单备注" value="口味、偏好" is-link></van-cell>
<van-cell title="餐具份数" value="必选" is-link></van-cell>
<van-cell title="发票信息" value="未选择" is-link></van-cell>
</van-row>
</section>
<van-submit-bar
:loading="btnLoading"
:price="checkoutData.price_final*100"
:tip="submitBarTip"
button-text="提交订单"
@submit="onSubmit"
/>
<pay :order_no="order_no" :showActionSheet="showActionSheet" @click="payAction"></pay>
<cube-loading v-if="showLoading" :size="40"></cube-loading>
</div>
</template>
<script>
import pay from "@/components/pay.vue";
import confirmFoodsList from "@/components/confirm-foods-list.vue";
import { mapState, mapMutations } from "vuex";
import { preorder, placeOrder } from "../../common/serve";
export default {
data() {
return {
geohash: "", //geohash位置信息
shopId: null, //商店id值
showLoading: true, //显示加载动画
checkoutData: {
price_final: 0
}, //数据返回值
shopCart: null, //购物车数据
needbuy: [], // 待支付商品
btnLoading: false,
showActionSheet: false,
submitBarTip: "", //提交订单提示
order_no: "", // 订单支付成功后返回的 order_no
showPayWay: false, //显示付款方式
payWayId: 1, //付款方式
showAlert: false, //弹出框
alertText: null //弹出框内容
};
},
created() {
//获取上个页面传递过来的shopid值
this.shopId = this.$route.params.shopId;
//获取当前商铺购物车信息
this.shopCart = this.cartList[this.shopId];
// 当前定位
this.geohash = this.$route.query.geohash;
},
mounted() {
if (this.geohash) {
this.initData();
// this.SAVE_GEOHASH(this.geohash);
}
if (!(this.userInfo && this.userInfo.user_id)) {
// this.showAlert = true;
// this.alertText = '您还没有登录';
}
},
components: {
pay,
confirmFoodsList
},
computed: {
...mapState([
"cartList",
"shopInfo",
"choosed_address",
"inputText",
"invoice",
"userInfo"
]),
addressTitle() {
return (
this.choosed_address.address_detail +
this.choosed_address.address_suffix.split(",")[1]
);
},
//备注页返回的信息进行处理
remarklist: function() {
let str = new String();
if (this.remarkText) {
Object.values(this.remarkText).forEach(item => {
str += item[1] + ",";
});
}
//是否有自定义备注,分开处理
if (this.inputText) {
return str + this.inputText;
} else {
return str.substr(0, str.lastIndexOf(","));
}
}
},
methods: {
//初始化数据
async initData() {
let newArr = new Array();
Object.values(this.shopCart).forEach(categoryItem => {
Object.values(categoryItem).forEach(item => {
newArr.push({
goods_id: item.id,
goods_quantity: item.num
});
});
});
this.needbuy = newArr;
//检验订单是否满足条件
let msg = await preorder(
this.shopId,
this.checkoutData.price_final,
this.choosed_address.id,
newArr
);
if (msg.code == 0) {
this.checkoutData = msg.data;
}
this.showLoading = false;
},
//获取地址信息,第一个地址为默认选择地址
/* async initAddress() {
const addressRes = await getAddressList(this.userInfo.user_id);
if (addressRes instanceof Array && addressRes.length) {
// this.CHOOSE_ADDRESS({address: addressRes[0], index: 0});
}
}, */
// 添加地址
selectAddress() {
this.$router.push({ name: "address" });
},
// 提交订单
async onSubmit() {
this.btnLoading = true;
if (!this.choosed_address || !this.choosed_address.id) {
this.submitBarTip = "请选择收货地址";
this.btnLoading = false;
return;
}
let res = await placeOrder(
this.shopId,
this.checkoutData.price_final,
this.choosed_address.id,
this.needbuy
);
if (res.code == 0) {
this.order_no = res.data.order_no;
// 预下单商品检测成功后执行支付操作
this.showActionSheet = true;
} else {
if (res.code == 2054) {
this.submitBarTip = res.message;
return;
}
this.$toast(res.message);
}
this.btnLoading = false;
},
payAction() {
this.showActionSheet = false;
}
}
};
</script>
<style lang="stylus" scoped>
@import '~common/stylus/variable.styl';
@import '~common/stylus/mixin.styl';
.van-contact-card {
.van-cell__title {
strong {
font-size: $fontsize-large;
font-weight: 600;
}
}
}
.confirm-order-container {
p, span {
font-family: Helvetica Neue, Tahoma, Arial;
}
}
.order-box .van-cell__value {
scw($fontsize-medium, #3e3e3e, 600);
}
.fade-enter-active, .fade-leave-active {
transition: opacity 0.3s;
}
.fade-enter, .fade-leave-active {
opacity: 0;
}
.slid_up-enter-active, .slid_up-leave-active {
transition: all 0.3s;
}
.slid_up-enter, .slid_up-leave-active {
transform: translate3d(0, 10rem, 0);
}
.router-slid-enter-active, .router-slid-leave-active {
transition: all 0.4s;
}
.router-slid-enter, .router-slid-leave-active {
transform: translate3d(2rem, 0, 0);
opacity: 0;
}
</style>
......@@ -18,7 +18,7 @@
<i class="cubeic-location text-primary text-extra-large"></i>
<span
class="text-medium"
>{{currentAddress.address_detail?currentAddress.address_detail:'定位中...'}}</span>
>{{curLocation.formattedAddress}}</span>
<div class="location-action">
<i class="cubeic-select text-extra-small"></i>
</div>
......@@ -61,7 +61,7 @@
<section class="section">
<div class="section-hd">附件商家</div>
<ul class="cards">
<shop-list :options="shopsData"></shop-list>
<shop-list :options="shopsData" :location="curLocation"></shop-list>
</ul>
</section>
</cube-scroll>
......@@ -136,7 +136,6 @@ export default {
data() {
return {
loading: true,
currentAddress: {}, // 当前收货地址
gridsData: d,
shopsData: [b, b, b],
......@@ -163,23 +162,25 @@ export default {
};
},
created() {
/* setTimeout(() => {
setTimeout(() => {
map = new AMap.Map("amap", {
resizeEnable: true,
zoom: 16
});
this.$store.dispatch("GET_LOCATION", map);
}, 20); */
// if (this.location.lat) {
// this.loading = false;
// }
}, 20);
},
mounted() {
this.initData();
},
/* computed: {
...mapState(["location"])
}, */
computed: {
...mapState(["location","choosed_address"]),
// 当前使用的定位
curLocation(){
console.log(this.choosed_address)
return this.choosed_address.lat?this.choosed_address:(this.location.lat?this.location:'定位中')
},
},
components: {
footGuide,
CubePage,
......@@ -187,39 +188,21 @@ export default {
},
methods: {
async initData() {
let p1 = getNearbyShop(
this.curLocation.lat,
this.curLocation.lng
); // 获取附近的商家
let p2 = getReceivingAddress(); // 获取默认的收货地址
Promise.all([p2])
Promise.all([p1,p2])
.then(result => {
let addressData = result[0].data;
// this.currentAddress = addressData.find(item => item.is_default==1);
let addressData = result[1].data;
this.currentAddress = addressData[4];
Object.assign(this.currentAddress, {
lat: 121.514158,
lng: 31.299059
});
this.loading = false;
})
.catch(error => {
console.log(error);
});
let msg = await getReceivingAddress(); // 获取默认的收货地址
if (msg.code == 0) {
let addressData = msg.data;
// this.currentAddress = addressData.find(item => item.is_default==1);
this.currentAddress = addressData[4];
Object.assign(this.currentAddress, {
lat: 121.514632,
lng: 31.298043
});
}
let res = await getNearbyShop(
this.currentAddress.lat,
this.currentAddress.lng
); // 获取附近的商家
if (res.code == 0) {
}
this.loading = false;
},
scrollHandler({ y }) {
......
<template>
<div>
dingdan
<div class="container scroll-list-wrap">
<cube-loading v-if="pageLoading" :size="40"></cube-loading>
<!--
<van-list
v-if="orderList.length&&!pageLoading"
v-model="loading"
:finished="finished"
@load="onLoad"
:offset="10"
>-->
<cube-scroll
v-if="orderList.length&&!pageLoading"
ref="scroll"
:data="orderList"
:options="options"
@pulling-down="onPullingDown"
@pulling-up="onPullingUp"
>
<order-card :data="orderList" @select="orderDetail" @show="linkShop" class="content"></order-card>
</cube-scroll>
<van-row
v-else-if="!pageLoading"
type="flex"
justify="center"
class="bg-transparent nodata-tip"
>
<van-icon name="bag-o" size="60" color="#7d7e80">
<p class="text-default">暂无订单</p>
</van-icon>
</van-row>
<footGuide default="orderIndex"></footGuide>
</div>
</template>
<script>
import orderCard from "@/components/order-card.vue";
import footGuide from "../../components/footer";
import { getOrder } from "../../common/serve";
import {mapState } from 'vuex';
export default {
data() {
return {};
return {
pageLoading: true,
orderList: [],
pageNumber: 1,
loading: false, //控制上拉加载的加载动画
finished: false, //控制在页面往下移动到底部时是否调用接口获取数据
isLoading: false //控制下拉刷新的加载动画
};
},
computed: {
...mapState(["location","choosed_address"]),
// 当前使用的定位
curLocation(){
return this.choosed_address.lat?this.choosed_address:(this.location.lat?this.location:'定位中')
},
options() {
return {
pullDownRefresh: this.pullDownRefreshObj,
pullUpLoad: this.pullUpLoadObj,
scrollbar: true
};
},
pullDownRefreshObj: function() {
return this.pullDownRefresh
? {
threshold: 10,
txt: '13'
}
: false;
},
pullUpLoadObj: function() {
return this.pullUpLoad
? {
threshold: 10,
txt: {
more: '加载更多...',
noMore: ''
}
}
: false;
}
},
components: {
orderCard,
footGuide
},
created() {
this.initData();
},
methods: {
initData() {
this.getOrder();
},
async getOrder() {
//获取不同类型的订单
const orderType = "all";
let res = await getOrder(orderType, this.pageNumber);
if (res.code == 0) {
this.orderList = this.orderList.concat(res.data.data);
this.loading = false; //停止加载状态
if (this.pageNumber > res.data.page.count) {
// 结束加载
this.finished = true;
}
this.pageNumber++;
} else {
this.finished = true;
}
// 页面初始化是加载动画
if (this.pageNumber <= 2) {
this.pageLoading = false;
}
this.loading = false;
},
onPullingDown() {
// 模拟更新数据
setTimeout(() => {
if (Math.random() > 0.5) {
// 如果有新数据
this.items.unshift(_foods[1]);
} else {
// 如果没有新数据
this.$refs.scroll.forceUpdate();
}
}, 1000);
},
onPullingUp() {
// 模拟更新数据
setTimeout(() => {
if (Math.random() > 0.5) {
// 如果有新数据
let newPage = _foods.slice(0, 5);
this.items = this.items.concat(newPage);
} else {
// 如果没有新数据
this.$refs.scroll.forceUpdate();
}
}, 1000);
},
orderDetail(order_no) {
this.$router.push({ name: "orderDetails", params: { order_no: order_no } });
},
linkShop(shopId) {
this.$router.push({ name: "shop", params: { id: shopId },query:{geohash:this.curLocation.lat+','+this.curLocation.lng }});
},
},
watch: {
"$route.query": function(newVal, oldVal) {
if (newVal.type == "all") {
this.orderList = [];
this.initData();
}
}
}
};
</script>
\ No newline at end of file
</script>
<style lang="stylus" scoped>
.scroll-list-wrap {
bottom: 50px;
}
.content {
padding: 10px;
}
.van-cell__label {
line-height: 1;
margin-top: 0;
}
.van-panel__content .van-cell__value, .van-panel__footer {
text-align: right;
}
</style>
<template>
<div class="scroll-list-wrap">
<cube-scroll ref="scroll">
<h1 class="page-title">订单已送达</h1>
<section class="section">
<confirm-foods-list :shopInfo="shopInfo" :goods_list="order.goods"></confirm-foods-list>
<van-cell title="联系商家" class="total">
<span>
实付 ¥
<strong class="text-medium">{{order.price_final}}</strong>
</span>
</van-cell>
</section>
<van-panel title="配送信息" class="section">
<div class="text-base">
<van-cell title="送达时间" value="尽快配送"></van-cell>
<van-cell title="收货地址">
<span>
{{this.choosed_address.address_detail +
this.choosed_address.address_suffix.split(",")[1]}}
<p>{{choosed_address.name}}{{choosed_address.gender==0?'':(choosed_address.gender==1?'(男士)':'(女士)')}} {{this.choosed_address.tel}}</p>
</span>
</van-cell>
<van-cell title="配送方式" value></van-cell>
<van-cell title="配送骑手" value="名字"></van-cell>
</div>
</van-panel>
<van-panel title="订单信息" class="section">
<div class="text-base">
<van-cell title="订单号" :value="order.order_no"></van-cell>
<van-cell title="支付方式" value="在线支付"></van-cell>
<van-cell title="下单时间" :value="order.created_at"></van-cell>
<van-cell title="订单备注" value="暂无"></van-cell>
</div>
</van-panel>
</cube-scroll>
</div>
</template>
<script>
import confirmFoodsList from "@/components/confirm-foods-list.vue";
import { mapState, mapMutations } from "vuex";
import { setTimeout } from "timers";
import { getOrderDetail } from "../../common/serve";
export default {
data() {
return {
order: {
order_status: "",
goods: []
},
btnLoading: false,
showActionSheet: false,
activeSteps: 0, // 步骤条
orderAddress: {}
};
},
components: {
confirmFoodsList
},
computed: {
...mapState(["shopInfo", "choosed_address"])
},
created() {
this.getOrderInfo();
},
methods: {
async getOrderInfo() {
//根据路由参数 获取不同类型的订单
const orderNo = this.$route.params.order_no;
let res = await getOrderDetail(orderNo);
if (res.code == 0) {
let data = res.data;
this.order = res.data;
} else {
// 显示错误页面
}
this.$toast.clear();
}
}
};
</script>
<style lang="stylus" scoped>
@import '~common/stylus/variable.styl';
.page-title {
padding: 20px 10px;
}
.van-cell__value {
font-size: $fontsize-medium;
color: #6a6a6a;
}
</style>
......@@ -57,7 +57,8 @@
</div>
</van-row>
<div v-else-if="keyword==''&& searchHistory.length==0" class="no-data">暂无历史搜索</div>
<div v-else-if="keyword==''&& searchHistory.length==0" class="empty_tips"><p>找不到地址?</p> <p>尝试输入小区、写字楼或学校名</p> <p>详细地址(如门牌号等)可稍后输入哦</p></div>
</cube-scroll>
</div>
</div>
......@@ -96,6 +97,7 @@ export default {
});
poiPicker.on("poiPicked", function(poiResult) {
vm.recordHistory(poiResult.item);
vm.poiPickedFn(poiResult.item);
console.log(poiResult);
});
......@@ -112,17 +114,14 @@ export default {
this.searchHistory.push(poi);
}
localstorage.save("search-location", this.searchHistory);
// this.searchHistory = [];
},
//监听poi选中信息
//监听poi选中信息: 用户选中的poi点信息 存入Vuex
poiPickedFn(poi) {
this.recordHistory(poi);
// 用户选中的poi点信息 存入Vuex
this.$store.commit("CHOISE_POSITION", poi);
this.$router.go(-1);
this.$store.commit("RECORD_ADDRESS", {lat: poi.location.lat, lng: poi.location.lng, formattedAddress: poi.name});
this.$router.push({name:'home'});
},
setCurrentGeohash(){
setCurrentGeohash(tag){
this.poiPickedFn(tag)
},
onRouterLink(keyword) {
this.$router.replace({
......
<template>
<transition name="move" @after-leave="afterLeave">
{{food}}
<div class="food" v-show="visible">
<cube-scroll ref="scroll">
<div class="food-content">
......@@ -146,7 +145,7 @@ export default {
const food = this.food;
const addInfo = {
shopid: this.shopId,
category_id: this.categoryId,
category_id: food.goods_category_id,
food_id: food.id,
name: food.name,
favorable_price: food.favorable_price,
......@@ -164,9 +163,7 @@ export default {
}
},
components: {
// CartControl,
RatingSelect
// Split
}
};
</script>
......@@ -225,7 +222,7 @@ export default {
padding: 18px;
.title {
line-height: 14px;
line-height: 1.2;
margin-bottom: 8px;
font-size: $fontsize-medium;
font-weight: 700;
......
......@@ -50,9 +50,6 @@
</cube-scroll-nav>
<!-- 底部功能条 -->
<cube-popup type="my-popup" :position="position" :mask-closable="true" ref="toggleCart"></cube-popup>
<!-- <section class="shop-cart-wrapper">
<cube-shop-cart
ref="shopCart"
......@@ -60,23 +57,16 @@
:delivery-price="seller.deliveryPrice"
:min-price="seller.minPrice"
></cube-shop-cart>
</section>-->
<!-- 商品详情 -->
<!-- <cube-popup type="my-popup" :mask="true" ref="detailPopup">
<food-detail @close="closeDetailPopup"></food-detail>
</cube-popup>-->
</section> -->
</div>
</template>
<script type="text/ecmascript-6">
import { allCategoryAndGoods } from "../../../common/serve";
// import goodsData from "../../../data";
import foodDetail from "../children/food-detail";
import cubeShopCart from "../../../components/shopCart/shop-cart";
import { mapState } from "vuex";
// const goods = goodsData.goods;
export default {
data() {
......
......@@ -2,7 +2,7 @@
<div class="scroll-list-wrap">
<cube-sticky :pos="scrollY">
<cube-scroll ref="scroll" :scroll-events="scrollEvents" @scroll="scrollHandler">
<section class="page-header">
<section ref="header" class="page-header">
<van-image width="76" height="76" :src="$globalUrlFile+shopInfo.icon"></van-image>
<div class="prepend-content">
<h1>{{shopInfo.name}}</h1>
......@@ -39,7 +39,7 @@ import { allCategoryAndGoods, getShopInfo } from "../../common/serve";
import shopTab from "./children/shop";
import evaluate from "./children/rating/rating-select";
import shopInfo from "./children/shopInfo";
import cubeShopCart from "../../components/shopCart/shop-cart";
import goodsData from "../../data";
const goods = goodsData.goods;
......@@ -48,12 +48,14 @@ export default {
components: {
shopTab,
evaluate,
shopInfo
shopInfo,
cubeShopCart
},
data() {
return {
scrollY: 0,
scrollEvents: ["scroll"],
headerH:0, // 头部高度
checkTop: false,
data: goods,
......@@ -67,7 +69,6 @@ export default {
{ name: "商家", is: "shopInfo" }
],
labels: ["点餐", "评价", "商家"]
// components: ["shopTab", "evaluate", "shopInfo"]
};
},
created() {
......@@ -79,12 +80,17 @@ export default {
return "shopTab";
}
},
mounted(){
this.headerH = this.$refs.header.offsetHeight;
},
methods: {
scrollHandler({ y }) {
this.scrollY = -y;
},
changeHandler(label) {
this.currentTab = label;
console.log("changed to:", label);
},
async initData() {
......@@ -101,13 +107,10 @@ export default {
let shopMsg = result[1];
if (shopMsg.code == 0) {
this.shopInfo = shopMsg.data;
this.$store.commit('CURRENT_SHOPINFO',shopMsg.data)
this.$store.commit("CURRENT_SHOPINFO", shopMsg.data);
}
})
.catch(error => {
});
.catch(error => {});
}
}
};
......
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