Browse Source

Merge branch 'dev_ljj' of http://git.elinkit.com.cn:7070/r/tduck-front into dev_ljj

old
13176889840 4 years ago
parent
commit
6bb0a39fbd
  1. 6
      src/components/parser/Parser.vue
  2. 941
      src/views/form/setting/index.vue
  3. 538
      src/views/form/write/index.vue

6
src/components/parser/Parser.vue

@ -260,14 +260,12 @@ function setValueLabel (event, config, scheme) {
console.log(scheme)
// input
let tagOptionKey = processType[config.tag]
debugger
if (tagOptionKey) {
if (event instanceof Array) {
//
//
if (!event.includes(0) && config.tag != 'el-cascader') {
// other
this.$set(this[this.formConf.labelFormModel], `${scheme.__vModel__}other`, '')

941
src/views/form/setting/index.vue

File diff suppressed because it is too large

538
src/views/form/write/index.vue

@ -1,48 +1,50 @@
<template>
<div class="write-container">
<h1 id="inActiveTime" style="display: none;" />
<div v-if="writeStatus==0" class="title-icon-view">
<div class="icon-view">
<i class="el-icon-check success-icon" />
</div>
<p v-if="writeNotStartPrompt" style="text-align: center;">
<span v-if="writeNotStartPrompt">{{ writeNotStartPrompt }}</span>
</p>
</div>
<div v-if="writeStatus==1">
<project-form
v-if="projectConfig.projectKey"
:project-config="projectConfig"
@submit="submitForm"
/>
</div>
<div v-if="writeStatus==2" class="title-icon-view">
<div class="icon-view">
<i class="el-icon-check success-icon" />
</div>
<p style="text-align: center;">
<span v-if="userProjectSetting.submitPromptText">{{ userProjectSetting.submitPromptText }}</span>
<span v-else>{{ globalDefaultValue.projectSubmitPromptText }}</span>
</p>
<div>
<el-image
v-if="userProjectSetting.submitPromptImg"
:src="userProjectSetting.submitPromptImg"
fit="cover"
/>
</div>
<el-button v-if="userProjectSetting.publicResult" type="primary" @click="openPublicResultHandle">
查看数据
</el-button>
</div>
<div class="write-container">
<h1 id="inActiveTime"
style="display: none;" />
<div v-if="writeStatus==0"
class="title-icon-view">
<div class="icon-view">
<i class="el-icon-check success-icon" />
</div>
<p v-if="writeNotStartPrompt"
style="text-align: center;">
<span v-if="writeNotStartPrompt">{{ writeNotStartPrompt }}</span>
</p>
</div>
<div v-if="writeStatus==1">
<project-form v-if="projectConfig.projectKey"
:project-config="projectConfig"
@submit="submitForm" />
</div>
<div v-if="writeStatus==2"
class="title-icon-view">
<div class="icon-view">
<i class="el-icon-check success-icon" />
</div>
<p style="text-align: center;">
<span v-if="userProjectSetting.submitPromptText">{{ userProjectSetting.submitPromptText }}</span>
<span v-else>{{ globalDefaultValue.projectSubmitPromptText }}</span>
</p>
<div>
<el-image v-if="userProjectSetting.submitPromptImg"
:src="userProjectSetting.submitPromptImg"
fit="cover" />
</div>
<el-button v-if="userProjectSetting.publicResult"
type="primary"
@click="openPublicResultHandle">
查看数据
</el-button>
</div>
</div>
</template>
<script>
import ProjectForm from '../preview/ProjectForm'
import loadWXJs from '@/utils/loadWxSdk'
import defaultValue from '@/utils/defaultValue'
import {getQueryString} from '@/utils'
import { getQueryString } from '@/utils'
import constants from '@/utils/constants'
const uaParser = require('ua-parser-js')
@ -50,240 +52,258 @@ const ua = uaParser(navigator.userAgent)
require('@/utils/ut')
export default {
name: 'WriteView',
components: {
ProjectForm
name: 'WriteView',
components: {
ProjectForm
},
props: {},
data () {
return {
inActiveTime: 0,
projectConfig: {
projectKey: '',
preview: false,
showBtns: true
},
writeStatus: 1,
writeNotStartPrompt: '',
userProjectSetting: {
submitPromptText: ''
},
globalDefaultValue: defaultValue,
//
wxAuthorizationUrl: '',
wxAuthorizationCode: '',
wxUserInfo: {},
wxSignature: {},
//
clientType: '',//:gov:resi:oper
orgId: '',//Id(agencyId;deptId;gridId)
orgName: '',//---
orgType: '',//(:agency;:dept;:grid)
realName: '',//
}
},
metaInfo: {
meta: [
{
name: 'viewport',
content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'
}
]
},
async created () {
this.clientType = this.$route.query.clientType
this.orgId = this.$route.query.orgId
this.orgName = this.$route.query.orgName
this.orgType = this.$route.query.orgType
this.realName = this.$route.query.realName
let key = this.$route.query.key || this.$route.params.key
this.projectConfig.projectKey = key
let wxCode = getQueryString('code')
if (wxCode) {
this.wxAuthorizationCode = wxCode
await this.getWxAuthorizationUserInfo()
}
this.getWxAuthorizationUrl()
this.queryProjectSettingStatus()
this.queryProjectSetting()
if (constants.enableWx) {
//
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/wx/jsapi/signature`, { params: { url: window.location.href } }).then(res => {
this.wxSignature = res.data
this.setWxConfig()
})
}
},
mounted () {
this.viewProjectHandle()
}, methods: {
viewProjectHandle () {
//
this.$api.post(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/view/${this.projectConfig.projectKey}`, { params: { projectKey: this.projectConfig.projectKey } }).then(() => {
})
},
props: {},
data() {
return {
inActiveTime: 0,
projectConfig: {
projectKey: '',
preview: false,
showBtns: true
},
writeStatus: 1,
writeNotStartPrompt: '',
userProjectSetting: {
submitPromptText: ''
},
globalDefaultValue: defaultValue,
//
wxAuthorizationUrl: '',
wxAuthorizationCode: '',
wxUserInfo: {},
wxSignature: {}
queryProjectSettingStatus () {
//
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/setting-status`, {
params: {
projectKey: this.projectConfig.projectKey,
wxOpenId: this.wxUserInfo ? this.wxUserInfo.openid : ''
}
}).then(res => {
if (res.msg) {
this.writeNotStartPrompt = res.msg
this.writeStatus = 0
}
})
},
metaInfo: {
meta: [
{
name: 'viewport',
content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'
}
]
},
async created() {
let key = this.$route.query.key || this.$route.params.key
this.projectConfig.projectKey = key
let wxCode = getQueryString('code')
if (wxCode) {
this.wxAuthorizationCode = wxCode
await this.getWxAuthorizationUserInfo()
getWxAuthorizationUserInfo () {
let wxAuthorizationCode = this.wxAuthorizationCode
// code
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/wx/jsapi/authorization/user/info`, {
params: {
code: wxAuthorizationCode
}
this.getWxAuthorizationUrl()
this.queryProjectSettingStatus()
this.queryProjectSetting()
if (constants.enableWx) {
//
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/wx/jsapi/signature`, {params: {url: window.location.href}}).then(res => {
this.wxSignature = res.data
this.setWxConfig()
})
}).then(res => {
if (res.data) {
this.wxUserInfo = res.data
}
})
},
mounted() {
this.viewProjectHandle()
}, methods: {
viewProjectHandle() {
//
this.$api.post(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/view/${this.projectConfig.projectKey}`, {params: {projectKey: this.projectConfig.projectKey}}).then(() => {
})
},
queryProjectSettingStatus() {
//
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/setting-status`, {
params: {
projectKey: this.projectConfig.projectKey,
wxOpenId: this.wxUserInfo ? this.wxUserInfo.openid : ''
}
}).then(res => {
if (res.msg) {
this.writeNotStartPrompt = res.msg
this.writeStatus = 0
}
})
},
getWxAuthorizationUserInfo() {
let wxAuthorizationCode = this.wxAuthorizationCode
// code
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/wx/jsapi/authorization/user/info`, {
params: {
code: wxAuthorizationCode
}
}).then(res => {
if (res.data) {
this.wxUserInfo = res.data
}
})
},
getWxAuthorizationUrl() {
// url
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/wx/jsapi/authorization/url`, {params: {url: window.location.href}}).then(res => {
if (res.data) {
this.wxAuthorizationUrl = res.data
}
})
},
setWxConfig() {
let that = this
let signature = this.wxSignature
loadWXJs(wx => {
wx.config({
debug: false, // ,apialertpclogpc
appId: signature.appId, //
timestamp: signature.timestamp, //
nonceStr: signature.nonceStr, //
signature: signature.signature, //
jsApiList: [
'updateAppMessageShareData',
'updateTimelineShareData',
'onMenuShareAppMessage',
'onMenuShareTimeline',
'showMenuItems',
'hideMenuItems',
'chooseWXPay'
] // 使JS
})
// sdk
wx.ready(function() {
//
console.log('ready')
that.setWxProjectShare(wx)
})
})
},
/**
* 微信分享
*/
setWxProjectShare(wx) {
let {shareImg, shareTitle, shareDesc} = this.userProjectSetting
wx.updateAppMessageShareData({
title: shareTitle || defaultValue.projectShareTitle, //
desc: shareDesc || defaultValue.projectShareDesc, //
link: window.location.href, // JS
imgUrl: shareImg || defaultValue.projectShareImg, //
success: function() {
//
console.log('succcess')
},
fail: function() {
console.log('fail')
}
})
wx.updateTimelineShareData({
title: shareTitle || defaultValue.projectShareTitle, //
desc: shareDesc || defaultValue.projectShareDesc, //
link: window.location.href, // JS
imgUrl: shareImg || defaultValue.projectShareImg, //
success: function() {
//
console.log('succcess')
},
fail: function() {
console.log('fail')
}
})
wx.onMenuShareTimeline({
title: shareTitle || defaultValue.projectShareTitle, //
desc: shareDesc || defaultValue.projectShareDesc, //
link: window.location.href, // JS
imgUrl: shareImg || defaultValue.projectShareImg, //
success: function() {
//
console.log('succcess')
}
})
wx.onMenuShareAppMessage({
title: shareTitle || defaultValue.projectShareTitle, //
desc: shareDesc || defaultValue.projectShareDesc, //
link: window.location.href, // JS
imgUrl: shareImg || defaultValue.projectShareImg, //
success: function() {
//
console.log('succcess')
}
})
getWxAuthorizationUrl () {
// url
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/wx/jsapi/authorization/url`, { params: { url: window.location.href } }).then(res => {
if (res.data) {
this.wxAuthorizationUrl = res.data
}
})
},
setWxConfig () {
let that = this
let signature = this.wxSignature
loadWXJs(wx => {
wx.config({
debug: false, // ,apialertpclogpc
appId: signature.appId, //
timestamp: signature.timestamp, //
nonceStr: signature.nonceStr, //
signature: signature.signature, //
jsApiList: [
'updateAppMessageShareData',
'updateTimelineShareData',
'onMenuShareAppMessage',
'onMenuShareTimeline',
'showMenuItems',
'hideMenuItems',
'chooseWXPay'
] // 使JS
})
// sdk
wx.ready(function () {
//
console.log('ready')
that.setWxProjectShare(wx)
})
})
},
/**
* 微信分享
*/
setWxProjectShare (wx) {
let { shareImg, shareTitle, shareDesc } = this.userProjectSetting
wx.updateAppMessageShareData({
title: shareTitle || defaultValue.projectShareTitle, //
desc: shareDesc || defaultValue.projectShareDesc, //
link: window.location.href, // JS
imgUrl: shareImg || defaultValue.projectShareImg, //
success: function () {
//
console.log('succcess')
},
queryProjectSetting() {
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/setting/${this.projectConfig.projectKey}`).then(res => {
if (res.data) {
this.userProjectSetting = res.data
//
if (res.data && res.data.wxWrite) {
//
if (res.data.recordWxUser && !this.wxAuthorizationCode) {
location.href = this.wxAuthorizationUrl
} else {
this.onlyWxOpenHandle()
}
}
}
})
fail: function () {
console.log('fail')
}
})
wx.updateTimelineShareData({
title: shareTitle || defaultValue.projectShareTitle, //
desc: shareDesc || defaultValue.projectShareDesc, //
link: window.location.href, // JS
imgUrl: shareImg || defaultValue.projectShareImg, //
success: function () {
//
console.log('succcess')
},
/**
* 仅在微信打开
*/
onlyWxOpenHandle() {
let wxUa = navigator.userAgent.toLowerCase()
let isWeixin = wxUa.indexOf('micromessenger') != -1
if (!isWeixin) {
document.head.innerHTML = '<title>抱歉,出错了</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0"><link rel="stylesheet" type="text/css" href="https://res.wx.qq.com/open/libs/weui/0.4.1/weui.css">'
document.body.innerHTML = '<div class="weui_msg"><div class="weui_icon_area"><i class="weui_icon_info weui_icon_msg"></i></div><div class="weui_text_area"><h4 class="weui_msg_title">请在微信客户端打开链接</h4></div></div>'
fail: function () {
console.log('fail')
}
})
wx.onMenuShareTimeline({
title: shareTitle || defaultValue.projectShareTitle, //
desc: shareDesc || defaultValue.projectShareDesc, //
link: window.location.href, // JS
imgUrl: shareImg || defaultValue.projectShareImg, //
success: function () {
//
console.log('succcess')
}
})
wx.onMenuShareAppMessage({
title: shareTitle || defaultValue.projectShareTitle, //
desc: shareDesc || defaultValue.projectShareDesc, //
link: window.location.href, // JS
imgUrl: shareImg || defaultValue.projectShareImg, //
success: function () {
//
console.log('succcess')
}
})
},
queryProjectSetting () {
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/setting/${this.projectConfig.projectKey}`).then(res => {
if (res.data) {
this.userProjectSetting = res.data
//
if (res.data && res.data.wxWrite) {
//
if (res.data.recordWxUser && !this.wxAuthorizationCode) {
location.href = this.wxAuthorizationUrl
} else {
this.onlyWxOpenHandle()
}
},
openPublicResultHandle() {
let projectKey = this.projectConfig.projectKey
this.$router.replace({path: '/project/public/result', query: {projectKey}})
},
submitForm(data) {
//
let inActiveTime = document.getElementById('inActiveTime').innerText
this.$api.post(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/create`, {
'completeTime': inActiveTime,
'projectKey': this.projectConfig.projectKey,
'submitOs': ua.os.name,
'submitBrowser': ua.browser.name,
'submitUa': ua,
'wxUserInfo': this.wxUserInfo,
'wxOpenId': this.wxUserInfo ? this.wxUserInfo.openid : '',
'originalData': data.formModel,
'processData': data.labelFormModel
}).then(() => {
this.writeStatus = 2
if (this.userProjectSetting.submitJumpUrl) {
setTimeout(() => {
window.location.replace(this.userProjectSetting.submitJumpUrl)
}, 1000)
}
})
}
}
})
},
/**
* 仅在微信打开
*/
onlyWxOpenHandle () {
let wxUa = navigator.userAgent.toLowerCase()
let isWeixin = wxUa.indexOf('micromessenger') != -1
if (!isWeixin) {
document.head.innerHTML = '<title>抱歉,出错了</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0"><link rel="stylesheet" type="text/css" href="https://res.wx.qq.com/open/libs/weui/0.4.1/weui.css">'
document.body.innerHTML = '<div class="weui_msg"><div class="weui_icon_area"><i class="weui_icon_info weui_icon_msg"></i></div><div class="weui_text_area"><h4 class="weui_msg_title">请在微信客户端打开链接</h4></div></div>'
}
},
openPublicResultHandle () {
let projectKey = this.projectConfig.projectKey
this.$router.replace({ path: '/project/public/result', query: { projectKey } })
},
submitForm (data) {
//
let inActiveTime = document.getElementById('inActiveTime').innerText
this.$api.post(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/create`, {
'completeTime': inActiveTime,
'projectKey': this.projectConfig.projectKey,
'submitOs': ua.os.name,
'submitBrowser': ua.browser.name,
'submitUa': ua,
'wxUserInfo': this.wxUserInfo,
'wxOpenId': this.wxUserInfo ? this.wxUserInfo.openid : '',
'originalData': data.formModel,
'processData': data.labelFormModel,
'clientType': this.clientType,//:gov:resi:oper
'orgId': this.orgId,//Id(agencyId;deptId;gridId)
'orgName': this.orgName,//---
'orgType': this.orgType,//(:agency;:dept;:grid)
'realName': this.realName,//
}).then(() => {
this.writeStatus = 2
if (this.userProjectSetting.submitJumpUrl) {
setTimeout(() => {
window.location.replace(this.userProjectSetting.submitJumpUrl)
}, 1000)
}
})
}
}
}
</script>

Loading…
Cancel
Save