123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- import http from '../../base/httputil'
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- host: app.globalData.host,
- enterpriseId: null,
- details: {
- id: null,
- longitude: Number,
- latitude: Number,
- name: null,
- code: null,
- remark: '',
- },
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.data.enterpriseId = options.enterpriseId
- // this.getDetails()
- },
- // getDetails() {
- // let obj = new Object();
- // obj.id = this.id
- // http.post("/system/AppEnterpriseController/getEnterpriseDetails", obj, this.getEnterpriseDetailsSuccess)
- // },
- // getEnterpriseDetailsSuccess(res) {
- // this.setData({
- // enterpriseDetails: res.enterpriseDetails,
- // })
- // },
- //-----------------------------------------
- bindInputName(e) {
- this.data.details.name = e.detail.value
- },
- bindInputRemark(e) {
- this.data.details.remark = e.detail.value
- },
- bindInputCode(e) {
- this.data.details.code = e.detail.value
- },
- bindViewScan(){
- wx.scanCode({
- onlyFromCamera: true,
- success: (res) => {
- this.setData({
- ['details.code']:res.result,
- })
- },
- fail: (res) => {
- wx.showToast({
- title: '扫描失败请重试',
- icon:'none'
- })
- }
- })
- },
- //------------------------------------------
- updateDetails() {
- if(this.data.details.name==null){
- wx.showToast({
- title:'请输入巡更点名称',
- icon:'none'
- })
- return
- }
-
- if(this.data.details.code==null){
- wx.showToast({
- title:'请扫描或输入巡更点编码',
- icon:'none'
- })
- return
- }
-
- if(isNaN(this.data.details.longitude)||isNaN(this.data.details.latitude)){
- wx.showToast({
- title:'请点击定位当前位置',
- icon:'none'
- })
- return
- }
-
- let obj = new Object();
- obj.busEnterpriseId = this.data.enterpriseId
- obj.busPatrolstationName = this.data.details.name
- obj.busPatrolstationCode = this.data.details.code
- obj.longitude=this.data.details.longitude
- obj.latitude=this.data.details.latitude
- obj.remarks = this.data.details.remark
-
- http.post("/system/AppPatrolstationController/addPatrolstation", obj, this.updateDetailsSuccess)
- },
- updateDetailsSuccess(res) {
- wx.showToast({
- title: res.msg,
- icon:'none'
- })
- if(res.code == 200){
- wx.navigateBack()
- }
- },
- deletePatrolPoint() {
- // let obj = new Object();
- // obj.busEnterpriseId = this.data.enterpriseDetails.busEnterpriseId
- // http.post("/system/AppEnterpriseController/deleteEnterprise", obj, this.deleteEnterpriseSuccess)
- },
- // deleteEnterpriseSuccess(res) {
- // wx.showToast({
- // title: res.msg,
- // })
- // if(res.code == 200){
- // wx.navigateTo({
- // url: '../qiye/qiye'
- // })
- // }
- // },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- },
-
- getLocation() {
- let that = this
- wx.getLocation({
- type: 'wgs84', //返回可以用于wx.openLocation的经纬度
- success: function (res) {
- that.setData({
- ['details.longitude']: res.longitude,
- ['details.latitude']: res.latitude
- })
- },
- })
- },
- })
|