From 0ad28dbac74ba51b604c31c2dee7494d4e7f8fe4 Mon Sep 17 00:00:00 2001
From: hailu <962012470@qq.com>
Date: 星期一, 27 十一月 2023 17:21:15 +0800
Subject: [PATCH] 安装流程
---
GoldC/pages/problemReport/proRep.js | 256 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 245 insertions(+), 11 deletions(-)
diff --git a/GoldC/pages/problemReport/proRep.js b/GoldC/pages/problemReport/proRep.js
index 9731f0f..da520d5 100644
--- a/GoldC/pages/problemReport/proRep.js
+++ b/GoldC/pages/problemReport/proRep.js
@@ -27,6 +27,7 @@
erectoList2: [],
deviceList1: [],
deviceList2: [],
+ imgUrl: '/images/img.png',
time: '閫夋嫨棰勭害鏃堕棿',
multiArray: [],//piker鐨刬tem椤�
@@ -45,9 +46,10 @@
* 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
*/
onLoad: function (options) {
- if (options) {
+
+ if (options && options.info) {
let info = JSON.parse(options.info)
- info.state = 3
+ console.log(info);
this.setData({
showJD: true,
paramsInfo: info,
@@ -59,16 +61,200 @@
erectoList2: [info.erectoName]
})
wx.setNavigationBarTitle({
- title:this.data.form.device.deviceName
+ title: this.data.form.device.deviceName
})
- console.log(this.data);
} else {
this.getErectoList()
this.getDeviceList()
}
+ },
+ changeUserName(e) {
+ this.data.form.userName = e.detail.value
+ },
+ changePhone(e) {
+ this.data.form.userPhone = e.detail.value
+ },
+ changeaddress(e) {
+ this.data.form.address = e.detail.value
+ },
+ changeRemark(e) {
+ this.data.form.remark = e.detail.value
+ },
+ Cancel() {
+ wx.navigateBack()
+ },
+ Yes() {
+ console.log(this.data.form);
+ if (this.data.form.state == 3) {
+ if (!this.data.form.imgUrl) {
+ wx.showToast({
+ title: '璇蜂笂浼犲浘鐗�',
+ icon: 'none'
+ });
+ return
+ }
+ this.data.form.orderType='1'
+ console.log(this.data.form);
+ wx.request({
+ url: `https://puyue.yhupai.com/prod-api/iot/deviceOrder`,
+ method: "put",
+ header: {
+ "Access-Control-Allow-Headers": 'token',
+ Authorization: `Bearer ${wx.getStorageSync('token')}`
+ },
+ data: this.data.form,
+ success: (res, header) => {
+ if (res.data.code != 200) {
+ wx.showToast({
+ title: res.data.msg,
+ icon: 'none'
+ });
+ } else {
+ wx.navigateBack()
+ }
+ }
+ })
+ } else if (Object.keys(this.data.paramsInfo).length > 0 && this.data.form.state != 3) {
+ console.log(this.data.form);
+ let phoneReg = /^1[3456789]\d{9}$/;
+ if (!this.data.form.userName) {
+ wx.showToast({
+ title: '璇疯緭鍏ョ敤鎴峰悕',
+ icon: 'none'
+ })
+ return
+ } else if (!phoneReg.test(this.data.form.userPhone)) {
+ wx.showToast({
+ title: '璇疯緭鍏ユ纭墜鏈哄彿',
+ icon: 'none'
+ })
+ return
+ } else if (!this.data.form.address) {
+ wx.showToast({
+ title: '璇疯緭鍏ュ畨瑁呭湴鍧�',
+ icon: 'none'
+ })
+ return
+ }
+ wx.request({
+ url: `https://puyue.yhupai.com/prod-api/iot/deviceOrder`,
+ method: "put",
+ header: {
+ "Access-Control-Allow-Headers": 'token',
+ Authorization: `Bearer ${wx.getStorageSync('token')}`
+ },
+ data: this.data.form,
+ success: (res, header) => {
+ if (res.data.code != 200) {
+ wx.showToast({
+ title: res.data.msg,
+ icon: 'none'
+ });
+ } else {
+ wx.navigateBack()
+ }
+ }
+ })
+ } else {
+ console.log(this.data.form);
+ let phoneReg = /^1[3456789]\d{9}$/;
+ if (!this.data.form.userName) {
+ wx.showToast({
+ title: '璇疯緭鍏ョ敤鎴峰悕',
+ icon: 'none'
+ })
+ return
+ } else if (!phoneReg.test(this.data.form.userPhone)) {
+ wx.showToast({
+ title: '璇疯緭鍏ユ纭墜鏈哄彿',
+ icon: 'none'
+ })
+ return
+ } else if (!this.data.form.address) {
+ wx.showToast({
+ title: '璇疯緭鍏ュ畨瑁呭湴鍧�',
+ icon: 'none'
+ })
+ return
+ }
+ wx.request({
+ url: `https://puyue.yhupai.com/prod-api/iot/deviceOrder`,
+ method: "post",
+ header: {
+ "Access-Control-Allow-Headers": 'token',
+ Authorization: `Bearer ${wx.getStorageSync('token')}`
+ },
+ data: this.data.form,
+ success: (res, header) => {
+ console.log(res);
+ if (res.data.code != 200) {
+ wx.showToast({
+ title: res.data.msg,
+ icon: 'none'
+ });
+ } else {
+ wx.navigateTo({
+ url: '/pages/problemList/problemList',
+ })
+ }
+ }
+ })
+ }
+ },
+ chooseimage() {
+ var that = this; // 灏嗗綋鍓嶉〉闈㈢殑涓婁笅鏂囪祴鍊肩粰 that 鍙橀噺
+ // 鍦ㄦ煇涓簨浠跺鐞嗗嚱鏁颁腑璋冪敤浠ヤ笅浠g爜
+ wx.chooseImage({
+ count: 1, // 鏈�澶氬彲浠ラ�夋嫨鐨勫浘鐗囨暟閲忥紝杩欓噷璁句负1
+ sourceType: ['album'], // 浠庣浉鍐岄�夋嫨
+ success: function (res) {
+ // 閫夋嫨鎴愬姛鍚庯紝res.tempFilePaths 鏄�夊畾鐨勫浘鐗囩殑鏈湴鏂囦欢璺緞鍒楄〃
+ const tempFilePath = res.tempFilePaths;
+ wx.compressImage({
+ src: tempFilePath[0],
+ quality: 80, // 璁剧疆鍘嬬缉璐ㄩ噺锛岃寖鍥翠负 0-100
+ success: function (res) {
+ const compressedFilePath = res.tempFilePath;
+ console.log(compressedFilePath, 'compressedFilePath');
+ // 鍘嬬缉鍚庣殑鍥剧墖璺緞杩涜鐨勫悗缁搷浣�
+ try {
+ let data = compressedFilePath
+ wx.uploadFile({
+ // 涓婁紶鎺ュ彛璺緞
+ url: `https://puyue.yhupai.com/prod-api/iot/deviceOrder/profile/avatar`,
+ filePath: data,
+ name: 'avatarfile', // 涓婁紶鏂囦欢瀵瑰簲鐨� key 鍚嶇О
+ method: 'post',
+ header: {
+ 'content-type': 'application/form-data',
+ "Access-Control-Allow-Headers": 'token',
+ Authorization: `Bearer ${wx.getStorageSync('token')}`
+ },
+ // data: data
+ success: function (res) {
+ console.log(res.data);
+ // 涓婁紶鎴愬姛鍚庣殑澶勭悊閫昏緫
+ that.setData({
+ imgUrl: 'https://puyue.yhupai.com/prod-api' + JSON.parse(res.data).imgUrl // 灏嗛�夋嫨鐨勫浘鐗囪矾寰勮缃负椤甸潰鏁版嵁鐨勬煇涓睘鎬�
+ });
+ console.log(that.data.imgUrl);
+ that.data.form.imgUrl = that.data.imgUrl
+ },
+ fail: function (res) {
+ // 涓婁紶澶辫触鍚庣殑澶勭悊閫昏緫
+ console.log(res, '涓婁紶澶辫触鍚庣殑澶勭悊閫昏緫');
+ }
+ })
+ } catch (e) { }
-
-
+ },
+ fail: function (err) {
+ // 鍘嬬缉澶辫触鐨勫鐞�
+ console.error(err);
+ }
+ });
+ }
+ });
},
getDeviceList() {
let data = {
@@ -97,6 +283,8 @@
deviceList1: res.data.rows,
deviceList2: data
})
+ this.data.form.deviceId = res.data.rows[0].deviceId
+ this.data.form.deviceName = res.data.rows[0].deviceName
}
}
})
@@ -117,7 +305,6 @@
},
params: data,
success: (res, header) => {
-
if (res.data.code != 200) {
wx.showToast({
title: res.data.msg,
@@ -136,21 +323,47 @@
erectoList2: data
})
+ this.data.form.erectoId = -1
+ this.data.form.erectoName = '鏈寚娲�'
}
}
})
},
bindPicker(e) {
- // console.log('picker鍙戦�侀�夋嫨鏀瑰彉锛屾惡甯﹀�间负', e.detail.value)
+ console.log('picker鍙戦�侀�夋嫨鏀瑰彉锛屾惡甯﹀�间负', e.detail.value)
this.setData({
deviceIndex: e.detail.value
})
+ this.data.form.deviceId = this.data.deviceList1[e.detail.value].deviceId
+ this.data.form.deviceName = this.data.deviceList1[e.detail.value].deviceName
+ console.log(this.data.form, this.data.deviceList1);
},
bindPicker2(e) {
- // console.log('picker鍙戦�侀�夋嫨鏀瑰彉锛屾惡甯﹀�间负', e.detail.value)
this.setData({
erectoIndex: e.detail.value
})
+ if (this.data.erectoIndex == 0) {
+ let item = JSON.parse(JSON.stringify(this.data.form))
+ item.state = 0
+ this.setData({
+ form: item
+ })
+ // this.data.form.state = 0
+ this.data.form.erectoId = -1
+ this.data.form.erectoName = '鏈寚娲�'
+ } else {
+ let item = JSON.parse(JSON.stringify(this.data.form))
+ item.state = 1
+ this.setData({
+ form: item
+ })
+ // this.data.form.state = 1
+ this.data.form.erectoId = this.data.erectoList1[Number(e.detail.value)].userId
+ this.data.form.erectoName = this.data.erectoList1[Number(e.detail.value)].nickName
+ }
+ console.log(this.data.erectoList1, this.data.erectoList2, e.detail.value, this.data.form);
+
+
},
openShowDate() {
this.setData({
@@ -178,7 +391,7 @@
hour: hour, //璁板綍閫夋嫨鐨勬椂
minute: minute, //璁板綍閫夋嫨鐨勫垎
})
- console.log(this.data.time);
+ this.data.form.appointmentTime = this.data.time
},
bindMultiPickerColumnChange: function (e) { //鐩戝惉picker鐨勬粴鍔ㄤ簨浠�
@@ -369,7 +582,28 @@
* 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
*/
onShow: function () {
- if (!this.data.showJD) {
+
+ if (this.data.form && this.data.form.appointmentTime) {
+ var loadPickerData = DatePickerUtil.loadPickerData()
+ // var getCurrentDate = DatePickerUtil.getCurrentDate()
+ var GetMultiIndex = DatePickerUtil.GetMultiIndex()
+ //杩欓噷鍐欑殑鏄负浜嗚褰曞綋鍓嶆椂闂�
+ let year = parseInt(this.data.form.appointmentTime.substring(0, 4));
+ let month = parseInt(this.data.form.appointmentTime.substring(5, 7));
+ let day = parseInt(this.data.form.appointmentTime.substring(8, 10));
+ let hour = parseInt(this.data.form.appointmentTime.substring(11, 13));
+ let minute = parseInt(this.data.form.appointmentTime.substring(14, 16));
+ this.setData({
+ multiArray: loadPickerData,//picker鏁扮粍璧嬪�硷紝鏍煎紡 [years, months, days, hours, minutes]
+ multiIndex: GetMultiIndex,//璁剧疆pickerIndex锛孾0,0,0,0,0]
+ time: year + '-' + month + '-' + day + ' ' + hour + '-' + minute, //璁剧疆褰撳墠鏃堕棿 锛宑urrentYears+'-'+mm+'-'+dd+' '+hh+':'+min
+ year: year,//璁板綍閫夋嫨鐨勫勾
+ month: month,//璁板綍閫夋嫨鐨勬湀
+ day: day,//璁板綍閫夋嫨鐨勬棩
+ hour: hour,//璁板綍閫夋嫨鐨勬椂
+ minute: minute,//璁板綍閫夋嫨鐨勫垎
+ });
+ } else {
var loadPickerData = DatePickerUtil.loadPickerData()
var getCurrentDate = DatePickerUtil.getCurrentDate()
var GetMultiIndex = DatePickerUtil.GetMultiIndex()
--
Gitblit v1.8.0