| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730 |
- <template>
- <view class="content">
- <view class="header"></view>
- <view class="form">
- <view class="form_title">合作伙伴信息</view>
- <view class="form_item">
- <span class="icon">*</span>
- 姓名
- <uni-easyinput placeholder="请输入姓名" v-model="name"></uni-easyinput>
- </view>
- <view class="form_item">
- <span class="icon">*</span>
- 手机号
- <uni-easyinput type="number" placeholder="请输入手机号" v-model="phone"></uni-easyinput>
- </view>
- <view class="form_item">
- <span class="icon">*</span>
- 单位名称
- <uni-easyinput placeholder="请输入单位名称" v-model="company"></uni-easyinput>
- </view>
- <view class="form_title">项目信息登记</view>
- <view class="form_item">
- <span class="icon">*</span>
- 客户名称
- <uni-easyinput placeholder="请输入客户名称" v-model="clientName"></uni-easyinput>
- </view>
- <view class="form_item">
- <span class="icon">*</span>
- 项目名称
- <uni-easyinput placeholder="请输入项目名称" :maxlength="32" v-model="projectName"></uni-easyinput>
- </view>
- <view class="form_item">
- <span class="icon">*</span>
- 项目金额(万元)
- <uni-easyinput type="number" placeholder="请输入项目金额" v-model="projectAmount"></uni-easyinput>
- </view>
- <view class="form_item">
- <span class="icon">*</span>
- 预计投标时间
- <picker mode="date" fields="month" :start="getCurrentDate()" :value="biddingTime" @change="bindDateChange">
- <uni-easyinput disabled placeholder="请选择预计投标时间" suffixIcon="calendar-filled" v-model="biddingTime"></uni-easyinput>
- </picker>
- </view>
- <view class="form_item">
- <span class="icon">*</span>
- 所属行业
- <uni-data-select placeholder="请选择所属行业" v-model="industry" :localdata="range"></uni-data-select>
- </view>
- <view class="form_item">
- <span class="icon">*</span>
- 是否授权
- <uni-data-select placeholder="请选择是否授权" v-model="isAzt" :localdata="range_azt"></uni-data-select>
- </view>
- <view class="form_item">
- <span class="icon">*</span>
- 产品类型(多选)
- <uni-data-checkbox multiple v-model="productType" :localdata="hobby"></uni-data-checkbox>
- </view>
- <view class="form_item">
- 项目基本情况
- <uni-easyinput type="textarea" :maxlength="-1" placeholder="建议填写竞争情况 , 客户情况" v-model="projectInformation"></uni-easyinput>
- </view>
- <view class="form_item">
- 加入的控标参数
- <uni-easyinput type="textarea" :maxlength="-1" placeholder="建议填写加入的控标参数情况" v-model="projectParams"></uni-easyinput>
- </view>
- <view class="form_item">
- 附件材料(建议上传项目相关信息或清单图片)
- <uni-file-picker
- ref="filePicker"
- limit="3"
- title="最多上传3张图片"
- :value="projectImgList"
- fileMediatype="image"
- :image-styles="imageStyles"
- mode="grid"
- @select="select"
- @delete="handleDelete"
- ></uni-file-picker>
- </view>
- <button class="form_button" @click="handleSubmit">提交</button>
- <view class="footer">本系统由新华三江西代表处提供技术支持</view>
- </view>
- </view>
- <!-- 提交成功弹窗区域 -->
- <uni-popup ref="popup" type="center" :is-mask-click="false">
- <view class="popup_body">
- <img class="img" mode="aspectFill" src="../../static/success.png" />
- <view class="popup_text">提交成功</view>
- <view class="popup_btn" @click="handleSubscribe">我知道了</view>
- </view>
- </uni-popup>
- <!-- 用于图片压缩的canvas画布 -->
- <canvas
- :style="{
- width: cw + 'px',
- height: cw + 'px',
- position: 'absolute',
- zIndex: -1,
- left: '-10000rpx',
- top: '-10000rpx'
- }"
- canvas-id="zipCanvas"
- ></canvas>
- <!--画布结束-->
- </template>
- <script setup>
- import { ref, onMounted } from 'vue'
- import { myRequest } from '@/util/api.js'
- // 图片压缩方法
- import getLessLimitSizeImage from '@/util/imageCompress.js'
- onMounted(() => {
- const accredit = uni.getStorageSync('accredit')
- if (accredit) {
- uni.login({
- //使用微信登录
- provider: 'weixin',
- success: (res) => {
- submit(res.code)
- }
- })
- }
- })
- //画板边长默认是屏幕宽度,正方形画布
- const cw = uni.getWindowInfo().windowWidth
- // 用户姓名绑定数据
- const name = ref(uni.getStorageSync('form_name') || '')
- // 用户手机号绑定数据
- const phone = ref(uni.getStorageSync('form_phone') || '')
- // 用户单位绑定数据
- const company = ref(uni.getStorageSync('form_company') || '')
- // 客户名称
- const clientName = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).clientName : '')
- // 项目名称
- const projectName = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).projectName : '')
- // 项目金额
- const projectAmount = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).projectAmount : '')
- // 预计投标时间
- const biddingTime = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).biddingTime : '')
- // 所属行业
- const industry = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).industry : '')
- // 是否授权
- const isAzt = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).isAzt : '')
- // 产品类型
- const productType = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).productType : [])
- // 项目基本情况
- const projectInformation = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).projectInformation : '')
- // 加入的控标参数
- const projectParams = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).projectParams : '')
- // 显示的图片数据
- const projectImgList = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).projectImgList : [])
- // 上传的图片数据
- const subImgList = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).subImgList : [])
- // 微信手机号码绑定数据
- const wxPhone = ref(uni.getStorageSync('wxPhone') || '')
- // 所属行业数组数据
- const range = ref([
- {
- value: 0,
- text: '政府'
- },
- {
- value: 1,
- text: '教育'
- },
- {
- value: 2,
- text: '医疗'
- },
- {
- value: 3,
- text: '企业'
- },
- {
- value: 4,
- text: '公检法'
- },
- {
- value: 5,
- text: '交通'
- },
- {
- value: 6,
- text: '分销&SMB'
- },
- {
- value: 7,
- text: '其他'
- }
- ])
- const range_azt = ref([
- {
- value: 0,
- text: '是'
- },
- {
- value: 1,
- text: '否'
- }
- ])
- // 产品类型数组
- const hobby = ref([
- {
- text: '网络',
- value: 0
- },
- {
- text: '安全',
- value: 1
- },
- {
- text: 'IT',
- value: 2
- },
- {
- text: '云智',
- value: 3
- },
- {
- text: 'PC',
- value: 4
- },
- {
- text: 'AI视觉',
- value: 5
- }
- ])
- // 图片上传框的样式
- const imageStyles = {
- width: 75,
- height: 75,
- border: {
- color: '#ccc',
- width: 1,
- style: 'dashed',
- radius: '5px'
- }
- }
- // 上传组件元素
- const filePicker = ref(null)
- // 提交成功弹窗元素
- const popup = ref(null)
- // 模版id
- const templateOrder = ref('I3o8CRAiaaNbug3Ukkmv1o3S7l1FZlAKMUAJzIJ4zhs')
- // 点击弹窗 我知道了 按钮回调
- const handleSubscribe = () => {
- popup.value.close()
- // 订阅消息
- uni.getSetting({
- withSubscriptions: true,
- success: (res) => {
- console.log(res)
- if (res.subscriptionsSetting.mainSwitch) {
- uni.requestSubscribeMessage({
- tmplIds: [templateOrder.value],
- success: (res) => {
- console.log(res)
- if (res[templateOrder.value] !== 'reject') {
- console.log('成功')
- // uni.showToast({
- // title:"订阅成功",
- // icon:'success'
- // })
- } else {
- console.log('拒绝2')
- // uni.showToast({
- // title:"订阅失败",
- // icon:'fail'
- // })
- uni.showModal({
- content: '当前没有订阅,是否去设置打开?',
- confirmText: '确认',
- cancelText: '取消',
- success: (res) => {
- if (res.confirm) {
- uni.openSetting({
- success: (res) => {}
- })
- } else {
- }
- }
- })
- }
- },
- fail(err) {
- console.log(err)
- console.log('调用失败')
- }
- })
- } else {
- uni.showModal({
- content: '当前订阅总开关关闭,是否去设置打开?',
- confirmText: '确认',
- cancelText: '取消',
- success: (res) => {
- if (res.confirm) {
- uni.openSetting({
- success: (res) => {}
- })
- } else {
- }
- }
- })
- }
- }
- })
- }
- // 日期选择框绑定回调
- const bindDateChange = (e) => {
- const val = e.detail.value
- biddingTime.value = val
- }
- // 提交按钮回调
- const handleSubmit = () => {
- const flag = handleValidate()
- if (flag) {
- uni.setStorageSync('form_name', name.value)
- uni.setStorageSync('form_phone', phone.value)
- uni.setStorageSync('form_company', company.value)
- const formContent = {
- clientName: clientName.value,
- projectName: projectName.value,
- projectAmount: projectAmount.value,
- biddingTime: biddingTime.value,
- industry: industry.value,
- isAzt: isAzt.value,
- productType: productType.value,
- projectInformation: projectInformation.value,
- projectParams: projectParams.value,
- projectImgList: projectImgList.value,
- subImgList: subImgList.value
- }
- uni.setStorageSync('form_content', JSON.stringify(formContent))
- if (!wxPhone.value) {
- uni.showModal({
- title: '提示',
- content: '本次操作需要获取您的手机号码',
- success: (res) => {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/authorization/authorization'
- })
- } else if (res.cancel) {
- }
- }
- })
- } else {
- uni.showModal({
- title: '提示',
- content: '确认提交吗',
- success: (res) => {
- if (res.confirm) {
- uni.login({
- //使用微信登录
- provider: 'weixin',
- success: (res) => {
- submit(res.code)
- }
- })
- } else if (res.cancel) {
- }
- }
- })
- }
- }
- }
- // 验证表格信息是否符合规范
- const handleValidate = () => {
- const reName = /^[\u4e00-\u9fa5]{2,4}$/
- const rePhone = /^1[3-9]\d{9}$/
- const reProjectAmount = /^[+]?([0-9]+(?:[.][0-9]*)?|\.[0-9]+)$/
- if (name.value == '') {
- uni.showToast({
- title: '请输入姓名',
- icon: 'none'
- })
- return false
- }
- if (!reName.test(name.value)) {
- uni.showToast({
- title: '姓名格式有误',
- icon: 'none'
- })
- return false
- }
- if (phone.value == '') {
- uni.showToast({
- title: '请输入手机号',
- icon: 'none'
- })
- return false
- }
- if (!rePhone.test(phone.value)) {
- uni.showToast({
- title: '手机格式有误',
- icon: 'none'
- })
- return false
- }
- if (company.value == '') {
- uni.showToast({
- title: '请输入单位名称',
- icon: 'none'
- })
- return false
- }
- if (clientName.value == '') {
- uni.showToast({
- title: '请输入客户名称',
- icon: 'none'
- })
- return false
- }
- if (projectName.value == '') {
- uni.showToast({
- title: '请输入项目名称',
- icon: 'none'
- })
- return false
- }
- if (projectAmount.value == '') {
- uni.showToast({
- title: '请输入项目金额',
- icon: 'none'
- })
- return false
- }
- if (!reProjectAmount.test(projectAmount.value)) {
- uni.showToast({
- title: '项目金额请输入正数',
- icon: 'none'
- })
- return false
- }
- if (biddingTime.value == '') {
- uni.showToast({
- title: '请选择预计投标时间',
- icon: 'none'
- })
- return false
- }
- if (industry.value === '') {
- uni.showToast({
- title: '请选择所属行业',
- icon: 'none'
- })
- return false
- }
- if (isAzt.value === '') {
- uni.showToast({
- title: '请选择是否授权',
- icon: 'none'
- })
- return false
- }
- if (productType.value.length == 0) {
- uni.showToast({
- title: '请选择产品类型',
- icon: 'none'
- })
- return false
- }
- return true
- }
- // 请求提交接口回调
- const submit = async (code) => {
- const bProduct = []
- productType.value.forEach((item) => {
- bProduct.push(hobby.value[item].text)
- })
- const res = await myRequest({
- url: '/informationReporting/add',
- method: 'post',
- data: {
- // 姓名
- name: name.value,
- // 手机号码
- phone: phone.value,
- // 单位名称
- company: company.value,
- // 客户名称
- customerName: clientName.value,
- // 项目名称
- entryName: projectName.value,
- // 项目金额
- projectAmount: projectAmount.value,
- // 预计投标时间
- tenderTime: biddingTime.value,
- // 项目基本情况
- content: projectInformation.value,
- // 所属行业
- trade: range.value[industry.value].text,
- // 产品类型
- bProduct,
- // 提交人手机号码
- wxPhone: wxPhone.value,
- // 附件材料
- bFile: subImgList.value,
- // 是否授权
- licensing: isAzt.value,
- // 加入的控标参数
- parameters: projectParams.value,
- code
- }
- })
- // console.log(res)
- if (res.success && res.code == 1) {
- // uni.showToast({
- // title: '提交成功',
- // duration: 3000
- // })
- popup.value.open()
- clientName.value = ''
- projectName.value = ''
- projectAmount.value = ''
- biddingTime.value = ''
- industry.value = ''
- isAzt.value = ''
- productType.value = []
- projectInformation.value = ''
- projectParams.value = ''
- subImgList.value = []
- projectImgList.value = []
- filePicker.value.clearFiles()
- uni.removeStorageSync('form_content')
- uni.setStorageSync('accredit', false)
- } else {
- uni.showToast({
- title: res.message,
- icon: 'error'
- })
- }
- }
- // 获取当前时间 YY-MM-DD
- const getCurrentDate = () => {
- const date = new Date()
- let year = date.getFullYear()
- let month = date.getMonth() + 1
- let day = date.getDate()
- month = month > 9 ? month : '0' + month
- day = day > 9 ? day : '0' + day
- return `${year}-${month}-${day}`
- }
- // 选择图片回调
- const select = (e) => {
- console.log(e)
- e.tempFiles.forEach((item) => {
- //这里的id和页面中写的html代码的canvas的id要一致
- let canvasId = 'zipCanvas'
- //原图的路径
- let imagePath = item.path
- //大小限制1024kb
- let limitSize = 1024
- //初始绘画区域是画布自身的宽度也就是屏幕宽度
- let drawWidth = uni.getWindowInfo().windowWidth
- getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, (resPath) => {
- uni.showLoading({
- title: '上传中'
- })
- uni.uploadFile({
- url: `https://jiangxih3cpartner.com/reporting/file/fileUpDown`,
- filePath: resPath,
- name: 'file',
- success: (uploadFileRes) => {
- subImgList.value.push(JSON.parse(uploadFileRes.data).data.join())
- projectImgList.value.push({
- url: item.path,
- name: ''
- })
- uni.hideLoading()
- },
- fail: () => {
- uni.showToast({
- title: '上传失败',
- icon: 'error'
- })
- }
- })
- })
- })
- }
- // 删除图片回调
- const handleDelete = (e) => {
- // console.log(e);
- const num = projectImgList.value.findIndex((v) => v.url === e.tempFilePath)
- subImgList.value.splice(num, 1)
- projectImgList.value.splice(num, 1)
- }
- </script>
- <style lang="scss" scoped>
- .content {
- width: 100vw;
- .header {
- width: 750rpx;
- height: 300rpx;
- border-radius: 0 0 10% 10%;
- background-color: #1e7dfb;
- }
- .form {
- position: absolute;
- top: 42rpx;
- left: 30rpx;
- right: 30rpx;
- padding: 0 32rpx;
- border-radius: 10rpx;
- background-color: #fff;
- .form_title {
- line-height: 105rpx;
- font-weight: bold;
- font-size: 34rpx;
- }
- .form_item {
- margin-bottom: 20rpx;
- font-size: 28rpx;
- .icon {
- color: #d43030;
- }
- :deep .uni-easyinput {
- margin-top: 10rpx;
- background-color: #f2f2f2;
- }
- :deep .uni-stat__select {
- margin-top: 10rpx;
- background-color: #f2f2f2;
- }
- :deep .uni-data-checklist {
- margin-top: 10rpx !important;
- background-color: #f2f2f2;
- }
- }
- .form_button {
- margin-top: 65rpx;
- background-color: #1e7dfb;
- color: #fff;
- font-size: 28rpx;
- }
- .footer {
- margin: 70rpx 0;
- text-align: center;
- font-size: 24rpx;
- color: #999999;
- }
- }
- }
- .popup_body {
- display: flex;
- flex-direction: column;
- align-items: center;
- width: 480rpx;
- height: 400rpx;
- border-radius: 22rpx;
- background-color: #fff;
- .img {
- margin-top: 50rpx;
- width: 98rpx;
- height: 98rpx;
- }
- .popup_text {
- margin-top: 20rpx;
- color: #0f194d;
- font-size: 28rpx;
- }
- .popup_btn {
- display: flex;
- justify-content: center;
- align-items: center;
- margin-top: 50rpx;
- width: 220rpx;
- height: 76rpx;
- color: #fff;
- font-size: 25rpx;
- border-radius: 43rpx;
- background: linear-gradient(90deg, #1e7dfb 0%, #1b75eb 100%);
- }
- }
- </style>
|