index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. <template>
  2. <view class="content">
  3. <view class="header"></view>
  4. <view class="form">
  5. <view class="form_title">合作伙伴信息</view>
  6. <view class="form_item">
  7. <span class="icon">*</span>
  8. 姓名
  9. <uni-easyinput placeholder="请输入姓名" v-model="name"></uni-easyinput>
  10. </view>
  11. <view class="form_item">
  12. <span class="icon">*</span>
  13. 手机号
  14. <uni-easyinput type="number" placeholder="请输入手机号" v-model="phone"></uni-easyinput>
  15. </view>
  16. <view class="form_item">
  17. <span class="icon">*</span>
  18. 单位名称
  19. <uni-easyinput placeholder="请输入单位名称" v-model="company"></uni-easyinput>
  20. </view>
  21. <view class="form_title">项目信息登记</view>
  22. <view class="form_item">
  23. <span class="icon">*</span>
  24. 客户名称
  25. <uni-easyinput placeholder="请输入客户名称" v-model="clientName"></uni-easyinput>
  26. </view>
  27. <view class="form_item">
  28. <span class="icon">*</span>
  29. 项目名称
  30. <uni-easyinput placeholder="请输入项目名称" v-model="projectName"></uni-easyinput>
  31. </view>
  32. <view class="form_item">
  33. <span class="icon">*</span>
  34. 项目金额(万元)
  35. <uni-easyinput type="number" placeholder="请输入项目金额" v-model="projectAmount"></uni-easyinput>
  36. </view>
  37. <view class="form_item">
  38. <span class="icon">*</span>
  39. 预计投标时间
  40. <picker mode="date" fields="month" :start="getCurrentDate()" :value="biddingTime" @change="bindDateChange">
  41. <uni-easyinput disabled placeholder="请选择预计投标时间" suffixIcon="calendar-filled" v-model="biddingTime"></uni-easyinput>
  42. </picker>
  43. </view>
  44. <view class="form_item">
  45. <span class="icon">*</span>
  46. 所属行业
  47. <uni-data-select placeholder="请选择所属行业" v-model="industry" :localdata="range"></uni-data-select>
  48. </view>
  49. <view class="form_item">
  50. <span class="icon">*</span>
  51. 是否授权
  52. <uni-data-select placeholder="请选择是否授权" v-model="isAzt" :localdata="range_azt"></uni-data-select>
  53. </view>
  54. <view class="form_item">
  55. <span class="icon">*</span>
  56. 产品类型(多选)
  57. <uni-data-checkbox multiple v-model="productType" :localdata="hobby"></uni-data-checkbox>
  58. </view>
  59. <view class="form_item">
  60. 项目基本情况
  61. <uni-easyinput type="textarea" :maxlength="-1" placeholder="建议填写竞争情况 , 客户情况" v-model="projectInformation"></uni-easyinput>
  62. </view>
  63. <view class="form_item">
  64. 加入的控标参数
  65. <uni-easyinput type="textarea" :maxlength="-1" placeholder="建议填写加入的控标参数情况" v-model="projectParams"></uni-easyinput>
  66. </view>
  67. <view class="form_item">
  68. 附件材料(建议上传项目相关信息或清单图片)
  69. <uni-file-picker
  70. ref="filePicker"
  71. limit="3"
  72. title="最多上传3张图片"
  73. :value="projectImgList"
  74. fileMediatype="image"
  75. :image-styles="imageStyles"
  76. mode="grid"
  77. @select="select"
  78. @delete="handleDelete"
  79. ></uni-file-picker>
  80. </view>
  81. <button class="form_button" @click="handleSubmit">提交</button>
  82. <view class="footer">本系统由新华三江西代表处提供技术支持</view>
  83. </view>
  84. </view>
  85. <!-- 提交成功弹窗区域 -->
  86. <uni-popup ref="popup" type="center" :is-mask-click="false">
  87. <view class="popup_body">
  88. <img class="img" mode="aspectFill" src="../../static/success.png" />
  89. <view class="popup_text">提交成功</view>
  90. <view class="popup_btn" @click="handleSubscribe">我知道了</view>
  91. </view>
  92. </uni-popup>
  93. <!-- 用于图片压缩的canvas画布 -->
  94. <canvas
  95. :style="{
  96. width: cw + 'px',
  97. height: cw + 'px',
  98. position: 'absolute',
  99. zIndex: -1,
  100. left: '-10000rpx',
  101. top: '-10000rpx'
  102. }"
  103. canvas-id="zipCanvas"
  104. ></canvas>
  105. <!--画布结束-->
  106. </template>
  107. <script setup>
  108. import { ref, onMounted } from 'vue'
  109. import { myRequest } from '@/util/api.js'
  110. // 图片压缩方法
  111. import getLessLimitSizeImage from '@/util/imageCompress.js'
  112. onMounted(() => {
  113. const accredit = uni.getStorageSync('accredit')
  114. if (accredit) {
  115. submit()
  116. }
  117. })
  118. //画板边长默认是屏幕宽度,正方形画布
  119. const cw = uni.getSystemInfoSync().windowWidth
  120. // 用户姓名绑定数据
  121. const name = ref(uni.getStorageSync('form_name') || '')
  122. // 用户手机号绑定数据
  123. const phone = ref(uni.getStorageSync('form_phone') || '')
  124. // 用户单位绑定数据
  125. const company = ref(uni.getStorageSync('form_company') || '')
  126. // 客户名称
  127. const clientName = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).clientName : '')
  128. // 项目名称
  129. const projectName = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).projectName : '')
  130. // 项目金额
  131. const projectAmount = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).projectAmount : '')
  132. // 预计投标时间
  133. const biddingTime = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).biddingTime : '')
  134. // 所属行业
  135. const industry = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).industry : '')
  136. // 是否授权
  137. const isAzt = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).isAzt : '')
  138. // 产品类型
  139. const productType = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).productType : [])
  140. // 项目基本情况
  141. const projectInformation = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).projectInformation : '')
  142. // 加入的控标参数
  143. const projectParams = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).projectParams : '')
  144. // 显示的图片数据
  145. const projectImgList = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).projectImgList : [])
  146. // 上传的图片数据
  147. const subImgList = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).subImgList : [])
  148. // 微信手机号码绑定数据
  149. const wxPhone = ref(uni.getStorageSync('wxPhone') || '')
  150. // 所属行业数组数据
  151. const range = ref([
  152. {
  153. value: 0,
  154. text: '政府'
  155. },
  156. {
  157. value: 1,
  158. text: '教育'
  159. },
  160. {
  161. value: 2,
  162. text: '医疗'
  163. },
  164. {
  165. value: 3,
  166. text: '企业'
  167. },
  168. {
  169. value: 4,
  170. text: '公检法'
  171. },
  172. {
  173. value: 5,
  174. text: '交通'
  175. },
  176. {
  177. value: 6,
  178. text: '分销&SMB'
  179. },
  180. {
  181. value: 7,
  182. text: '其他'
  183. }
  184. ])
  185. const range_azt = ref([
  186. {
  187. value: 0,
  188. text: '是'
  189. },
  190. {
  191. value: 1,
  192. text: '否'
  193. }
  194. ])
  195. // 产品类型数组
  196. const hobby = ref([
  197. {
  198. text: '网络',
  199. value: 0
  200. },
  201. {
  202. text: '安全',
  203. value: 1
  204. },
  205. {
  206. text: 'IT',
  207. value: 2
  208. },
  209. {
  210. text: '云智',
  211. value: 3
  212. },
  213. {
  214. text: 'PC',
  215. value: 4
  216. },
  217. {
  218. text: 'AI视觉',
  219. value: 5
  220. }
  221. ])
  222. // 图片上传框的样式
  223. const imageStyles = {
  224. width: 75,
  225. height: 75,
  226. border: {
  227. color: '#ccc',
  228. width: 1,
  229. style: 'dashed',
  230. radius: '5px'
  231. }
  232. }
  233. // 上传组件元素
  234. const filePicker = ref(null)
  235. // 提交成功弹窗元素
  236. const popup = ref(null)
  237. // 模版id
  238. const templateOrder = ref('I3o8CRAiaaNbug3Ukkmv1t-pCIbzxU8OicqMWvdR9lc')
  239. // 点击弹窗 我知道了 按钮回调
  240. const handleSubscribe = () => {
  241. popup.value.close()
  242. // 订阅消息
  243. uni.getSetting({
  244. withSubscriptions: true,
  245. success: (res) => {
  246. // console.log(res)
  247. if (res.subscriptionsSetting[templateOrder.value] !== 'reject') {
  248. uni.requestSubscribeMessage({
  249. tmplIds: [templateOrder.value],
  250. success: (res) => {
  251. // console.log(res)
  252. if (res[templateOrder.value] !== 'reject') {
  253. console.log('成功')
  254. // uni.showToast({
  255. // title:"订阅成功",
  256. // icon:'success'
  257. // })
  258. } else {
  259. console.log('拒绝2')
  260. // uni.showToast({
  261. // title:"订阅失败",
  262. // icon:'fail'
  263. // })
  264. }
  265. },
  266. fail(err) {
  267. console.log(err)
  268. console.log('调用失败')
  269. }
  270. })
  271. } else {
  272. uni.showModal({
  273. content: '当前没有订阅,是否去设置打开?',
  274. confirmText: '确认',
  275. cancelText: '取消',
  276. success: (res) => {
  277. if (res.confirm) {
  278. uni.openSetting({
  279. success: (res) => {}
  280. })
  281. } else {
  282. }
  283. }
  284. })
  285. }
  286. }
  287. })
  288. }
  289. // 日期选择框绑定回调
  290. const bindDateChange = (e) => {
  291. const val = e.detail.value
  292. biddingTime.value = val
  293. }
  294. // 提交按钮回调
  295. const handleSubmit = () => {
  296. const flag = handleValidate()
  297. if (flag) {
  298. uni.setStorageSync('form_name', name.value)
  299. uni.setStorageSync('form_phone', phone.value)
  300. uni.setStorageSync('form_company', company.value)
  301. const formContent = {
  302. clientName: clientName.value,
  303. projectName: projectName.value,
  304. projectAmount: projectAmount.value,
  305. biddingTime: biddingTime.value,
  306. industry: industry.value,
  307. isAzt: isAzt.value,
  308. productType: productType.value,
  309. projectInformation: projectInformation.value,
  310. projectParams: projectParams.value,
  311. projectImgList: projectImgList.value,
  312. subImgList: subImgList.value
  313. }
  314. uni.setStorageSync('form_content', JSON.stringify(formContent))
  315. if (!wxPhone.value) {
  316. uni.showModal({
  317. title: '提示',
  318. content: '本次操作需要获取您的手机号码',
  319. success: (res) => {
  320. if (res.confirm) {
  321. uni.navigateTo({
  322. url: '/pages/authorization/authorization'
  323. })
  324. } else if (res.cancel) {
  325. }
  326. }
  327. })
  328. } else {
  329. uni.showModal({
  330. title: '提示',
  331. content: '确认提交吗',
  332. success: (res) => {
  333. if (res.confirm) {
  334. submit()
  335. } else if (res.cancel) {
  336. }
  337. }
  338. })
  339. }
  340. }
  341. }
  342. // 验证表格信息是否符合规范
  343. const handleValidate = () => {
  344. const reName = /^[\u4e00-\u9fa5]{2,4}$/
  345. const rePhone = /^[1][3,4,5,7,8,9][0-9]{9}$/
  346. const reProjectAmount = /^[+]?([0-9]+(?:[.][0-9]*)?|\.[0-9]+)$/
  347. if (name.value == '') {
  348. uni.showToast({
  349. title: '请输入姓名',
  350. icon: 'none'
  351. })
  352. return false
  353. }
  354. if (!reName.test(name.value)) {
  355. uni.showToast({
  356. title: '姓名格式有误',
  357. icon: 'none'
  358. })
  359. return false
  360. }
  361. if (phone.value == '') {
  362. uni.showToast({
  363. title: '请输入手机号',
  364. icon: 'none'
  365. })
  366. return false
  367. }
  368. if (!rePhone.test(phone.value)) {
  369. uni.showToast({
  370. title: '手机格式有误',
  371. icon: 'none'
  372. })
  373. return false
  374. }
  375. if (company.value == '') {
  376. uni.showToast({
  377. title: '请输入单位名称',
  378. icon: 'none'
  379. })
  380. return false
  381. }
  382. if (clientName.value == '') {
  383. uni.showToast({
  384. title: '请输入客户名称',
  385. icon: 'none'
  386. })
  387. return false
  388. }
  389. if (projectName.value == '') {
  390. uni.showToast({
  391. title: '请输入项目名称',
  392. icon: 'none'
  393. })
  394. return false
  395. }
  396. if (projectAmount.value == '') {
  397. uni.showToast({
  398. title: '请输入项目金额',
  399. icon: 'none'
  400. })
  401. return false
  402. }
  403. if (!reProjectAmount.test(projectAmount.value)) {
  404. uni.showToast({
  405. title: '项目金额请输入正数',
  406. icon: 'none'
  407. })
  408. return false
  409. }
  410. if (biddingTime.value == '') {
  411. uni.showToast({
  412. title: '请选择预计投标时间',
  413. icon: 'none'
  414. })
  415. return false
  416. }
  417. if (industry.value === '') {
  418. uni.showToast({
  419. title: '请选择所属行业',
  420. icon: 'none'
  421. })
  422. return false
  423. }
  424. if (isAzt.value === '') {
  425. uni.showToast({
  426. title: '请选择是否授权',
  427. icon: 'none'
  428. })
  429. return false
  430. }
  431. if (productType.value.length == 0) {
  432. uni.showToast({
  433. title: '请选择产品类型',
  434. icon: 'none'
  435. })
  436. return false
  437. }
  438. return true
  439. }
  440. // 请求提交接口回调
  441. const submit = async () => {
  442. const bProduct = []
  443. productType.value.forEach((item) => {
  444. bProduct.push(hobby.value[item].text)
  445. })
  446. const res = await myRequest({
  447. url: '/informationReporting/add',
  448. method: 'post',
  449. data: {
  450. name: name.value,
  451. phone: phone.value,
  452. company: company.value,
  453. customerName: clientName.value,
  454. entryName: projectName.value,
  455. projectAmount: projectAmount.value,
  456. tenderTime: biddingTime.value,
  457. content: projectInformation.value,
  458. trade: range.value[industry.value].text,
  459. bProduct,
  460. wxPhone: wxPhone.value,
  461. bFile: subImgList.value
  462. }
  463. })
  464. // console.log(res)
  465. if (res.success && res.code == 1) {
  466. // uni.showToast({
  467. // title: '提交成功',
  468. // duration: 3000
  469. // })
  470. popup.value.open()
  471. clientName.value = ''
  472. projectName.value = ''
  473. projectAmount.value = ''
  474. biddingTime.value = ''
  475. industry.value = ''
  476. isAzt.value = ''
  477. productType.value = []
  478. projectInformation.value = ''
  479. projectParams.value = ''
  480. subImgList.value = []
  481. projectImgList.value = []
  482. filePicker.value.clearFiles()
  483. uni.removeStorageSync('form_content')
  484. uni.setStorageSync('accredit', false)
  485. } else {
  486. uni.showToast({
  487. title: res.message,
  488. icon: 'error'
  489. })
  490. }
  491. }
  492. // 获取当前时间 YY-MM-DD
  493. const getCurrentDate = () => {
  494. const date = new Date()
  495. let year = date.getFullYear()
  496. let month = date.getMonth() + 1
  497. let day = date.getDate()
  498. month = month > 9 ? month : '0' + month
  499. day = day > 9 ? day : '0' + day
  500. return `${year}-${month}-${day}`
  501. }
  502. // 选择图片回调
  503. const select = (e) => {
  504. // console.log(e);
  505. e.tempFiles.forEach((item) => {
  506. //这里的id和页面中写的html代码的canvas的id要一致
  507. let canvasId = 'zipCanvas'
  508. //原图的路径
  509. let imagePath = item.path
  510. //大小限制1024kb
  511. let limitSize = 1024
  512. //初始绘画区域是画布自身的宽度也就是屏幕宽度
  513. let drawWidth = uni.getSystemInfoSync().windowWidth
  514. getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, (resPath) => {
  515. uni.showLoading({
  516. title: '上传中'
  517. })
  518. uni.uploadFile({
  519. url: `https://jiangxih3cpartner.com/reporting/file/fileUpDown`,
  520. filePath: resPath,
  521. name: 'file',
  522. success: (uploadFileRes) => {
  523. subImgList.value.push(JSON.parse(uploadFileRes.data).data.join())
  524. projectImgList.value.push({
  525. url: item.path,
  526. name: ''
  527. })
  528. uni.hideLoading()
  529. },
  530. fail: () => {
  531. uni.showToast({
  532. title: '上传失败',
  533. icon: 'error'
  534. })
  535. }
  536. })
  537. })
  538. })
  539. }
  540. // 删除图片回调
  541. const handleDelete = (e) => {
  542. // console.log(e);
  543. const num = projectImgList.value.findIndex((v) => v.url === e.tempFilePath)
  544. subImgList.value.splice(num, 1)
  545. projectImgList.value.splice(num, 1)
  546. }
  547. </script>
  548. <style lang="scss" scoped>
  549. .content {
  550. width: 100vw;
  551. .header {
  552. width: 750rpx;
  553. height: 300rpx;
  554. border-radius: 0 0 10% 10%;
  555. background-color: #1e7dfb;
  556. }
  557. .form {
  558. position: absolute;
  559. top: 42rpx;
  560. left: 30rpx;
  561. right: 30rpx;
  562. padding: 0 32rpx;
  563. border-radius: 10rpx;
  564. background-color: #fff;
  565. .form_title {
  566. line-height: 105rpx;
  567. font-weight: bold;
  568. font-size: 34rpx;
  569. }
  570. .form_item {
  571. margin-bottom: 20rpx;
  572. font-size: 28rpx;
  573. .icon {
  574. color: #d43030;
  575. }
  576. :deep .uni-easyinput {
  577. margin-top: 10rpx;
  578. background-color: #f2f2f2;
  579. }
  580. :deep .uni-stat__select {
  581. margin-top: 10rpx;
  582. background-color: #f2f2f2;
  583. }
  584. :deep .uni-data-checklist {
  585. margin-top: 10rpx !important;
  586. background-color: #f2f2f2;
  587. }
  588. }
  589. .form_button {
  590. margin-top: 65rpx;
  591. background-color: #1e7dfb;
  592. color: #fff;
  593. font-size: 28rpx;
  594. }
  595. .footer {
  596. margin: 70rpx 0;
  597. text-align: center;
  598. font-size: 24rpx;
  599. color: #999999;
  600. }
  601. }
  602. }
  603. .popup_body {
  604. display: flex;
  605. flex-direction: column;
  606. align-items: center;
  607. width: 480rpx;
  608. height: 400rpx;
  609. border-radius: 22rpx;
  610. background-color: #fff;
  611. .img {
  612. margin-top: 50rpx;
  613. width: 98rpx;
  614. height: 98rpx;
  615. }
  616. .popup_text {
  617. margin-top: 20rpx;
  618. color: #0f194d;
  619. font-size: 28rpx;
  620. }
  621. .popup_btn {
  622. display: flex;
  623. justify-content: center;
  624. align-items: center;
  625. margin-top: 50rpx;
  626. width: 220rpx;
  627. height: 76rpx;
  628. color: #fff;
  629. font-size: 25rpx;
  630. border-radius: 43rpx;
  631. background: linear-gradient(90deg, #1e7dfb 0%, #1b75eb 100%);
  632. }
  633. }
  634. </style>