| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333 |
- <!--
- *危险区现场巡查
- *
- -->
- <template>
- <view class="container">
- <uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
- @clickLeft="toBack">
- <view class="nav-title">
- <text>{{title}}</text>
- </view>
- </uni-nav-bar>
- <uni-forms ref="baseForm" :model="formData">
- <uni-card title="定位信息" :is-shadow="false">
- <view class="view-flex-inline" style="margin-bottom: 10px;">
- <view style="width: 100px;">经纬度</view>
- <view v-if="longitude != '' && latitude != ''">{{longitude}},{{latitude}}</view>
- </view>
- <view style="margin-bottom: 5px;font-size: 0.6rem;color:skyblue;">
- 备注:定位地址可进行人工修改</view>
- <uni-forms-item name='lng' label="定位地址" label-width="100px">
- <uni-easyinput v-model="formData.address" placeholder="请录入定位地址" />
- </uni-forms-item>
- </uni-card>
- <uni-card title="巡查反馈" :is-shadow="false">
- <uni-forms-item name="isFlood" label="是否有山洪" label-width="100px" required>
- <uni-data-checkbox v-model="formData.isFlood" :localdata="checkItems.items">
- </uni-data-checkbox>
- </uni-forms-item>
- <uni-forms-item name="isDamage" label="是否成灾" label-width="100px" required>
- <uni-data-checkbox v-model="formData.isDamage" :localdata="checkItems.items">
- </uni-data-checkbox>
- </uni-forms-item>
- <uni-forms-item name='remark' label="备注" label-width="100px">
- <uni-easyinput v-model="formData.remark" placeholder="请录入其他需要说明的情况" />
- </uni-forms-item>
- </uni-card>
- <uni-card title="巡查图片" extra="点击下方按钮开始拍摄" :is-shadow="false">
- <view class="view-flex-inline">
- <view v-for="(item, index) in checkPhotos" :key="index" class="view-flex-block-center"
- style="width: 100px;">
- <view class="img-container">
- <view class="note-image-box">
- <view class="note-image-item">
- <view class="close-icon" @click="onCheckPhotoDel(index)">
- <uni-icons type="closeempty" size="18" color="#fff"></uni-icons>
- </view>
- <view class="image-box">
- <image :src="toOss(item)" mode="widthFix">
- </image>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="view-flex-block-center" style="width: 80px;">
- <view class="img-container">
- <view class="note-image-box">
- <view class="note-image-item" @click="onCheckPhotoAdd()">
- <view class="image-box">
- <uni-icons type="plusempty" size="50" color="#eee"></uni-icons>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </uni-card>
- </uni-forms>
- <view class="footer">
- <view class="control">
- <view class="view-flex-inline-center">
- <view class="block"
- style="width: 120px;height:28px;margin-left: 10px;margin-right: 10px;border-radius:7px;background-color:lightpink"
- @click="toSubmit()">
- <view class="view-flex-block-center">
- <uni-icons class="input-uni-icon" type="checkmarkempty" size="18" color="#999" />
- </view>
- <view class="view-flex-block-center" style="padding-left:5px;">
- <text style="color:black;font-size:0.7rem">立即提交</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- role
- } from "@/api/role.js";
- import http from '@/http/api.js';
- import {
- oss,
- devUrl,
- prodUrl
- } from '@/common/setting';
- export default {
- data() {
- return {
- title: '现场巡查',
- baseURL: '',
- baseOSS: '',
- checkType: 0,
- warnId: '',
- latitude: '',
- longitude: '',
- formData: {
- address: '',
- isFlood: 0,
- isDamage: 0,
- remark: '',
- },
- checkPhotos: [],
- checkItems: {
- items: [{
- 'value': 0,
- 'text': '否'
- }, {
- 'value': 1,
- 'text': '是'
- }],
- current: 0,
- },
- }
- },
- onLoad(option) {
- let that = this;
- this.baseOSS = oss;
- this.baseURL = process.env.NODE_ENV === 'development' ? devUrl : prodUrl;
- this.checkType = option.type;
- this.warnId = option.id;
- // #ifdef APP-PLUS
- console.log("app")
- uni.getLocation({
- type: 'gcj02',
- geocode: true,
- success: function(res) {
- console.log('当前位置:' + JSON.stringify(res));
- that.latitude = res.latitude;
- that.longitude = res.longitude;
- //that.getAddress(res.longitude;,res.latitude);
- }
- });
- // #endif
- // #ifdef MP-WEIXIN
- console.log("weixin")
- uni.getLocation({
- type: 'wgs84',
- success: function(res) {
- console.log('当前位置:' + JSON.stringify(res));
- that.latitude = res.latitude;
- that.longitude = res.longitude;
- //that.getAddress(res.longitude;,res.latitude);
- }
- });
- // #endif
- },
- computed: {
- },
- onShow() {
- },
- methods: {
- toOss(path) {
- let url = this.baseOSS + path;
- return url;
- },
- //返回上一页
- toBack() {
- uni.navigateBack({
- delta: 1
- })
- },
- onBackPress() {
- // #ifdef APP-PLUS
- plus.key.hideSoftKeybord();
- // #endif
- },
- getAddress(lng, lat) {
- console.log("get address " + lat + lng);
- let url = 'https://apis.map.qq.com/ws/geocoder/v1/?location=' + lat + ',' + lng +
- '&key=4HYBZ-EB23D-SLC42-HQ5R3-LP3LQ-OZFU5';
- console.log(url);
- http.request({
- url: url,
- method: 'GET',
- }).then(res => {
- console.log('当前位置:' + JSON.stringify(res));
- }).catch(err => {
- console.log(err)
- })
- },
- onCheckPhotoAdd() {
- let that = this;
- uni.chooseImage({
- sourceType: ['camera'],
- sizeType: ['compressed'],
- success: (res) => {
- const len = res.tempFilePaths.length;
- if (len === 1) {
- res.tempFilePaths.forEach(path => {
- that.uploadCheckPhoto(path);
- })
- } else {
- uni.showModal({
- content: '只能选择一张图片,请确认!',
- showCancel: false
- });
- }
- }
- })
- },
- uploadCheckPhoto(imagePath) {
- let that = this;
- uni.showLoading({
- title: '上传中'
- });
- uni.uploadFile({
- url: this.baseURL + '/galaxy-resource/oss/endpoint/put-file-attach?Blade-Auth=' +
- uni.getStorageSync('accessToken'),
- fileType: 'image',
- filePath: imagePath,
- name: 'file',
- success: (uploadFileRes) => {
- if (uploadFileRes.statusCode == 200) {
- let data = JSON.parse(uploadFileRes.data);
- if (data.success) {
- let path = data.data['name'];
- that.checkPhotos.push(path);
- }
- }
- },
- fail: (err) => {
- console.log(err);
- reject('err')
- },
- complete() {
- uni.hideLoading()
- }
- });
- },
- onCheckPhotoDel(index) {
- this.checkPhotos.splice(index, 1);
- },
- toSubmit() {
- let that = this;
- this.$refs.baseForm.validate().then(res => {
- console.log('表单数据信息1:', res);
- that.submit();
- }).catch(err => {
- console.log('表单错误信息:', err);
- uni.showModal({
- content: "巡查内容录入错误,请根据提示信息检查录入内容!",
- showCancel: false,
- success(res) {
- if (res.confirm) {
- //that.$refs.baseForm.clearValidate();
- }
- }
- });
- })
- },
- submit() {
- let formdata = this.formData;
- formdata['checkType'] = this.checkType;
- formdata['warnId'] = this.warnId;
- formdata['longitude'] = this.longitude;
- formdata['latitude'] = this.latitude;
- if (this.checkPhotos.length > 0) {
- let photos = '';
- for (let i = 0; i < this.checkPhotos.length; i++) {
- if (photos.length > 0) {
- photos = photos + ',';
- }
- photos = photos + this.checkPhotos[i];
- }
- formdata['checkPhotos'] = photos;
- }
- console.log('toSubmit事件:', JSON.stringify(formdata));
- let that = this;
- http.request({
- url: '/galaxy-business/yj/check/report',
- method: 'POST',
- data: formdata
- }).then(res => {
- console.log('res ', JSON.stringify(res));
- if (res.success) {
- if (res.code == 200) {
- //that.clearCache();
- uni.showModal({
- content: '巡查信息已成功提交',
- showCancel: false,
- success(res) {
- if (res.confirm) {
- that.toBack();
- }
- }
- });
- } else {
- uni.showModal({
- content: '提交失败',
- showCancel: false
- });
- }
- } else {
- uni.showModal({
- content: '提交失败',
- showCancel: false
- });
- }
- }).catch(err => {
- // console.log('errr3',JSON.stringify(err));
- uni.showModal({
- content: '' + err.data.msg,
- showCancel: false
- });
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- padding: 0 0 100rpx;
- }
- </style>
|