diff --git a/api/common.js b/api/common.js
index f32f023..6b75dcb 100644
--- a/api/common.js
+++ b/api/common.js
@@ -1,12 +1,6 @@
import request from './request'
let app = getApp();
-let token;
-wx.getStorage({
- key:'accessToken',
- success:(res)=>{
- token = res.data;
- }
-})
+const token = wx.getStorageSync('accessToken');
export default {
community:{
@@ -22,35 +16,41 @@ export default {
},
add:(data)=>request.post('/api/address',data),
update:(data)=>request.put(`/api/address/${data.id}`,data),
+ detail:(address_id)=>request.get(`/api/address/${address_id}`),
+ delete:(address_id)=>request.delete(`/api/address/${address_id}`)
},
building:{
- list(communityId){
+ list(community_id){
if(!app){
app = getApp();
}
const data = {
- community_id:communityId,
+ community_id,
user_id:app.globalData.userInfo.userid
}
- return request.get('/api/community/building/list')
+ return request.get('/api/community/building/list',{community_id})
}
},
station:{
list:(community_id)=>request.get('/api/station',{community_id})
},
uploadImg(file){
- // const formData = new formData();
- // return request.post('/api/upload/image',{file:file});
- wx.uploadFile({
- filePath: file.tempFilePath,
- name: 'name',
- header:{
- Authorization: `Bearer ${token}`
- },
- formData:{
- file:file
- },
- url: request.baseUrl+'/api/upload/image',
- })
+ return new Promise((rs,rj)=>{
+ wx.uploadFile({
+ filePath: file.tempFilePath,
+ name: 'file',
+ header:{
+ Authorization: `Bearer ${token}`
+ },
+ url: request.baseUrl+'/api/upload/image',
+ success:(res)=>{
+ const response = JSON.parse(res.data);
+ rs(response.data);
+ },
+ fail:(res)=>{
+ rj(res);
+ }
+ })
+ });
}
}
\ No newline at end of file
diff --git a/api/request.js b/api/request.js
index 8a11fb2..1df8e60 100644
--- a/api/request.js
+++ b/api/request.js
@@ -1,14 +1,8 @@
const baseUrl = 'https://api-dev.beefast.co';
-let token;
-wx.getStorage({
- key:'accessToken',
- success:(res)=>{
- token = res.data;
- }
-})
+let app = getApp();
const sendRequest = (options)=>{
- console.log(options.data?options.data.file:1,12121212);
+ if(!app)app = getApp();
return new Promise((rs,rj)=>{
wx.request({
url: `${baseUrl}${options.url}`,
@@ -23,10 +17,15 @@ const sendRequest = (options)=>{
method:options.method,
data:options.data,
header:{
- Authorization: `Bearer ${token}`,
+ Authorization: `Bearer ${app.globalData.accessToken}`,
"content-type":options.data&&options.data.file?'application/x-www-form-urlencoded':'application/json'
},
- fail:rj
+ fail:(res)=>{
+ wx.showToast({
+ title: 'Request Error',
+ })
+ rj(res);
+ }
})
})
}
diff --git a/api/shop.js b/api/shop.js
index 1ecd7be..9576348 100644
--- a/api/shop.js
+++ b/api/shop.js
@@ -2,15 +2,53 @@ import request from './request';
export default {
category:()=>request.get('/api/merchant-categories'),
- list:(cid)=>request.get('/api/merchant',cid?{category_id:cid}:{}),
- detail:(id)=>request.get(`/api/merchant/${id}`),
+ list(category_id,longitude,latitude){
+ const data = {longitude,latitude};
+ if(category_id){
+ data.category_id = category_id;
+ }
+ if(longitude&&latitude){
+ data.longitude = longitude;
+ data.latitude = latitude;
+ }
+ return request.get('/api/merchant',data);
+ },
+ detail(id,lng,lat){
+ const data = {};
+ if(lng&&lat){
+ data.longitude = lng;
+ data.latitude = lat;
+ }
+ return request.get(`/api/merchant/${id}`,data);
+ },
productList:(merchant_id)=>request.get('/api/merchant/product/list',merchant_id?{merchant_id}:{}),
+
+
+ orderList:()=>request.get('/api/merchant-pay'),
+ //计算商品订单金额
+ calculateOrderPrice:(merchant_product_id)=>request.post('/api/merchant/order/calculate-price',{merchant_product_id}),
+ //计算在线买单赠送积分
+ calculateOrderPoint:(merchant_id,amount)=>request.post('/api/merchant-pay/calculate-points',{merchant_id,amount}),
+ //创建店铺商品订单
order(merchant_product_id,order_amount){
const data = {};
return request.post('/api/merchant/order',{merchant_product_id,order_amount})
},
- orderList:()=>request.get('/api/merchant-pay'),
- calculatePrice:(merchant_product_id)=>request.post('/api/merchant/order/calculate-price',{merchant_product_id}),
- merchantPay:(merchant_id,amount)=>request.post('/api/merchant-pay',{merchant_id,amount})
+ //创建在线买单订单
+ merchantPay:(merchant_id,amount)=>request.post('/api/merchant-pay',{merchant_id,amount}),
+
+ merchantOrderStatusKV:{
+ CREATED:'已下单',UNVERIFIED:'未核销',VERIFIED:'已核销',REFUNDING:'退款中',REFUNDED:'已退款'
+ },
+ merchantOrderStatus:{
+ created:'CREATED',unverified:'UNVERIFIED',verified:'VERIFIED',refunding:'REFUNDING',refunded:'REFUNDED'
+ },
+
+ merchantPayOrderStatusKV:{
+ UNPAID:'未支付',PAID:'已支付',REFUNDING:'退款中',REFUNDED:'已退款'
+ },
+ merchantPayOrderStatus:{
+ unpaid:'UNPAID',paid:'PAID',refunding:'REFUNDING',refunded:'REFUNDED'
+ }
}
\ No newline at end of file
diff --git a/api/user.js b/api/user.js
index 8d0fc58..98fd39a 100644
--- a/api/user.js
+++ b/api/user.js
@@ -20,9 +20,18 @@ export default {
return request.get('/api/user/info');
},
order:{
+ statusKV:{
+ CREATED:'已创建',CANCELLED:'已取消',RECEIVED:'已接单',
+ DELIVERING:'配送中',UNPAID:'未支付',COMPLETED:'已完成'
+ },
+ status:{
+ created:'CREATED',cancelled:'CANCELLED',received:'RECEIVED',
+ delivering:'DELIVERING',unpaid:'UNPAID',completed:'COMPLETED'
+ },
pre:(data)=>request.post('/api/order/pre-order',data),
real:(data)=>request.post('/api/order',data),
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}`),
detail:(orderid)=>request.get(`/api/order/${orderid}`)
diff --git a/app.js b/app.js
index 03b2b91..d19ee48 100644
--- a/app.js
+++ b/app.js
@@ -1,5 +1,6 @@
import userApi from './api/user';
import commonApi from './api/common';
+let token = wx.getStorageSync('accessToken');
App({
onLaunch() {
wx.getStorage({
@@ -32,9 +33,36 @@ App({
this.globalData.userInfoGetTime = new Date();
return data;
},
+ getLocation(){
+ return new Promise((rs,rj)=>{
+ if(this.globalData.locationGetTime&&
+ this.globalData.location&&
+ new Date()-this.globalData.locationGetTime<1000*60*1){
+ rs(this.globalData.location);
+ }
+ wx.authorize({
+ scope: 'scope.userLocation',
+ success:(res)=>{
+ wx.getLocation({
+ success:(_res)=>{
+ this.globalData.location = _res;
+ this.globalData.locationGetTime = new Date();
+ rs(_res)
+ },
+ fail(res){
+ rj();
+ }
+ });
+ },
+ fail:()=>{
+ rj();
+ }
+ })
+ })
+ },
globalData: {
userInfo: null,
- accessToken:null,
+ accessToken:token,
community:{
_list:[],
lastFetchTime:null,
diff --git a/app.json b/app.json
index 856a235..7a61ebe 100644
--- a/app.json
+++ b/app.json
@@ -64,5 +64,11 @@
"style": "v2",
"componentFramework": "glass-easel",
"sitemapLocation": "sitemap.json",
- "lazyCodeLoading": "requiredComponents"
+ "lazyCodeLoading": "requiredComponents",
+ "permission": {
+ "scope.userLocation": {
+ "desc": "你的位置信息将用于小程序位置接口的效果展示"
+ }
+ },
+ "requiredPrivateInfos": ["getLocation"]
}
\ No newline at end of file
diff --git a/app.wxss b/app.wxss
index 6a726f1..cc92615 100644
--- a/app.wxss
+++ b/app.wxss
@@ -2,11 +2,12 @@
page{
font-size:32rpx;
line-height: 1;
- color: #222222;
padding-bottom:80rpx;
+ --main-font-color:#222222;
--main-bgclolor:#F5F5F5;
--main-color:#FEC400;
--main-hover-color:#fcce39;
+ color:var(--main-font-color);
background-color:var(--main-bgclolor);
}
@@ -57,6 +58,10 @@ button[type=primary][plain]:hover{
border-color:var(--main-color);
color:var(--main-color);
}
+button[loading][type=primary] {
+ background-color:var(--main-color);
+ color: hsla(0,0%,100%,.6);
+}
radio-group{
line-height: 34rpx;
@@ -143,6 +148,10 @@ page-container .content{
border: 0.5px solid rgba(153, 153, 153, 0.5);
border-radius: 6rpx;
}
+.tags .tag.yellow{
+ color: #FFC300;
+ border-color:#FFC300;
+}
.spliter{
border-bottom: 1px solid rgba(153, 153, 153, 0.2);
}
diff --git a/assets/icon/help/success@2x.png b/assets/icon/help/success@2x.png
index ef71123..bd65176 100644
Binary files a/assets/icon/help/success@2x.png and b/assets/icon/help/success@2x.png differ
diff --git a/assets/icon/navbar/back@2x.png b/assets/icon/navbar/back@2x.png
new file mode 100644
index 0000000..99e316b
Binary files /dev/null and b/assets/icon/navbar/back@2x.png differ
diff --git a/assets/icon/navbar/share@2x.png b/assets/icon/navbar/share@2x.png
new file mode 100644
index 0000000..2895522
Binary files /dev/null and b/assets/icon/navbar/share@2x.png differ
diff --git a/assets/icon/shop/phone@2x.png b/assets/icon/shop/phone@2x.png
index 03a8279..fd36efd 100644
Binary files a/assets/icon/shop/phone@2x.png and b/assets/icon/shop/phone@2x.png differ
diff --git a/components/address/index.js b/components/address/index.js
index f1d0394..a1eeb6b 100644
--- a/components/address/index.js
+++ b/components/address/index.js
@@ -100,6 +100,7 @@ Component({
commonApi.address.update(data);
}else{
//新增
+ data.is_default = true;
commonApi.address.add(data).then((data)=>{
const pages = getCurrentPages();
const prePage = pages[pages.length-2];
diff --git a/components/navbar/index.js b/components/navbar/index.js
index 05382be..41b9578 100644
--- a/components/navbar/index.js
+++ b/components/navbar/index.js
@@ -4,8 +4,23 @@ Component({
/**
* 组件的属性列表
*/
- properties: {
-
+ properties:{
+ back:{
+ type:Boolean,
+ value:false
+ },
+ backTitle:{
+ type:String,
+ value:''
+ },
+ share:{
+ type:Boolean,
+ value:false
+ },
+ background:{
+ type:String,
+ value:''
+ }
},
/**
@@ -28,6 +43,10 @@ Component({
* 组件的方法列表
*/
methods: {
-
+ back(){
+ wx.navigateBack();
+ },
+ share(){
+ },
}
})
\ No newline at end of file
diff --git a/components/navbar/index.wxml b/components/navbar/index.wxml
index 7f55008..1c1d7a6 100644
--- a/components/navbar/index.wxml
+++ b/components/navbar/index.wxml
@@ -1,5 +1,16 @@
-
+
-
+
+
+
+
+
+
+ {{backTitle}}
+
+
+
+
+
\ No newline at end of file
diff --git a/components/navbar/index.wxss b/components/navbar/index.wxss
index 4114c0b..3605b44 100644
--- a/components/navbar/index.wxss
+++ b/components/navbar/index.wxss
@@ -1,9 +1,51 @@
/* components/navBar.wxss */
.nav-bar{
- text-align: center;
}
.nav-bar-content{
display: flex;
align-items: center;
- justify-content: center;
-}
\ No newline at end of file
+ justify-content: space-between;
+ padding:0 34rpx;
+}
+.nav-bar-content .left{
+ flex:1;
+ display: flex;
+ align-items: center;
+}
+.nav-bar-content .left .btns{
+ display: inline-flex;
+ align-items: center;
+ border-radius: 60rpx;
+ vertical-align: middle;
+}
+.nav-bar-content .left .spliter{
+ width:1.2rpx;height:36rpx;
+ background-color:#D8D8D8;
+}
+/*单一一个返回或者加上 backTitle的时候*/
+.nav-bar-content .back{
+ width:40rpx;height:40rpx;
+ padding:12rpx 14rpx 12rpx 0;
+}
+.nav-bar-content .left .btns.border{
+ border: 1.2px solid #D8D8D8;
+}
+/*有俩按钮 back+share 的时候*/
+.nav-bar-content .left .btns.border .back{
+ padding:12rpx 24rpx;
+ width:36rpx;height:36rpx;
+}
+.nav-bar-content .back-title{
+ font-size: 36rpx;
+ font-weight: 600;
+ white-space: nowrap;
+}
+.nav-bar-content .share{
+ width:30rpx;height:34rpx;
+ padding:12rpx 28rpx;
+}
+.nav-bar-content .center{
+ flex:1;
+ text-align: center;
+}
+.nav-bar-content .right{flex:1;}
\ No newline at end of file
diff --git a/components/shopItem/index.js b/components/shopItem/index.js
index b603d7d..ec09c8b 100644
--- a/components/shopItem/index.js
+++ b/components/shopItem/index.js
@@ -22,6 +22,5 @@ Component({
* 组件的方法列表
*/
methods: {
-
}
})
\ No newline at end of file
diff --git a/components/shopItem/index.wxml b/components/shopItem/index.wxml
index 98224e6..4f385a5 100644
--- a/components/shopItem/index.wxml
+++ b/components/shopItem/index.wxml
@@ -1,24 +1,22 @@
-
+
{{data.name}}
{{data.address}}
{{data.distance||''}}
-
-
-
- {{data.featured_product.product_name}}
+
+
+
+
-
\ No newline at end of file
diff --git a/components/shopItem/index.wxss b/components/shopItem/index.wxss
index 6d58f60..f5ee4a0 100644
--- a/components/shopItem/index.wxss
+++ b/components/shopItem/index.wxss
@@ -19,38 +19,15 @@
display: flex;
color:#888888;
margin-top:14rpx;
+ padding-bottom:10rpx;
}
.shop-item .line2-1{
flex:1;
-}
-.shop-item .line-coupon{
- font-size: 26rpx;
- margin-top: 20rpx;
- position: relative;
-}
-.shop-item .line-coupon::before{
- content: '惠';
- width:34rpx;height:34rpx;
- font-size:22rpx;
- border-radius: 8rpx;
- background-color: #FF8400;
- color: #fff;
- display: inline-block;
- text-align: center;
- line-height: 34rpx;
- vertical-align: top;
- margin-right: 8rpx;
-}
-.shop-item .money{
- font-size: 32rpx;
-}
-.shop-item .money-disable{
- font-size: 28rpx;
- margin-left:10rpx;
+ margin-right:10rpx;
}
.shop-item .promation{
- margin-top:30rpx;
+ margin-top:20rpx;
}
.shop-item .promation .coupon{
@@ -58,6 +35,10 @@
align-items: center;
font-size: 24rpx;
}
+.shop-item .promation.buy .coupon::before{
+ content: '买';
+ background-color:#EB0000;
+}
.shop-item .promation .coupon::before{
content: '券';
background-color: #FFC300;
@@ -66,8 +47,14 @@
border-radius: 4rpx;
color:#fff;
}
+.shop-item .promation.buy .tag{
+ color:#ff0000;
+}
.shop-item .promation .tag{
font-weight: 500;
margin:0 16rpx;
color:#FFC300;
+}
+.shop-item .promation .detail{
+ color:#555555;
}
\ No newline at end of file
diff --git a/pages/help/address/edit/index.js b/pages/help/address/edit/index.js
index 3f6ea07..e86e31a 100644
--- a/pages/help/address/edit/index.js
+++ b/pages/help/address/edit/index.js
@@ -1,36 +1,143 @@
-// pages/help/address/edit/index.js
+import commonApi from '../../../../api/common';
+
+
Page({
/**
* 页面的初始数据
*/
data: {
+ buildingList:[],
+ buildingIndex:0,
+ communityId:null,
+ communityName:'',
+ editType:'add',
+ addressDetail:{},
+
+ name:'',
+ gender:'',
+ phone:'',
+ community_building_id:'',
+ address_detail:''
},
deleteAddress(){
- console.log('delete');
wx.showModal({
title: '确定删除此地址吗',
content: '',
complete: (res) => {
- if (res.cancel) {
-
- }
if (res.confirm) {
-
+ commonApi.address.delete(this.data.addressDetail.id).then(()=>{
+ wx.navigateBack({
+ success(){
+ wx.showToast({
+ title: '删除成功',
+ icon:'success'
+ });
+ }
+ });
+ });
}
}
})
},
- saveAddress(){
- console.log('save');
- },
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
- },
+ const communityId = options.community_id;
+ const communityName = options.community_name;
+ const addressId = options.address_id;
+ this.setData({
+ editType:addressId?'edit':'add'
+ });
+
+ //修改
+ if(addressId){
+ commonApi.address.detail(addressId).then((data)=>{
+ this.setData({
+ communityId:data.community_id,
+ communityName:data.community_name,
+ addressDetail:data,
+
+ name:data.name,
+ gender:data.gender,
+ phone:data.phone,
+ community_building_id:data.community_building_id,
+ address_detail:data.address_detail
+ });
+ this.getBuildingList();
+ });
+ }else{
+ //新增
+ this.setData({
+ communityId,communityName
+ })
+
+ this.getBuildingList();
+ }
+ },
+ save(){
+ let data = {
+ community_id:this.data.communityId,
+ community_building_id:this.data.buildingList[this.data.buildingIndex].id,
+ address_detail:this.data.address_detail,
+ name:this.data.name,
+ gender:this.data.gender,
+ phone:this.data.phone
+ }
+ if(this.data.editType=='edit'){
+ //编辑
+ data.id = this.data.addressDetail.id;
+ commonApi.address.update(data).then((data)=>{
+ wx.navigateBack({
+ success(){
+ wx.showToast({
+ title: '修改成功',
+ icon:'success'
+ });
+ }
+ });
+ });
+ }else if(this.data.editType=='add'){
+ //新增
+ data.is_default = true;
+
+ commonApi.address.add(data).then((data)=>{
+ // const pages = getCurrentPages();
+ // const prePage = pages[pages.length-2];
+ // prePage.changeAddress(data);
+ wx.navigateBack({
+ delta:2,
+ success(){
+ wx.showToast({
+ title: '新增成功',
+ icon:'success'
+ });
+ }
+ });
+ });
+ }
+ },
+ getBuildingList(){
+ commonApi.building.list(this.data.communityId).then((data)=>{
+ let buildingIndex = 0;
+ data.items.map((item,index)=>{
+ item.displayText = `${item.community_name} ${item.building_name}`;
+ if(item.id==this.data.addressDetail.community_building_id){
+ buildingIndex = index;
+ }
+ });
+ this.setData({
+ buildingList:data.items,
+ buildingIndex
+ })
+ });
+ },
+ buildingChange(event){
+ console.log(this.data.buildingIndex);
+ },
/**
* 生命周期函数--监听页面初次渲染完成
*/
diff --git a/pages/help/address/edit/index.wxml b/pages/help/address/edit/index.wxml
index 83c6280..8d35f21 100644
--- a/pages/help/address/edit/index.wxml
+++ b/pages/help/address/edit/index.wxml
@@ -1 +1,43 @@
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 女士
+
+
+
+
+ 手机号码
+
+
+
+
+
+ 选择楼栋
+
+
+
+
+
+ 详细地址
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/help/address/edit/index.wxss b/pages/help/address/edit/index.wxss
index 885ffb7..4edea08 100644
--- a/pages/help/address/edit/index.wxss
+++ b/pages/help/address/edit/index.wxss
@@ -1 +1,42 @@
-/* pages/help/address/edit/index.wxss */
\ No newline at end of file
+.page-container.editor{
+ padding-top:0;
+ font-size: 30rpx;
+}
+.editor .item{
+ display: flex;
+ align-items: center;
+ border-bottom: 1rpx solid rgba(153, 153, 153, 0.2);
+ min-height: 130rpx;
+}
+.editor .item.no-border{
+ border:none;
+}
+
+.editor .item .key{
+}
+.editor .item .key::before{
+ content: '*';
+ color: #EB0000;
+}
+.editor .item label.value{
+ line-height: 1.5;
+ height: auto;
+ align-self: center;
+}
+.editor .item .value{
+ flex:1;
+ margin-left: 30rpx;
+ height: 100%;
+ padding:15rpx 0;
+ box-sizing: border-box;
+}
+.editor .item .right-icon{
+ width:34rpx;height:34rpx;
+}
+
+.editor .radio-group{
+ font-size: 24rpx;
+}
+.editor button+button{
+ margin-top:30rpx;
+}
\ No newline at end of file
diff --git a/pages/help/address/index/index.js b/pages/help/address/index/index.js
index 6714677..0882174 100644
--- a/pages/help/address/index/index.js
+++ b/pages/help/address/index/index.js
@@ -7,21 +7,17 @@ Page({
*/
data: {
addressList:[],
- communityId:null
+ communityId:null,
+ communityName:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
- console.log(options);
this.setData({
- communityId:options.communityId
- })
- commonApi.address.list(options.communityId).then((data)=>{
- this.setData({
- addressList:data
- })
+ communityId:options.community_id,
+ communityName:options.community_name
})
},
@@ -36,7 +32,11 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
-
+ commonApi.address.list(this.data.communityId).then((data)=>{
+ this.setData({
+ addressList:data
+ })
+ });
},
/**
@@ -73,12 +73,25 @@ Page({
onShareAppMessage() {
},
-
+ setCurrentAddress(event){
+ const item = event.currentTarget.dataset.item;
+ console.log(item);
+ commonApi.address.update({
+ id:item.id,
+ is_default:true
+ }).then(()=>{
+ wx.navigateBack();
+ })
+ },
goToAddressEditor(event){
const item = event.currentTarget.dataset.item;
- app.globalData.tempAddress = item;
wx.navigateTo({
- url: '/pages/help/address/edit/index',
+ url:`/pages/help/address/edit/index?address_id=${item.id}`,
+ })
+ },
+ goToAddAddress(){
+ wx.navigateTo({
+ url: `/pages/help/address/edit/index?community_id=${this.data.communityId}&&community_name=${this.data.communityName}`,
})
}
})
\ No newline at end of file
diff --git a/pages/help/address/index/index.wxml b/pages/help/address/index/index.wxml
index 99405ca..beb3358 100644
--- a/pages/help/address/index/index.wxml
+++ b/pages/help/address/index/index.wxml
@@ -1,19 +1,20 @@
-
+
常用地址
-
+
{{item.address_detail}}
{{item.name}} {{item.phone}}
+ capture-catch:tap="goToAddressEditor" data-item="{{item}}"/>
- 暂无常用地址
+ 该小区暂无常用地址
使用过的地址会在这里显示
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/pages/help/address/index/index.wxss b/pages/help/address/index/index.wxss
index 210f16e..ad57cfa 100644
--- a/pages/help/address/index/index.wxss
+++ b/pages/help/address/index/index.wxss
@@ -27,3 +27,6 @@
width:36rpx;height:36rpx;
padding:10rpx;
}
+.add-button{
+ margin: 40rpx 20rpx!important;
+}
\ No newline at end of file
diff --git a/pages/help/index/index.js b/pages/help/index/index.js
index ca03f4c..14cc1ca 100644
--- a/pages/help/index/index.js
+++ b/pages/help/index/index.js
@@ -1,6 +1,5 @@
const app = getApp();
import commonApi from '../../../api/common';
-import user from '../../../api/user';
import userApi from '../../../api/user';
Page({
@@ -9,7 +8,6 @@ Page({
* 页面的初始数据
*/
data: {
- // communityList:[],
isLogin:!!app.globalData.accessToken,
currentAddress:null,
currentCommunity:{
@@ -22,24 +20,38 @@ Page({
},
isShowOrderConfirm:false,
- preOrder:{}
+ preOrder:{},
- // addressList:[],
- // addressIndex:0
+ manuallyChangedCommunity:false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
- this.getAddress();
+ this.setData({
+ isLogin:!!app.globalData.accessToken
+ })
+ // this.getAddress();
+ },
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady() {
+
+ },
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow() {
wx.getStorage({
key:'pre-order',
success:(res)=>{
console.log(res.data);
const name = [];
let count = 0;
- res.data.price_request.package.map((item)=>{
+ res.data.price_request.packages.map((item)=>{
name.push(item.station_name);
count+=item.pickup_codes.split(',').length;
});
@@ -50,20 +62,20 @@ Page({
}
})
}
- })
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
-
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- //这里要要重新过滤当前送达地址,因为可能会重新选择社区
+ });
+ if(!this.data.manuallyChangedCommunity){
+ app.forceGetUserInfo().then((data)=>{
+ if(data.default_address){
+ this.setData({
+ currentCommunity:{
+ id:data.default_address.community_id,
+ name:data.default_address.community_name
+ },
+ currentAddress:data.default_address
+ })
+ }
+ })
+ }
},
getAddress(communityId){
commonApi.address.list(communityId).then((data)=>{
@@ -76,28 +88,25 @@ Page({
this.setData({
currentAddress,
});
- if(currentAddress.id){
- this.setData({
- currentCommunity:{
- id:currentAddress.community_id,
- name:currentAddress.community_name
- }
- })
- }
});
},
changeCommunity(community){
+ console.log('changeCommunity',community);
+ //手动设置社区之后 做个标记
this.setData({
currentCommunity:{
id:community.id,
name:community.name
- }
+ },
+ manuallyChangedCommunity:true
});
this.getAddress(community.id);
},
changeAddress(address){
+ //手动设置地址之后,由于同时设置了默认地址,所以标记改为 false 便于找当前显示的地址
this.setData({
- currentAddress:address
+ currentAddress:address,
+ manuallyChangedCommunity:false
})
},
preOrder(){
@@ -105,7 +114,7 @@ Page({
key:'pre-order',
success:(res)=>{
userApi.order.pre({
- packages:res.data.price_request.package
+ packages:res.data.price_request.packages
}).then((data)=>{
this.setData({
isShowOrderConfirm:true,
@@ -119,17 +128,13 @@ Page({
wx.getStorage({
key:'pre-order',
success:(res)=>{
- // let packages = [];
- // res.data.price_request.package.map((item)=>{
- // packages.push({
- // station_id:item.station_id,
- // pickup_codes:item.pickup_codes
- // });
- // });
res.data.addressid = this.data.currentAddress.id;
userApi.order.real(res.data).then((data)=>{
+ wx.removeStorage({
+ key: 'pre-order',
+ });
wx.navigateTo({
- url: '/pages/help/success',
+ url: `/pages/help/success/index?id=${data.order.orderid}&success_text=${data.success_text}`,
})
});
}
@@ -182,9 +187,16 @@ Page({
},
goToAddress(){
if(app.globalData.accessToken){
- wx.navigateTo({
- url: `/pages/help/address/index/index?communityId=${this.data.currentCommunity.id}`,
- })
+ if(this.data.currentCommunity&&this.data.currentCommunity.id){
+ wx.navigateTo({
+ url: `/pages/help/address/index/index?community_id=${this.data.currentCommunity.id}&community_name=${this.data.currentCommunity.name}`,
+ })
+ }else{
+ wx.showToast({
+ icon:'error',
+ title: '请先选择小区',
+ })
+ }
}else{
app.navToLogin();
}
diff --git a/pages/help/index/index.wxml b/pages/help/index/index.wxml
index f216afd..06ef172 100644
--- a/pages/help/index/index.wxml
+++ b/pages/help/index/index.wxml
@@ -65,7 +65,7 @@
-
+
您有2张免费跑腿券待领取
先领券,再下单,立享免费跑腿
@@ -90,14 +90,27 @@
+ 服务费
+ {{preOrder.price_info.original_amount}}
+
+
跑腿券
- 0张
+ - {{preOrder.price_info.coupon_discount_amount}}
+
+
+ 蜂蜜抵
+ - {{preOrder.price_info.points_used}}克
- 跑腿费
- ¥3.5
+
+ 应支付
+
+ 先付后享
+
+
+ {{preOrder.price_info.final_amount}}
- *基础费3元 (含5件包裹) 超出部分0.5元/件
+ {{preOrder.price_detail_text}}
diff --git a/pages/help/index/index.wxss b/pages/help/index/index.wxss
index 95eba37..1fea1fb 100644
--- a/pages/help/index/index.wxss
+++ b/pages/help/index/index.wxss
@@ -168,6 +168,13 @@
.pc-content .kv-item .key{
font-size: 30rpx;
}
+.pc-content .kv-item .key{
+ display: flex;
+ align-items: center;
+}
+.pc-content .kv-item .tags{
+ margin-left:20rpx;
+}
.pc-content .kv-item .value{
font-weight: 500;
}
diff --git a/pages/help/package/index.js b/pages/help/package/index.js
index 589bb27..537895f 100644
--- a/pages/help/package/index.js
+++ b/pages/help/package/index.js
@@ -7,10 +7,8 @@ Page({
* 页面的初始数据
*/
data: {
- package:[],
stationList:[],
- sendType:'',
- preOrder:{}
+ sendType:''
},
bottomBarButtonTap(){
@@ -19,14 +17,14 @@ Page({
data.push({
station_id:item.id,
station_name:item.name,
- pickup_codes:item.package.join(',')
+ pickup_codes:item.package.filter((item)=>item!='').join(',')
});
})
wx.setStorage({
key:'pre-order',
data:{
price_request:{
- package:data
+ packages:data
},
delivery_method:this.data.sendType
},
@@ -47,38 +45,17 @@ Page({
});
},
deletePackage(event){
- console.log(this.data.package);
- this.data.package.splice(event.currentTarget.dataset.index,1);
+ const itemIndex = event.currentTarget.dataset.index;
+ const packageIndex = event.currentTarget.dataset.p_index;
+ this.data.stationList[itemIndex].package.splice(packageIndex,1);
this.setData({
- package:this.data.package
+ stationList:this.data.stationList
})
},
setPackageCode(event){
const itemIndex = event.currentTarget.dataset.index;
const packageIndex = event.currentTarget.dataset.p_index;
- console.log(itemIndex,packageIndex,11111);
this.data.stationList[itemIndex].package[packageIndex] = event.detail.value;
- this.setData({
- package:this.data.stationList
- });
- console.log(this.data.stationList);
- },
- preOrder(){
- console.log(this.data.stationList);
- const data = [];
- this.data.stationList.map((item)=>{
- data.push({
- station_id:item.id,
- pickup_codes:item.package.join(',')
- });
- })
- userApi.order.pre({
- packages:data
- }).then((data)=>{
- this.setData({
- preOrder:data
- })
- });
},
/**
@@ -89,14 +66,10 @@ Page({
wx.getStorage({
key:'pre-order',
success:(res)=>{
- console.log(res.data);
data.items.map((item)=>{
- const __item = res.data.price_request.package.find((_item)=>_item.station_id==item.id);
+ const __item = res.data.price_request.packages.find((_item)=>_item.station_id==item.id);
item.package = __item.pickup_codes.split(',');
});
- if(res.data.price_request){
- this.preOrder();
- }
this.setData({
stationList:data.items
})
diff --git a/pages/help/package/index.wxml b/pages/help/package/index.wxml
index 41650ba..17e5a42 100644
--- a/pages/help/package/index.wxml
+++ b/pages/help/package/index.wxml
@@ -3,7 +3,7 @@
{{item.name}}
- 服务时间 10:00-21:00
+ {{item.service_text}}
diff --git a/pages/help/success/index.js b/pages/help/success/index.js
index d38116f..e938abc 100644
--- a/pages/help/success/index.js
+++ b/pages/help/success/index.js
@@ -5,16 +5,24 @@ Page({
* 页面的初始数据
*/
data: {
-
+ successText:'',
+ orderId:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
-
+ this.setData({
+ successText:options.success_text,
+ orderId:options.id
+ });
+ },
+ navToOrderDetail(){
+ wx.redirectTo({
+ url: `/pages/order/detail/index?id=${this.data.orderId}`,
+ })
},
-
/**
* 生命周期函数--监听页面初次渲染完成
*/
diff --git a/pages/help/success/index.wxml b/pages/help/success/index.wxml
index 76975e1..5e0890d 100644
--- a/pages/help/success/index.wxml
+++ b/pages/help/success/index.wxml
@@ -1,6 +1,6 @@
恭喜下单成功
- 预计今晚18:00后送达,感谢您的支持!
-
+ {{successText}}
+
\ No newline at end of file
diff --git a/pages/login/login.js b/pages/login/login.js
index f5351e8..2b40302 100644
--- a/pages/login/login.js
+++ b/pages/login/login.js
@@ -1,8 +1,10 @@
import userApi from '../../api/user';
+const app = getApp();
Page({
data: {
- isAgree: true
+ isAgree: false,
+ loging:false
},
handleAgreeChange(e) {
@@ -22,20 +24,31 @@ Page({
},
getPhoneNumber(event){
- console.log(event);
+ this.setData({
+ loging:true
+ });
wx.login({
success: (res) => {
// 实现登录逻辑
- console.log('登录成功', res)
this.sendLogin(res.code,event.detail.code);
}
})
},
sendLogin(wxcode,phonecode){
userApi.loginWithCode(wxcode,phonecode).then((data)=>{
+ this.setData({
+ loging:false
+ });
+ app.globalData.accessToken = data.access_token;
wx.setStorage({
key:"accessToken",
- data:data.access_token
+ data:data.access_token,
+ success(){
+ console.log(app.globalData);
+ wx.reLaunch({
+ url: '/pages/help/index/index',
+ })
+ }
})
})
}
diff --git a/pages/login/login.wxml b/pages/login/login.wxml
index f8a1d90..614e190 100644
--- a/pages/login/login.wxml
+++ b/pages/login/login.wxml
@@ -1,14 +1,14 @@
-
+
-
- 我已阅读并同意
- 《用户协议》与《隐私政策》
-
+
+ 我已阅读并同意
+ 《用户协议》与
+ 《隐私政策》
-
\ No newline at end of file
diff --git a/pages/login/login.wxss b/pages/login/login.wxss
index 67c0123..5cd6ac9 100644
--- a/pages/login/login.wxss
+++ b/pages/login/login.wxss
@@ -13,6 +13,7 @@
}
.bottom .yellow{
color:#FEC400;
+ margin-left:0;
}
.policy{
font-size: 26rpx;
diff --git a/pages/my/index/index.js b/pages/my/index/index.js
index fc7eb81..5c7df53 100644
--- a/pages/my/index/index.js
+++ b/pages/my/index/index.js
@@ -24,11 +24,6 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
- app.getUserInfo().then((data)=>{
- this.setData({
- userInfo:data
- });
- })
},
/**
diff --git a/pages/my/index/index.wxml b/pages/my/index/index.wxml
index d3614c8..6cb799c 100644
--- a/pages/my/index/index.wxml
+++ b/pages/my/index/index.wxml
@@ -39,7 +39,7 @@
-
+
-
+
\ No newline at end of file
diff --git a/pages/my/index/index.wxss b/pages/my/index/index.wxss
index 5d55f66..15f6362 100644
--- a/pages/my/index/index.wxss
+++ b/pages/my/index/index.wxss
@@ -73,4 +73,12 @@
background: rgba(153, 153, 153, 0.2);
width:100%;
height: 8rpx;
+}
+.cell.is-button{
+ background-color: #fff;
+ font-weight: normal;
+ text-align: left;
+}
+.cell.is-button:hover{
+ background-color: #fff;
}
\ No newline at end of file
diff --git a/pages/my/setting/index.js b/pages/my/setting/index.js
index 28fa8d0..db9d5e1 100644
--- a/pages/my/setting/index.js
+++ b/pages/my/setting/index.js
@@ -9,26 +9,43 @@ Page({
*/
data: {
isShowPopup:false,
- name:app.globalData.userInfo.nickname,
- inputName:app.globalData.userInfo.nickname
+ name:'',
+ inputName:'',
+ avatar:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
+ this.setData({
+ isShowPopup:false,
+ name:app.globalData.userInfo.nickname,
+ inputName:app.globalData.userInfo.nickname,
+ avatar:app.globalData.userInfo.avatar
+ })
},
saveName(){
- userApi.updateUser({
- nickname:this.data.inputName
- }).then((data)=>{
+ this.saveUser();
+ },
+ saveUser(avatar){
+ const data = {};
+ if(avatar){
+ data.avatar = avatar;
+ }else{
+ data.nickname = this.data.inputName;
+ }
+ userApi.updateUser(data).then((data)=>{
this.setData({
- name:data.nickname
+ name:data.nickname,
+ avatar:data.avatar
});
wx.showToast({
title: '更新成功',
});
- wx.navigateBack();
+ if(!avatar){
+ wx.navigateBack();
+ }
app.forceGetUserInfo();
})
},
@@ -37,8 +54,9 @@ Page({
count:1,
mediaType:'image',
success:(res)=>{
- console.log(res);
- commonApi.uploadImg(res.tempFiles[0]);
+ commonApi.uploadImg(res.tempFiles[0]).then((data)=>{
+ this.saveUser(data.url);
+ });
}
});
},
diff --git a/pages/my/setting/index.wxml b/pages/my/setting/index.wxml
index e97c0bd..9ad4ba6 100644
--- a/pages/my/setting/index.wxml
+++ b/pages/my/setting/index.wxml
@@ -2,7 +2,7 @@
修改头像
-
+
diff --git a/pages/my/setting/index.wxss b/pages/my/setting/index.wxss
index 1f514e4..e6218ef 100644
--- a/pages/my/setting/index.wxss
+++ b/pages/my/setting/index.wxss
@@ -1,5 +1,6 @@
.cell .avatar{
width:80rpx;height:80rpx;
+ border-radius: 50%;
}
.content{
height:100vh;
diff --git a/pages/order/detail/index.js b/pages/order/detail/index.js
index e55e138..c5c43e9 100644
--- a/pages/order/detail/index.js
+++ b/pages/order/detail/index.js
@@ -5,14 +5,19 @@ Page({
* 页面的初始数据
*/
data: {
- orderDetail:{}
+ orderDetail:{},
+ orderStatusKV:userApi.order.statusKV,
+ orderStatus:userApi.order.status
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
- userApi.order.detail(options.id).then((data)=>{
+ this.getOrderDetail(options.id);
+ },
+ getOrderDetail(id){
+ userApi.order.detail(id).then((data)=>{
let totalPackage = 0;
data.packages.map((item)=>{
item.pickup_codes = item.pickup_codes.split(',');
@@ -24,11 +29,36 @@ Page({
})
})
},
+ cancelOrder(){
+ wx.showModal({
+ title: '你确定取消此订单吗?',
+ complete: (res) => {
+ if (res.confirm) {
+ userApi.order.cancel(this.data.orderDetail.order.orderid).then(()=>{
+ this.getOrderDetail(this.data.orderDetail.order.orderid);
+ const pages = getCurrentPages();
+ const prePage = pages[pages.length-2];
+ prePage.loadOrderList();
+ });
+ }
+ }
+ })
+ },
copyOrderId(){
wx.setClipboardData({
data: this.data.orderDetail.order.orderid,
})
},
+ handleContact(e){
+ console.log('handleContact');
+ console.log(e.detail.path)
+ console.log(e.detail.query)
+ },
+ makePhoneCall(){
+ wx.makePhoneCall({
+ phoneNumber: this.data.orderDetail.order.deliveryman_phone,
+ })
+ },
/**
* 生命周期函数--监听页面初次渲染完成
*/
diff --git a/pages/order/detail/index.wxml b/pages/order/detail/index.wxml
index d0b0f71..03289ef 100644
--- a/pages/order/detail/index.wxml
+++ b/pages/order/detail/index.wxml
@@ -1,14 +1,14 @@
-待接单
+{{orderStatusKV[orderDetail.order.status]}}
跑腿员
-
+
- 张三
- 已安全送达0件
+ {{orderDetail.order.deliveryman_nickname}}
+ 已安全送达{{orderDetail.order.delivery_count}}件
-
- 取消订单
- 联系客服
+ 取消订单
+
+ 联系客服
\ No newline at end of file
diff --git a/pages/order/detail/index.wxss b/pages/order/detail/index.wxss
index e496765..aa9cd05 100644
--- a/pages/order/detail/index.wxss
+++ b/pages/order/detail/index.wxss
@@ -23,9 +23,10 @@
align-items: center;
font-size: 40rpx;
font-weight: 600;
+ color:var(--main-color);
}
-.order-status.waiting{
- color:#1A4DEB;
+.order-status.COMPLETED,.order-status.CANCELLED{
+ color:var(--main-font-color);
}
.order-status::before{
content: "";
@@ -33,10 +34,10 @@
width:10rpx;height:44rpx;
margin-right:24rpx;
border-radius: 6rpx;
- background-color:#000;
+ background-color:var(--main-color);
}
-.order-status.waiting::before{
- background-color: #1A4DEB;
+.order-status.COMPLETED::before,.order-status.CANCELLED::before{
+ background-color:var(--main-font-color);
}
.page-container .spliter{
margin:24rpx 0 40rpx 0;
@@ -64,8 +65,6 @@
.sender .info .button{
font-size: 24rpx;
font-weight: normal;
- border: 0.6px solid #1A4DEB;
- color:#1A4DEB;
border-radius: 12rpx;
}
.sender .info .icon{
@@ -153,8 +152,6 @@
font-size: 32rpx;
}
.bottom-bar .button2{
- color: #1A4DEB;
- border: 1rpx solid #1A4DEB;
font-size: 32rpx;
margin-left:30rpx;
}
diff --git a/pages/order/index/index.js b/pages/order/index/index.js
index 2bb174a..e9428d3 100644
--- a/pages/order/index/index.js
+++ b/pages/order/index/index.js
@@ -10,7 +10,15 @@ Page({
tabIndex:0,
orderList:[],
merchantOrderList:[],
- couponList:[]
+ couponList:[],
+ orderStatus:userApi.order.status,
+ orderStatusKV:userApi.order.statusKV,
+
+ merchantPayOrderStatus:shopApi.merchantPayOrderStatus,
+ merchantPayOrderStatusKV:shopApi.merchantPayOrderStatusKV,
+
+ merchantOrderStatus:shopApi.merchantOrderStatus,
+ merchantOrderStatusKV:shopApi.merchantOrderStatusKV,
},
changeTab(event){
const tabIndex = event.currentTarget.dataset.index;
@@ -33,18 +41,27 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
+ this.loadOrderList();
+ this.loadMerchantOrderList();
+ this.loadMerchantPayOrderList();
+ },
+ loadOrderList(){
//代取快递列表
userApi.order.list().then((data)=>{
this.setData({
orderList:data.items
})
});
+ },
+ loadMerchantPayOrderList(){
//消费买单列表
shopApi.orderList().then((data)=>{
this.setData({
merchantOrderList:data.items
})
})
+ },
+ loadMerchantOrderList(){
//代金券列表
userApi.order.merchantList().then((data)=>{
this.setData({
diff --git a/pages/order/index/index.wxml b/pages/order/index/index.wxml
index 4e3cb56..2f9f0c0 100644
--- a/pages/order/index/index.wxml
+++ b/pages/order/index/index.wxml
@@ -18,20 +18,20 @@
代取快递
-
- {{index==0?'待接单':(index==1?'已接单':'')}}
+
+ {{orderStatusKV[item.status]}}
{{item.address.community_name}}{{item.address.address_detail}}
下单时间:{{item.create_time}}
-
+
跑腿费用
- 3.4
+ {{item.final_amount}}
- 立即支付
+ 立即支付
@@ -43,7 +43,7 @@
-{{item.amount}}
订单状态
- {{item.status}}
+ {{merchantPayOrderStatusKV[item.status]}}
支付方式
@@ -74,7 +74,7 @@
{{item.merchant_name}}
- {{item.status}}
+ {{merchantOrderStatusKV[item.status]}}
diff --git a/pages/order/index/index.wxss b/pages/order/index/index.wxss
index ca31340..a9cc71c 100644
--- a/pages/order/index/index.wxss
+++ b/pages/order/index/index.wxss
@@ -22,13 +22,11 @@
}
.order-list .head .status{
font-size: 32rpx;
-}
-.order-list .head .status.waiting{
- color: #1A4DEB;
-}
-.order-list .head .status.receiving{
color:#FF8400;
}
+.order-list .head .status.CANCELLED,.order-list .head .status.COMPLETED{
+ color:var(--main-font-color);
+}
.order-list .head .icon-con{
padding: 10rpx;
background-color: #1A4DEB;
diff --git a/pages/shop/bill/index.js b/pages/shop/bill/index.js
index b5bbd68..ea2f07b 100644
--- a/pages/shop/bill/index.js
+++ b/pages/shop/bill/index.js
@@ -21,7 +21,7 @@ Page({
},
checkAmount(){
if(this.data.amount){
- shopApi.merchantPay(this.data.shopId,this.data.amount).then((data)=>{
+ shopApi.calculateOrderPoint(this.data.shopId,this.data.amount).then((data)=>{
this.setData({
checkedAmount:data
})
@@ -62,6 +62,9 @@ Page({
shopId:options.id,
shopName:options.name
});
+ wx.setNavigationBarTitle({
+ title: '123',
+ })
},
/**
diff --git a/pages/shop/bill/index.json b/pages/shop/bill/index.json
index d8bbc60..e4e2198 100644
--- a/pages/shop/bill/index.json
+++ b/pages/shop/bill/index.json
@@ -1,4 +1,7 @@
{
- "usingComponents": {},
- "navigationBarTitleText": ""
+ "usingComponents": {
+ "nav-bar":"/components/navbar/index"
+ },
+ "navigationBarTitleText": "",
+ "navigationStyle": "custom"
}
\ No newline at end of file
diff --git a/pages/shop/bill/index.wxml b/pages/shop/bill/index.wxml
index 1ec992e..fc6012b 100644
--- a/pages/shop/bill/index.wxml
+++ b/pages/shop/bill/index.wxml
@@ -1,3 +1,4 @@
+
{
+ shopApi.calculateOrderPrice(currentProduct.id).then((data)=>{
this.setData({
calculatedPrice:data,
currentProduct,
@@ -46,6 +47,16 @@ Page({
}
})
});
+ }).catch((error)=>{
+ this.setData({
+ isShowConfirm:false
+ })
+ wx.showModal({
+ title: error.message,
+ showCancel:false,
+ complete: (res) => {
+ }
+ })
});
},
@@ -54,11 +65,12 @@ Page({
*/
onLoad(options) {
const shopId = options.id;
- shopApi.detail(shopId).then((data)=>{
- this.setData({
- detail:data
- });
- });
+
+ app.getLocation().then((data)=>{
+ this.getOrderDetail(shopId,data.longitude,data.latitude);
+ }).catch(()=>{
+ this.getOrderDetail(shopId);
+ })
shopApi.productList(shopId).then((data)=>{
data.items.map((item)=>{
item.tags = item.tags.split(',')
@@ -68,7 +80,18 @@ 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';
+ }
+ this.setData({
+ detail:data
+ });
+ });
+ },
/**
* 生命周期函数--监听页面初次渲染完成
*/
diff --git a/pages/shop/detail/index.json b/pages/shop/detail/index.json
index 60b1518..e5c8349 100644
--- a/pages/shop/detail/index.json
+++ b/pages/shop/detail/index.json
@@ -1,6 +1,6 @@
{
"usingComponents": {
- "navBar":"/components/navbar"
+ "nav-bar":"/components/navbar"
},
"navigationStyle": "custom"
}
\ No newline at end of file
diff --git a/pages/shop/detail/index.wxml b/pages/shop/detail/index.wxml
index 4a4c45b..ed2e10a 100644
--- a/pages/shop/detail/index.wxml
+++ b/pages/shop/detail/index.wxml
@@ -13,7 +13,7 @@
-->
-
+
@@ -48,7 +48,7 @@
快捷买单
- 在线买单 赠送蜂蜜
+ 在线买单 赠送蜂蜜{{detail.pay_gift_points_rate}}%
diff --git a/pages/shop/detail/index.wxss b/pages/shop/detail/index.wxss
index b44535b..ba3d5ea 100644
--- a/pages/shop/detail/index.wxss
+++ b/pages/shop/detail/index.wxss
@@ -95,7 +95,7 @@
.page-container.shop-info{
margin:0;
- padding:0 40rpx 24rpx 40rpx;
+ padding:30rpx 40rpx 24rpx 40rpx;
position: relative;
border-radius: 0;
}
@@ -181,7 +181,7 @@
flex:1;
}
.group-buy .item .button{
- border-radius: 12rpx;
+ border-radius: 60rpx;
font-size: 28rpx;
line-height: 1;
padding:18rpx 46rpx;
diff --git a/pages/shop/index/index.js b/pages/shop/index/index.js
index 94187ff..3e0dfbe 100644
--- a/pages/shop/index/index.js
+++ b/pages/shop/index/index.js
@@ -12,7 +12,9 @@ Page({
tabIndex:0,
categories:[],
shopList:[],
- userInfo:{}
+ userInfo:{},
+ lng:null,
+ lat:null
},
changeTab(event){
const tabIndex = event.currentTarget.dataset.index;
@@ -27,7 +29,16 @@ Page({
})
},
loadList(cid){
- shopApi.list(cid).then((data)=>{
+ shopApi.list(cid,this.data.lng,this.data.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 = item.distance+'m';
+ }
+ }
+ })
this.setData({
shopList:data.items
})
@@ -37,12 +48,21 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
+ app.getLocation().then((data)=>{
+ this.setData({
+ lng:data.longitude,
+ lat:data.latitude
+ });
+ this.loadList();
+ }).catch(()=>{
+ this.loadList();
+ })
+
shopApi.category().then((data)=>{
this.setData({
categories:[{id:0,name:'全部'},...data.items]
});
})
- this.loadList();
app.getUserInfo().then((data)=>{
this.setData({
userInfo:data