228 lines
5.4 KiB
JavaScript
228 lines
5.4 KiB
JavaScript
// pages/qtest/form.js
|
|
const api = require("../../utils/request.js");
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
items: [
|
|
{ name: '铅衣', value: '铅衣' },
|
|
{ name: '铅帽', value: '铅帽' },
|
|
{ name: '铅围裙', value: '铅围裙' },
|
|
{ name: '铅围脖', value: '铅围脖' },
|
|
{ name: '一整套防护用品', value: '一整套防护用品' },
|
|
]
|
|
},
|
|
checkboxChange: function (e) {
|
|
this.data.tests = e.detail.value
|
|
},
|
|
addressInput: function(e){
|
|
this.data.address = e.detail.value
|
|
},
|
|
nameInput: function(e){
|
|
this.data.name = e.detail.value
|
|
},
|
|
phoneInput: function(e){
|
|
this.data.phone = e.detail.value
|
|
},
|
|
kdInput: function(e){
|
|
this.data.kdd = e.detail.value
|
|
},
|
|
tap1:function(){
|
|
api.request('/cms/material/','get', {name:'个人防护用品检测介绍和案例'}).then(res=>{
|
|
var res1 = res.data
|
|
if(res1.count){
|
|
var fileurl = getApp().globalData.host + res1.results[0].path
|
|
wx.showLoading({
|
|
title: '正在下载...',
|
|
})
|
|
wx.downloadFile({
|
|
url: fileurl,
|
|
success(res) {
|
|
wx.showLoading({
|
|
title: '成功,正在打开...',
|
|
})
|
|
const filePath = res.tempFilePath
|
|
var filetype
|
|
if (fileurl.indexOf(".docx") != -1) {
|
|
filetype = 'docx'
|
|
}
|
|
else if (fileurl.indexOf(".doc") != -1) {
|
|
filetype = 'doc'
|
|
}
|
|
else if (fileurl.indexOf(".xlsx") != -1) {
|
|
filetype = 'xlsx'
|
|
}
|
|
else if (fileurl.indexOf(".xls") != -1) {
|
|
filetype = 'xls'
|
|
}
|
|
else if (fileurl.indexOf(".pptx") != -1) {
|
|
filetype = 'pptx'
|
|
}
|
|
else if (fileurl.indexOf(".ppt") != -1) {
|
|
filetype = 'ppt'
|
|
}
|
|
else if (fileurl.indexOf(".pdf") != -1) {
|
|
filetype = 'pdf'
|
|
} else {
|
|
wx.hideLoading()
|
|
return
|
|
}
|
|
wx.openDocument({
|
|
filePath,
|
|
fileType: filetype,
|
|
success(res) {
|
|
wx.hideLoading()
|
|
console.log('打开文档成功')
|
|
}, fail: function (e) {
|
|
wx.hideLoading()
|
|
}
|
|
})
|
|
}
|
|
})
|
|
}
|
|
})
|
|
},
|
|
tap2:function(){
|
|
api.request('/cms/material/','get', {name:'个人防护用品检测申请单'}).then(res=>{
|
|
var res1 = res.data
|
|
if(res1.count){
|
|
var fileurl = getApp().globalData.host + res1[0].path
|
|
wx.showLoading({
|
|
title: '正在下载...',
|
|
})
|
|
wx.downloadFile({
|
|
url: fileurl,
|
|
success(res) {
|
|
wx.showLoading({
|
|
title: '成功,正在打开...',
|
|
})
|
|
const filePath = res.tempFilePath
|
|
var filetype
|
|
if (fileurl.indexOf(".docx") != -1) {
|
|
filetype = 'docx'
|
|
}
|
|
else if (fileurl.indexOf(".doc") != -1) {
|
|
filetype = 'doc'
|
|
}
|
|
else if (fileurl.indexOf(".xlsx") != -1) {
|
|
filetype = 'xlsx'
|
|
}
|
|
else if (fileurl.indexOf(".xls") != -1) {
|
|
filetype = 'xls'
|
|
}
|
|
else if (fileurl.indexOf(".pptx") != -1) {
|
|
filetype = 'pptx'
|
|
}
|
|
else if (fileurl.indexOf(".ppt") != -1) {
|
|
filetype = 'ppt'
|
|
}
|
|
else if (fileurl.indexOf(".pdf") != -1) {
|
|
filetype = 'pdf'
|
|
} else {
|
|
wx.hideLoading()
|
|
return
|
|
}
|
|
wx.openDocument({
|
|
filePath,
|
|
fileType: filetype,
|
|
success(res) {
|
|
wx.hideLoading()
|
|
console.log('打开文档成功')
|
|
}, fail: function (e) {
|
|
wx.hideLoading()
|
|
}
|
|
})
|
|
}
|
|
})
|
|
}
|
|
})
|
|
},
|
|
submit: function(){
|
|
if(this.data.name&&this.data.phone&&this.data.address){
|
|
let data = {
|
|
name:this.data.name,
|
|
phone:this.data.phone,
|
|
address:this.data.address,
|
|
tests:this.data.tests,
|
|
kdd:this.data.kdd
|
|
}
|
|
api.request('/qtest/consult/','POST', data).then(res=>{
|
|
wx.showModal({
|
|
title: '提示!',
|
|
content: '已提交信息.',
|
|
confirmText: '好的',
|
|
showCancel:false,
|
|
success(res) {
|
|
if (res.confirm) {
|
|
wx.navigateBack({
|
|
delta: 0,
|
|
})
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}else{
|
|
wx.showToast({
|
|
title: '填写不完整',
|
|
icon:'none'
|
|
})
|
|
}
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}) |