index.vue 16 KB

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