Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
杨建斌
/
dy-wx2
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
2aaabffe
authored
2019-10-16 23:11:25 +0800
by
fuenxin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
clear ls.user
1 parent
73aafca1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
242 additions
and
241 deletions
js/controller/mainController.js
js/controller/mainController.js
View file @
2aaabff
angular
.
module
(
'myApp'
)
.
controller
(
'mainController'
,
[
'$scope'
,
'$rootScope'
,
'dingdaService'
,
'$state'
,
'globalService'
,
function
(
$scope
,
$rootScope
,
dingdaService
,
$state
,
globalService
)
{
.
controller
(
'mainController'
,
[
'$scope'
,
'$rootScope'
,
'dingdaService'
,
'$state'
,
'globalService'
,
function
(
$scope
,
$rootScope
,
dingdaService
,
$state
,
globalService
)
{
$rootScope
.
isRendBike
=
false
;
$rootScope
.
isLoadFinish
=
false
;
$scope
.
unfinishOrder
=
{};
var
init
=
function
()
{
// globalService.init();
function
getUrl
(
name
){
var
reg
=
new
RegExp
(
"(^|&)"
+
name
+
"=([^&]*)(&|$)"
);
var
r
=
window
.
location
.
search
.
substr
(
1
).
match
(
reg
);
if
(
r
!=
null
)
return
unescape
(
r
[
2
]);
return
null
;
var
init
=
function
()
{
// globalService.init();
function
getUrl
(
name
)
{
var
reg
=
new
RegExp
(
"(^|&)"
+
name
+
"=([^&]*)(&|$)"
);
var
r
=
window
.
location
.
search
.
substr
(
1
).
match
(
reg
);
if
(
r
!=
null
)
return
unescape
(
r
[
2
]);
return
null
;
}
var
code
=
getUrl
(
'code'
)
var
loginUrlCode
=
function
(
code
)
{
if
(
code
)
{
if
(
code
)
{
dingdaService
.
verifyThirdCode
(
code
).
success
(
function
(
res
)
{
globalService
.
saveData
(
'loginCode'
,
code
)
if
(
res
.
meta
.
code
==
200
)
{
dingdaService
.
verifyPhoneCode
(
res
.
data
.
mobile
,
res
.
data
.
code
).
success
(
function
(
data
)
{
if
(
data
.
meta
.
code
==
200
)
{
data
.
data
.
userName
=
res
.
data
.
mobile
;
globalService
.
saveData
(
'user'
,
data
.
data
);
layer
.
open
({
content
:
'登录成功'
,
time
:
1
});
setTimeout
(
function
()
{
if
(
res
.
meta
.
code
==
200
)
{
dingdaService
.
verifyPhoneCode
(
res
.
data
.
mobile
,
res
.
data
.
code
).
success
(
function
(
data
)
{
if
(
data
.
meta
.
code
==
200
)
{
data
.
data
.
userName
=
res
.
data
.
mobile
;
globalService
.
saveData
(
'user'
,
data
.
data
);
layer
.
open
({
content
:
'登录成功'
,
time
:
1
});
setTimeout
(
function
()
{
window
.
location
.
href
=
window
.
location
.
origin
+
window
.
location
.
pathname
// location.reload();
}
,
300
);
}
else
if
(
data
.
meta
.
code
==
401
)
{
layer
.
open
({
content
:
data
.
meta
.
message
,
time
:
1
});
// alert(data.meta.message);
// layer.msg(data.data.error);
return
;
}
})
// location.reload();
}
,
300
);
}
else
if
(
data
.
meta
.
code
==
401
)
{
layer
.
open
({
content
:
data
.
meta
.
message
,
time
:
1
});
// alert(data.meta.message);
// layer.msg(data.data.error);
return
;
}
})
}
if
(
res
.
meta
.
code
==
500
)
{
$state
.
go
(
'login'
,
{},
{
reload
:
true
});
if
(
res
.
meta
.
code
==
500
)
{
$state
.
go
(
'login'
,
{},
{
reload
:
true
});
}
})}
else
{
$scope
.
userinfo
=
{};
$scope
.
userinfo
.
userName
=
"未登录"
;
$scope
.
userinfo
.
loginState
=
false
;
}
})
}
else
{
$scope
.
userinfo
=
{};
$scope
.
userinfo
.
userName
=
"未登录"
;
$scope
.
userinfo
.
loginState
=
false
;
}
}
$scope
.
userinfo
=
globalService
.
getData
(
"user"
);
if
(
!
$scope
.
userinfo
)
{
if
(
!
$scope
.
userinfo
)
{
loginUrlCode
()
}
else
{
var
loginCode
=
globalService
.
getData
(
"loginCode"
);
if
(
code
&&
(
loginCode
!==
code
)){
if
(
code
&&
(
loginCode
!==
code
))
{
localStorage
.
removeItem
(
'ls.user'
)
loginUrlCode
()
return
}
// alert("getUnfinishedOrder")
dingdaService
.
getUnfinishedOrder
().
success
(
function
(
data
,
status
){
// alert(JSON.stringify(data))
if
(
data
.
meta
.
code
===
303
){
layer
.
open
({
content
:
data
.
meta
.
message
,
time
:
2
})
localStorage
.
removeItem
(
'ls.user'
)
}
if
(
data
.
meta
.
code
===
401
)
{
layer
.
open
({
content
:
'登录token失效,请重新登录'
,
time
:
2
})
localStorage
.
removeItem
(
'ls.user'
)
return
}
if
(
data
.
meta
.
code
===
200
)
{
if
(
data
.
data
.
unfinishedOrder
.
id
)
{
$rootScope
.
isRendBike
=
true
;
$scope
.
unfinishOrder
=
data
.
data
.
unfinishedOrder
;
layer
.
open
({
content
:
'您有未支付的订单,是否前往支付?'
,
btn
:
[
'确认'
,
'取消'
],
shadeClose
:
false
,
yes
:
function
(
index
){
layer
.
close
(
index
);
$state
.
go
(
'tripDetail'
,
{
orderId
:
$scope
.
unfinishOrder
.
id
});
return
;
},
no
:
function
(
index
){
layer
.
close
(
index
);
}
});
}
else
{
dingdaService
.
getUnfinishedOrder
().
success
(
function
(
data
,
status
)
{
if
(
data
.
meta
.
code
===
303
)
{
layer
.
open
({
content
:
data
.
meta
.
message
,
time
:
2
})
localStorage
.
removeItem
(
'ls.user'
)
}
if
(
data
.
meta
.
code
===
401
)
{
layer
.
open
({
content
:
'登录token失效,请重新登录'
,
time
:
2
})
localStorage
.
removeItem
(
'ls.user'
)
return
}
if
(
data
.
meta
.
code
===
200
)
{
if
(
data
.
data
.
unfinishedOrder
.
id
)
{
$rootScope
.
isRendBike
=
true
;
$scope
.
unfinishOrder
=
data
.
data
.
unfinishedOrder
;
layer
.
open
({
content
:
'您有未支付的订单,是否前往支付?'
,
btn
:
[
'确认'
,
'取消'
],
shadeClose
:
false
,
yes
:
function
(
index
)
{
layer
.
close
(
index
);
$state
.
go
(
'tripDetail'
,
{
orderId
:
$scope
.
unfinishOrder
.
id
});
return
;
},
no
:
function
(
index
)
{
layer
.
close
(
index
);
}
});
}
}
}
}).
error
(
function
(
data
,
status
)
{
console
.
log
(
JSON
.
stringify
(
data
))
})
}
}).
error
(
function
(
data
,
status
)
{
console
.
log
(
JSON
.
stringify
(
data
))
})
}
$scope
.
moduleList
=
[];
$scope
.
moduleList
.
push
({
name
:
"行程记录"
,
icon
:
"images/trip.png"
,
state
:
"trip"
name
:
"行程记录"
,
icon
:
"images/trip.png"
,
state
:
"trip"
});
$scope
.
moduleList
.
push
({
name
:
"钱包"
,
icon
:
"images/wallet.png"
,
state
:
"wallet"
name
:
"钱包"
,
icon
:
"images/wallet.png"
,
state
:
"wallet"
});
$scope
.
moduleList
.
push
({
name
:
"保证金"
,
icon
:
"images/bond.png"
,
state
:
"bond"
name
:
"保证金"
,
icon
:
"images/bond.png"
,
state
:
"bond"
});
$scope
.
moduleList
.
push
({
name
:
"联系我们"
,
icon
:
"images/contact.png"
,
state
:
"contact"
name
:
"联系我们"
,
icon
:
"images/contact.png"
,
state
:
"contact"
});
// $scope.moduleList.push({
// name : "意见反馈",
...
...
@@ -129,44 +130,44 @@ angular.module('myApp')
// state : "opinion"
// });
}
$scope
.
doAction
=
function
(
index
)
{
if
(
$scope
.
checkLogin
())
{
$scope
.
doAction
=
function
(
index
)
{
if
(
$scope
.
checkLogin
())
{
var
arg
=
{};
if
(
index
==
2
||
index
==
4
)
{
arg
=
{
longitude
:
$rootScope
.
currentPoint
.
longitude
,
latitude
:
$rootScope
.
currentPoint
.
latitude
};
if
(
index
==
2
||
index
==
4
)
{
arg
=
{
longitude
:
$rootScope
.
currentPoint
.
longitude
,
latitude
:
$rootScope
.
currentPoint
.
latitude
};
}
if
(
index
==
3
)
{
if
(
index
==
3
)
{
location
.
href
=
"http://wx.dy.dingdatech.com/contactUs.html"
;
}
else
{
$state
.
go
(
$scope
.
moduleList
[
index
].
state
,
arg
);
}
}
}
$scope
.
checkLogin
=
function
()
{
if
(
!
globalService
.
getData
(
"user"
))
{
$state
.
go
(
'login'
,
{},
{
reload
:
true
});
$scope
.
checkLogin
=
function
()
{
if
(
!
globalService
.
getData
(
"user"
))
{
$state
.
go
(
'login'
,
{},
{
reload
:
true
});
return
false
;
}
return
true
;
}
$scope
.
logout
=
function
()
{
$scope
.
logout
=
function
()
{
$scope
.
userinfo
=
{};
$scope
.
userinfo
.
userName
=
"未登录"
;
$scope
.
userinfo
.
loginState
=
false
;
globalService
.
clearData
(
"user"
);
location
.
reload
()
globalService
.
clearData
(
"user"
);
location
.
reload
()
}
var
initScan
=
function
()
{
var
initScan
=
function
()
{
$rootScope
.
openScan
=
false
;
$rootScope
.
openDetail
=
false
;
$rootScope
.
openMenu
=
false
;
$rootScope
.
openRing
=
false
;
$rootScope
.
$watch
(
"openScan"
,
function
(
newVal
,
oldVal
)
{
if
(
newVal
!==
oldVal
&&
newVal
)
{
$rootScope
.
$watch
(
"openScan"
,
function
(
newVal
,
oldVal
)
{
if
(
newVal
!==
oldVal
&&
newVal
)
{
// if(!$scope.checkLogin()) {
// return;
// }
...
...
@@ -178,161 +179,161 @@ angular.module('myApp')
$rootScope
.
openScan
=
false
;
if
(
!
appClient
)
{
layer
.
open
({
content
:
'调起摄像头失败'
,
time
:
2
});
if
(
!
appClient
)
{
layer
.
open
({
content
:
'调起摄像头失败'
,
time
:
2
});
}
else
{
appClient
.
getERCode
(
''
,
function
(
str
,
cb
)
{
dingdaService
.
verifyScanCode
(
str
).
success
(
function
(
data
,
status
)
{
// alert(JSON.stringify(data))
if
(
data
.
meta
.
code
==
200
)
{
if
(
data
.
data
.
orderDetail
.
id
)
{
}
else
{
appClient
.
getERCode
(
''
,
function
(
str
,
cb
)
{
dingdaService
.
verifyScanCode
(
str
).
success
(
function
(
data
,
status
)
{
// alert(JSON.stringify(data))
if
(
data
.
meta
.
code
==
200
)
{
if
(
data
.
data
.
orderDetail
.
id
)
{
layer
.
open
({
content
:
"租车成功,订单号为:"
+
data
.
data
.
orderDetail
.
id
,
time
:
2
});
// alert("租车成功,订单号为:" + data.data.orderDetail.id);
layer
.
open
({
content
:
"租车成功,订单号为:"
+
data
.
data
.
orderDetail
.
id
,
time
:
2
});
// alert("租车成功,订单号为:" + data.data.orderDetail.id);
$rootScope
.
isRendBike
=
true
;
$state
.
go
(
'rentDetail'
,
{},
{
reload
:
true
});
$state
.
go
(
'rentDetail'
,
{},
{
reload
:
true
});
}
}
else
if
(
data
.
meta
.
code
==
202
)
{
layer
.
open
({
content
:
data
.
meta
.
message
,
time
:
2
});
$state
.
go
(
'bond'
,
{
longitude
:
$rootScope
.
currentPoint
.
longitude
,
latitude
:
$rootScope
.
currentPoint
.
latitude
});
}
else
if
(
data
.
meta
.
code
==
202
)
{
layer
.
open
({
content
:
data
.
meta
.
message
,
time
:
2
});
$state
.
go
(
'bond'
,
{
longitude
:
$rootScope
.
currentPoint
.
longitude
,
latitude
:
$rootScope
.
currentPoint
.
latitude
});
}
else
{
layer
.
open
({
content
:
data
.
meta
.
message
,
time
:
2
});
content
:
data
.
meta
.
message
,
time
:
2
});
}
}).
error
(
function
(
data
,
status
)
{
layer
.
open
({
content
:
"租车失败"
+
JSON
.
stringify
(
data
),
time
:
2
});
}).
error
(
function
(
data
,
status
)
{
layer
.
open
({
content
:
"租车失败"
+
JSON
.
stringify
(
data
),
time
:
2
});
});
})
// window.WebViewJavascriptBridge.registerHandler('postERCode', function(data, responseCallback) {
// layer.open({
// content: data,
// time: 10
// });
// })
// window.WebViewJavascriptBridge.callHandler('getERCode', function(data, responseCallback) {
// })
// }else if(isiOS){
// appClient.appObj.registerHandler('postERCode', function(data, responseCallback) {
// layer.open({
// content: JSON.stringify(data),
// time: 10
// });
// })
// appClient.getERCode('getERCode', function (res) {
// // layer.open({
// // content: JSON.stringify(res) + 'cb',
// // time: 10
// // });
// }, '')
})
// window.WebViewJavascriptBridge.registerHandler('postERCode', function(data, responseCallback) {
// layer.open({
// content: data,
// time: 10
// });
// })
// window.WebViewJavascriptBridge.callHandler('getERCode', function(data, responseCallback) {
// })
// }else if(isiOS){
// appClient.appObj.registerHandler('postERCode', function(data, responseCallback) {
// layer.open({
// content: JSON.stringify(data),
// time: 10
// });
// })
// appClient.getERCode('getERCode', function (res) {
// // layer.open({
// // content: JSON.stringify(res) + 'cb',
// // time: 10
// // });
// }, '')
}
// wx.scanQRCode({
// needResult: 1, // 默认为1,扫描结果由微信处理,1则直接返回扫描结果,
// scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码,默认二者都有
// success: function (res) {
// var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
// // alert(result);
// dingdaService.verifyScanCode(result).success(function(data , status){
// // alert(JSON.stringify(data))
// if(data.meta.code == 200) {
// if(data.data.orderDetail.id) {
//
// layer.open({
// content: "租车成功,订单号为:" + data.data.orderDetail.id,
// time:2
// });
// // alert("租车成功,订单号为:" + data.data.orderDetail.id);
// $rootScope.isRendBike = true;
//
// $state.go('rentDetail', {}, {reload: true});
//
// }
// } else if(data.meta.code == 202) {
// layer.open({
// content: data.meta.message,
// time:2
// });
// $state.go('bond', {longitude: $rootScope.currentPoint.longitude , latitude: $rootScope.currentPoint.latitude });
// } else {
// layer.open({
// content: data.meta.message,
// time:2
// });
// }
// }).error(function(data , status){
// layer.open({
// content: "租车失败" + JSON.stringify(data),
// time:2
// });
// });
// }
// });
// wx.scanQRCode({
// needResult: 1, // 默认为1,扫描结果由微信处理,1则直接返回扫描结果,
// scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码,默认二者都有
// success: function (res) {
// var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
// // alert(result);
// dingdaService.verifyScanCode(result).success(function(data , status){
// // alert(JSON.stringify(data))
// if(data.meta.code == 200) {
// if(data.data.orderDetail.id) {
//
// layer.open({
// content: "租车成功,订单号为:" + data.data.orderDetail.id,
// time:2
// });
// // alert("租车成功,订单号为:" + data.data.orderDetail.id);
// $rootScope.isRendBike = true;
//
// $state.go('rentDetail', {}, {reload: true});
//
// }
// } else if(data.meta.code == 202) {
// layer.open({
// content: data.meta.message,
// time:2
// });
// $state.go('bond', {longitude: $rootScope.currentPoint.longitude , latitude: $rootScope.currentPoint.latitude });
// } else {
// layer.open({
// content: data.meta.message,
// time:2
// });
// }
// }).error(function(data , status){
// layer.open({
// content: "租车失败" + JSON.stringify(data),
// time:2
// });
// });
// }
// });
}
})
$rootScope
.
$watch
(
"openDetail"
,
function
(
newVal
,
oldVal
)
{
if
(
newVal
===
oldVal
)
return
;
if
(
newVal
)
{
dingdaService
.
getUnfinishedOrder
().
success
(
function
(
data
,
status
)
{
if
(
data
.
meta
.
code
==
200
)
{
if
(
!
data
.
data
.
unfinishedOrder
.
id
)
{
})
$rootScope
.
$watch
(
"openDetail"
,
function
(
newVal
,
oldVal
)
{
if
(
newVal
===
oldVal
)
return
;
if
(
newVal
)
{
dingdaService
.
getUnfinishedOrder
().
success
(
function
(
data
,
status
)
{
if
(
data
.
meta
.
code
==
200
)
{
if
(
!
data
.
data
.
unfinishedOrder
.
id
)
{
layer
.
open
({
content
:
'租车完成'
,
time
:
2
});
// alert("租车完成")
$state
.
go
(
'main'
);
content
:
'租车完成'
,
time
:
2
});
// alert("租车完成")
$state
.
go
(
'main'
);
}
}
if
(
data
.
data
.
unfinishedOrder
.
status
==
200
)
{
$state
.
go
(
'tripDetail'
,
{
orderId
:
data
.
data
.
unfinishedOrder
.
id
});
if
(
data
.
data
.
unfinishedOrder
.
status
==
200
)
{
$state
.
go
(
'tripDetail'
,
{
orderId
:
data
.
data
.
unfinishedOrder
.
id
});
}
else
{
$state
.
go
(
'rentDetail'
,
{},
{
reload
:
true
});
$state
.
go
(
'rentDetail'
,
{},
{
reload
:
true
});
}
}).
error
(
function
(
data
,
status
)
{
}).
error
(
function
(
data
,
status
)
{
console
.
log
(
JSON
.
stringify
(
data
))
})
}
})
$rootScope
.
$watch
(
"openRing"
,
function
(
newVal
,
oldVal
)
{
})
$rootScope
.
$watch
(
"openRing"
,
function
(
newVal
,
oldVal
)
{
// TODO open new message
})
$rootScope
.
$watch
(
"isLoadFinish"
,
function
(
newVal
,
oldVal
)
{
if
(
newVal
===
oldVal
)
return
;
if
(
newVal
)
{
if
(
document
.
getElementById
(
"sliderMenu"
))
{
document
.
getElementById
(
"sliderMenu"
).
style
.
display
=
"block"
;
}
})
$rootScope
.
$watch
(
"isLoadFinish"
,
function
(
newVal
,
oldVal
)
{
if
(
newVal
===
oldVal
)
return
;
if
(
newVal
)
{
if
(
document
.
getElementById
(
"sliderMenu"
))
{
document
.
getElementById
(
"sliderMenu"
).
style
.
display
=
"block"
;
}
}
})
document
.
getElementById
(
"sliderMenu"
).
addEventListener
(
"touchmove"
,
function
()
{
document
.
getElementById
(
"sliderMenu"
).
addEventListener
(
"touchmove"
,
function
()
{
return
;
}
,
false
);
},
false
);
}
// mui.init();
// mui.init();
initScan
();
init
();
}]);
}]);
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment