数据准备齐全,即将提交数据
This commit is contained in:
parent
4ae2daba4d
commit
c4a1aa873a
@ -1,9 +1,34 @@
|
|||||||
import request from './request'
|
import request from './request'
|
||||||
|
let app = getApp();
|
||||||
|
|
||||||
module.exports = {
|
export default {
|
||||||
community:{
|
community:{
|
||||||
list(params){
|
list:()=>request.get('/api/community')
|
||||||
return request.get('/api/community')
|
},
|
||||||
|
address:{
|
||||||
|
list(commityId){
|
||||||
|
const data = {};
|
||||||
|
if(commityId){
|
||||||
|
data.community_id = commityId;
|
||||||
|
}
|
||||||
|
return request.get('/api/address',data)
|
||||||
|
},
|
||||||
|
add:(data)=>request.post('/api/address',data),
|
||||||
|
update:(data)=>request.put(`/api/address/${data.id}`,data),
|
||||||
|
},
|
||||||
|
building:{
|
||||||
|
list(communityId){
|
||||||
|
if(!app){
|
||||||
|
app = getApp();
|
||||||
|
}
|
||||||
|
const data = {
|
||||||
|
community_id:communityId,
|
||||||
|
user_id:app.globalData.userInfo.userid
|
||||||
|
}
|
||||||
|
return request.get('/api/community/building/list')
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
station:{
|
||||||
|
list:(community_id)=>request.get('/api/station',{community_id})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -26,10 +26,16 @@ const sendRequest = (options)=>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
get(url,params){
|
get(url,data){
|
||||||
sendRequest({url,method:'get',params});
|
return sendRequest({url,method:'get',data});
|
||||||
},
|
},
|
||||||
post(url,data){
|
post(url,data){
|
||||||
sendRequest({url,method:'post',data});
|
return sendRequest({url,method:'post',data});
|
||||||
|
},
|
||||||
|
put(url,data){
|
||||||
|
return sendRequest({url,method:'put',data});
|
||||||
|
},
|
||||||
|
delete(url,data){
|
||||||
|
return sendRequest({url,method:'delete',data});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -18,5 +18,8 @@ export default {
|
|||||||
},
|
},
|
||||||
info(){
|
info(){
|
||||||
return request.get('/api/user/info');
|
return request.get('/api/user/info');
|
||||||
|
},
|
||||||
|
order:{
|
||||||
|
pre:(data)=>request.post('/api/order/pre-order',data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
54
app.js
54
app.js
@ -1,4 +1,5 @@
|
|||||||
import userApi from './api/user';
|
import userApi from './api/user';
|
||||||
|
import commonApi from './api/common';
|
||||||
App({
|
App({
|
||||||
onLaunch() {
|
onLaunch() {
|
||||||
// 展示本地存储能力
|
// 展示本地存储能力
|
||||||
@ -15,14 +16,61 @@ App({
|
|||||||
wx.getStorage({
|
wx.getStorage({
|
||||||
key:'accessToken',
|
key:'accessToken',
|
||||||
success:(res)=>{
|
success:(res)=>{
|
||||||
console.log(res.data);
|
|
||||||
this.globalData.accessToken = res.data;
|
this.globalData.accessToken = res.data;
|
||||||
userApi.info()
|
if(res.data){
|
||||||
|
userApi.info().then((data)=>{
|
||||||
|
this.globalData.userInfo = data;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
navToLogin(){
|
||||||
|
wx.navigateTo({
|
||||||
|
url: '/pages/login/login',
|
||||||
|
})
|
||||||
|
},
|
||||||
globalData: {
|
globalData: {
|
||||||
userInfo: null,
|
userInfo: null,
|
||||||
accessToken:null
|
accessToken:null,
|
||||||
|
community:{
|
||||||
|
_list:[],
|
||||||
|
lastFetchTime:null,
|
||||||
|
getList(){
|
||||||
|
let lft = this.lastFetchTime;
|
||||||
|
return new Promise((rs,rj)=>{
|
||||||
|
if(!lft&&new Date()-lft>30){
|
||||||
|
commonApi.community.list().then((data)=>{
|
||||||
|
this.lastFetchTime = new Date();
|
||||||
|
this._list = data;
|
||||||
|
rs(data)
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
rs(this._list);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
address:{
|
||||||
|
_list:[],
|
||||||
|
lastFetchTime:null,
|
||||||
|
getList(){
|
||||||
|
let lft = this.lastFetchTime;
|
||||||
|
return new Promise((rs,rj)=>{
|
||||||
|
if(!lft&&new Date()-lft>30){
|
||||||
|
commonApi.address.list().then((data)=>{
|
||||||
|
this.lastFetchTime = new Date();
|
||||||
|
this._list = data;
|
||||||
|
rs(data)
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
rs(this._list);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getAddressList(){
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
// components/address/index.js
|
import commonApi from '../../api/common';
|
||||||
|
const app = getApp();
|
||||||
|
|
||||||
Component({
|
Component({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,6 +14,10 @@ Component({
|
|||||||
deleteText:{
|
deleteText:{
|
||||||
type:String,
|
type:String,
|
||||||
value:''
|
value:''
|
||||||
|
},
|
||||||
|
communityId:{
|
||||||
|
type:Number,
|
||||||
|
value:null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -19,18 +25,123 @@ Component({
|
|||||||
* 组件的初始数据
|
* 组件的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
building:['一栋','二栋','三栋','四栋','五栋'],
|
buildingList:[],
|
||||||
},
|
buildingIndex:0,
|
||||||
|
communityList:[],
|
||||||
|
communityIndex:0,
|
||||||
|
|
||||||
|
currentEditAddress:{},
|
||||||
|
name:'',
|
||||||
|
gender:'',
|
||||||
|
phone:'',
|
||||||
|
community_building_id:'',
|
||||||
|
address_detail:''
|
||||||
|
},
|
||||||
|
lifetimes:{
|
||||||
|
attached(){
|
||||||
|
if(app.globalData.tempAddress){
|
||||||
|
this.setData({
|
||||||
|
currentEditAddress:app.globalData.tempAddress,
|
||||||
|
name:app.globalData.tempAddress.name,
|
||||||
|
gender:app.globalData.tempAddress.gender,
|
||||||
|
phone:app.globalData.tempAddress.phone,
|
||||||
|
community_building_id:app.globalData.tempAddress.community_building_id,
|
||||||
|
address_detail:app.globalData.tempAddress.address_detail
|
||||||
|
})
|
||||||
|
}
|
||||||
|
commonApi.community.list().then((data)=>{
|
||||||
|
let communityIndex;
|
||||||
|
this.setData({
|
||||||
|
communityList:data.items
|
||||||
|
});
|
||||||
|
data.items.map((item,index)=>{
|
||||||
|
if(item.id==this.data.currentEditAddress.id){
|
||||||
|
communityIndex = index;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
//没有找到 id 就是新增,就去找默认的社区进行填充
|
||||||
|
if(communityIndex){
|
||||||
|
this.getBuildingList();
|
||||||
|
}else{
|
||||||
|
for(let [index,item] of data.items.entries()){
|
||||||
|
if(item.id==this.properties.communityId){
|
||||||
|
this.setData({
|
||||||
|
communityIndex:index
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.getBuildingList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// console.log(app.globalData.tempAddress);
|
||||||
|
}
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 组件的方法列表
|
* 组件的方法列表
|
||||||
*/
|
*/
|
||||||
methods: {
|
methods: {
|
||||||
save(){
|
save(){
|
||||||
this.triggerEvent('save')
|
|
||||||
|
|
||||||
|
this.triggerEvent('save');
|
||||||
|
let data = {
|
||||||
|
community_id:this.data.communityList[this.data.communityIndex].id,
|
||||||
|
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
|
||||||
|
}
|
||||||
|
console.log(data);
|
||||||
|
if(this.data.currentEditAddress&&this.data.currentEditAddress.id){
|
||||||
|
//编辑
|
||||||
|
data.id = this.data.currentEditAddress.id;
|
||||||
|
commonApi.address.update(data);
|
||||||
|
}else{
|
||||||
|
//新增
|
||||||
|
commonApi.address.add(data).then((data)=>{
|
||||||
|
const pages = getCurrentPages();
|
||||||
|
const prePage = pages[pages.length-2];
|
||||||
|
prePage.changeAddress(data);
|
||||||
|
wx.navigateBack({
|
||||||
|
success(){
|
||||||
|
wx.showToast({
|
||||||
|
title: '新增成功',
|
||||||
|
icon:'success'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getBuildingList(){
|
||||||
|
const current = this.data.communityList[this.data.communityIndex];
|
||||||
|
commonApi.building.list(current.id).then((data)=>{
|
||||||
|
let buildingIndex = 0;
|
||||||
|
data.items.map((item,index)=>{
|
||||||
|
item.displayText = `${item.community_name} ${item.building_name}`;
|
||||||
|
if(item.id==this.data.currentEditAddress.id){
|
||||||
|
buildingIndex = index;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.setData({
|
||||||
|
buildingList:data.items,
|
||||||
|
buildingIndex
|
||||||
|
})
|
||||||
|
});
|
||||||
},
|
},
|
||||||
del(){
|
del(){
|
||||||
this.triggerEvent('delete')
|
this.triggerEvent('delete')
|
||||||
|
},
|
||||||
|
chooseCommonity(event){
|
||||||
|
this.setData({
|
||||||
|
communityIndex:event.detail.value
|
||||||
|
})
|
||||||
|
},
|
||||||
|
buildingChange(event){
|
||||||
|
const buildingIndex = event.detail.value;
|
||||||
|
this.setData({buildingIndex});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -1,37 +1,42 @@
|
|||||||
<view class="page-container shadow editor">
|
<view class="page-container shadow editor">
|
||||||
<view class="item">
|
<picker range="{{communityList}}" range-key="name" value="{{communityIndex}}" bindchange="chooseCommonity">
|
||||||
<label class="key">绑定小区</label>
|
<view class="item">
|
||||||
<label class="value">朝阳时代西锦</label>
|
<label class="key">绑定小区</label>
|
||||||
</view>
|
<label class="value">
|
||||||
|
{{communityList&&communityList.length>0?communityList[communityIndex].name:''}}
|
||||||
|
</label>
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<label class="key">用户姓名</label>
|
<label class="key">用户姓名</label>
|
||||||
<input class="value" placeholder="请输入用户名"/>
|
<input class="value" placeholder="请输入用户名" model:value="{{name}}"/>
|
||||||
<radio-group class="radio-group">
|
<radio-group class="radio-group" model:value="{{gender}}">
|
||||||
<label>
|
<label>
|
||||||
<radio class="radio" checked></radio>
|
<radio value="MALE" class="radio" checked></radio>
|
||||||
<label>先生</label>
|
<label>先生</label>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<radio class="radio"></radio>
|
<radio value="FEMALE" class="radio"></radio>
|
||||||
<label>女士</label>
|
<label>女士</label>
|
||||||
</label>
|
</label>
|
||||||
</radio-group>
|
</radio-group>
|
||||||
</view>
|
</view>
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<label class="key">手机号码</label>
|
<label class="key">手机号码</label>
|
||||||
<input class="value" placeholder="请输入手机号码"/>
|
<input class="value" placeholder="请输入手机号码" model:value="{{phone}}"/>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<picker range="{{building}}">
|
<picker range="{{buildingList}}" range-key="displayText" bindchange="buildingChange"
|
||||||
|
value="{{buildingIndex}}">
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<label class="key">选择楼栋</label>
|
<label class="key">选择楼栋</label>
|
||||||
<input class="value" placeholder="请选择" disabled/>
|
<input class="value" placeholder="请选择" disabled value="{{buildingList[buildingIndex].displayText}}" />
|
||||||
<image class="right-icon" src="/assets/icon/help/arrow-right@2x.png"/>
|
<image class="right-icon" src="/assets/icon/help/arrow-right@2x.png"/>
|
||||||
</view>
|
</view>
|
||||||
</picker>
|
</picker>
|
||||||
<view class="item no-border">
|
<view class="item no-border">
|
||||||
<label class="key">详细地址</label>
|
<label class="key">详细地址</label>
|
||||||
<input class="value" placeholder="例:1 单元1301"/>
|
<input class="value" placeholder="例:1 单元1301" model:value="{{address_detail}}"/>
|
||||||
</view>
|
</view>
|
||||||
<button type="primary" bind:tap="save">{{saveText}}</button>
|
<button type="primary" bind:tap="save">{{saveText}}</button>
|
||||||
<button wx:if="{{deleteText}}" type="primary" plain bind:tap="del">{{deleteText}}</button>
|
<button wx:if="{{deleteText}}" type="primary" plain bind:tap="del">{{deleteText}}</button>
|
||||||
|
|||||||
@ -29,7 +29,6 @@ Page({
|
|||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
"address-editor":"/components/address"
|
"address-editor":"/components/address"
|
||||||
}
|
},
|
||||||
|
"navigationBarTitleText": "编辑地址"
|
||||||
}
|
}
|
||||||
@ -1,21 +1,28 @@
|
|||||||
// pages/help/address/index.js
|
import commonApi from '../../../../api/common';
|
||||||
|
const app = getApp();
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面的初始数据
|
* 页面的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
items: [
|
addressList:[],
|
||||||
{ name: '1', value: 'cell standard' },
|
communityId:null
|
||||||
{ name: '2', value: 'cell standard', checked: 'true' },
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
console.log(options);
|
||||||
|
this.setData({
|
||||||
|
communityId:options.communityId
|
||||||
|
})
|
||||||
|
commonApi.address.list(options.communityId).then((data)=>{
|
||||||
|
this.setData({
|
||||||
|
addressList:data
|
||||||
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,7 +74,9 @@ Page({
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
goToAddressEditor(){
|
goToAddressEditor(event){
|
||||||
|
const item = event.currentTarget.dataset.item;
|
||||||
|
app.globalData.tempAddress = item;
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '/pages/help/address/edit/index',
|
url: '/pages/help/address/edit/index',
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
"address-editor":"/components/address"
|
"address-editor":"/components/address"
|
||||||
}
|
},
|
||||||
|
"navigationBarTitleText": "收件人信息"
|
||||||
}
|
}
|
||||||
@ -1,26 +1,19 @@
|
|||||||
<address-editor saveText="保存并使用"/>
|
<address-editor saveText="保存并使用" communityId="{{communityId}}"/>
|
||||||
|
|
||||||
<view class="page-container address-list">
|
<view class="page-container address-list">
|
||||||
<view class="head">常用地址</view>
|
<view class="head">常用地址</view>
|
||||||
<view class="item">
|
<block wx:if="{{addressList.length>0}}">
|
||||||
<view class="text">
|
<view class="item" wx:for="{{addressList}}" wx:key="index">
|
||||||
<view class="title">朝阳时代西锦 3栋2单元1802</view>
|
<view class="text">
|
||||||
<view class="sub-title">何灵 13486745777</view>
|
<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}}"/>
|
||||||
</view>
|
</view>
|
||||||
<image class="icon" src="/assets/icon/help/edit@2x.png" bind:tap="goToAddressEditor"/>
|
</block>
|
||||||
</view>
|
<view class="list-empty" wx:else>
|
||||||
<view class="item">
|
<view class="title">暂无常用地址</view>
|
||||||
<view class="text">
|
<view class="sub-title">使用过的地址会在这里显示</view>
|
||||||
<view class="title">朝阳时代西锦 3栋2单元1802</view>
|
|
||||||
<view class="sub-title">何灵 13486745777</view>
|
|
||||||
</view>
|
|
||||||
<image class="icon" src="/assets/icon/help/edit@2x.png" bind:tap="goToAddressEditor"/>
|
|
||||||
</view>
|
|
||||||
<view class="item">
|
|
||||||
<view class="text">
|
|
||||||
<view class="title">朝阳时代西锦 3栋2单元1802</view>
|
|
||||||
<view class="sub-title">何灵 13486745777</view>
|
|
||||||
</view>
|
|
||||||
<image class="icon" src="/assets/icon/help/edit@2x.png" bind:tap="goToAddressEditor"/>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -27,3 +27,17 @@
|
|||||||
width:36rpx;height:36rpx;
|
width:36rpx;height:36rpx;
|
||||||
padding:10rpx;
|
padding:10rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.list-empty{
|
||||||
|
text-align: center;
|
||||||
|
padding:60rpx 0 30rpx 0;
|
||||||
|
}
|
||||||
|
.list-empty .title{
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
.list-empty .sub-title{
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #A1A1A1;
|
||||||
|
margin-top:24rpx;
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
const commonApi = require('../../../api/common');
|
import commonApi from '../../../api/common';
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
@ -10,28 +10,31 @@ Page({
|
|||||||
communityList:[]
|
communityList:[]
|
||||||
},
|
},
|
||||||
onSelectItem(event){
|
onSelectItem(event){
|
||||||
|
const pages = getCurrentPages();
|
||||||
|
const prePage = pages[pages.length-2];
|
||||||
const currentCommunity = event.currentTarget.dataset.item;
|
const currentCommunity = event.currentTarget.dataset.item;
|
||||||
this.setData({currentCommunity})
|
this.setData({currentCommunity})
|
||||||
wx.setStorage({
|
prePage.changeCommunity(currentCommunity);
|
||||||
key:"currentCommunity",
|
wx.navigateBack();
|
||||||
data:currentCommunity
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
wx.getStorage({
|
console.log(options);
|
||||||
key:'currentCommunity',
|
|
||||||
success:(res)=>{
|
|
||||||
console.log(res);
|
|
||||||
this.setData({currentCommunity:res.data})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
commonApi.community.list().then((data)=>{
|
commonApi.community.list().then((data)=>{
|
||||||
const communityList = data.items;
|
const communityList = data.items;
|
||||||
this.setData({communityList});
|
let currentCommunity;
|
||||||
|
data.items.map((item)=>{
|
||||||
|
if(item.id==options.communityId){
|
||||||
|
currentCommunity = item;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.setData({
|
||||||
|
communityList,
|
||||||
|
currentCommunity
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
const app = getApp();
|
||||||
|
import commonApi from '../../../api/common';
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
@ -5,35 +7,92 @@ Page({
|
|||||||
* 页面的初始数据
|
* 页面的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
index:0,
|
// communityList:[],
|
||||||
array:[1,2,3,4],
|
isLogin:!!app.globalData.accessToken,
|
||||||
communityList:[],
|
currentAddress:null,
|
||||||
currentCommunity:null
|
currentCommunity:{
|
||||||
|
id:null,
|
||||||
|
name:''
|
||||||
|
},
|
||||||
|
package:{
|
||||||
|
name:'',
|
||||||
|
count:0
|
||||||
|
}
|
||||||
|
|
||||||
|
// addressList:[],
|
||||||
|
// addressIndex:0
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
this.getAddress();
|
||||||
|
wx.getStorage({
|
||||||
|
key:'pre-order',
|
||||||
|
success:(res)=>{
|
||||||
|
console.log(res.data);
|
||||||
|
const name = [];
|
||||||
|
let count = 0;
|
||||||
|
res.data.price_request.package.map((item)=>{
|
||||||
|
name.push(item.station_name);
|
||||||
|
count+=item.pickup_codes.split(',').length;
|
||||||
|
});
|
||||||
|
this.setData({
|
||||||
|
package:{
|
||||||
|
name:name.join('|'),
|
||||||
|
count:count
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面初次渲染完成
|
* 生命周期函数--监听页面初次渲染完成
|
||||||
*/
|
*/
|
||||||
onReady() {
|
onReady() {
|
||||||
},
|
|
||||||
|
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面显示
|
* 生命周期函数--监听页面显示
|
||||||
*/
|
*/
|
||||||
onShow() {
|
onShow() {
|
||||||
wx.getStorage({
|
//这里要要重新过滤当前送达地址,因为可能会重新选择社区
|
||||||
key:"currentCommunity",
|
},
|
||||||
success:(res)=>{
|
getAddress(communityId){
|
||||||
|
commonApi.address.list(communityId).then((data)=>{
|
||||||
|
let currentAddress = data[0]||{};
|
||||||
|
data.map((item,index)=>{
|
||||||
|
if(item.is_default){
|
||||||
|
currentAddress = item;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.setData({
|
||||||
|
currentAddress,
|
||||||
|
});
|
||||||
|
if(currentAddress.id){
|
||||||
this.setData({
|
this.setData({
|
||||||
currentCommunity:res.data
|
currentCommunity:{
|
||||||
|
id:currentAddress.community_id,
|
||||||
|
name:currentAddress.community_name
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
changeCommunity(community){
|
||||||
|
this.setData({
|
||||||
|
currentCommunity:{
|
||||||
|
id:community.id,
|
||||||
|
name:community.name
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.getAddress(community.id);
|
||||||
|
},
|
||||||
|
changeAddress(address){
|
||||||
|
this.setData({
|
||||||
|
currentAddress:address
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -73,17 +132,21 @@ Page({
|
|||||||
},
|
},
|
||||||
goToAddPackage(){
|
goToAddPackage(){
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '/pages/help/package/index',
|
url: `/pages/help/package/index?communityId=${this.data.currentCommunity.id}`,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
goToCommunity(){
|
goToCommunity(){
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '/pages/help/community/index',
|
url: `/pages/help/community/index?communityId=${this.data.currentCommunity.id}`,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
goToAddress(){
|
goToAddress(){
|
||||||
wx.navigateTo({
|
if(app.globalData.accessToken){
|
||||||
url: '/pages/help/address/index/index',
|
wx.navigateTo({
|
||||||
})
|
url: `/pages/help/address/index/index?communityId=${this.data.currentCommunity.id}`,
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
app.navToLogin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -4,23 +4,40 @@
|
|||||||
<image class="logo" src="/assets/icon/navbar/lanfeng@2x.png"/>
|
<image class="logo" src="/assets/icon/navbar/lanfeng@2x.png"/>
|
||||||
</nav-bar>
|
</nav-bar>
|
||||||
<view class="choose-community" bind:tap="goToCommunity">
|
<view class="choose-community" bind:tap="goToCommunity">
|
||||||
<view class="text">{{currentCommunity?currentCommunity.name:'选择小区'}}</view>
|
<view class="text">
|
||||||
|
{{
|
||||||
|
currentCommunity.id?currentCommunity.name:'请选择小区'
|
||||||
|
}}
|
||||||
|
</view>
|
||||||
<image class="arrow" src="/assets/icon/help/arrow-down@2x.png"/>
|
<image class="arrow" src="/assets/icon/help/arrow-down@2x.png"/>
|
||||||
</view>
|
</view>
|
||||||
<view class="address-panel">
|
<view class="address-panel">
|
||||||
<view class="ap-item send" bind:tap="goToAddress">
|
<view class="ap-item send" bind:tap="goToAddress">
|
||||||
<image class="icon" src="/assets/icon/help/send@2x.png"/>
|
<image class="icon" src="/assets/icon/help/send@2x.png"/>
|
||||||
<view class="text">
|
<view class="text">
|
||||||
<view class="title">朝阳时代西锦12栋1单元2072朝阳时代西锦12栋1单元2072</view>
|
<block wx:if="{{currentAddress&¤tAddress.id}}">
|
||||||
<view class="sub-title">周先生 13888888888</view>
|
<view class="title">
|
||||||
|
{{currentAddress.community_name}}
|
||||||
|
{{currentAddress.address_detail}}
|
||||||
|
</view>
|
||||||
|
<view class="sub-title">
|
||||||
|
{{currentAddress.name}} {{currentAddress.phone}}
|
||||||
|
</view>
|
||||||
|
</block>
|
||||||
|
<block wx:else>
|
||||||
|
<view class="title">请录入配送地址</view>
|
||||||
|
</block>
|
||||||
</view>
|
</view>
|
||||||
<image class="arrow" src="/assets/icon/help/arrow-right@2x.png"/>
|
<image class="arrow" src="/assets/icon/help/arrow-right@2x.png"/>
|
||||||
</view>
|
</view>
|
||||||
<view class="ap-item take" bind:tap="goToAddPackage">
|
<view class="ap-item take" bind:tap="goToAddPackage">
|
||||||
<image class="icon" src="/assets/icon/help/take@2x.png"/>
|
<image class="icon" src="/assets/icon/help/take@2x.png"/>
|
||||||
<view class="text">
|
<view class="text" wx:if="{{package.name}}">
|
||||||
|
<view class="title">{{package.name}}</view>
|
||||||
|
<view class="sub-title">共计 {{package.count}} 个包裹</view>
|
||||||
|
</view>
|
||||||
|
<view class="text" wx:else>
|
||||||
<view class="title">送达地址</view>
|
<view class="title">送达地址</view>
|
||||||
<view class="sub-title"></view>
|
|
||||||
</view>
|
</view>
|
||||||
<image class="arrow" src="/assets/icon/help/arrow-right@2x.png"/>
|
<image class="arrow" src="/assets/icon/help/arrow-right@2x.png"/>
|
||||||
</view>
|
</view>
|
||||||
@ -41,7 +58,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<button type="primary" class="order-button">立即下单</button>
|
<button type="primary" class="order-button">立即下单</button>
|
||||||
<view class="login-panel">
|
<view class="login-panel" wx:if="{{!isLogin}}">
|
||||||
<image class="icon" src="/assets/icon/help/redpacket@2x.png"/>
|
<image class="icon" src="/assets/icon/help/redpacket@2x.png"/>
|
||||||
<view class="text">登录后享跑腿服务</view>
|
<view class="text">登录后享跑腿服务</view>
|
||||||
<navigator url="/pages/login/login">
|
<navigator url="/pages/login/login">
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
// pages/help/package/index.js
|
import commonApi from '../../../api/common';
|
||||||
|
import userApi from '../../../api/user';
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -6,19 +8,41 @@ Page({
|
|||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
package:[],
|
package:[],
|
||||||
testvalue:'123'
|
stationList:[],
|
||||||
|
sendType:''
|
||||||
},
|
},
|
||||||
|
|
||||||
bottomBarButtonTap(){
|
bottomBarButtonTap(){
|
||||||
wx.navigateTo({
|
const data = [];
|
||||||
url: '/pages/help/success/index',
|
this.data.stationList.map((item)=>{
|
||||||
|
data.push({
|
||||||
|
station_id:item.id,
|
||||||
|
station_name:item.name,
|
||||||
|
pickup_codes:item.package.join(',')
|
||||||
|
});
|
||||||
|
})
|
||||||
|
wx.setStorage({
|
||||||
|
key:'pre-order',
|
||||||
|
data:{
|
||||||
|
price_request:{
|
||||||
|
package:data
|
||||||
|
},
|
||||||
|
delivery_method:this.data.sendType
|
||||||
|
},
|
||||||
|
success(){
|
||||||
|
wx.navigateBack();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
addPackage(){
|
addPackage(event){
|
||||||
this.data.package.push('')
|
const index = event.currentTarget.dataset.index;
|
||||||
|
if(!this.data.stationList[index].package){
|
||||||
|
this.data.stationList[index].package = [];
|
||||||
|
}
|
||||||
|
this.data.stationList[index].package.push('');
|
||||||
this.setData({
|
this.setData({
|
||||||
package:this.data.package
|
stationList:this.data.stationList
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
deletePackage(event){
|
deletePackage(event){
|
||||||
@ -29,16 +53,40 @@ Page({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
setPackageCode(event){
|
setPackageCode(event){
|
||||||
this.data.package[event.currentTarget.dataset.index] = event.detail.value;
|
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({
|
this.setData({
|
||||||
package:this.data.package
|
package:this.data.stationList
|
||||||
});
|
});
|
||||||
|
console.log(this.data.stationList);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
commonApi.station.list(options.communityId).then((data)=>{
|
||||||
|
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);
|
||||||
|
item.package = __item.pickup_codes.split(',');
|
||||||
|
});
|
||||||
|
console.log(data.items);
|
||||||
|
this.setData({
|
||||||
|
stationList:data.items
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.setData({
|
||||||
|
stationList:data.items
|
||||||
|
})
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,46 +1,34 @@
|
|||||||
<view class="page-container">
|
<view class="page-container" wx:for="{{stationList}}" wx:key="index">
|
||||||
<view class="head">
|
<view class="head">
|
||||||
<image class="icon" src="/assets/icon/help/house@2x.png"/>
|
<image class="icon" src="/assets/icon/help/house@2x.png"/>
|
||||||
<view class="text">
|
<view class="text">
|
||||||
<view class="title">妈妈驿站(朝阳时代西锦)</view>
|
<view class="title">{{item.name}}</view>
|
||||||
<view class="sub-title">服务时间 10:00-80:30</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<button type="default" class="button">
|
|
||||||
<image src="/assets/icon/help/plus@2x.png" class="icon"/>
|
|
||||||
<label>添加取件码</label>
|
|
||||||
</button>
|
|
||||||
</view>
|
|
||||||
<view class="page-container">
|
|
||||||
<view class="head">
|
|
||||||
<image class="icon" src="/assets/icon/help/house@2x.png"/>
|
|
||||||
<view class="text">
|
|
||||||
<view class="title">菜鸟驿站(朝阳时代西锦)</view>
|
|
||||||
<view class="sub-title">服务时间 10:00-21:00</view>
|
<view class="sub-title">服务时间 10:00-21:00</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="package-list">
|
<view class="package-list">
|
||||||
<view class="item" wx:for="{{package}}" wx:key="index">
|
<view class="item" wx:for="{{item.package}}" wx:for-item="pItem" wx:for-index="pIndex" wx:key="pIndex">
|
||||||
<label class="label">取件码{{index+1}}</label>
|
<label class="label">取件码{{pIndex+1}}</label>
|
||||||
<input value="{{item}}" class="input" bindinput="setPackageCode" data-index="{{index}}"/>
|
<input value="{{pItem}}" class="input" bindinput="setPackageCode"
|
||||||
<button class="button" bind:tap="deletePackage" data-index="{{index}}">
|
data-index="{{index}}" data-p_index="{{pIndex}}"/>
|
||||||
|
<button class="button" bind:tap="deletePackage" data-index="{{index}}" data-p_index="{{pIndex}}">
|
||||||
<image class="icon" src="/assets/icon/help/delete@2x.png"/>
|
<image class="icon" src="/assets/icon/help/delete@2x.png"/>
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<button type="default" class="button" bind:tap="addPackage">
|
<button type="default" class="button" bind:tap="addPackage" data-index="{{index}}">
|
||||||
<image src="/assets/icon/help/plus@2x.png" class="icon"/>
|
<image src="/assets/icon/help/plus@2x.png" class="icon"/>
|
||||||
<label>添加取件码</label>
|
<label>添加取件码</label>
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
<view class="page-container">
|
<view class="page-container">
|
||||||
<radio-group class="radio" value="1">
|
<radio-group class="radio" model:value="{{sendType}}">
|
||||||
<label>
|
<label>
|
||||||
<radio value="1" checked/>
|
<radio value="DELIVERY_AT_DOORSTEP" checked/>
|
||||||
<label>敲门递件</label>
|
<label>敲门递件</label>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<radio value="2"/>
|
<radio value="DELIVERY_TO_ROOM"/>
|
||||||
<label>放在门口</label>
|
<label>放在门口</label>
|
||||||
</label>
|
</label>
|
||||||
</radio-group>
|
</radio-group>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user