大面积 bug

This commit is contained in:
2025-02-13 19:11:45 +08:00
parent df410f1142
commit 1f81134eea
54 changed files with 778 additions and 282 deletions

View File

@ -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);
}
})
});
}
}

View File

@ -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);
}
})
})
}

View File

@ -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'
}
}

View File

@ -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}`)

30
app.js
View File

@ -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,

View File

@ -64,5 +64,11 @@
"style": "v2",
"componentFramework": "glass-easel",
"sitemapLocation": "sitemap.json",
"lazyCodeLoading": "requiredComponents"
"lazyCodeLoading": "requiredComponents",
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
},
"requiredPrivateInfos": ["getLocation"]
}

View File

@ -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);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 778 B

After

Width:  |  Height:  |  Size: 454 B

View File

@ -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];

View File

@ -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(){
},
}
})

View File

@ -1,5 +1,16 @@
<view class="nav-bar" style="padding-top:{{statusBarHeight}}px;">
<view class="nav-bar" style="padding-top:{{statusBarHeight}}px;background-color:{{background}};">
<view class="nav-bar-content" style="height:{{navBarHeight}}px;">
<slot/>
<view class="left">
<view class="btns {{(back||backTitle)&&share?'border':''}}" wx:if="{{share||back||backTitle}}">
<image src="/assets/icon/navbar/back@2x.png" class="back" wx:if="{{back||backTitle}}" bind:tap="back"/>
<view class="spliter" wx:if="{{share&&back}}"></view>
<image src="/assets/icon/navbar/share@2x.png" class="share" wx:if="{{share}}" bind:tap="share"/>
</view>
<view class="back-title" wx:if="{{backTitle}}" bind:tap="back">{{backTitle}}</view>
</view>
<view class="center">
<slot/>
</view>
<view class="right"></view>
</view>
</view>

View File

@ -1,9 +1,51 @@
/* components/navBar.wxss */
.nav-bar{
text-align: center;
}
.nav-bar-content{
display: flex;
align-items: center;
justify-content: center;
}
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;}

View File

@ -22,6 +22,5 @@ Component({
* 组件的方法列表
*/
methods: {
}
})

View File

@ -1,24 +1,22 @@
<view class="page-container shop-item">
<image class="logo" src="{{data.brand_image_url}}"/>
<image class="logo" src="{{data.optimized_brand_image_url}}"/>
<view class="content">
<view class="line1">{{data.name}}</view>
<view class="line2">
<view class="line2-1">{{data.address}}</view>
<view class="line2-2">{{data.distance||''}}</view>
</view>
<view class="promation">
<view class="coupon" wx-if="{{data.featured_product}}">
<label class="tag">[新客专享]</label>
{{data.featured_product.product_name}}
<view class="promation buy">
<view class="coupon">
<label class="tag">[在线买单]</label>
<label class="detail">赠送蜂蜜{{data.pay_gift_points_rate}}%</label>
</view>
</view>
<!-- <view class="line-coupon">
<label class="money">22.9</label>
<label class="money-disable">22.9</label>【5座】标准洗车
<view class="promation">
<view class="coupon" wx-if="{{data.featured_product}}">
<label class="tag">[{{data.featured_product.promotion_text}}]</label>
<label class="detail">{{data.featured_product.product_name}}</label>
</view>
</view>
<view class="line-coupon">
<label class="money">22.9</label>
<label class="money-disable">22.9</label>【5座】标准洗车
</view> -->
</view>
</view>

View File

@ -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;
}

View File

@ -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);
},
/**
* 生命周期函数--监听页面初次渲染完成
*/

View File

@ -1 +1,43 @@
<address-editor saveText="保存" deleteText="删除" bind:save="saveAddress" bind:delete="deleteAddress"/>
<view class="page-container shadow editor">
<!-- <picker range="{{communityList}}" range-key="name" value="{{communityIndex}}" bindchange="chooseCommonity"> -->
<view class="item">
<label class="key">绑定小区</label>
<label class="value">
{{communityName}}
</label>
</view>
<!-- </picker> -->
<view class="item">
<label class="key">用户姓名</label>
<input class="value" placeholder="请输入用户名" model:value="{{name}}"/>
<radio-group class="radio-group" model:value="{{gender}}">
<label>
<radio value="MALE" class="radio" checked="{{gender=='MALE'}}"></radio>
<label>先生</label>
</label>
<label>
<radio value="FEMALE" class="radio" checked="{{gender=='FEMALE'}}"></radio>
<label>女士</label>
</label>
</radio-group>
</view>
<view class="item">
<label class="key">手机号码</label>
<input class="value" placeholder="请输入手机号码" model:value="{{phone}}"/>
</view>
<picker range="{{buildingList}}" range-key="displayText" bindchange="buildingChange"
model:value="{{buildingIndex}}">
<view class="item">
<label class="key">选择楼栋</label>
<input class="value" placeholder="请选择" disabled value="{{buildingList[buildingIndex].displayText}}" />
<image class="right-icon" src="/assets/icon/help/arrow-right@2x.png"/>
</view>
</picker>
<view class="item no-border">
<label class="key">详细地址</label>
<input class="value" placeholder="例1 单元1301" model:value="{{address_detail}}"/>
</view>
<button type="primary" bind:tap="save">{{editType=='add'?'保存并使用':'保存'}}</button>
<button wx:if="{{editType=='edit'}}" type="primary" plain bind:tap="deleteAddress">删除</button>
</view>

View File

@ -1 +1,42 @@
/* pages/help/address/edit/index.wxss */
.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;
}

View File

@ -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}`,
})
}
})

