17 changed files with 307 additions and 9 deletions
Split View
Diff Options
-
12api/saas.js
-
4app.js
-
4app.json
-
17pages/home/customer-info/index.js
-
1pages/home/customer-info/index.json
-
7pages/home/customer-info/index.wxml
-
5pages/home/customer-list/index.js
-
3pages/home/index/index.wxml
-
98pages/setting/vehicle-detial/index.js
-
10pages/setting/vehicle-detial/index.json
-
21pages/setting/vehicle-detial/index.wxml
-
1pages/setting/vehicle-detial/index.wxss
-
85pages/setting/vehicle-list/index.js
-
10pages/setting/vehicle-list/index.json
-
35pages/setting/vehicle-list/index.wxml
-
1pages/setting/vehicle-list/index.wxss
-
2utils/util.js
@ -0,0 +1,98 @@ |
|||
// pages/setting/paper-detial/index.js
|
|||
import Scene from '../../index/scene' |
|||
import Dialog from '../../../components/dialog/dialog' |
|||
import { getCarInfo, saveCar, editCar, deleteCar } from "../../../api/saas" |
|||
const event = require('../../../utils/event') |
|||
const util = require('../../../utils/util') |
|||
const app = getApp() |
|||
|
|||
Scene({ |
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
data: { |
|||
safeBottom: app.globalData.safeBottom, |
|||
form: {} |
|||
}, |
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
onLoad: function (options) { |
|||
if(options.id){ |
|||
wx.showLoading({ title: '正在获取', mask: true }) |
|||
getCarInfo(options.id).then(result => { |
|||
wx.hideLoading() |
|||
this.setData({ form: result.data, safeBottom: app.globalData.safeBottom }) |
|||
}).catch(err => { |
|||
wx.hideLoading() |
|||
util.showToast(err) |
|||
}) |
|||
} |
|||
}, |
|||
showPlate: function(e){ |
|||
if(e.currentTarget.id == 'plateNumber'){ |
|||
this.keyboard = this.keyboard || this.selectComponent('#wux-keyboard') |
|||
this.keyboard.show(this.data.form.plateNumber, 0) |
|||
} else { |
|||
var that = this |
|||
var events = {} |
|||
events.onCallback = function(data){ |
|||
if (data.what == 121) { |
|||
that.data.form.driverId = data.detail.enterpriseMemberId |
|||
that.setData({ ['form.driverName']: data.detail.enterpriseMemberName }) |
|||
} |
|||
} |
|||
wx.navigateTo({url: `/pages/home/employee/index?type=1`, events}) |
|||
} |
|||
}, |
|||
onPlatenumber: function({detail}){ |
|||
if(detail && detail.plateNumber){ |
|||
this.setData({ ['form.plateNumber']: detail.plateNumber }) |
|||
} |
|||
}, |
|||
deleteForm: function(e){ |
|||
Dialog.confirm({ title: '温馨提示', message: '确定删除该纸品?' }).then(() => { |
|||
wx.showLoading({ title: '正在处理', mask: true }) |
|||
deleteCar(this.data.form.id).then(result => { |
|||
wx.hideLoading() |
|||
util.showBackToast('删除成功') |
|||
event.emit('OrderMessage', { what: 201 }) |
|||
}).catch(err => { |
|||
wx.hideLoading() |
|||
util.showToast(err) |
|||
}) |
|||
}).catch(err => { |
|||
}) |
|||
}, |
|||
submitForm: function(e){ |
|||
if(util.isEmpty(this.data.form.plateNumber)){ |
|||
util.showToast('请输入车牌号码') |
|||
return |
|||
} |
|||
if(util.isEmpty(this.data.form.driverId)){ |
|||
util.showToast('请选择司机') |
|||
return |
|||
} |
|||
wx.showLoading({ title: '正在处理', mask: true }) |
|||
if(util.isEmpty(this.data.form.id)){ |
|||
saveCar(this.data.form).then(result => { |
|||
wx.hideLoading() |
|||
util.showBackToast('添加成功') |
|||
event.emit('OrderMessage', { what: 201 }) |
|||
}).catch(err => { |
|||
wx.hideLoading() |
|||
util.showToast(err) |
|||
}) |
|||
} else { |
|||
editCar(this.data.form).then(result => { |
|||
wx.hideLoading() |
|||
util.showBackToast('修改成功') |
|||
event.emit('OrderMessage', { what: 202, detail: this.data.form }) |
|||
}).catch(err => { |
|||
wx.hideLoading() |
|||
util.showToast(err) |
|||
}) |
|||
} |
|||
} |
|||
|
|||
}) |
|||
@ -0,0 +1,10 @@ |
|||
{ |
|||
"usingComponents": { |
|||
"van-button": "/components/button/index", |
|||
"van-field": "/components/field/index", |
|||
"van-dialog": "/components/dialog/index", |
|||
"vehicle-keyboard": "/components/vehicle-keyboard/index", |
|||
"van-notice-bar": "/components/notice-bar/index", |
|||
"notification": "/pages/message/notification/index" |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
<!--pages/setting/paper-detial/index.wxml--> |
|||
<cu-custom bgColor="bg-white" isBack="{{true}}"> |
|||
<view slot="content" style="color:black;font-size:18px">车辆详情</view> |
|||
</cu-custom> |
|||
|
|||
<van-notice-bar color="#1989fa" background="#008AFF" left-icon="info-o" text="点击可以修改车辆信息" /> |
|||
<van-field id="plateNumber" title-width="360rpx" required value="{{form.plateNumber }}" readonly input-align="right" |
|||
label="车牌号码:" is-link arrow-direction="down" bindtap="showPlate" placeholder="请输入车牌号码" /> |
|||
<van-field title-width="360rpx" required value="{{form.driverName }}" readonly input-align="right" label="司机名称:" is-link |
|||
bindtap="showPlate" placeholder="请选择司机" /> |
|||
|
|||
<view style="margin-top:48rpx;padding:48rpx 32rpx"> |
|||
<van-button block type="danger" bind:click="deleteForm" wx:if="{{ form.id}}">删除</van-button> |
|||
<view style="height:36rpx" wx:if="{{ form.id}}"></view> |
|||
<van-button block type="info" bind:click="submitForm">保存</van-button> |
|||
</view> |
|||
|
|||
<vehicle-keyboard id="wux-keyboard" safeBottom="{{safeBottom}}" triplet="{{1}}" bind:change="onPlatenumber"> |
|||
</vehicle-keyboard> |
|||
<van-dialog id="van-dialog" /> |
|||
<notification id="qn-notification" /> |
|||
@ -0,0 +1 @@ |
|||
/* pages/setting/paper-detial/index.wxss */ |
|||
@ -0,0 +1,85 @@ |
|||
// pages/process/order-list/index.js
|
|||
import Scene from '../../index/scene' |
|||
import { getCarList } from "../../../api/saas" |
|||
const event = require('../../../utils/event') |
|||
const util = require('../../../utils/util') |
|||
const app = getApp() |
|||
|
|||
Scene({ |
|||
// * 页面的初始数据
|
|||
data: { |
|||
height: app.globalData.fragmentHeight, |
|||
loading: true, |
|||
requesting: false, |
|||
finished: false, |
|||
top: 0, |
|||
orderList: [], |
|||
form: { |
|||
pageNum: 1, |
|||
pageSize: 15 |
|||
}, |
|||
page: -1, |
|||
index: -1 |
|||
}, |
|||
// * 生命周期函数--监听页面加载
|
|||
onLoad: function (options) { |
|||
event.on('OrderMessage', this, this.onEvent) |
|||
this.setData({ height: app.globalData.fragmentHeight }) |
|||
this.fetchOrderList() |
|||
}, |
|||
onEvent: function(message){ |
|||
if (message.what == 201) { |
|||
this.onRefreshList() |
|||
} else if (message.what == 202) { |
|||
this.setData({ [`orderList[${this.data.page}][${this.data.index}]`]: message.detail }) |
|||
} |
|||
}, |
|||
onRefreshList: function () { |
|||
if (this.data.requesting) { |
|||
return |
|||
} |
|||
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false }) |
|||
this.fetchOrderList() |
|||
}, |
|||
fetchOrderList: function () { |
|||
if (this.data.requesting || this.data.finished) { |
|||
return |
|||
} |
|||
this.data.requesting = true |
|||
getCarList(this.data.form).then(result => { |
|||
if (result.data && result.data.records && result.data.records.length) { |
|||
var respList = result.data.records |
|||
let nowList = `orderList[${this.data.orderList.length}]` |
|||
var num = this.data.form.pageNum |
|||
var finished = ((num - 1) * this.data.form.pageSize + respList.length) >= result.data.total |
|||
if(this.data.form.pageNum == 1){ |
|||
this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), finished, top: 0, requesting: false, loading: false }) |
|||
} else { |
|||
this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), finished, requesting: false, loading: false }) |
|||
} |
|||
} else { |
|||
this.setData({ finished: true, requesting: false, loading: false }) |
|||
} |
|||
}).catch(err => { |
|||
this.setData({ requesting: false, loading: false }) |
|||
util.showToast(err) |
|||
}).then(() => { |
|||
this.refresh = this.refresh || this.selectComponent('#refresh') |
|||
this.refresh.setRefresh(false) |
|||
}) |
|||
}, |
|||
lookItem: function (e) { |
|||
if(e.currentTarget.dataset.page >= 0){ |
|||
this.data.page = e.currentTarget.dataset.page |
|||
this.data.index = e.currentTarget.dataset.index |
|||
var item = this.data.orderList[this.data.page][ this.data.index] |
|||
wx.navigateTo({ url: `/pages/setting/vehicle-detial/index?id=${item.id}` }) |
|||
} else { |
|||
wx.navigateTo({ url: `/pages/setting/vehicle-detial/index` }) |
|||
} |
|||
}, |
|||
onUnload: function(){ |
|||
event.remove('OrderMessage', this) |
|||
} |
|||
|
|||
}) |
|||
@ -0,0 +1,10 @@ |
|||
{ |
|||
"usingComponents": { |
|||
"refresh-view": "/components/refresh-view/index", |
|||
"van-button": "/components/button/index", |
|||
"van-cell": "/components/cell/index", |
|||
"van-divider": "/components/divider/index", |
|||
"van-loading": "/components/loading/index", |
|||
"notification": "/pages/message/notification/index" |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
<!--pages/setting/paper/index.wxml--> |
|||
<cu-custom bgColor="bg-white" isBack="{{true}}"> |
|||
<view slot="content" style="color:black;font-size:18px">车辆管理</view> |
|||
</cu-custom> |
|||
|
|||
<refresh-view id="refresh" height="{{height}}" bind:refresh="onRefreshList" bind:loadmore="fetchOrderList"> |
|||
<view class="list-empty" style="height:{{height}}rpx" wx:if="{{!orderList.length}}"> |
|||
<view style="margin-bottom:24px" wx:if="{{loading}}"> |
|||
<van-loading type="spinner" size="32" /> |
|||
</view> |
|||
<image class="img-empty" src="/assets/image/list_empty.png" wx:else></image> |
|||
<view class="text-empty">{{loading? '正在加载' : '暂无数据'}}</view> |
|||
</view> |
|||
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{orderList}}" wx:key="pageIndex"> |
|||
<van-cell center clickable is-link wx:for="{{pageItem}}" wx:key="index"> |
|||
<view slot="title" data-page="{{pageIndex}}" data-index="{{index}}" bindtap="lookItem"> |
|||
<view class="text-sg text-bold">车牌号你:{{item.plateNumber}}</view> |
|||
<view class="text-sm text-gray" style="line-height: 28rpx"> |
|||
<text>司机:{{item.driverName}}({{item.mobile}})</text> |
|||
</view> |
|||
</view> |
|||
</van-cell> |
|||
</view> |
|||
<!--加载更多的UI--> |
|||
<van-divider content-position="center" wx:if="{{ form.pageNum > 1}}" custom-style="padding:0rpx 120rpx"> |
|||
<van-loading type="spinner" size="16" wx:if="{{!finished}}" /> |
|||
<text class="text-sm" style="margin-left:8rpx">{{finished?'到底啦~':'加载中...'}}</text> |
|||
</van-divider> |
|||
</refresh-view> |
|||
|
|||
<view style="border-radius: 50rpx;position: fixed;bottom:160rpx;right:50rpx"> |
|||
<van-button round type="info" icon="plus" bind:click="lookItem" custom-style="width: 100rpx;height: 100rpx;"></van-button> |
|||
</view> |
|||
|
|||
<notification id="qn-notification"/> |
|||
@ -0,0 +1 @@ |
|||
/* pages/setting/paper-list/index.wxss */ |
|||
Write
Preview
Loading…
Cancel
Save