diff --git a/api/shop.js b/api/shop.js
index 9576348..2eade75 100644
--- a/api/shop.js
+++ b/api/shop.js
@@ -3,7 +3,7 @@ import request from './request';
export default {
category:()=>request.get('/api/merchant-categories'),
list(category_id,longitude,latitude){
- const data = {longitude,latitude};
+ const data = {};
if(category_id){
data.category_id = category_id;
}
diff --git a/api/user.js b/api/user.js
index 98fd39a..1f362f5 100644
--- a/api/user.js
+++ b/api/user.js
@@ -33,7 +33,15 @@ export default {
list:()=>request.get('/api/order/user/list'),
cancel:(orderid)=>request.post(`/api/order/${orderid}/user/cancel`),
merchantList:()=>request.get('/api/merchant/order/user'),
- merchantDetail:(order_id)=>request.get(`/api/merchant/order/${order_id}`),
+ merchantDetail(order_id,longitude,latitude){
+ const data = {};
+ if(longitude&&latitude){
+ data.longitude = longitude;
+ data.latitude = latitude;
+ }
+ return request.get(`/api/merchant/order/${order_id}`,data);
+ },
+ orderQRCode:(order_id)=>request.get(`/api/merchant/order/${order_id}/verify-qrcode`),
detail:(orderid)=>request.get(`/api/order/${orderid}`)
},
coupon:{
diff --git a/app.js b/app.js
index d19ee48..35458cb 100644
--- a/app.js
+++ b/app.js
@@ -7,9 +7,6 @@ App({
key:'accessToken',
success:(res)=>{
this.globalData.accessToken = res.data;
- if(res.data){
- this.getUserInfo();
- }
}
})
},
diff --git a/components/merchantOrder/index.js b/components/merchantOrder/index.js
new file mode 100644
index 0000000..a0f1463
--- /dev/null
+++ b/components/merchantOrder/index.js
@@ -0,0 +1,68 @@
+import shopApi from '../../api/shop';
+import userApi from '../../api/user';
+
+Component({
+
+ /**
+ * 组件的属性列表
+ */
+ properties: {
+ },
+
+ /**
+ * 组件的初始数据
+ */
+ data: {
+ calculatedPrice:{},
+ product:{},
+ isShowConfirm:false
+ },
+
+ /**
+ * 组件的方法列表
+ */
+ methods: {
+ preOrder(product){
+ shopApi.calculateOrderPrice(product.id).then((data)=>{
+ this.setData({
+ calculatedPrice:data,
+ product,
+ isShowConfirm:true
+ });
+ })
+ },
+ getOrder(){
+ shopApi.order(this.data.product.id).then((data)=>{
+ userApi.createPayment(data.order_id,'PRODUCT').then((data)=>{
+ this.triggerEvent('orderCreated');
+ wx.requestPayment({
+ timeStamp:data.payment_params.timeStamp,
+ nonceStr:data.payment_params.nonceStr,
+ package:data.payment_params.package,
+ signType:data.payment_params.signType,
+ paySign:data.payment_params.paySign,
+ success:(res)=>{
+ console.log(res);
+ wx.navigateTo({
+ url: '/pages/shop/success/index',
+ })
+ },
+ fail:(res)=>{
+ console.log(res);
+ }
+ })
+ });
+ }).catch((error)=>{
+ this.setData({
+ isShowConfirm:false
+ })
+ wx.showModal({
+ title: error.message,
+ showCancel:false,
+ complete: (res) => {
+ }
+ })
+ });
+ },
+ }
+})
\ No newline at end of file
diff --git a/components/merchantOrder/index.json b/components/merchantOrder/index.json
new file mode 100644
index 0000000..c07b0d2
--- /dev/null
+++ b/components/merchantOrder/index.json
@@ -0,0 +1,5 @@
+{
+ "component": true,
+ "usingComponents": {},
+ "styleIsolation": "shared"
+}
\ No newline at end of file
diff --git a/components/merchantOrder/index.wxml b/components/merchantOrder/index.wxml
new file mode 100644
index 0000000..57f224e
--- /dev/null
+++ b/components/merchantOrder/index.wxml
@@ -0,0 +1,22 @@
+
+
+ {{product.name}}
+
+ {{tag}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/merchantOrder/index.wxss b/components/merchantOrder/index.wxss
new file mode 100644
index 0000000..3946194
--- /dev/null
+++ b/components/merchantOrder/index.wxss
@@ -0,0 +1,31 @@
+.pc-content{
+ padding:60rpx 30rpx 0 30rpx;
+}
+.pc-content .title{
+ font-size: 40rpx;
+ font-weight: 500;
+}
+.pc-content .tags{
+ margin-top:20rpx;
+}
+.pc-content .spliter{
+ margin:40rpx 0;
+}
+.pc-content .price{
+ display: flex;
+ justify-content: space-between;
+}
+.pc-content .price .key{
+ font-size: 28rpx;
+ margin-right: 12rpx;
+}
+.pc-content .price .money{
+ font-size: 44rpx;
+}
+.pc-content .price .weight{
+ font-size: 44rpx;
+ color:#FFC300;
+}
+.pc-content .button{
+ margin:54rpx 0 50rpx;
+}
\ No newline at end of file
diff --git a/components/shopItem/index.js b/components/shopItem/index.js
index ec09c8b..2394e4b 100644
--- a/components/shopItem/index.js
+++ b/components/shopItem/index.js
@@ -5,7 +5,7 @@ Component({
* 组件的属性列表
*/
properties: {
- data:{
+ shop:{
type:Object,
value:{}
}
@@ -22,5 +22,10 @@ Component({
* 组件的方法列表
*/
methods: {
+ goToDetail(event){
+ wx.navigateTo({
+ url: `/pages/shop/detail/index?id=${this.properties.shop.id}`,
+ })
+ },
}
})
\ No newline at end of file
diff --git a/components/shopItem/index.wxml b/components/shopItem/index.wxml
index 4f385a5..627e198 100644
--- a/components/shopItem/index.wxml
+++ b/components/shopItem/index.wxml
@@ -1,21 +1,21 @@
-
-
+
+
- {{data.name}}
+ {{shop.name}}
- {{data.address}}
- {{data.distance||''}}
+ {{shop.address}}
+ {{shop.distance||''}}
-
+
-
-
-
+
+
+
diff --git a/pages/help/index/index.wxss b/pages/help/index/index.wxss
index 1fea1fb..c2977b6 100644
--- a/pages/help/index/index.wxss
+++ b/pages/help/index/index.wxss
@@ -1,5 +1,5 @@
.bg{
- background: linear-gradient(180deg, #1A4DEB 62%, #F8F9FB 100%);
+ background: linear-gradient(180deg, #FEC400 62%, #F8F9FB 100%);
height:90vw;
width:100%;
position:absolute;
diff --git a/pages/order/detail-group/index.js b/pages/order/detail-group/index.js
index da695be..763fa48 100644
--- a/pages/order/detail-group/index.js
+++ b/pages/order/detail-group/index.js
@@ -1,4 +1,5 @@
import userApi from '../../../api/user';
+const app = getApp();
Page({
@@ -6,7 +7,8 @@ Page({
* 页面的初始数据
*/
data: {
- orderDetail:{}
+ orderDetail:{},
+ qrcodeUrl:''
},
goToSuccess(){
@@ -29,13 +31,34 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
- userApi.order.merchantDetail(options.id).then((data)=>{
+ app.getLocation().then((data)=>{
+ this.getOrderDetail(options.id,data.longitude,data.latitude);
+ }).catch(()=>{
+ this.getOrderDetail(options.id);
+ });
+ userApi.order.orderQRCode(options.id).then((data)=>{
+ this.setData({
+ qrcodeUrl:data.qrcode_url
+ })
+ });
+ },
+ getOrderDetail(id,lng,lat){
+ userApi.order.merchantDetail(id,lng,lat).then((data)=>{
+ if(data.distance){
+ if(data.distance>=1000){
+ data.distance = parseFloat(data.distance/1000).toFixed(1)+'km';
+ }else{
+ data.distance+='m';
+ }
+ }
+ if(data.product_tags){
+ data.product_tags = data.product_tags.split(',');
+ }
this.setData({
orderDetail:data
})
- })
+ });
},
-
/**
* 生命周期函数--监听页面初次渲染完成
*/
diff --git a/pages/order/detail-group/index.wxml b/pages/order/detail-group/index.wxml
index 975ed12..0bfd866 100644
--- a/pages/order/detail-group/index.wxml
+++ b/pages/order/detail-group/index.wxml
@@ -3,22 +3,21 @@
{{orderDetail.product_name}}
- 周一至周五可用
- 免预约
+ {{item}}
{{orderDetail.order_amount}}
- 二维码区域,小程序存储总量限制
+
{{orderDetail.merchant_name}}
- 距离 xxx km
+ 距离{{orderDetail.distance}}
@@ -52,10 +51,6 @@
交易方式
微信支付
-
- 手机号码
- {{}}
-
下单时间
{{orderDetail.create_time}}
diff --git a/pages/order/detail-group/index.wxss b/pages/order/detail-group/index.wxss
index 061b08f..7d2f7b0 100644
--- a/pages/order/detail-group/index.wxss
+++ b/pages/order/detail-group/index.wxss
@@ -29,6 +29,10 @@
margin: 0 auto;
background-color: #999;
}
+.prd-info .qrcode .image{
+ width:100%;height:100%;
+ vertical-align: middle;
+}
.address{
display: flex;
diff --git a/pages/order/index/index.js b/pages/order/index/index.js
index e9428d3..837bef3 100644
--- a/pages/order/index/index.js
+++ b/pages/order/index/index.js
@@ -30,13 +30,32 @@ Page({
url: `/pages/order/detail/index?id=${orderId}`,
})
},
+ goToShopDetail(event){
+ const item = event.currentTarget.dataset.item;
+ //缺少 shopid
+ // wx.navigateTo({
+ // url: `/pages/shop/detail/index?id=${item.id}`,
+ // })
+ },
goToCouponDetail(event){
const id = event.currentTarget.dataset.id;
wx.navigateTo({
url: `/pages/order/detail-group/index?id=${id}`,
})
},
-
+ orderAgain(event){
+ const order = event.currentTarget.dataset.item;
+ const orderConfirm = this.selectComponent("#merchantOrderConfirm");
+ orderConfirm.preOrder({
+ id:order.merchant_product_id,
+ name:order.product_name,
+ tags:order.product_tags
+ });
+ },
+ orderCreated(){
+ //创建成功之后刷新 order 列表,成功之后会跳转,不用刷新
+ this.loadMerchantOrderList();
+ },
/**
* 生命周期函数--监听页面加载
*/
@@ -64,6 +83,11 @@ Page({
loadMerchantOrderList(){
//代金券列表
userApi.order.merchantList().then((data)=>{
+ data.map((item)=>{
+ if(item.product_tags){
+ item.product_tags = item.product_tags.split(',');
+ }
+ })
this.setData({
couponList:data
})
diff --git a/pages/order/index/index.json b/pages/order/index/index.json
index e5c8349..90bcbed 100644
--- a/pages/order/index/index.json
+++ b/pages/order/index/index.json
@@ -1,6 +1,7 @@
{
"usingComponents": {
- "nav-bar":"/components/navbar"
+ "nav-bar":"/components/navbar",
+ "merchant-order":"/components/merchantOrder"
},
"navigationStyle": "custom"
}
\ No newline at end of file
diff --git a/pages/order/index/index.wxml b/pages/order/index/index.wxml
index 2f9f0c0..8213143 100644
--- a/pages/order/index/index.wxml
+++ b/pages/order/index/index.wxml
@@ -38,7 +38,7 @@
-
+
{{item.merchant_name}}
-{{item.amount}}
@@ -68,31 +68,33 @@
-
+
-
+
- {{merchantOrderStatusKV[item.status]}}
+ {{merchantOrderStatusKV[item.status]}}
{{item.product_name}}
- 周一至周五可用
- 免预约
+ {{item}}
{{item.order_amount}}
-
-
+
+
暂无相关订单
-
\ No newline at end of file
+
+
+
+
\ No newline at end of file
diff --git a/pages/order/index/index.wxss b/pages/order/index/index.wxss
index a9cc71c..c6d12f9 100644
--- a/pages/order/index/index.wxss
+++ b/pages/order/index/index.wxss
@@ -94,11 +94,14 @@
.group-list .item{
background-color: #fff;
border-radius: 18rpx;
- padding: 30rpx 40rpx;
+ padding: 20rpx 40rpx;
margin:24rpx 0;
}
-.group-list .item.status-waiting .status{
- color: #1A4DEB;
+.group-list .item .status{
+ color:var(--main-color);
+}
+.group-list .item .status.VERIFIED,.group-list .item .status.REFUNDED{
+ color:var(--main-font-color);
}
.group-list .head{
display: flex;
@@ -109,6 +112,7 @@
flex:1;
display: flex;
align-items: center;
+ padding:10rpx 0;
}
.group-list .head .name .icon{
width:28rpx;height:28rpx;
@@ -117,7 +121,7 @@
.group-list .content{
display: flex;
- margin-top:30rpx;
+ margin-top:20rpx;
}
.group-list .content .image{
width:160rpx;height:160rpx;
@@ -138,8 +142,11 @@
padding:16rpx 26rpx;
border-radius: 12rpx;
}
+.group-list .btns .button1{
+ color: #555555;
+ border-color: rgba(153, 153, 153, 0.5);
+}
.group-list .btns .button2{
- color: #1A4DEB;
margin-left: 20rpx;
}
diff --git a/pages/shop/detail/index.js b/pages/shop/detail/index.js
index 6ac88c5..f502fd9 100644
--- a/pages/shop/detail/index.js
+++ b/pages/shop/detail/index.js
@@ -19,46 +19,10 @@ Page({
showConfirm(event){
const currentProduct = event.currentTarget.dataset.item;
- shopApi.calculateOrderPrice(currentProduct.id).then((data)=>{
- this.setData({
- calculatedPrice:data,
- currentProduct,
- isShowConfirm:true
- });
- })
- },
- getOrder(){
- shopApi.order(this.data.currentProduct.id).then((data)=>{
- userApi.createPayment(data.order_id,'PRODUCT').then((data)=>{
- wx.requestPayment({
- timeStamp:data.payment_params.timeStamp,
- nonceStr:data.payment_params.nonceStr,
- package:data.payment_params.package,
- signType:data.payment_params.signType,
- paySign:data.payment_params.paySign,
- success:(res)=>{
- console.log(res);
- wx.navigateTo({
- url: '/pages/shop/success/index',
- })
- },
- fail:(res)=>{
- console.log(res);
- }
- })
- });
- }).catch((error)=>{
- this.setData({
- isShowConfirm:false
- })
- wx.showModal({
- title: error.message,
- showCancel:false,
- complete: (res) => {
- }
- })
- });
+ const orderConfirm = this.selectComponent("#merchantOrderConfirm");
+ orderConfirm.preOrder(currentProduct);
},
+
/**
* 生命周期函数--监听页面加载
@@ -82,10 +46,12 @@ Page({
},
getOrderDetail(id,lng,lat){
shopApi.detail(id,lng,lat).then((data)=>{
- if(data.distance&&data.distance>=1000){
- data.distance = parseFloat(data.distance/1000).toFixed(1)+'km';
- }else{
- data.distance+='m';
+ if(data.distance){
+ if(data.distance>=1000){
+ data.distance = parseFloat(data.distance/1000).toFixed(1)+'km';
+ }else{
+ data.distance+='m';
+ }
}
this.setData({
detail:data
diff --git a/pages/shop/detail/index.json b/pages/shop/detail/index.json
index e5c8349..90bcbed 100644
--- a/pages/shop/detail/index.json
+++ b/pages/shop/detail/index.json
@@ -1,6 +1,7 @@
{
"usingComponents": {
- "nav-bar":"/components/navbar"
+ "nav-bar":"/components/navbar",
+ "merchant-order":"/components/merchantOrder"
},
"navigationStyle": "custom"
}
\ No newline at end of file
diff --git a/pages/shop/detail/index.wxml b/pages/shop/detail/index.wxml
index ed2e10a..77a9e77 100644
--- a/pages/shop/detail/index.wxml
+++ b/pages/shop/detail/index.wxml
@@ -26,7 +26,7 @@
{{detail.address}}
- 距离{{detail.distance}}
+ 距离{{detail.distance}}
@@ -76,26 +76,4 @@
-
-
-
- {{currentProduct.name}}
-
- {{tag}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
diff --git a/pages/shop/detail/index.wxss b/pages/shop/detail/index.wxss
index ba3d5ea..5c78051 100644
--- a/pages/shop/detail/index.wxss
+++ b/pages/shop/detail/index.wxss
@@ -187,34 +187,4 @@
padding:18rpx 46rpx;
margin-left:40rpx;
}
-.pc-content{
- padding:60rpx 30rpx 0 30rpx;
-}
-.pc-content .title{
- font-size: 40rpx;
- font-weight: 500;
-}
-.pc-content .tags{
- margin-top:20rpx;
-}
-.pc-content .spliter{
- margin:40rpx 0;
-}
-.pc-content .price{
- display: flex;
- justify-content: space-between;
-}
-.pc-content .price .key{
- font-size: 28rpx;
- margin-right: 12rpx;
-}
-.pc-content .price .money{
- font-size: 44rpx;
-}
-.pc-content .price .weight{
- font-size: 44rpx;
- color:#FFC300;
-}
-.pc-content .button{
- margin:54rpx 0 50rpx;
-}
+
diff --git a/pages/shop/index/index.js b/pages/shop/index/index.js
index 3e0dfbe..926d660 100644
--- a/pages/shop/index/index.js
+++ b/pages/shop/index/index.js
@@ -22,12 +22,6 @@ Page({
this.setData({tabIndex})
this.loadList(cid);
},
- goToDetail(event){
- const item = event.currentTarget.dataset.item;
- wx.navigateTo({
- url: `/pages/shop/detail/index?id=${item.id}`,
- })
- },
loadList(cid){
shopApi.list(cid,this.data.lng,this.data.lat).then((data)=>{
data.items.map((item)=>{
diff --git a/pages/shop/index/index.wxml b/pages/shop/index/index.wxml
index 406aed4..59b65d7 100644
--- a/pages/shop/index/index.wxml
+++ b/pages/shop/index/index.wxml
@@ -13,8 +13,8 @@
-
-
+
+
diff --git a/pages/shop/success/index.js b/pages/shop/success/index.js
index b43b4d6..3c0b16f 100644
--- a/pages/shop/success/index.js
+++ b/pages/shop/success/index.js
@@ -1,4 +1,6 @@
import shopApi from '../../../api/shop';
+const app = getApp();
+
Page({
/**
@@ -12,7 +14,23 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
- shopApi.list().then((data)=>{
+ app.getLocation().then((res)=>{
+ this.getProductList(res.longitude,res.latitude);
+ }).catch(()=>{
+ this.getProductList();
+ })
+ },
+ getProductList(lng,lat){
+ shopApi.list(null,lng,lat).then((data)=>{
+ data.items.map((item)=>{
+ if(item.distance){
+ if(item.distance>=1000){
+ item.distance = parseFloat(item.distance/1000).toFixed(1)+'km';
+ }else{
+ item.distance+='m';
+ }
+ }
+ });
this.setData({
shopList:data.items
});
diff --git a/pages/shop/success/index.wxml b/pages/shop/success/index.wxml
index ad1baaa..ca14604 100644
--- a/pages/shop/success/index.wxml
+++ b/pages/shop/success/index.wxml
@@ -4,7 +4,7 @@
-
+
\ No newline at end of file