View File

@ -1,19 +1,20 @@
<address-editor saveText="保存并使用" communityId="{{communityId}}"/>
<!-- <address-editor saveText="保存并使用" communityId="{{communityId}}"/> -->
<view class="page-container address-list">
<view class="head">常用地址</view>
<block wx:if="{{addressList.length>0}}">
<view class="item" wx:for="{{addressList}}" wx:key="index">
<view class="item" wx:for="{{addressList}}" data-item="{{item}}" wx:key="index" bind:tap="setCurrentAddress">
<view class="text">
<view class="title">{{item.address_detail}}</view>
<view class="sub-title">{{item.name}} {{item.phone}}</view>
</view>
<image class="icon" src="/assets/icon/help/edit@2x.png"
bind:tap="goToAddressEditor" data-item="{{item}}"/>
capture-catch:tap="goToAddressEditor" data-item="{{item}}"/>
</view>
</block>
<view class="list-empty" wx:else>
<view class="title">暂无常用地址</view>
<view class="title">该小区暂无常用地址</view>
<view class="sub-title">使用过的地址会在这里显示</view>
</view>
</view>
</view>
<button type="primary" class="add-button" bind:tap="goToAddAddress">添加</button>

View File

@ -27,3 +27,6 @@
width:36rpx;height:36rpx;
padding:10rpx;
}
.add-button{
margin: 40rpx 20rpx!important;
}

View File

@ -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();
}

View File

@ -65,7 +65,7 @@
<button class="button" size="mini">一键登录</button>
</navigator>
</view>
<view class="promotion-panel">
<view class="promotion-panel" wx:if="{{false}}">
<view class="text">
<view class="title">您有<label class="spec">2张</label>免费跑腿券待领取</view>
<view class="sub-title">先领券,再下单,立享免费跑腿</view>
@ -90,14 +90,27 @@
</view>
<view class="spliter"></view>
<view class="kv-item">
<view class="key">服务费</view>
<view class="value">{{preOrder.price_info.original_amount}}</view>
</view>
<view class="kv-item" wx:if="{{preOrder.price_info.coupon_discount_amount}}">
<view class="key">跑腿券</view>
<view class="value yellow">0张</view>
<view class="value yellow">- {{preOrder.price_info.coupon_discount_amount}}</view>
</view>
<view class="kv-item" wx:if="{{preOrder.price_info.points_used}}">
<view class="key">蜂蜜抵</view>
<view class="value yellow">- {{preOrder.price_info.points_used}}克</view>
</view>
<view class="kv-item">
<view class="key">跑腿费</view>
<view class="value red">¥3.5</view>
<view class="key">
<view>应支付</view>
<view class="tags">
<view class="tag yellow">先付后享</view>
</view>
</view>
<view class="value money">{{preOrder.price_info.final_amount}}</view>
</view>
<view class="tips">*基础费3元 (含5件包裹) 超出部分0.5元/件</view>
<view class="tips">{{preOrder.price_detail_text}}</view>
<button class="button" type="primary" bind:tap="getOrder">立即购买</button>
</view>

