var Constant = require('../../utils/constant.js');
|
var app = getApp();
|
import Request from "../../utils/api"
|
Page({
|
data: {
|
currentCorpID: 1,
|
currentEmployeeID: 1, //当前用户ID
|
|
imagesList: [], //报修图片
|
|
requestFormId: 0,
|
taskFormId: 0,
|
RequestEntity: {},
|
TaskEntity: {},
|
|
longitude: 0, //经纬度
|
latitude: 0,
|
userLocAddress: "", //定位的地址(可能不是报修地址)
|
|
isShowConfirmDlg: false,
|
operateNote: '' //信息
|
},
|
onLoad: function (options) {
|
console.log(options)
|
if (options.requestformid == '' || options.requestformid == undefined)
|
return;
|
if (options.taskformid == '' || options.taskformid == undefined)
|
return;
|
var that = this;
|
|
var userInfo = app.globalData.userInfo;
|
|
var requestformid = options.requestformid;
|
var taskformid = options.taskformid;
|
that.setData({
|
taskFormId: taskformid,
|
requestFormId: requestformid,
|
currentCorpID: userInfo.CorpID,
|
currentEmployeeID: userInfo.EmployeeID
|
});
|
|
|
//获取当前经纬度
|
setTimeout(function () {
|
that.getCurrentLocation();
|
}, 1000);
|
|
//初始化表单信息
|
that.initialFormInfo();
|
},
|
onShareAppMessage: function () {
|
return Constant.Share;
|
},
|
//初始化表单信息
|
initialFormInfo: function () {
|
var that = this;
|
var requestformid = this.data.requestFormId;
|
var taskformid = this.data.taskFormId;
|
Request({
|
url: Constant.BASE_SERVER_URL + "Repair/RepairTaskForm/Mobile/GetMyProgressDetailByID@V1.0",
|
method: 'GET',
|
data: {
|
CorpID: this.data.currentCorpID,
|
ID: requestformid,
|
},
|
header: {
|
'content-type': 'application/json'
|
},
|
fail: function (err) {
|
// wx.showModal({
|
// title: '',
|
// content: '通讯失败',
|
// })
|
}, //请求失败
|
success: function (res) {
|
console.log(res.data,"进行中详细")
|
var result = res.data;
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '',
|
content: result.message,
|
});
|
return;
|
}
|
var RequestEntity = result.Data.RequestForm;
|
var imagesList = [];
|
if (RequestEntity.FileList != null && RequestEntity.FileList.length > 0) {
|
for (var i = 0; i < RequestEntity.FileList.length; i++) {
|
var big_image_name = Constant.BASE_SERVER_URL + RequestEntity.FileList[i].StorageUrl;
|
|
var m = {};
|
m.OriginPath = big_image_name;
|
m.ThumbPath = big_image_name;
|
imagesList.push(m);
|
}
|
}
|
//console.log(imagesList)
|
that.setData({
|
RequestEntity: RequestEntity,
|
TaskEntity: result.Data,
|
imagesList: imagesList
|
})
|
}
|
});
|
},
|
|
//查看图片
|
previewImage: function (e) {
|
var that = this;
|
var imagesList = [];
|
var current = e.target.dataset.src.OriginPath;
|
var images = that.data.imagesList;
|
for (var i = 0; i < images.length; i++) {
|
imagesList.push(images[i].OriginPath)
|
}
|
// console.log(current, imagesList, "bigPicture:大图", "smallPicture:小图")
|
wx.previewImage({
|
current: current,
|
urls: imagesList
|
})
|
},
|
|
//加载定位
|
getCurrentLocation: function () {
|
var that = this;
|
wx.getLocation({
|
type: 'gcj02', // 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
|
success(resLoc) {
|
//console.log("getCurrentLocation", resLoc);
|
if (resLoc.longitude == 0 || resLoc.latitude == 0) { //当前位置信号较弱,请换个位置尝试
|
return;
|
}
|
|
//
|
that.setData({
|
longitude: resLoc.longitude,
|
latitude: resLoc.latitude,
|
})
|
//发送请求通过经纬度反查地址信息
|
var getAddressUrl = "https://apis.map.qq.com/ws/geocoder/v1/?location=" + resLoc.latitude + "," + resLoc.longitude + "&key=GFDBZ-D3NKX-LNL4Z-TSWGU-RYCE3-4HB3I";
|
wx.request({
|
url: getAddressUrl,
|
success: function (result) {
|
//console.log("getAddressUrl", result);
|
that.setData({
|
userLocAddress: result.data.result.address
|
});
|
}
|
});
|
}
|
});
|
},
|
//显示确认对话框
|
tapShowConfirmDlg: function () {
|
if (this.data.longitude == 0 || this.data.latitude == 0) {
|
this.getCurrentLocation(); //获取当前经纬度
|
}
|
|
this.setData({
|
isShowConfirmDlg: true
|
});
|
},
|
//
|
inputOperateNote: function (e) {
|
this.setData({
|
operateNote: e.detail.value
|
})
|
},
|
/*** 弹出框蒙层截断touchmove事件*/
|
preventTouchMove: function () {},
|
/*** 隐藏模态对话框 */
|
hideConfirmDlg: function () {
|
this.setData({
|
isShowConfirmDlg: false
|
})
|
},
|
/*** 对话框取消按钮点击事件*/
|
onCancel: function () {
|
this.hideConfirmDlg()
|
},
|
/***确认*/
|
onConfirm: function () {
|
//console.log(this.data.operateNote);
|
var that = this;
|
Request({
|
url: Constant.BASE_SERVER_URL + "Repair/RepairTaskForm/Mobile/Start@V1.0",
|
method: 'POST',
|
data: {
|
CorpID: Constant.CorpID,
|
ID: that.data.requestFormId,
|
Note:that.data.operateNote
|
},
|
header: {
|
'content-type': 'application/x-www-form-urlencoded'
|
},
|
fail: function (err) {
|
// wx.showModal({
|
// title: '',
|
// content: '通讯失败',
|
// })
|
}, //请求失败
|
success: function (res) {
|
console.log(res.data,"已开工");
|
var result = res.data;
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '',
|
content: result.Message,
|
});
|
return;
|
}
|
|
wx.showToast({
|
title: '已开工',
|
icon: 'success',
|
duration: 2000
|
});
|
|
|
var pages = getCurrentPages();
|
if (pages.length >= 2) {
|
//var currPage = pages[pages.length - 1]; //当前页面
|
var prevPage = pages[pages.length - 2]; //上一个页面
|
//console.log(prevPage.route)
|
if (prevPage) {
|
var fn = prevPage.refreshRepairInfo;
|
if (typeof fn == "function")
|
fn(that.data.taskFormId, "startWork");
|
wx.navigateBack({
|
delta: 1
|
});
|
} else {
|
wx.navigateBack({
|
delta: 1
|
});
|
}
|
} else {
|
wx.navigateBack({
|
delta: 1
|
});
|
}
|
|
//that.hideModal();
|
//wx.redirectTo({
|
// url: '/repair/myTask/index',
|
//});
|
|
}
|
});
|
|
},
|
|
onReady: function () {},
|
onShow: function () {},
|
onHide: function () {},
|
onUnload: function () {},
|
onPullDownRefresh: function () {},
|
onReachBottom: function () {},
|
onShareAppMessage: function () {}
|
})
|