数据准备齐全,即将提交数据
This commit is contained in:
parent
4ae2daba4d
commit
c4a1aa873a
@ -1,9 +1,34 @@
|
||||
import request from './request'
|
||||
let app = getApp();
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
community:{
|
||||
list(params){
|
||||
return request.get('/api/community')
|
||||
list:()=>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 {
|
||||
get(url,params){
|
||||
sendRequest({url,method:'get',params});
|
||||
get(url,data){
|
||||
return sendRequest({url,method:'get',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(){
|
||||
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 commonApi from './api/common';
|
||||
App({
|
||||
onLaunch() {
|
||||
// 展示本地存储能力
|
||||
@ -15,14 +16,61 @@ App({
|
||||
wx.getStorage({
|
||||
key:'accessToken',
|
||||
success:(res)=>{
|
||||
console.log(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: {
|
||||
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({
|
||||
|
||||
/**
|
||||
@ -12,6 +14,10 @@ Component({
|
||||
deleteText:{
|
||||
type:String,
|
||||
value:''
|
||||
},
|
||||
communityId:{
|
||||
type:Number,
|
||||
value:null
|
||||
}
|
||||
},
|
||||
|
||||
@ -19,18 +25,123 @@ Component({
|
||||
* 组件的初始数据
|
||||
*/
|
||||
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: {
|
||||
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(){
|
||||
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="item">
|
||||
<label class="key">绑定小区</label>
|
||||
<label class="value">朝阳时代西锦</label>
|
||||
</view>
|
||||
<picker range="{{communityList}}" range-key="name" value="{{communityIndex}}" bindchange="chooseCommonity">
|
||||
<view class="item">
|
||||
<label class="key">绑定小区</label>
|
||||
<label class="value">
|
||||
{{communityList&&communityList.length>0?communityList[communityIndex].name:''}}
|
||||
</label>
|
||||
</view>
|
||||
</picker>
|
||||
<view class="item">
|
||||
<label class="key">用户姓名</label>
|
||||
<input class="value" placeholder="请输入用户名"/>
|
||||
<radio-group class="radio-group">
|
||||
<input class="value" placeholder="请输入用户名" model:value="{{name}}"/>
|
||||
<radio-group class="radio-group" model:value="{{gender}}">
|
||||
<label>
|
||||
<radio class="radio" checked></radio>
|
||||
<radio value="MALE" class="radio" checked></radio>
|
||||
<label>先生</label>
|
||||
</label>
|
||||
<label>
|
||||
<radio class="radio"></radio>
|
||||
<radio value="FEMALE" class="radio"></radio>
|
||||
<label>女士</label>
|
||||
</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
<view class="item">
|
||||
<label class="key">手机号码</label>
|
||||
<input class="value" placeholder="请输入手机号码"/>
|
||||
<input class="value" placeholder="请输入手机号码" model:value="{{phone}}"/>
|
||||
</view>
|
||||
|
||||
<picker range="{{building}}">
|
||||
<picker range="{{buildingList}}" range-key="displayText" bindchange="buildingChange"
|
||||
value="{{buildingIndex}}">
|
||||
<view class="item">
|
||||
<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"/>
|
||||
</view>
|
||||
</picker>
|
||||
<view class="item no-border">
|
||||
<label class="key">详细地址</label>
|
||||
<input class="value" placeholder="例:1 单元1301"/>
|
||||
<input class="value" placeholder="例:1 单元1301" model:value="{{address_detail}}"/>
|
||||
</view>
|
||||
<button type="primary" bind:tap="save">{{saveText}}</button>
|
||||
<button wx:if="{{deleteText}}" type="primary" plain bind:tap="del">{{deleteText}}</button>
|
||||
|
||||
@ -29,7 +29,6 @@ Page({
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"address-editor":"/components/address"
|
||||
}
|
||||
},
|
||||
"navigationBarTitleText": "编辑地址"
|
||||
}
|
||||
@ -1,21 +1,28 @@
|
||||
// pages/help/address/index.js
|
||||
import commonApi from '../../../../api/common';
|
||||
const app = getApp();
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
items: [
|
||||
{ name: '1', value: 'cell standard' },
|
||||
{ name: '2', value: 'cell standard', checked: 'true' },
|
||||
],
|
||||
addressList:[],
|
||||
communityId:null
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
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({
|
||||
url: '/pages/help/address/edit/index',
|
||||
})
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"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="head">常用地址</view>
|
||||
<view class="item">
|
||||
<view class="text">
|
||||
<view class="title">朝阳时代西锦 3栋2单元1802</view>
|
||||
<view class="sub-title">何灵 13486745777</view>
|
||||
<block wx:if="{{addressList.length>0}}">
|
||||
<view class="item" wx:for="{{addressList}}" wx:key="index">
|
||||
<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}}"/>
|
||||
</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 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"/>
|
||||
</block>
|
||||
<view class="list-empty" wx:else>
|
||||
<view class="title">暂无常用地址</view>
|
||||
<view class="sub-title">使用过的地址会在这里显示</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -26,4 +26,18 @@
|
||||
.address-list .item .icon{
|
||||
width:36rpx;height:36rpx;
|
||||
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({
|
||||
|
||||
@ -10,28 +10,31 @@ Page({
|
||||
communityList:[]
|
||||
},
|
||||
onSelectItem(event){
|
||||
const pages = getCurrentPages();
|
||||
const prePage = pages[pages.length-2];
|
||||
const currentCommunity = event.currentTarget.dataset.item;
|
||||
this.setData({currentCommunity})
|
||||
wx.setStorage({
|
||||
key:"currentCommunity",
|
||||
data:currentCommunity
|
||||
});
|
||||
prePage.changeCommunity(currentCommunity);
|
||||
wx.navigateBack();
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
wx.getStorage({
|
||||
key:'currentCommunity',
|
||||
success:(res)=>{
|
||||
console.log(res);
|
||||
this.setData({currentCommunity:res.data})
|
||||
}
|
||||
})
|
||||
console.log(options);
|
||||
commonApi.community.list().then((data)=>{
|
||||
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({
|
||||
|
||||
@ -5,35 +7,92 @@ Page({
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
index:0,
|
||||
array:[1,2,3,4],
|
||||
communityList:[],
|
||||
currentCommunity:null
|
||||
// communityList:[],
|
||||
isLogin:!!app.globalData.accessToken,
|
||||
currentAddress:null,
|
||||
currentCommunity:{
|
||||
id:null,
|
||||
name:''
|
||||
},
|
||||
package:{
|
||||
name:'',
|
||||
count:0
|
||||
}
|
||||
|
||||
// addressList:[],
|
||||
// addressIndex:0
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
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() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
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({
|
||||
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(){
|
||||
wx.navigateTo({
|
||||
url: '/pages/help/package/index',
|
||||
url: `/pages/help/package/index?communityId=${this.data.currentCommunity.id}`,
|
||||
})
|
||||
},
|
||||
goToCommunity(){
|
||||
wx.navigateTo({
|
||||
url: '/pages/help/community/index',
|
||||
url: `/pages/help/community/index?communityId=${this.data.currentCommunity.id}`,
|
||||
})
|
||||
},
|
||||
goToAddress(){
|
||||
wx.navigateTo({
|
||||
url: '/pages/help/address/index/index',
|
||||
})
|
||||
if(app.globalData.accessToken){
|
||||
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"/>
|
||||
</nav-bar>
|
||||
<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"/>
|
||||
</view>
|
||||
<view class="address-panel">
|
||||
<view class="ap-item send" bind:tap="goToAddress">
|
||||
<image class="icon" src="/assets/icon/help/send@2x.png"/>
|
||||
<view class="text">
|
||||
<view class="title">朝阳时代西锦12栋1单元2072朝阳时代西锦12栋1单元2072</view>
|
||||
<view class="sub-title">周先生 13888888888</view>
|
||||
<block wx:if="{{currentAddress&¤tAddress.id}}">
|
||||
<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>
|
||||
<image class="arrow" src="/assets/icon/help/arrow-right@2x.png"/>
|
||||
</view>
|
||||
<view class="ap-item take" bind:tap="goToAddPackage">
|
||||
<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="sub-title"></view>
|
||||
</view>
|
||||
<image class="arrow" src="/assets/icon/help/arrow-right@2x.png"/>
|
||||
</view>
|
||||
@ -41,7 +58,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<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"/>
|
||||
<view class="text">登录后享跑腿服务</view>
|
||||
<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({
|
||||
|
||||
/**
|
||||
@ -6,19 +8,41 @@ Page({
|
||||
*/
|
||||
data: {
|
||||
package:[],
|
||||
testvalue:'123'
|
||||
stationList:[],
|
||||
sendType:''
|
||||
},
|
||||
|
||||
bottomBarButtonTap(){
|
||||
wx.navigateTo({
|
||||
url: '/pages/help/success/index',
|
||||
const data = [];
|
||||
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(){
|
||||
this.data.package.push('')
|
||||
addPackage(event){
|
||||
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({
|
||||
package:this.data.package
|
||||
stationList:this.data.stationList
|
||||
});
|
||||
},
|
||||
deletePackage(event){
|
||||
@ -29,16 +53,40 @@ Page({
|
||||
})
|
||||
},
|
||||
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({
|
||||
package:this.data.package
|
||||
package:this.data.stationList
|
||||
});
|
||||
console.log(this.data.stationList);
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
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">
|
||||
<image class="icon" src="/assets/icon/help/house@2x.png"/>
|
||||
<view class="text">
|
||||
<view class="title">妈妈驿站(朝阳时代西锦)</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="title">{{item.name}}</view>
|
||||
<view class="sub-title">服务时间 10:00-21:00</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="package-list">
|
||||
<view class="item" wx:for="{{package}}" wx:key="index">
|
||||
<label class="label">取件码{{index+1}}</label>
|
||||
<input value="{{item}}" class="input" bindinput="setPackageCode" data-index="{{index}}"/>
|
||||
<button class="button" bind:tap="deletePackage" data-index="{{index}}">
|
||||
<view class="item" wx:for="{{item.package}}" wx:for-item="pItem" wx:for-index="pIndex" wx:key="pIndex">
|
||||
<label class="label">取件码{{pIndex+1}}</label>
|
||||
<input value="{{pItem}}" class="input" bindinput="setPackageCode"
|
||||
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"/>
|
||||
</button>
|
||||
</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"/>
|
||||
<label>添加取件码</label>
|
||||
</button>
|
||||
</view>
|
||||
<view class="page-container">
|
||||
<radio-group class="radio" value="1">
|
||||
<radio-group class="radio" model:value="{{sendType}}">
|
||||
<label>
|
||||
<radio value="1" checked/>
|
||||
<radio value="DELIVERY_AT_DOORSTEP" checked/>
|
||||
<label>敲门递件</label>
|
||||
</label>
|
||||
<label>
|
||||
<radio value="2"/>
|
||||
<radio value="DELIVERY_TO_ROOM"/>
|
||||
<label>放在门口</label>
|
||||
</label>
|
||||
</radio-group>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user