123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- Page({
-
- data: {
- carNum: '',
- carId: '',
- updateFlag: false,
- isDef: false,
- },
- inputPlateNumber(e){
- console.info(e.detail.value)
- console.info(e)
- this.setData({
- carNum: e.detail.value
- });
- },
- saveCarNum(){
- let carNum = this.data.carNum;
- if (!this.checkCarNum(carNum)) {
- wx.showModal({
- title: '提示',
- showCancel:false,
- content: '车牌号输入有误,请重新输入',
- confirmColor:'#00AADD',
- });
- return;
- } else {
- this.setData({
- carNum: carNum,
- errorMsg: ''
- });
- }
- this.bindUpdateCarNum(carNum);
- },
- checkCarNum(carNum){
- if (carNum){
-
-
-
-
- if(carNum.length<1 || carNum.length>10){
- return false;
- }
- }else{
- return false;
- }
- return true;
- },
- bindUpdateCarNum(carNum) {
- let that = this;
- let userInfo = wx.getStorageSync('userInfo');
-
-
-
- console.info(this.data.updateFlag)
- if(this.data.updateFlag){
- console.info("更新车牌号:" + carNum + ",用户:" + userInfo.loginName + ",车牌号:" + this.data.carNum )
-
- wx.request({
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/carAlter?loginName=' + userInfo.loginName,
- data: {
- carId: that.data.carId,
- plateNumber: carNum,
- defaultType: that.data.isDef?"1":"0"
- },
- method: 'POST',
- success: function (res) {
- console.info(res)
- wx.navigateBack({
- delta: 1
- });
- },
- fail(e) {
- console.log("更新车牌号失败");
- log.info('[更新车牌号]','[fail]', e);
- }
- });
-
-
- }else{
- console.info("新增车牌号:" + carNum + ",用户:" + userInfo.loginName + "")
-
- wx.request({
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/saveCar?loginName=' + userInfo.loginName + '&plateNumber=' + carNum + '&defaultType=' + (that.data.isDef?"1":"0"),
-
-
-
-
-
- method: 'POST',
- success: function (res) {
- console.info(res)
- wx.setStorageSync("chooseCar_plateNumber", {plateNumber:carNum});
- wx.navigateBack({
- delta: 2
- });
- },
- fail(e) {
- console.log("新增车牌号失败",e);
-
- }
- });
-
- }
- },
-
- onLoad(options) {
- let {carId,plateNumber,defaultType} = options;
- let updateFlag = false;
- if(carId){
- updateFlag = true;
- }else{
- if(carId==0){
- updateFlag = true
- }else{
- updateFlag = false
- }
- }
- console.info(updateFlag?'更新模式':'新增模式')
- console.info(plateNumber)
- this.setData({
- carId,
- updateFlag,
- carNum:plateNumber,
- isDef:defaultType==1
- })
- },
- radioChange: function(e) {
- let that = this;
- this.setData({
- isDef:!that.data.isDef
- })
- },
-
- onReady() {
-
- },
-
-
- onShow() {
- let data = wx.getStorageSync("chooseCar_plateNumber");
- console.info(data)
- if(data){
- this.setData({
- carNum:data.carNum
- })
- }
- },
-
-
- onHide() {
-
- },
-
-
- onUnload() {
-
- },
-
-
- onPullDownRefresh() {
-
- },
-
-
- onReachBottom() {
-
- },
-
-
- onShareAppMessage() {
-
- }
- })
|