View File

@ -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;
}

View File

@ -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
})

View File

@ -3,7 +3,7 @@
<image class="icon" src="/assets/icon/help/house@2x.png"/>
<view class="text">
<view class="title">{{item.name}}</view>
<view class="sub-title">服务时间 10:00-21:00</view>
<view class="sub-title">{{item.service_text}}</view>
</view>
</view>
<view class="package-list">

View File

@ -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}`,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/

View File

@ -1,6 +1,6 @@
<view class="page-success">
<image class="icon" src="/assets/icon/help/success@2x.png"/>
<view class="title">恭喜下单成功</view>
<view class="sub-title">预计今晚18:00后送达感谢您的支持</view>
<button class="button" type="primary" plain="true">前往查看订单</button>
<view class="sub-title">{{successText}}</view>
<button class="button" type="primary" plain="true" bind:tap="navToOrderDetail">前往查看订单</button>
</view>

View File

@ -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',
})
}
})
})
}

View File

@ -1,14 +1,14 @@
<view class="head">
</view>
<view class="bottom">
<radio-group>
<radio-group bindchange="handleAgreeChange">
<label class="policy">
<radio class="radio" checked="{{isAgree}}"></radio>
<label>我已阅读并同意
<label class="yellow">《用户协议》</label>与<label class="yellow">《隐私政策》</label>
</label>
<radio class="radio" value="agree" checked="{{isAgree}}"></radio>
<label>我已阅读并同意</label>
<label class="yellow">《用户协议》</label>与
<label class="yellow">《隐私政策》</label>
</label>
</radio-group>
<button class="button" type="primary"
<button class="button" type="primary" disabled="{{!isAgree||loging}}" loading="{{loging}}"
open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">手机号快捷登录</button>
</view>

View File

@ -13,6 +13,7 @@
}
.bottom .yellow{
color:#FEC400;
margin-left:0;
}
.policy{
font-size: 26rpx;

View File

@ -24,11 +24,6 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
app.getUserInfo().then((data)=>{
this.setData({
userInfo:data
});
})
},
/**

View File

@ -39,7 +39,7 @@
</view>
<view class="cell-ft"></view>
</navigator>
<navigator url="" class="cell" hover-class="cell-active">
<button class="cell is-button" hover-class="cell-active" open-type="contact">
<view class="cell-hd">
<image class="icon" src="/assets/icon/my/cs@2x.png"></image>
</view>
@ -47,5 +47,5 @@
<view>在线客服</view>
</view>
<view class="cell-ft"></view>
</navigator>
</button>
</view>

View File

@ -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;
}

View File

@ -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);
});
}
});
},

View File

@ -2,7 +2,7 @@
<view class="cell" bind:tap="chooseImage">
<view class="cell-bd">修改头像</view>
<view class="cell-ft">
<image src="/assets/imgs/for_test/avatar.png" class="avatar"/>
<image src="{{avatar}}" class="avatar"/>
</view>
</view>
<view class="cell" bind:tap="modifyName">

View File

@ -1,5 +1,6 @@
.cell .avatar{
width:80rpx;height:80rpx;
border-radius: 50%;
}
.content{
height:100vh;

View File

@ -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,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/

View File

@ -1,14 +1,14 @@
<view class="order-status waiting">待接单</view>
<view class="order-status {{orderDetail.order.status}}">{{orderStatusKV[orderDetail.order.status]}}</view>
<view class="page-container sender" wx:if="{{orderDetail.order.deliveryman_user_id}}">
<view class="title">跑腿员</view>
<view class="spliter"></view>
<view class="info">
<image class="avatar" src="/assets/imgs/for_test/avatar.png"/>
<image class="avatar" src="{{orderDetail.order.deliveryman_avatar}}"/>
<view class="center">
<view class="name">张三</view>
<view class="desc">已安全送达0件</view>
<view class="name">{{orderDetail.order.deliveryman_nickname}}</view>
<view class="desc">已安全送达{{orderDetail.order.delivery_count}}件</view>
</view>
<button class="button" plain size="mini">
<button class="button" plain size="mini" bind:tap="makePhoneCall">
<image class="icon" src="/assets/icon/shop/phone@2x.png"/>
<label>联系他</label>
</button>
@ -75,7 +75,9 @@
</view>
</view>
<view class="bottom-bar">
<button class="button button1" plain size="mini">取消订单</button>
<button class="button button2" plain size="mini">联系客服</button>
<button class="button button1" plain size="mini" bind:tap="cancelOrder"
wx:if="{{orderDetail.order.status==orderStatus.created}}">取消订单</button>
<!-- <button class="button button2" plain size="mini">联系客服</button> -->
<button class="button button2" open-type="contact" bindcontact="handleContact" plain size="mini">联系客服</button>
</view>
<view class="patch"></view>

View File

@ -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;
}

View File

@ -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({

View File

@ -18,20 +18,20 @@
<image class="icon" src="/assets/icon/order/package@2x.png"/>
</view>
<view class="center">代取快递</view>
<view class="status {{index==0?'waiting':(index==1?'receiving':'')}}">
{{index==0?'待接单':(index==1?'已接单':'')}}
<view class="status {{item.status}}">
{{orderStatusKV[item.status]}}
</view>
</view>
<view class="content">
<view class="spliter"></view>
<view class="address">{{item.address.community_name}}{{item.address.address_detail}}</view>
<view class="time">下单时间:{{item.create_time}}</view>
<view class="pay" wx:if="{{index==2}}">
<view class="pay" wx:if="{{item.status==orderStatus.UNPAID}}">
<view class="left">
<label>跑腿费用</label>
<label class="money">3.4</label>
<label class="money">{{item.final_amount}}</label>
</view>
<button class="button" type="primary" size="mini">立即支付</button>
<button class="button" type="primary" plain size="mini">立即支付</button>
</view>
</view>
</view>
@ -43,7 +43,7 @@
<view class="amount">-{{item.amount}}</view>
<view class="kv">
<view class="key">订单状态</view>
<view class="value">{{item.status}}</view>
<view class="value">{{merchantPayOrderStatusKV[item.status]}}</view>
</view>
<view class="kv">
<view class="key">支付方式</view>
@ -74,7 +74,7 @@
<label>{{item.merchant_name}}</label>
<image class="icon" src="/assets/icon/order/right-arrow@2x.png"/>
</view>
<view class="status">{{item.status}}</view>
<view class="status">{{merchantOrderStatusKV[item.status]}}</view>
</view>
<view class="content">
<view class="center">

View File

@ -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;

View File

@ -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',
})
},
/**

View File

@ -1,4 +1,7 @@
{
"usingComponents": {},
"navigationBarTitleText": ""
"usingComponents": {
"nav-bar":"/components/navbar/index"
},
"navigationBarTitleText": "",
"navigationStyle": "custom"
}

View File

@ -1,3 +1,4 @@
<nav-bar backTitle="{{shopName}}"/>
<view class="page-container">
<view class="input-area">
<input class="input" type="number" placeholder="请输入消费金额"

View File

@ -1,5 +1,6 @@
import shopApi from '../../../api/shop';
import userApi from '../../../api/user';
const app = getApp();
Page({
@ -18,7 +19,7 @@ Page({
showConfirm(event){
const currentProduct = event.currentTarget.dataset.item;
shopApi.calculatePrice(currentProduct.id).then((data)=>{
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
});
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/

View File

@ -1,6 +1,6 @@
{
"usingComponents": {
"navBar":"/components/navbar"
"nav-bar":"/components/navbar"
},
"navigationStyle": "custom"
}

View File

@ -13,7 +13,7 @@
<image src="/assets/icon/shop/right-arrow@2x.png" class="right-arrow"/>
</view>
</view> -->
<navBar/>
<nav-bar background="#fff" share back></nav-bar>
<view class="page-container shop-info">
<view class="head">
<view class="left">
@ -48,7 +48,7 @@
<view class="left">
<view class="title">快捷买单</view>
<view class="bl-money">
<label class="tips">在线买单 赠送蜂蜜</label>
<label class="tips">在线买单 赠送蜂蜜{{detail.pay_gift_points_rate}}%</label>
</view>
</view>
<view class="right">

View File

@ -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;

View File

@ -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