Commit f1f6c94e by iambtr

录车工具v1.0.66

parents
const { api, imgName, getUserInfo, wxLogin} =require('./lib/util.js')
App({
onLaunch: function () {
},
globalData: {
}
})
\ No newline at end of file
{
"pages": [
"pages/welcome2/welcome2",
"pages/choose_point/choose_point",
"pages/user_index/user_index"
],
"window": {
"backgroundTextStyle": "dark",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTitleText": "智管家",
"navigationBarTextStyle": "black"
},
"networkTimeout": {
"request": 5000
}
}
\ No newline at end of file
page{
min-height: 100%;
box-sizing: border-box;
}
view{
box-sizing: border-box;
font-size: 32rpx
}
::-webkit-scrollbar {
width : 3px ;
}
::-webkit-scrollbar-track {
background : transparent ;
border-radius: 0px ;
}
::-webkit-scrollbar-thumb {
border-radius: 1px ;
background : #999 ;
}
// const type = 'dev'
const type = 'pro'
var config = {
dev: {
appid: 'wx719af42c3a22ad73',
appSecret: '4ad928af54d91683cfd16b0f4d1c10a4',
api: 'https://records.zhizukj.com/ydb/entry/',
version: 'v1.0.00',
imgPath: '/static/image/',
key: '3URBZ-FX6KD-H654D-H25M2-YVGJO-UAFXD'
},
pro: {
appid: 'wx719af42c3a22ad73',
appSecret: '4ad928af54d91683cfd16b0f4d1c10a4',
api: 'https://records.zhizukj.com/ydb/entry/',
version: 'v1.0.00',
imgPath: '/static/image/',
key: 'G5DBZ-NH5KD-D3A4F-HK246-D7SJZ-H3BDB'
}
}
module.exports = config[type]
\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
// pages/choose_point/choose_point.js
const { api, alertTip } = require('../../lib/util.js')
Page({
/**
* 页面的初始数据
*/
data: {
companyArray: ['未获取'],
companyIndex: 0,//一级网点
pointArray: ['未获取'],
pointIndex: 0,//二级网点
},
/**
* 生命周期函数--监听页面加载
*/
onShow: function () {
this.getCompany()
},
//一级网点变化
companyChange(e) {
this.setData({
companyIndex: e.detail.value
})
let company = this.data.companyArray[this.data.companyIndex]
this.getPoints(company.id)
},
//二级网点变化
pointChange(e) {
console.log(e)
this.setData({
pointIndex: e.detail.value
})
// let point = this.data.pointArray[this.data.pointIndex]
},
//获取一级网点
getCompany() {
let that = this
api.get('company/getByCompany')
.then(({ items }) => {
that.setData({
companyArray: items
})
that.getPoints(items[0].id)
})
.catch(err => {
alertTip(err)
})
},
//获取2级网点
getPoints(companyId) {
let that = this
api.get('site/getByCompanyId', { companyId })
.then(({ items }) => {
that.setData({
pointArray: items
})
})
.catch(err => {
alertTip(err)
that.setData({
dataError: true
})
})
},
surePoint(){
let point = this.data.pointArray[this.data.pointIndex]
wx.showModal({
title: '提示',
content: `确认您的二级网点是${point.companyName}`,
success: function (res) {
if (res.confirm) {
wx.setStorageSync('siteId', point.id)
wx.redirectTo({
url: '/pages/user_index/user_index',
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
}
})
\ No newline at end of file
{
"navigationBarTitleText": "选择网点"
}
\ No newline at end of file
<view class='phone list'>
<text>一级网点:</text>
<picker class='input-text point' bindchange="companyChange" value="{{companyIndex}}" range-key="companyName" range="{{companyArray}}">
<view>{{companyArray[companyIndex].companyName}}</view>
</picker>
<text class='fresh-car' catchtap='getCompany'>刷新公司</text>
</view>
<view class='phone list'>
<text>二级网点:</text>
<picker class='input-text point' bindchange="pointChange" value="{{pointIndex}}" range-key="companyName" range="{{pointArray}}">
<view>{{pointArray[pointIndex].companyName}}</view>
</picker>
</view>
<button class='sure' catchtap='surePoint'>开始收车</button>
/* pages/choose_point/choose_point.wxss */
@import '../user_index/user_index.wxss'
.sure{
background-color: #d7193c;
margin-top: 100rpx;
}
\ No newline at end of file
const config = require('../../config/index.js')
const { api, mapApi, imgName, getUserInfo, wxLogin, alertTip, wxscan, authAgainByUser, userLocation } = require('../../lib/util.js')
let carTimer = null
Page({
/**
* 页面的初始数据
*/
data: {
tab: '',//tab是列表
//详情页数据
carLists: [
/**{
}*/
],
role:1,//角色 录车1 和 收车0
siteId:null,
frameNo:'',
hasPoint:true,
vcuNo: '',
licensePlate: '',
user:null,
imgScan:imgName('imgscan.png'),
// mode:false,//录入模式
typeIndex:0,
modifyIndex:0,
modify:false,//修改模式
carOarray: [],//原始车型类别
carArray: []
},
onShow:function(){
// 录车
if(this.data.role==1){
this.freshCar()
}
},
onUnload(){
wx.removeStorageSync('listtip')
},
//tab切换
tabCarMenu(e) {
let id = e.target.id
if (e.target.id === this.data.tab) return
let tab = this.data.tab === '' ? 'tab' : ''
if(tab){
if(!wx.getStorageSync('listtip')){
alertTip('左右滑动显示更多车型信息')
wx.setStorageSync('listtip', 'has')
}
}
this.setData({
tab
})
},
onLoad: function () {
let carLists = wx.getStorageSync('carLists')
let user = wx.getStorageSync('user').wUserMapp
let role = user.type
if (!carLists) {
carLists = []
}else{
// 入车和收车数据不一致时 删除数据
if (!((role == 1 && carLists[0] && carLists[0].vcuNo) || (role == 0 && carLists[0]&&!carLists[0].vcuNo))){
carLists = []
wx.setStorageSync('carLists', [])
}
}
//收车时要先判断 有没有siteId
if(role==0){
let siteId=wx.getStorageSync('siteId')
if(!siteId){
wx.reLaunch({
url: '/pages/welcome2/welcome2',
})
return
}else{
this.setData({
siteId
})
}
}
this.setData({
carLists,
role,
user
})
wx.setNavigationBarTitle({
title: `${role==1?"录车":"收车"}操作员:${user.name}`
})
},
onUnload() {
wx.setStorageSync('carLists', this.data.carLists)
},
// beQuick(e) {
// if(!this.data.mode){
// alertTip(`快速录车模式下将锁定车型为${this.data.carArray[this.data.typeIndex]},先扫描车架号,再扫描中控号`)
// }
// this.setData({
// mode: e.detail.value
// })
// },
carTypeChange(e){
this.setData({
typeIndex: e.detail.value
})
},
scanCarCode(e) {
let tar = e.target.id.substring(1)
let that=this
wxscan()
.then(no=>{
that.setData({
[tar]:no
})
})
.catch()
},
numInput(e) {
this.setData({
[e.target.id]: e.detail.value
})
},
resetData(){
this.setData({
frameNo: '',
vcuNo: '',
licensePlate: '',
typeIndex: 0,
})
},
//保存数据
saveCarList(){
if (this.checkInput()){
//录车
if(this.data.role==1){
this.data.carLists.push({
licensePlate : this.data.licensePlate,
vcuNo : this.data.vcuNo,
frameNo: this.data.frameNo,
vehicleType: this.data.carArray[this.data.typeIndex],
vehicleModelId: this.data.carOarray[this.data.typeIndex].id
})
}else{
//收车
this.data.carLists.push({
frameNo: this.data.frameNo,
siteId: String(this.data.siteId)
})
}
this.setData({
carLists: this.data.carLists,
licensePlate: '',
frameNo: '',
vcuNo: ''
})
console.log('保存', this.data.carLists)
}
},
//检验数据
checkData(typeNo,no){
switch(typeNo){
case 0:
return this.data.carLists.some(item=>{
return item.frameNo==no
})
break;
default:
return this.data.carLists.some(item => {
return item.vcuNo == no
})
}
},
addCar(){
this.saveCarList()
},
modifyItem(e){
let frame=e.target.id
let index=this.data.carLists.findIndex(item=>{
return item.frameNo == frame
})
//录车
if(this.data.role==1){
this.setData({
licensePlate: this.data.carLists[index].licensePlate,
frameNo: this.data.carLists[index].frameNo,
vcuNo: this.data.carLists[index].vcuNo,
modify: true,
modifyIndex: index,
typeIndex: this.data.carArray.indexOf(this.data.carLists[index].vehicleType) > 0 ? this.data.carArray.indexOf(this.data.carLists[index].vehicleType) : 0,
tab: ''
})
}else{
this.setData({
frameNo: this.data.carLists[index].frameNo,
modify: true,
modifyIndex: index,
tab: ''
})
}
},
removeItem(e){
let frame = e.target.id
this.setData({
carLists: this.data.carLists.filter(item=>{
return item.frameNo != frame
})
})
},
cancelModify(){
this.setData({
licensePlate: '',
frameNo: '',
vcuNo: '',
mode: false,
modify: false,
typeIndex: 0,
tab: 'tab'
})
},
sureModify(){
if (this.checkInput()) {
//录车
let mItem = this.data.carLists[this.data.modifyIndex]
if(this.data.role==1){
mItem.licensePlate = this.data.licensePlate
mItem.frameNo = this.data.frameNo
mItem.vcuNo = this.data.vcuNo
mItem.vehicleType = this.data.carArray[this.data.typeIndex]
mItem.vehicleModelId = this.data.carOarray[this.data.typeIndex].id
}else{
mItem.frameNo = this.data.frameNo
}
this.setData({
carLists: this.data.carLists
})
this.cancelModify()
}
},
freshCar(){
let that =this
let user=wx.getStorageSync('user').wUserMapp
if(!user){
wx.redirectTo({
url: '/pages/welcome2/welcome2',
})
return
}
api.get('vehicle/getVehicleModel')
.then(({ items })=>{
let carArray=items.map(item=>{
return `${item.model}-${item.version}-${item.code}`
})
that.setData({
carOarray:items,
carArray,
user
})
})
.catch(msg=>{
alertTip(msg)
})
},
submitList(){
let that=this
let { carLists, user}=this.data
if (carLists.length==0){
alertTip('还没有录入车辆')
return
}
//录车
if(this.data.role==1){
api.post('vehicle/entry', {
data: JSON.stringify(carLists),
userId: user.userId
})
.then(res => {
alertTip(res.message)
that.setData({
licensePlate: '',
frameNo: '',
vcuNo: '',
carLists: [],
modify: false,
typeIndex: 0,
tab: 'tab'
})
wx.removeStorageSync('carLists')
})
.catch(err => {
alertTip(err)
})
}else{
api.post('check/check', {
data: JSON.stringify(carLists),
userId: user.userId
})
.then(res => {
alertTip(res.message)
that.setData({
licensePlate: '',
frameNo: '',
vcuNo: '',
carLists: [],
modify: false,
typeIndex: 0,
tab: 'tab'
})
wx.removeStorageSync('carLists')
})
.catch(err => {
alertTip(err)
})
}
},
checkInput(){
if (this.data.frameNo == '') {
alertTip('请录入车架号')
return false
}
//录车时判断中空号
if(this.data.role==1){
if (this.data.vcuNo == '') {
alertTip('请录入中控号')
return false
}
}
let that = this
let exist = that.checkData(0, that.data.frameNo)
if (exist) {
alertTip('已经录入过该车架号')
return false
}
//录车时检验中控号
if (that.data.role == 1) {
let exist2 = that.checkData(1, that.data.vcuNo)
if (exist2) {
alertTip('已经录入过该中控号')
return false
}
}
return true
},
//重选网点
repoint(){
wx.navigateTo({
url: '/pages/choose_point/choose_point',
})
}
})
\ No newline at end of file
{
}
\ No newline at end of file
<!--pages/user_index/user_index.wxml-->
<view class='con'>
<view class='tab-header'>
<view class='main' catchtap='tabCarMenu'>
<view class='item {{tab===""? "active":""}}'>{{role==1?"录入":"收车"}}</view>
<view class='item {{tab==="tab"? "active":""}}' id='tab'>列表 {{carLists.length>0?carLists.length+'台':''}}</view>
</view>
</view>
<view class='body-box {{tab}}'>
<view class='tab-map'>
<view>
<!-- <view hidden='{{modify}}' class='mode list agree {{mode?"insurance":""}}'>
<switch bindchange="beQuick" checked='{{mode}}' color='#ffd200' /> 快速录车模式
</view> -->
<!--收车 -->
<view class='phone list' wx:if='{{role==1}}'>
<text>车型:</text>
<picker class='input-text point' bindchange="carTypeChange" value="{{typeIndex}}" range="{{carArray}}">
<view>{{carArray[typeIndex]}}</view>
</picker>
<text class='fresh-car' catchtap='freshCar'>刷新车型</text>
</view>
<view class='phone list' wx:if='{{role==1}}'>
<text>号牌:</text>
<input class='input-text' id='licensePlate' value='{{licensePlate}}' placeholder='请输入号牌' bindinput='numInput'></input>
</view>
<view class='phone list'>
<text>车架号:</text>
<input class='input-text' id='frameNo' value='{{frameNo}}' placeholder='请输入车架号' bindinput='numInput'></input>
<image src='{{imgScan}}' catchtap='scanCarCode' id='iframeNo'></image>
</view>
<view class='phone list' wx:if='{{role==1}}'>
<text>中控号:</text>
<input class='input-text' id='vcuNo' value='{{vcuNo}}' placeholder='请输入中控号' bindinput='numInput'></input>
<image src='{{imgScan}}' catchtap='scanCarCode' id='ivcuNo'></image>
</view>
</view>
<view class='option' wx:if='{{modify}}'>
<button catchtap='cancelModify'>取消修改</button>
<button catchtap='sureModify'>确定修改</button>
</view>
<view wx:else>
<view class='option'>
<button catchtap='resetData'>重置</button>
<button catchtap='addCar'>确定</button>
</view>
</view>
<view wx:if='{{!role}}' class='repoint submit-sys' catchtap='repoint'>网点重选</view>
</view>
<view class='tab-detail'>
<scroll-view scroll-y scroll-x='{{role==1}}' class='{{role==0?"mode":""}} device-list' scroll-left='{{role==1?"250":"0"}}'>
<view class='list-title'>
<text wx:if='{{role==1}}'>号牌</text>
<text>车架号</text>
<text wx:if='{{role==1}}'>中控号</text>
<text wx:if='{{role==1}}'>车型</text>
<text>操作</text>
</view>
<block wx:for='{{carLists}}' wx:key='{{item.frameNo}}'>
<view class='list-tr'>
<text class='list-td' wx:if='{{role==1}}'>{{item.licensePlate}}</text>
<text class='list-td'>{{item.frameNo}}</text>
<text class='list-td' wx:if='{{role==1}}'>{{item.vcuNo}}</text>
<text class='list-td' wx:if='{{role==1}}'>{{item.vehicleType}}</text>
<view class='list-td option2'>
<text id='{{item.frameNo}}' catchtap='modifyItem'>修改</text>
<text id='{{item.frameNo}}' catchtap='removeItem'>删除</text>
</view>
</view>
</block>
</scroll-view>
<view class='submit-sys' catchtap='submitList'>提交</view>
</view>
</view>
</view>
\ No newline at end of file
page {
height: 100%;
overflow: hidden;
}
page .con {
height: 100%;
overflow: hidden;
position: relative;
}
page .con .tab-header {
box-sizing: border-box;
display: flex;
justify-content: space-between;
align-items: stretch;
padding: 28rpx 28rpx 0 28rpx;
height: 103rpx;
color: #686868;
border-bottom: 2rpx solid #e9e9e9;
}
page .con .tab-header .person {
height: 100%;
width: 42rpx;
}
page .con .tab-header .main {
height: 100%;
flex: 1;
display: flex;
justify-content: space-between;
position: relative;
transform: translateY(2rpx);
}
page .con .tab-header .main .item {
font-size: 32rpx;
text-align: center;
flex: 1 0 auto;
border-bottom: 6rpx solid transparent;
}
page .con .tab-header .item.active {
color: #d7193c;
border-bottom-color: #d7193c;
}
page .con .body-box {
height: 1111rpx;
width: 200%;
box-sizing: border-box;
transform: translateX(0);
transition: all 0.2s;
display: flex;
}
page .con .body-box .tab-map {
width: 50%;
display: flex;
flex-direction: column;
/* justify-content: space-between; */
}
page .con .body-box .tab-detail {
width: 50%;
height: 100%;
box-sizing: border-box;
/* padding: 0 40rpx 50rpx; */
}
page .con .tab {
transform: translateX(-50%);
}
.phone {
width: 100%;
}
.list {
height: 110rpx;
display: flex;
align-items: center;
padding: 0 30rpx;
border-bottom: 2rpx solid #f8f8f8;
}
.list image{
width: 50rpx;
height: 50rpx;
}
.list text{
flex-basis: 160rpx;
flex-shrink: 0;
}
.list .input-text{
flex: 1;
}
.insurance{
color: #d7193c;
}
.option{
display: flex;
margin-top: 50rpx;
}
.option button{
background-color: #d7193c;
font-size: 32rpx;
flex-basis: 250rpx;
color: #fff;
}
.list-title,.list-tr{
display: flex;
padding: 20rpx 30rpx;
width: 1310rpx;
border-bottom: 2px solid #f8f8f8;
align-items: center;
}
.list-title text,.list-tr .list-td{
flex:0 0 250rpx;
text-align: center;
word-break: break-all;
}
.mode .list-title,.mode .list-tr{
width: 100%;
}
.mode .list-title text,.mode .list-tr .list-td{
flex:1 0 250rpx;
}
.list-tr{
border-bottom: 1px solid #f8f8f8;
}
.option2{
display: flex;
flex-direction: column;
}
.option2 text{
padding: 10rpx 20rpx;
background-color: #d7193c;
border-radius:10rpx;
}
.option2 text:nth-of-type(1){
margin-bottom: 20rpx;
}
.submit-sys{
position: fixed;
background-color: rgba(214, 25, 59, 0.7);
left: 50%;
bottom: 100rpx;
padding: 30rpx 50rpx 30rpx 10rpx;
border-top-right-radius: 46rpx;
border-bottom-right-radius: 46rpx;
}
.repoint{
left: 0%;
}
.device-list{
width: 100%;
height: 100%;
overflow: scroll;
}
.fresh-car{
padding: 10rpx 20rpx;
background-color: #d7193c;
border-radius:10rpx;
text-align: center;
color: #fff;
}
button,.option2,.submit-sys{
color: #fff;
}
\ No newline at end of file
const { api, imgName, getUserInfo, wxLogin, alertTip, authAgainByUser } = require('../../lib/util.js')
Page({
data: {
//图片
imgLogo: imgName('logo.png'),
imgPerson: imgName('sign_in_phone_white.png'),
imgLock: imgName('sign_in_password_white.png')
},
onLoad: function () {
// wx.removeStorageSync('user')
},
formSubmit(e){
// if (!/^1\d{10}/.test(e.detail.value.mobile)) {
// alertTip('请输入正确的手机号!')
// return false
// }
// if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,}$/.test(e.detail.value.password)) {
// alertTip('请输入6-12位包含数字和字母的密码!')
// return false
// }
let { userName, password } = e.detail.value;
if(userName&&password){
api.get('user/logon', e.detail.value)
.then(({ data }) => {
wx.setStorageSync('user', data)
switch(data.wUserMapp.type){
case 1:
wx.redirectTo({
url: '/pages/user_index/user_index',
})
break;
default:
wx.redirectTo({
url: '/pages/choose_point/choose_point',
})
}
})
.catch(err => {
alertTip(err)
})
return
}
alertTip('用户名和密码不能为空!')
}
})
\ No newline at end of file
{
}
\ No newline at end of file
<view class='con'>
<image class='logo' src='{{imgLogo}}'></image>
<form class='from-login' bindsubmit="formSubmit" report-submit>
<view class='form-item'>
<label for='mobile'>
<image src='{{imgPerson}}'></image>
</label>
<input type='text' maxlength='11' id='mobile' name='userName' placeholder='请输入账号'></input>
</view>
<view class='form-item'>
<label for='password'>
<image src='{{imgLock}}'></image>
</label>
<input type='text' name='password' id='password' password placeholder='请输入密码'></input>
</view>
<button formType="submit">登录</button>
</form>
</view>
\ No newline at end of file
page {
height: 100%;
}
.con {
height: 100%;
text-align: center;
padding-top: 78rpx;
position: relative;
}
.con .logo {
width: 236rpx;
height: 236rpx;
}
.con .from-login {
display: block;
padding: 60rpx 62rpx 30rpx 62rpx;
}
.con .from-login .form-item {
box-sizing: border-box;
border: 4rpx solid #cccccc;
border-radius: 45rpx 45rpx;
background-color: #ffffff;
height: 90rpx;
line-height: 90rpx;
margin-bottom: 35rpx;
display: flex;
align-items: center;
justify-content: flex-start;
text-align: left;
font-size: 14px;
}
.con .from-login .form-item label {
width: 76rpx;
padding-left: 34rpx;
height: 42rpx;
line-height: 42rpx;
flex-grow: 0;
}
.con .from-login .form-item image {
width: 42rpx;
height: 42rpx;
margin-right: 34rpx;
}
.con .from-login .form-item input {
flex-grow: 1;
}
.con .from-login button {
margin-top: 82rpx;
background-color: #d7193c;
color: #ffffff;
font-size: 34rpx;
height: 90rpx;
border-radius: 45rpx;
letter-spacing: 4px;
}
{
"description": "录车小程序",
"setting": {
"urlCheck": true,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true
},
"compileType": "miniprogram",
"libVersion": "1.6.4",
"appid": "wx719af42c3a22ad73",
"projectname": "%E5%BD%95%E8%BD%A6%E5%B0%8F%E7%A8%8B%E5%BA%8F",
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"miniprogram": {
"current": -1,
"list": []
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment