Commit 8fe787dd by iambtr

智租科技A版

parent 668c3b91
{
"pages": [
"pages/welcome2/welcome2",
"pages/user_message/user_message",
"pages/return_car_pedding/return_car_pedding",
"pages/pay/pay",
"pages/user_index/user_index",
"pages/user_travel_path/user_travel_path",
......@@ -13,14 +14,13 @@
"pages/settting/setting",
"pages/path_detail/path_detail",
"pages/forgetpassword/forgetpassword",
"pages/user_device_message/user_device_message",
"pages/agreement_use/agreement_use",
"pages/user_car_loc/user_car_loc",
"pages/user_message/user_message",
"pages/qr_code/qr_code",
"pages/register2/register2",
"pages/point_detail/point_detail"
"pages/point_detail/point_detail",
"pages/choose_rent_type/choose_rent_type",
"pages/search/search"
],
"window": {
"backgroundTextStyle": "dark",
......
// components/search/search.js
Component({
/**
* 组件的属性列表
*/
properties: {
maxLenth: { // 属性名
type: Number, // 类型(必填),目前接受的类型包括:String, Number, Boolean, Object, Array, null(表示任意类型)
value: 5, // 属性初始值(可选),如果未指定则会根据类型选择一个
},
showHistory: { // 属性名
type: Boolean, // 类型(必填),目前接受的类型包括:String, Number, Boolean, Object, Array, null(表示任意类型)
value: false, // 属性初始值(可选),如果未指定则会根据类型选择一个
},
},
/**
* 组件的初始数据
*/
data: {
searchHistory: [],
hasFocus:false,
searchValue:''
},
/**
* 组件的方法列表
*/
methods: {
//失去焦点
_blurInput(e){
let value = e.detail.value
setTimeout(()=>{
this.setData({
hasFocus: false,
})
},200)
this.triggerSearch(value)
},
//输入
_searchInput(e) {
let value=e.detail.value
this.triggerChange(value)
},
//聚焦
_focusInput(e){
this.setData({
hasFocus: true,
})
},
//更新历史记录
_updateHistory(key){
let historyArray=this.data.searchHistory
let newHistoryArray=null
if (historyArray.length < this.data.maxLenth){
this.data.searchHistory.unshift(key)
}else{
this.data.searchHistory.unshift(key)
this.data.searchHistory.pop()
}
this.setData({
searchHistory: this.data.searchHistory
})
},
_historyItemTap(e){
let historyValue=e.currentTarget.id
this.setData({
searchValue:historyValue
})
},
//触发搜索事件
triggerSearch(value){
this.setData({
searchValue: value
})
this.triggerEvent('search', { value })
this._updateHistory(value)
},
//触发改变事件
triggerChange(value) {
this.triggerEvent('change', { value })
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<view class='wr_search'>
<image src='./search.png'></image>
<input placeholder='输入搜索项' value='{{searchValue}}' confirm-type='search' bindfocus='_focusInput' bindblur='_blurInput' bindinput='_searchInput'></input>
</view>
<view class='history-box' wx:if='{{showHistory&&hasFocus}}'>
<view class='wr_search_item' wx:for='{{searchHistory}}' wx:key='{{item}}' catchtap='_historyItemTap' id='{{item}}'>{{item}}</view>
</view>
\ No newline at end of file
/* components/search/search.wxss */
.wr_search{
display: flex;
background-color: #fff;
border-radius: 6rpx;
padding: 0 20rpx;
align-items: center;
height: 80rpx;
font-size: 32rpx;
position: relative;
}
.wr_search image{
width: 36rpx;
height: 36rpx;
margin-right: 30rpx;
}
.wr_search input{
flex: 1 0 auto;
}
.history-box{
position: absolute;
width: 100%;
z-index: 1000;
background-color: #eee;
color: #fff;
}
.wr_search_item{
padding: 10rpx 10rpx 10rpx 86rpx;
}
\ No newline at end of file
......@@ -607,6 +607,13 @@ const getProtocol = (id) => {
}
})
}
const changeTime = (mss)=>{
var days = parseInt(mss / (1000 * 60 * 60 * 24));
var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60));
var seconds = (mss % (1000 * 60)) / 1000;
return `${days ? days + '天' : ''}${hours ? hours + '小时' : ''}${minutes ? minutes + '分钟' : ''}${seconds ? seconds + '秒' : ''}`
}
module.exports = {
formatTime,
imgName,
......@@ -621,5 +628,6 @@ module.exports = {
getProtocol,
payApi,
rapi,
mockApi
mockApi,
changeTime
}
// pages/choose_rent_type/choose_rent_type.js
const {
api,
imgName,
getUserInfo,
wxLogin,
alertTip,
authAgainByUser
} = require('../../lib/util.js')
let timer = null
Page({
/**
* 页面的初始数据
*/
data: {
imgLogo: imgName('logo.png'),
userTypes: [{
value: 0,
name: '公司用户'
},
{
value: 1,
name: '个人用户'
}
],
companyName: '',
companyId: null,
pointName: '',
pointId: null,
id: null, //数据id
userType: null,
dataError: true,
user: null,
hasCar: null, //用车
status: 'normal' //normal正常 auth审核中 authFail审核驳回
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
let {
status
} = options
this.setData({
user: wx.getStorageSync('user').userMapp
})
let that = this
switch (status) {
case 'auth':
clearInterval(timer)
timer = setInterval(() => {
that.getStatus()
}, 5000)
break;
case 'authFail':
that.setData({
status: 'authFail'
})
break;
default:
clearInterval(timer)
that.setData({
status: 'normal'
})
break;
}
},
onShow: function() {
this.getStatus()
},
onUnload() {
clearInterval(timer)
},
onHide() {
clearInterval(timer)
},
giveUp() {
//放弃申请
let that = this
let {
id
} = that.data
if (!id) {
alertTip('请稍后重试')
return
}
wx.showModal({
title: '提示',
content: '是否放弃申请',
success: function(res) {
if (res.confirm) {
api.post('message/cancelJoin', {
id
}).then(res => {
that.setData({
status: 'normal'
})
clearInterval(timer)
}).catch(err => {
alertTip(err)
})
}
}
})
},
//用户选择
radioChange(e) {
let userType = Number(e.detail.value)
this.setData({
userType
})
},// 提交申请
applyFor() {
let { companyName, companyId,pointName, pointId } = this.data
if (!companyName) {
alertTip('未选择租赁商')
return
}
if (!pointName) {
alertTip('未选择站点')
return
}
let that = this
wx.showModal({
title: '提示',
content: `确定申请 ${companyName} 下站点:${pointName}`,
success: function (res) {
if (res.confirm) {
api.post('message/requestJoin', {
userId: that.data.user.id,
siteId: pointId,
companyId: companyId,
rentType: 0
})
.then(res => {
//申请成功
console.log(res)
that.setData({
status: 'auth'
})
wx.setStorageSync('hasTip', false)//重新申请授权驳回
//轮询状态
clearInterval(timer)
that.getStatus()
timer = setInterval(() => {
that.getStatus()
}, 5000)
})
.catch(err => {
//轮询状态 重复申请的情况
clearInterval(timer)
that.getStatus()
timer = setInterval(() => {
that.getStatus()
}, 5000)
alertTip(err)
})
}
}
})
},
rentCar(e) {
//个人用户开始租车
api.get('user/getByUserId', { userId: this.data.user.id })
.then(res => {
console.log(res)
// 判断是否存在未完成订单
if (res.data.isNoPayMoney != 0) {
// 付钱
wx.navigateTo({
url: '/pages/pay/pay?type=rent',
})
return
}
if (res.data.depositAmount == 0) {
alertTip('租车前请先支付押金!', function () {
wx.navigateTo({
url: `/pages/pay/pay?type=deposit`,
})
})
return
}
let user = wx.getStorageSync('user')
user.userMapp.userType = 1
user.userMapp.depositAmount = res.data.depositAmount
wx.setStorageSync('user', user)
wx.navigateTo({
url: '/pages/device_bind/device_bind',
})
})
.catch(err => {
console.error(err)
})
},
reApply() {
//重新申请
this.setData({
status: 'normal',//normal正常 auth审核中 authFail审核驳回
})
wx.setStorageSync('hasTip', true)
},
//登录页面
resetStatus() {
wx.reLaunch({
url: '/pages/welcome2/welcome2',
})
},
//获取审核状态
getStatus() {
let This = this
api.get('message/getMessageInfo', {
userId: This.data.user.id,
messageType: 7//用户申请加入站点
}, {}, true)
.then(res => {
let { state, id } = res.data
This.setData({
id
})
switch (state) {
//待审核
case 0:
This.setData({
status: 'auth'
})
break;
//审核通过去首页
case 1:
clearInterval(timer)
//存储用户类型,以这个为准
let user = wx.getStorageSync('user')
user.userMapp.userType = 0
wx.setStorageSync('user', user)
wx.redirectTo({
url: '/pages/device_bind/device_bind',
})
break;
//审核驳回
case -1:
if (wx.getStorageSync('hasTip')!=true){
This.setData({
status: 'authFail'
})
}
clearInterval(timer)
break;
//正常页面
default:
This.setData({
status: 'normal',//normal 和 pedding
})
clearInterval(timer)
}
})
.catch(err => {
console.error(err)
})
},
//获取一级网点
getCompany() {
wx.navigateTo({
url: '/pages/search/search?type=companyByName',
})
},
//获取2级网点
getPoint() {
wx.navigateTo({
url: '/pages/search/search?type=byCompanyId',
})
},
})
\ No newline at end of file
<view class='con'>
<image class='logo' src='{{imgLogo}}'></image>
<view wx:if='{{status=="normal"}}'>
<view class='phone-sure list'>
<text class='form-tip'>请选择:</text>
<radio-group class="radio-group" bindchange="radioChange">
<label class="radio" wx:for="{{userTypes}}" wx:key='{{item.name}}'>
<radio value="{{item.value}}" color='#d7193c' checked="{{userType===index}}" />{{item.name}}
</label>
</radio-group>
</view>
<view wx:if='{{userType===0}}'>
<view class='phone-sure list'>
<text>租赁商:</text>
<input value='{{companyName}}' placeholder='请输入租赁商' disabled catchtap='getCompany'></input>
</view>
<view class='phone-sure list' wx:if='{{companyName}}'>
<text>站点:</text>
<input value='{{pointName}}' placeholder='请输入站点' disabled catchtap='getPoint'></input>
</view>
<button class='btn' catchtap='applyFor'>提交申请</button>
<!--提交完申请 进入一个提示页面 点击确定返回登录页面 该页面轮询 处理结果 -->
</view>
<view wx:if='{{userType===1}}'>
<button class='btn' catchtap='rentCar'>点击开始租车</button>
</view>
</view>
<view wx:if='{{status=="auth"}}'>
<view class='wait-auto'>等待站点同意授权中...</view>
<view class='giveup2 giveup'>
<text catchtap='giveUp'>放弃申请?</text>
</view>
</view>
<view wx:if='{{status=="authFail"}}'>
<view class='wait-auto'>您的团租加入申请被驳回了...</view>
<view class='giveup'>
<text catchtap='resetStatus'>返回登录</text>
<text catchtap='reApply'>重新申请?</text>
</view>
</view>
</view>
\ No newline at end of file
/* pages/choose_rent_type/choose_rent_type.wxss */
@import '../welcome2/welcome2.wxss'
\ No newline at end of file
......@@ -77,7 +77,23 @@ Page({
alertTip('请同意租车协议')
return false
}
let { frameNo, userId, rentType}=This.data
//团租解绑了用户
if (This.data.rentType==0){
api.get('message/getMessageInfo', {
userId: This.data.userId,
messageType: 7//用户申请加入站点
}, {}, true)
.then(res => {
let { state } = res.data
if (state == 3) {
alertTip('站点解绑了你的账户',()=>{
wx.redirectTo({
url: '/pages/choose_rent_type/choose_rent_type?status=normal',
})
})
return
}
let { frameNo, userId, rentType } = This.data
api.post('message/requestJoinCar', {
frameNo, userId, rentType
})
......@@ -98,6 +114,30 @@ Page({
alertTip(err)
console.error(err)
})
})
.catch(err => {
console.error(err)
})
}else{
//个租
let { frameNo, userId, rentType } = This.data
api.post('message/requestJoinCar', {
frameNo, userId, rentType
})
.then(res => {
alertTip(res.message)
This.getStatus(rentType)
timer = setInterval(() => {
This.getStatus(rentType)
}, 5000)
return
})
.catch(err => {
alertTip(err)
console.error(err)
})
}
},
getStatus(userType){
let This=this
......@@ -108,11 +148,9 @@ Page({
},{},true)
.then(res=>{
let { state ,id } = res.data
if (!This.data.id){
This.setData({
id
})
}
switch(state){
//待审核
case 0:
......@@ -127,9 +165,49 @@ Page({
break;
//审核通过去首页
case 1:
//团租
if (This.data.rentType == 0){
wx.redirectTo({
url: '/pages/user_index/user_index',
})
return
}
//个租判断订单状态
api.get('order/getRentRecord', {
userId: This.data.userId
})
.then(res2 => {
let state2 = res2.data.state
switch (state2) {
case 1:
wx.redirectTo({
url: '/pages/user_index/user_index',
})
break;
case 5:
wx.redirectTo({
url: '/pages/return_car_pedding/return_car_pedding',
})
break;
}
})
.catch(err => {
console.error(err)
})
break;
//驳回
case -1:
if (This.data.status !='normal'){
alertTip('您的申请用车被驳回', () => {
This.setData({
status: 'normal',//normal 和 pedding
})
clearInterval(timer)
//判断是否未支付定单或者押金
This.getRentRecord()
})
}
break;
//正常页面
default:
......@@ -137,6 +215,8 @@ Page({
status: 'normal',//normal 和 pedding
})
clearInterval(timer)
//判断是否未支付定单或者押金
This.getRentRecord()
}
})
.catch(err=>{
......@@ -231,7 +311,6 @@ Page({
markers.push(oMarker)
return item
})
console.log(markers)
that.setData({
markers,
})
......@@ -253,5 +332,29 @@ Page({
wx.navigateTo({
url: '/pages/server_point/server_point',
})
},
//判断是否未支付定单或者押金
getRentRecord(){
api.get('order/getRentRecord', {
userId: this.data.userId
})
.then(res => {
let state = res.data.state
switch (state) {
case 2:
wx.redirectTo({
url: `/pages/pay/pay?type=rent`,
})
break;
case 4:
wx.redirectTo({
url: `/pages/pay/pay?type=deposit`,
})
break;
}
})
.catch(err => {
console.error(err)
})
}
})
\ No newline at end of file
<view class='con' wx:if='{{status=="normal"}}'>
<!--扫描 -->
<map id="myMap" catchtap='toServerPoint' wx:if='{{rentType}}' class='points' show-location longitude='{{longitude}}' latitude='{{latitude}}' markers='{{markers}}'></map>
<map id="myMap" bindtap='toServerPoint' wx:if='{{rentType}}' class='points' show-location longitude='{{longitude}}' latitude='{{latitude}}' markers='{{markers}}'></map>
<view class='con' wx:if='{{modelScan}}'>
<image src='{{imgScan}}' class='img-scan' bindtap='scanImg'></image>
<text class='title scan-title' bindtap='scanImg'>扫码用车</text>
......
......@@ -89,7 +89,7 @@ input{
}
.wait-auto{
color: #d7193c;
font-size: 50rpx;
font-size: 40rpx;
margin: 60rpx 0;
}
.giveup{
......
......@@ -84,22 +84,27 @@ Page({
// this.getFirstPage()
},
wxDepositRefund() {
// payApi.post('pay/wxRefund', {
// outRefundNo: '20180524194005033000337',
// outTradeNo: '20180524194005033000337'
// })
// .then(res => {
// alertTip('退款成功')
// console.log('退款', res)
// })
// .catch(err => {
// alertTip(err.err_code_des)
// console.error('退款', err)
// })
let that=this
api.get('order/getRentRecord', {
userId: wx.getStorageSync('user').userMapp.id
})
.then(res => {
let state = res.data.state
switch (state) {
case 1:
alertTip('请先还车后,再退押金')
break;
case 2:
alertTip('您存在未支付订单',()=>{
wx.redirectTo({
url: `/pages/pay/pay?type=rent`,
})
})
break;
case 3:
payApi.post('pay/wxDepositRefund')
.then(res => {
alertTip('押金退款请求成功',()=>{
alertTip('押金退款请求成功', () => {
// that.updateDeposit()
wx.reLaunch({
url: '/pages/welcome2/welcome2',
......@@ -110,6 +115,39 @@ Page({
alertTip(err.err_code_des || err.return_msg)
console.error('退款', err)
})
break;
case 5:
alertTip('您的还车申请审核中', () => {
// that.updateDeposit()
wx.redirectTo({
url: `/pages/return_car_pedding/return_car_pedding`,
})
})
break;
}
})
.catch(err => {
if (err=='数据为空'){
payApi.post('pay/wxDepositRefund')
.then(res => {
alertTip('押金退款请求成功', () => {
// that.updateDeposit()
wx.reLaunch({
url: '/pages/welcome2/welcome2',
})
})
})
.catch(err => {
alertTip(err.err_code_des || err.return_msg)
console.error('退款', err)
})
}else{
alertTip(err)
}
})
},
toDetailPage(e) {
let url = e.currentTarget.id
......
// pages/pay/pay.js
const { api, imgName, wxLogin, payApi, alertTip } = require('../../lib/util.js')
const { api, imgName, wxLogin, payApi, alertTip, useTime, changeTime} = require('../../lib/util.js')
Page({
data: {
price:'--',
payType: 'rent',//deposit rent
success:true,//
orderNumber:'',
startRentTime:'',
endRentTime:'',
useTime:''
},
/**
......@@ -15,19 +19,65 @@ Page({
this.setData({
payType,
})
this.setUI()
},
setUI(){
//租金
if (this.data.payType == 'rent') {
this.getRentRecord()
} else {
this.getDePosit()
}
},
//判断是否未支付定单或者押金 个租
getRentRecord() {
let that=this
api.get('order/getRentRecord', {
userId: wx.getStorageSync('user').userMapp.id
})
.then(res => {
let { orderNumber, rentAmount, startRentTime, endRentTime } = res.data
let useTime = changeTime(new Date(endRentTime) - new Date(startRentTime))
this.setData({
price: rentAmount,
orderNumber,
startRentTime: new Date(startRentTime).toLocaleString(),
endRentTime: new Date(endRentTime).toLocaleString(),
useTime
})
})
.catch(err => {
that.setData({
success:false
})
alertTip(err)
})
},
//押金配置
getDePosit() {
let that = this
api.get('pay/getDeposit.json')
.then(res => {
console.log(res)
let { deposit } = res.data
this.setData({
price: deposit,
})
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
})
.catch(err => {
that.setData({
success: false
})
alertTip(err)
})
},
onPullDownRefresh: function () {
if(this.data.success){
wx.stopPullDownRefresh()
}else{
//重新请求
this.setUI()
}
},
......@@ -40,66 +90,18 @@ Page({
}
},
payDeposit() {
// 原需要 订单号
// wxLogin()
// .then(code=>{
// payApi.get('pay/getOpenId.json',{
// code
// })
// .then(res=>{
// console.log('openid',res)
// let openId = res.openId
// wx.setStorageSync('openid', openId)
// payApi.post('pay/miniAppUnifiedOrder',{
// openId,
// outTradeNo: '20180524194005033000337'
// })
// .then(res => {
// console.log('miniAppUnifiedOrder', res)
// let { timeStamp, nonce_str: nonceStr, signType, prepay_id,paySign } = res
// //统一下单了
// wx.requestPayment({
// timeStamp,
// nonceStr,
// 'package': prepay_id,
// 'signType': 'MD5',
// paySign,
// 'success': function (res) {
// console.log(res)
// },
// 'fail': function (res) {
// console.error(res)
// }
// })
// })
// .catch(err => {
// alertTip(err.err_code_des)
// console.error(err)
// })
// })
// .catch(err=>{
// alertTip(err.remark)
// console.error('openid', err)
// })
// })
// .catch(err=>{
// console.log(err)
// })
console.log('押金支付')
wxLogin()
.then(code=>{
payApi.get('pay/getOpenId.json',{
code
})
.then(res=>{
console.log('openid',res)
let openId = res.openId
wx.setStorageSync('openid', openId)
payApi.post('pay/miniAppDepositOrder',{
openId
})
.then(res => {
console.log('miniAppUnifiedOrder', res)
let { timeStamp, nonce_str: nonceStr, signType, prepay_id,paySign } = res
//统一下单了
wx.requestPayment({
......@@ -134,7 +136,7 @@ Page({
},
payRent() {
let that=this
// 租金
wxLogin()
.then(code=>{
......@@ -143,13 +145,11 @@ Page({
})
.then(res=>{
let openId = res.openId
wx.setStorageSync('openid', openId)
payApi.post('pay/miniAppUnifiedOrder',{
payApi.post('pay/miniAppRentOrder',{
openId,
outTradeNo: '20180524194005033000337'
outTradeNo: that.data.orderNumber
})
.then(res => {
console.log('miniAppUnifiedOrder', res)
let { timeStamp, nonce_str: nonceStr, signType, prepay_id,paySign } = res
//统一下单了
wx.requestPayment({
......@@ -160,7 +160,9 @@ Page({
paySign,
'success': function (res) {
alertTip('租金支付成功!', function () {
wx.navigateBack()
wx.redirectTo({
url: '/pages/my/my',
})
})
console.log(res)
},
......@@ -182,6 +184,5 @@ Page({
.catch(err=>{
console.log(err)
})
}
})
\ No newline at end of file
{
"navigationBarTitleText": "押金支付",
"navigationBarTitleText": "支付",
"enablePullDownRefresh": true
}
\ No newline at end of file
......@@ -9,16 +9,28 @@
<text>支付金额:</text>
<text class='tip'>¥{{price}}元</text>
</view>
<view class='item' wx:if='{{payType=="deposit"}}'>
<view class='item'>
<text>提示:</text>
<text class='tip2 tip'>押金可以在租车结束后退还。</text>
</view>
</view>
<!--租金 -->
<view wx:else>
<view class='item' wx:if='{{payType=="deposit"}}'>
<text>订单:</text>
<text class='tip2 tip'>押金可以在租车结束后退还。</text>
<view class='item'>
<text>订单编号:</text>
<text class='tip'>{{orderNumber}}</text>
</view>
<view class='item'>
<text>起租时间:</text>
<text class='tip'>{{startRentTime}}</text>
</view>
<view class='item'>
<text>还车时间:</text>
<text class='tip'>{{endRentTime}}</text>
</view>
<view class='item'>
<text>用车时长:</text>
<text class='tip'>{{useTime}}</text>
</view>
<view class='item'>
<text>支付金额:</text>
......
......@@ -66,7 +66,7 @@ Page({
})
},
toProtocol: function () {
getProtocol(1)
getProtocol(4)
.then(res => {
console.log(res)
})
......@@ -205,7 +205,6 @@ Page({
success: function (res) {
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
let tempFilePath = res.tempFilePaths[0]
console.log(tempFilePath)
wx.showLoading({
title: '上传中。。',
})
......@@ -217,7 +216,6 @@ Page({
that.setData({
idPhoto: JSON.parse(res.data).picUrl
})
console.log(that.data.idPhoto)
},
fail(err){
alertTip('上传失败')
......
// pages/return_car_pedding/return_car_pedding.js
//轮询订单状态
const { api, imgName, wxLogin, payApi, alertTip } = require('../../lib/util.js')
let timer=null
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let userId=wx.getStorageSync('user').userMapp.id
this.setData({
userId,
})
},
onShow: function () {
this.getRentRecord()
clearInterval(timer)
timer=setInterval(()=>{
this.getRentRecord()
},5000)
},
onHide: function () {
clearInterval(timer)
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
clearInterval(timer)
},
//个租情况 获取行程状态
// state 1 index 5还车审核中
getRentRecord() {
api.get('order/getRentRecord', {
userId: this.data.userId
},true)
.then(res => {
let state = res.data.state
if(state==2){
//付押金
wx.redirectTo({
url: `/pages/pay/pay?type=rent`,
})
return
}
if (state == 1) {
//还车申请被驳回
alertTip('你的还车申请被驳回了',()=>{
wx.redirectTo({
url: `/pages/user_index/user_index`,
})
})
return
}
})
.catch(err => {
console.error(err)
if(err=='数据为空'){
wx.reLaunch({
url: `/pages/welcome2/welcome2`,
})
}
})
}
})
\ No newline at end of file
<view class='tip'>
<text>您的还车申请已经提交</text>
<text>请耐心等待站点同意。</text>
</view>
/* pages/return_car_pedding/return_car_pedding.wxss */
.tip{
display: flex;
flex-direction: column;
align-items: center;
color: #d7193c;
font-size: 40rpx;
margin: 60rpx 0;
}
\ No newline at end of file
// pages/search/search.js
const { api, alertTip } = require('../../lib/util.js')
Page({
/**
* 页面的初始数据
*/
data: {
prevPage:null,
searchList: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let searchType=options.type
var pages = getCurrentPages();
var prevPage = pages[pages.length - 2]; //上一个页面
this.setData({
searchType,
prevPage
})
this[this.data.searchType]()['search']('')
},
apiSearch(e){
// 触发搜索
let q=e.detail.value
this[this.data.searchType]()['search'](q)
},
resultSelect(e) {
// 选择结果
let sItem=e.currentTarget.dataset.values
this[this.data.searchType]()['result'](sItem)
},
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
companyByName(){
let that=this
return {
search(companyName){
api.get('site/getByCompanyByName', { companyName})
.then(({ items }) => {
let newItems=items.map(item=>{
item.itemName = item.province +'--'+ item.companyName
return item
})
that.setData({
searchList: newItems
})
})
.catch(err => {
alertTip(err)
})
},
result(sItem){
that.data.prevPage.setData({
companyName: sItem.companyName,
companyId: sItem.id,
pointName: '',
pointId: null,//二级网点
})
wx.navigateBack()
}
}
},
//网点
byCompanyId(){
let that = this
return {
search(companyName) {
api.get('site/getByCompanyIdAndCompanyName', { companyId: that.data.prevPage.data.companyId, companyName })
.then(({ items }) => {
let newItems = items.map(item => {
item.itemName = item.province + '--' + item.companyName
return item
})
that.setData({
searchList: newItems
})
})
.catch(err => {
alertTip(err)
})
},
result(sItem) {
that.data.prevPage.setData({
pointName: sItem.companyName,
pointId: sItem.id
})
wx.navigateBack()
}
}
}
})
\ No newline at end of file
{
"navigationBarTitleText": "搜索",
"usingComponents": {
"wr-serach": "/components/search/search"
}
}
\ No newline at end of file
<view class='con'>
<view class='search'>
<wr-serach onchange='apiSearch'></wr-serach>
</view>
<scroll-view scroll-y class='list'>
<view wx:if='{{searchList.length!=0}}'>
<view wx:for='{{searchList}}' wx:key='{{item.id}}' class='search-item'>
<text>{{item.itemName}}</text>
<button data-values='{{item}}' catchtap='resultSelect'>选择</button>
</view>
</view>
</scroll-view>
</view>
/* pages/search/search.wxss */
page,.con{
height: 100%;
}
.con{
display: flex;
flex-direction: column;
align-items: stretch;
}
.list{
flex: 1 0 50rpx;
overflow: hidden;
}
.search-item{
display: flex;
padding: 20rpx 30rpx;
font-size: 32rpx;
line-height: 32rpx;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #eee;
}
.search-item button{
margin: 0;
font-size: 32rpx;
line-height: 32rpx;
color: #fff;
background-color: #d7193c;
padding: 30rpx 60rpx;
}
.search{
padding: 20rpx 20rpx;
background-color: #eee;
}
\ No newline at end of file
......@@ -76,7 +76,7 @@
</view>
</view>
</view>
<view class='btn' wx:if='{{order.state!="已完成"}}'>
<view class='btn' wx:if='{{order.state!="已完成"||order.state!="已取消"}}'>
<button catchtap='cancleOrder'>取消工单</button>
</view>
</view>
\ No newline at end of file
......@@ -13,15 +13,16 @@ Page({
onLoad(){
this.mapCtx = wx.createMapContext('myMap')
let carLoc=wx.getStorageSync('carLocAlarm')
console.log(carLoc)
this.setData({
longitude: Number(carLoc.longitude),
latitude: Number(carLoc.latitude),
markers:[{
latitude: Number(carLoc.latitude),
longitude: Number(carLoc.longitude),
iconPath: imgName('loc.png'),
width:40,
height:46
iconPath: imgName('location_sucess.png'),
width:36,
height:36
}],
title: carLoc.content,
time: carLoc.msgTime
......
<map id="myMap" show-location scale='13' markers='{{markers}}' longitude='{{longitude}}' latitude='{{latitude}}'>
<map id="myMap" show-location scale='16' markers='{{markers}}' longitude='{{longitude}}' latitude='{{latitude}}'>
<cover-view class='des'>
<cover-image class='img-des' src='{{imgLogo}}'></cover-image>
<cover-view class='bar'></cover-view>
......
......@@ -57,6 +57,7 @@ map {
.toloc {
line-height: 36rpx;
color: #fff;
font-size: 32rpx;
padding: 20rpx 30rpx;
background-color: #d7193c;
......
......@@ -138,15 +138,24 @@ Page({
//获取硬件信息
getCarDetail() {
let { device, ui, details } = this.data
let that=this
if (device && device.vcuNo) {
api.get('device/getDevInfo', {
vcuNo: device.vcuNo
vcuNo: device.vcuNo,
userId: that.data.user.id
}, true)
.then(res => {
let { data } = res
console.log('实时数据', data)
//实时数据
if (data.isUseVehicle==1){
alertTip('你的车辆已被站点解绑',()=>{
wx.redirectTo({
url: '/pages/device_bind/device_bind',
})
})
return
}
if (data.address) {
ui.deviceAdress = data.address//位置
}
......@@ -169,7 +178,7 @@ Page({
})
})
.catch(err => {
console.error(err)
console.error(1,err)
})
}
......@@ -248,13 +257,12 @@ Page({
})
})
.catch(err => {
that.setData({
baseMsg: false
})
// that.setData({
// baseMsg: false
// })
if(/数据为空/.test(err)){
wx.reLaunch({
url: '/pages/welcome2/welcome2',
})
that.getRentRecord()
}
console.error(err)
})
......@@ -393,5 +401,68 @@ Page({
wx.redirectTo({
url: '/pages/welcome2/welcome2',
})
},
//判断是否未支付定单或者押金
getRentRecord(cb) {
api.get('order/getRentRecord', {
userId: this.data.user.id
})
.then(res => {
let state = res.data.state
switch (state) {
case 1:
cb&&cb()
break;
case 2:
wx.redirectTo({
url: `/pages/pay/pay?type=rent`,
})
break;
case 3:
wx.redirectTo({
url: `/pages/welcome2/welcome2`,
})
break;
case 4:
wx.redirectTo({
url: `/pages/pay/pay?type=deposit`,
})
break;
case 5:
wx.redirectTo({
url: `/pages/return_car_pedding/return_car_pedding`,
})
break;
}
})
.catch(err => {
alertTip(err)
})
},
//个租还车
returnCar(){
let that=this
this.getRentRecord(()=>{
api.post('message/applyReturnCar',{
frameNo: that.data.ui.froNo,
userId:that.data.user.id,
rentType:1
})
.then(res=>{
wx.redirectTo({
url: `/pages/return_car_pedding/return_car_pedding`,
})
})
.catch(err=>{
alertTip(err)
console.error(err)
})
})
},
//维修服务
toServer(){
wx.navigateTo({
url: '/pages/server_point/server_point',
})
}
})
\ No newline at end of file
......@@ -17,9 +17,9 @@
<cover-view>您有消息需要关注</cover-view>
<cover-image src='{{imgMore}}'></cover-image>
</cover-view>
<cover-view class='map-fee' catchtap='toMsgPage' wx:if='{{person}}'>
<!-- <cover-view class='map-fee' catchtap='toMsgPage' wx:if='{{person}}'>
<cover-view>预估费用(仅供参考,以实际结算为准):{{ui.fee}}元</cover-view>
</cover-view>
</cover-view> -->
<cover-view class='map-controltap'>
<cover-image src='{{imgFind}}' catchtap='netFindCar'></cover-image>
<cover-image src='{{imgToloc}}' catchtap='showMyLoc'></cover-image>
......@@ -33,17 +33,17 @@
<image class='km' src='{{imgKm}}'></image>
<view>里程:{{ui.estimatedMileage}}</view>
</view>
<view class='status-item'>
<!-- <view class='status-item'>
<image class='battery' src='{{imgSpeed}}'></image>
<view>速度:{{ui.speed}}</view>
</view>
</view> -->
<view class='status-item'>
<image class='battery' src='{{imgBattery}}'></image>
<view>电量:{{ui.dumpEnergy}}</view>
</view>
</view>
<view class='btn-action'>
<view class='lock' bindtap='returnCar' wx:if='{{person==1}}'>
<view class='lock' catchtap='returnCar' wx:if='{{person==1}}'>
<text>还车</text>
</view>
<view class='lock' bindtap='apiActionDevice'>
......@@ -98,7 +98,7 @@
</view>
<view class='notify' wx:if="{{hasMedical&&medicalScore<100}}">体检结果不佳,
<text catchtap='changeBar'> 我要保修。</text>
<text catchtap='toServer'> 我要保修。</text>
</view>
</view>
</view>
......
const { api, mapApi, imgName, getUserInfo, wxLogin, alertTip, authAgainByUser, userLocation} = require('../../lib/util.js')
const {
api,
mapApi,
imgName,
getUserInfo,
wxLogin,
alertTip,
authAgainByUser,
userLocation
} = require('../../lib/util.js')
let msgType = ['无', '震动', '移动', '碰撞', '倾斜', '%10电量警报', '%5电量警报', '电池拔出', '电池缺失', 'MCU故障', 'ICL故障', 'T-BOX故障', 'VCU故障', '超出电子围栏', '开锁', '关锁', '电量发生变化', '位移距上次超过10米', '进入娱乐模式']
Page({
data: {
alarMsgShowRead:0,
page: 1,//当前页面
hasMorePage: false,//更多页面
alarmMsg: [],//消息列表
alarMsgShowRead: 0,
page: 1, //当前页面
hasMorePage: false, //更多页面
alarmMsg: [], //消息列表
imgDot: imgName('dot.png'),
imgMore: imgName('seemore.png'),
imgHasalarm: imgName('hasalarm.png'),
......@@ -12,55 +22,66 @@ Page({
imgNoalarm: imgName('noalarm.png'),
imgNomes: imgName('nomes.png'),
},
onLoad: function () {
this.getMsgList(1)
onLoad: function() {
this.getMsgList()
},
//显示报警
showAlarm(){
//显示报警详细
showAlarm(e) {
console.log(e)
let {value}=e.currentTarget.dataset
let carLocAlarm={
latitude: value.latitude,
longitude: value.longitude,
content: value.alarmMsg,
msgTime: value.showTime,
}
wx.setStorageSync('carLocAlarm', carLocAlarm)
wx.navigateTo({
url: '/pages/user_car_loc/user_car_loc',
})
},
//拉取消息列表
getMsgList(page,success){
getMsgList(success) {
let that = this
let curPage = page || this.data.page
let user = wx.getStorageSync('user').userMapp
let device = wx.getStorageSync('device')
api.get('alarmRecord/getList.json', { curPage, userId: user.id, frameNo: device.frameNo})
api.get('alarmRecord/getList.json', {
userId: user.id,
frameNo: device.frameNo
})
.then(res => {
console.log('getList', res)
let alarmMsg = res.items.map(item => {
// item.startPosition = String(item.startPosition).slice(0, 5)
// item.endPosition = String(item.endPosition).slice(0, 5)
// item.useTime = new Date(item.endDate - item.startDate).getSeconds() + 1
// item.startDate = new Date(item.startDate).toLocaleString()
// item.endDate = new Date(item.endDate).toLocaleString()
// item.useMileage = ((item.endMileage - item.startMileage) / 1000).toFixed(2)
item.showTime = new Date(item.timestamp).toLocaleString()
item.alarmMsg = msgType[item.messageType]
return item
})
if (curPage == 1) {
this.setData({
alarmMsg,
page: curPage + 1,
hasMorePage: res.totalPage > curPage
alarmMsg
})
} else {
let newArrays = that.data.alarmMsg.concat(alarmMsg)
this.setData({
alarmMsg: newArrays,
page: curPage + 1,
hasMorePage: res.totalPage > curPage
})
}
// if (curPage == 1) {
// this.setData({
// alarmMsg,
// page: curPage + 1,
// hasMorePage: res.totalPage > curPage
// })
// } else {
// let newArrays = that.data.alarmMsg.concat(alarmMsg)
// this.setData({
// alarmMsg: newArrays,
// page: curPage + 1,
// hasMorePage: res.totalPage > curPage
// })
// }
success && success()
})
.catch(err => {
alertTip(err)
})
},
onPullDownRefresh(){
this.getMsgList(1,()=>{
onPullDownRefresh() {
this.getMsgList(() => {
wx.stopPullDownRefresh()
})
}
......
<view class='msg-body' wx:if='{{alarmMsg.length!=0}}'>
<block wx:for='{{alarmMsg}}'>
<view class='msg-item' id='{{item.id}}' data-read='{{item.msgStatus}}' catchtap='showAlarm'>
<view wx:for='{{alarmMsg}}' class='msg-item' data-value='{{item}}' wx:key='{{item.timestamp}}' catchtap='showAlarm'>
<image class='alarm' src='{{imgNoalarm}}'></image>
<view class='msg-content'>
<view>{{item.title}}</view>
<view>{{item.showTime}}</view>
<view>
<text>{{item.content}}</text>
<text>{{item.msgTime}}</text>
</view>
<text>您的车辆:</text><text class='tip'>{{item.alarmMsg}}</text> </view>
</view>
<image src='{{imgMore}}' class='more'></image>
</view>
</block>
<view class='btn' wx:if='{{hasMorePage}}'>
<!-- <view class='btn' wx:if='{{hasMorePage}}'>
<button catchtap='getMsgList'>加载更多</button>
</view>
</view> -->
</view>
<view wx:else class='des'>当前没有报警记录</view>
\ No newline at end of file
.msg-item{
padding: 20rpx 30rpx;
border-bottom: 1px solid #eee;
display: flex;
align-items: center;
justify-content: space-between;
}
.msg-item image{
flex: 0 0 auto;
width: 50rpx;
height: 50rpx;
}
.msg-item image.more{
width: 30rpx;
height: 50rpx;
}
.tip{
color: #d7193c;
}
.msg-content{
padding-left: 40rpx;
line-height: 50rpx;
flex: 1 0 auto;
}
.des{
text-align: center;
font-size: 30rpx;
padding-top: 22rpx;
color: #d7193c;
padding-top: 50rpx;
text-align: center;
}
\ No newline at end of file
......@@ -2,33 +2,14 @@ const { api, imgName, getUserInfo, wxLogin, alertTip, authAgainByUser } = requir
let timer=null
Page({
data: {
title:'智租科技',
titleDes:'这是一段描述',
//图片
imgLogo: imgName('logo.png'),
imgPerson: imgName('sign_in_phone_white.png'),
imgLock: imgName('sign_in_password_white.png'),
userTypes: [
{ value: 0, name: '公司用户' },
{ value: 1, name: '个人用户' }
],
companyArray:['未获取'],
companyIndex: 0,
pointArray: ['未获取'],
pointIndex: 0,
id:null,//数据id
userType:null,
dataError:true,
user:null,
hasCar:null,//用车
login:true,//true login 页面 false 登录成功
status: 'normal'//normal正常 auth审核中 authFail审核驳回
imgLock: imgName('sign_in_password_white.png')
},
onLoad: function () {
// wx.removeStorageSync('user')
},
onUnload(){clearInterval(timer)},
onHide() { clearInterval(timer)},
//登录
formSubmit(e){
if (!/^1\d{10}/.test(e.detail.value.mobile)) {
......@@ -46,7 +27,6 @@ Page({
let that=this
api.get('user/pass/logon',e.detail.value)
.then(res => {
console.log(res)
let {userMapp}=res.data
wx.setStorageSync('user', res.data)
that.setData({
......@@ -66,13 +46,9 @@ Page({
switch (userMapp.siteAuditState){
case 1:
//已提交审核 中。。
that.setData({
status:'auth'
wx.redirectTo({
url: '/pages/choose_rent_type/choose_rent_type?status=auth',
})
clearInterval(timer)
timer = setInterval(() => {
that.getStatus()
}, 5000)
break;
case 2:
//审核 过。。
......@@ -94,16 +70,16 @@ Page({
})
}
break;
case 3:
//审核 驳。。
that.setData({
status: 'authFail'
})
break;
// case 3:
// //审核 驳。。
// wx.redirectTo({
// url: '/pages/choose_rent_type/choose_rent_type?status=normal',
// })
// break;
default:
//正常 申请页面
that.setData({
status: 'normal'
wx.redirectTo({
url: '/pages/choose_rent_type/choose_rent_type?status=normal',
})
}
/**data:{
......@@ -124,236 +100,5 @@ Page({
wx.navigateTo({
url: '/pages/register2/register2',
})
},
giveUp(){
//放弃申请
let that = this
let { id } = that.data
if (!id) {
alertTip('请稍后重试')
return
}
wx.showModal({
title: '提示',
content: '是否放弃申请',
success: function (res) {
if (res.confirm) {
api.post('message/cancelJoin', {
id
}).then(res => {
that.setData({
status: 'normal'
})
clearInterval(timer)
}).catch(err => {
alertTip(err)
})
}
}
})
},
//用户选择
radioChange(e){
let userType=Number(e.detail.value)
this.setData({
userType
})
if (userType == 0 && this.data.companyArray[0] =='未获取'){
this.getCompany()
}
},
//租赁商变化
companyChange(e){
this.setData({
companyIndex: e.detail.value
})
let company = this.data.companyArray[this.data.companyIndex]
this.getPoints(company.id)
},
//站点变化
pointChange(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({
dataError: false,
companyArray: items
})
that.getPoints(items[0].id)
})
.catch(err => {
alertTip(err)
that.setData({
dataError:true
})
})
},
//获取站点
getPoints(companyId){
let that=this
api.get('site/getByCompanyId', { companyId})
.then(({ items }) => {
that.setData({
pointArray: items
})
})
.catch(err => {
alertTip(err)
that.setData({
dataError: true
})
})
},
// 提交申请
applyFor(){
if (this.data.pointArray.length==0) {
alertTip('该租赁商下不存在站点,请联系管理员')
return
}
let company = this.data.companyArray[this.data.companyIndex]
let point = this.data.pointArray[this.data.pointIndex]
let that=this
wx.showModal({
title: '提示',
content: `确定申请 ${company.companyName} 下站点:${point.companyName}`,
success: function (res) {
if (res.confirm) {
api.post('message/requestJoin',{
userId: that.data.user.id,
siteId: point.id,
companyId: company.id,
rentType:0
})
.then(res=>{
//申请成功
console.log(res)
that.setData({
status: 'auth'
})
//轮询状态
clearInterval(timer)
that.getStatus()
timer = setInterval(() => {
that.getStatus()
}, 5000)
})
.catch(err=>{
alertTip(err.message)
})
}
}
})
},
rentCar(e){
//个人用户开始租车
api.get('user/getByUserId',{userId:this.data.user.id})
.then(res=>{
console.log(res)
// 判断是否存在未完成订单
if (res.data.isNoPayMoney!=0){
// 付钱
wx.navigateTo({
url: '/pages/pay/pay?type=rent',
})
return
}
if (res.data.depositAmount == 0){
alertTip('租车前请先支付押金!',function(){
wx.navigateTo({
url: `/pages/pay/pay?type=deposite`,
})
})
return
}
let user = wx.getStorageSync('user')
user.userMapp.userType = 1
user.userMapp.depositAmount = res.data.depositAmount
wx.setStorageSync('user', user)
wx.navigateTo({
url: '/pages/device_bind/device_bind',
})
})
.catch(err=>{
console.error(err)
})
},
reApply(){
//重新申请
this.setData({
login: false,//true login 页面 false 登录成功
status: 'normal'//normal正常 auth审核中 authFail审核驳回
})
},
//登录页面
resetStatus(){
this.setData({
login: true,//true login 页面 false 登录成功
status: 'normal'//normal正常 auth审核中 authFail审核驳回
})
},
//获取审核状态
getStatus() {
let This = this
api.get('message/getMessageInfo', {
userId: This.data.user.id,
messageType: 7//用户申请加入站点
}, {}, true)
.then(res => {
let { state, id } = res.data
if (!This.data.id) {
This.setData({
id
})
}
switch (state) {
//待审核
case 0:
This.setData({
status: 'auth'
})
break;
//审核通过去首页
case 1:
clearInterval(timer)
//存储用户类型,以这个为准
let user = wx.getStorageSync('user')
user.userMapp.userType = 0
wx.setStorageSync('user', user)
wx.redirectTo({
url: '/pages/device_bind/device_bind',
})
break;
//审核驳回
case -1:
that.setData({
status: 'authFail'
})
clearInterval(timer)
break;
//正常页面
default:
This.setData({
status: 'normal',//normal 和 pedding
})
clearInterval(timer)
}
})
.catch(err => {
console.error(err)
})
},
//个租是否能租
personCanRent(){
return false
}
})
\ No newline at end of file
<!--登录和团个租站点选择 -->
<view class='con' wx:if='{{login}}'>
<view class='con'>
<image class='logo' src='{{imgLogo}}'></image>
<form class='from-login' bindsubmit="formSubmit" report-submit>
<view class='form-item'>
......@@ -21,54 +21,3 @@
<text catchtap='forgetPassword'>忘记密码?</text>
</view>
</view>
\ No newline at end of file
<view wx:else class='con'>
<image class='logo' src='{{imgLogo}}'></image>
<view wx:if='{{status=="normal"}}'>
<view class='phone-sure list'>
<text class='form-tip'>请选择:</text>
<radio-group class="radio-group" bindchange="radioChange">
<label class="radio" wx:for="{{userTypes}}" wx:key='{{item.name}}'>
<radio value="{{item.value}}" color='#d7193c' checked="{{userType===index}}"/>{{item.name}}
</label>
</radio-group>
</view>
<view wx:if='{{userType===0}}'>
<view wx:if='{{dataError}}'>
<view catchtap='getCompany'>获取站点信息失败,点击刷新</view>
</view>
<view wx:else>
<view class='phone-sure list'>
<text class='form-tip'>选择租赁商:</text>
<picker class='point' bindchange="companyChange" value="{{companyIndex}}" range-key='companyName' range="{{companyArray}}">
<view>{{companyArray[companyIndex].companyName}}</view>
</picker>
</view>
<view class='phone-sure list'>
<text class='form-tip'>选择站点:</text>
<picker class='point' bindchange="pointChange" value="{{pointIndex}}" range-key='companyName' range="{{pointArray}}">
<view>{{pointArray.length==0?'没有站点':pointArray[pointIndex].companyName}}</view>
</picker>
</view>
<button class='btn' catchtap='applyFor'>提交申请</button>
</view>
<!--提交完申请 进入一个提示页面 点击确定返回登录页面 该页面轮询 处理结果 -->
</view>
<view wx:if='{{userType===1}}'>
<button class='btn' catchtap='rentCar'>点击开始租车</button>
</view>
</view>
<view wx:if='{{status=="auth"}}'>
<view class='wait-auto'>等待站点同意授权中...</view>
<view class='giveup2 giveup'>
<text catchtap='giveUp'>放弃申请?</text>
</view>
</view>
<view wx:if='{{status=="authFail"}}'>
<view class='wait-auto'>您的申请被驳回了...</view>
<view class='giveup'>
<text catchtap='resetStatus'>返回登录</text>
<text catchtap='reApply'>重新申请?</text>
</view>
</view>
</view>
\ No newline at end of file
......@@ -62,7 +62,7 @@ button {
}
.wait-auto{
color: #d7193c;
font-size: 50rpx;
font-size: 40rpx;
margin: 60rpx 0;
}
.form-tip{
......
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