index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <template>
  2. <view class="content">
  3. <view class="header"></view>
  4. <view class="form">
  5. <view class="form_title">
  6. 合作伙伴信息
  7. </view>
  8. <view class="form_item">
  9. <span class="icon">*</span>姓名
  10. <uni-easyinput placeholder="请输入姓名" v-model="name"></uni-easyinput>
  11. </view>
  12. <view class="form_item">
  13. <span class="icon">*</span>手机号
  14. <uni-easyinput type="number" placeholder="请输入手机号" v-model="phone"></uni-easyinput>
  15. </view>
  16. <view class="form_item">
  17. <span class="icon">*</span>单位名称
  18. <uni-easyinput placeholder="请输入单位名称" v-model="company"></uni-easyinput>
  19. </view>
  20. <view class="form_title">
  21. 项目信息登记
  22. </view>
  23. <view class="form_item">
  24. <span class="icon">*</span>客户名称
  25. <uni-easyinput placeholder="请输入客户名称" v-model="clientName"></uni-easyinput>
  26. </view>
  27. <view class="form_item">
  28. <span class="icon">*</span>项目名称
  29. <uni-easyinput placeholder="请输入项目名称" v-model="projectName"></uni-easyinput>
  30. </view>
  31. <view class="form_item">
  32. <span class="icon">*</span>项目金额
  33. <uni-easyinput type="number" placeholder="请输入项目金额" v-model="projectAmount"></uni-easyinput>
  34. </view>
  35. <view class="form_item">
  36. <span class="icon">*</span>预计投标时间
  37. <picker mode="date" fields="month" :start="getCurrentDate()" :value="biddingTime" @change="bindDateChange">
  38. <uni-easyinput disabled placeholder="请选择预计投标时间" suffixIcon="calendar-filled" v-model="biddingTime">
  39. </uni-easyinput>
  40. </picker>
  41. </view>
  42. <view class="form_item">
  43. <span class="icon">*</span>所属行业
  44. <uni-data-select placeholder="请选择所属行业" v-model="industry" :localdata="range"></uni-data-select>
  45. </view>
  46. <view class="form_item">
  47. <span class="icon">*</span>产品类型(多选)
  48. <uni-data-checkbox multiple v-model="productType" :localdata="hobby"></uni-data-checkbox>
  49. </view>
  50. <view class="form_item">
  51. 项目基本情况
  52. <uni-easyinput type="textarea" :maxlength="-1" placeholder="建议填写竞争情况 , 客户情况"
  53. v-model="projectInformation">
  54. </uni-easyinput>
  55. </view>
  56. <button class="form_button" @click="handleSubmit">提交</button>
  57. <view class="footer">
  58. 本系统由新华三江西代表处提供技术支持
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. <script setup>
  64. import {
  65. ref,
  66. onMounted
  67. } from 'vue'
  68. import {
  69. myRequest
  70. } from "../../util/api.js"
  71. onMounted(() => {
  72. const accredit = uni.getStorageSync('accredit')
  73. if (accredit) {
  74. submit()
  75. }
  76. })
  77. // 用户姓名绑定数据
  78. const name = ref(uni.getStorageSync('form_name') || '')
  79. // 用户手机号绑定数据
  80. const phone = ref(uni.getStorageSync('form_phone') || '')
  81. // 用户单位绑定数据
  82. const company = ref(uni.getStorageSync('form_company') || '')
  83. // 客户名称
  84. const clientName = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).clientName :
  85. '')
  86. // 项目名称
  87. const projectName = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content'))
  88. .projectName : '')
  89. // 项目金额
  90. const projectAmount = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content'))
  91. .projectAmount : '')
  92. // 预计投标时间
  93. const biddingTime = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content'))
  94. .biddingTime : '')
  95. // 所属行业
  96. const industry = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).industry : '')
  97. // 产品类型
  98. const productType = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content'))
  99. .productType : [])
  100. // 项目基本情况
  101. const projectInformation = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content'))
  102. .projectInformation : '')
  103. // 微信手机号码绑定数据
  104. const wxPhone = ref(uni.getStorageSync('wxPhone') || '')
  105. // 所属行业数组数据
  106. const range = ref(
  107. [{
  108. value: 0,
  109. text: "政府"
  110. },
  111. {
  112. value: 1,
  113. text: "教育"
  114. },
  115. {
  116. value: 2,
  117. text: "医疗"
  118. },
  119. {
  120. value: 3,
  121. text: "企业"
  122. },
  123. {
  124. value: 4,
  125. text: "公检法"
  126. },
  127. {
  128. value: 5,
  129. text: "交通"
  130. },
  131. {
  132. value: 6,
  133. text: "分销&SMB"
  134. },
  135. {
  136. value: 7,
  137. text: "其他"
  138. }
  139. ]
  140. )
  141. // 产品类型数组
  142. const hobby = ref(
  143. [{
  144. text: '网络',
  145. value: 0
  146. }, {
  147. text: '安全',
  148. value: 1
  149. }, {
  150. text: 'IT',
  151. value: 2
  152. }, {
  153. text: '云智',
  154. value: 3
  155. }, {
  156. text: 'PC',
  157. value: 4
  158. }, {
  159. text: 'AI视觉',
  160. value: 5
  161. }]
  162. )
  163. // 日期选择框绑定回调
  164. const bindDateChange = (e) => {
  165. const val = e.detail.value
  166. biddingTime.value = val
  167. }
  168. // 提交按钮回调
  169. const handleSubmit = () => {
  170. const flag = handleValidate()
  171. if (flag) {
  172. uni.setStorageSync('form_name', name.value);
  173. uni.setStorageSync('form_phone', phone.value);
  174. uni.setStorageSync('form_company', company.value);
  175. const formContent = {
  176. clientName: clientName.value,
  177. projectName: projectName.value,
  178. projectAmount: projectAmount.value,
  179. biddingTime: biddingTime.value,
  180. industry: industry.value,
  181. productType: productType.value,
  182. projectInformation: projectInformation.value,
  183. }
  184. uni.setStorageSync('form_content', JSON.stringify(formContent));
  185. if (!wxPhone.value) {
  186. uni.showModal({
  187. title: '提示',
  188. content: '本次操作需要获取您的手机号码',
  189. success: (res) => {
  190. if (res.confirm) {
  191. uni.navigateTo({
  192. url: "/pages/authorization/authorization"
  193. })
  194. } else if (res.cancel) {}
  195. }
  196. });
  197. } else {
  198. uni.showModal({
  199. title: '提示',
  200. content: '确认提交吗',
  201. success: (res) => {
  202. if (res.confirm) {
  203. submit()
  204. } else if (res.cancel) {}
  205. }
  206. });
  207. }
  208. }
  209. }
  210. // 验证表格信息是否符合规范
  211. const handleValidate = () => {
  212. const reName = /^[\u4e00-\u9fa5]{2,4}$/
  213. const rePhone = /^[1][3,4,5,7,8,9][0-9]{9}$/
  214. const reProjectAmount = /^\+?[1-9][0-9]*$/
  215. if (name.value == '') {
  216. uni.showToast({
  217. title: '请输入姓名',
  218. icon: 'none'
  219. })
  220. return false
  221. }
  222. if (!reName.test(name.value)) {
  223. uni.showToast({
  224. title: '姓名格式有误',
  225. icon: 'none'
  226. })
  227. return false
  228. }
  229. if (phone.value == '') {
  230. uni.showToast({
  231. title: '请输入手机号',
  232. icon: 'none'
  233. })
  234. return false
  235. }
  236. if (!rePhone.test(phone.value)) {
  237. uni.showToast({
  238. title: '手机格式有误',
  239. icon: 'none'
  240. })
  241. return false
  242. }
  243. if (company.value == '') {
  244. uni.showToast({
  245. title: '请输入单位名称',
  246. icon: 'none'
  247. })
  248. return false
  249. }
  250. if (clientName.value == '') {
  251. uni.showToast({
  252. title: '请输入客户名称',
  253. icon: 'none'
  254. })
  255. return false
  256. }
  257. if (projectName.value == '') {
  258. uni.showToast({
  259. title: '请输入项目名称',
  260. icon: 'none'
  261. })
  262. return false
  263. }
  264. if (projectAmount.value == '') {
  265. uni.showToast({
  266. title: '请输入项目金额',
  267. icon: 'none'
  268. })
  269. return false
  270. }
  271. if (!reProjectAmount.test(projectAmount.value)) {
  272. uni.showToast({
  273. title: '项目金额请输入正整数',
  274. icon: 'none'
  275. })
  276. return false
  277. }
  278. if (biddingTime.value == '') {
  279. uni.showToast({
  280. title: '请选择预计投标时间',
  281. icon: 'none'
  282. })
  283. return false
  284. }
  285. if (industry.value === '') {
  286. uni.showToast({
  287. title: '请选择所属行业',
  288. icon: 'none'
  289. })
  290. return false
  291. }
  292. if (productType.value.length == 0) {
  293. uni.showToast({
  294. title: '请选择产品类型',
  295. icon: 'none'
  296. })
  297. return false
  298. }
  299. return true
  300. }
  301. // 请求提交接口回调
  302. const submit = async () => {
  303. const bProduct = []
  304. productType.value.forEach(item => {
  305. bProduct.push(hobby.value[item].text)
  306. })
  307. const res = await myRequest({
  308. url: "/informationReporting/add",
  309. method: "post",
  310. data: {
  311. name: name.value,
  312. phone: phone.value,
  313. company: company.value,
  314. customerName: clientName.value,
  315. entryName: projectName.value,
  316. projectAmount: projectAmount.value,
  317. tenderTime: biddingTime.value,
  318. content: projectInformation.value,
  319. trade: range.value[industry.value].text,
  320. bProduct,
  321. wxPhone: wxPhone.value,
  322. }
  323. })
  324. // console.log(res)
  325. if (res.success && res.code == 1) {
  326. uni.showToast({
  327. title: '提交成功',
  328. duration: 3000
  329. })
  330. clientName.value = ''
  331. projectName.value = ''
  332. projectAmount.value = ''
  333. biddingTime.value = ''
  334. industry.value = ''
  335. productType.value = []
  336. projectInformation.value = ''
  337. uni.removeStorageSync('form_content')
  338. uni.setStorageSync('accredit', false)
  339. } else {
  340. uni.showToast({
  341. title: res.message,
  342. icon: 'error'
  343. })
  344. }
  345. }
  346. // 获取当前时间 YY-MM-DD
  347. const getCurrentDate = () => {
  348. const date = new Date();
  349. let year = date.getFullYear();
  350. let month = date.getMonth() + 1;
  351. let day = date.getDate();
  352. month = month > 9 ? month : '0' + month;
  353. day = day > 9 ? day : '0' + day;
  354. return `${year}-${month}-${day}`;
  355. }
  356. </script>
  357. <style lang="scss" scoped>
  358. .content {
  359. width: 100vw;
  360. .header {
  361. width: 750rpx;
  362. height: 300rpx;
  363. border-radius: 0 0 10% 10%;
  364. background-color: #1E7DFB;
  365. }
  366. .form {
  367. position: absolute;
  368. top: 42rpx;
  369. left: 30rpx;
  370. right: 30rpx;
  371. padding: 0 32rpx;
  372. border-radius: 10rpx;
  373. background-color: #fff;
  374. .form_title {
  375. line-height: 105rpx;
  376. font-weight: bold;
  377. font-size: 34rpx;
  378. }
  379. .form_item {
  380. margin-bottom: 20rpx;
  381. font-size: 28rpx;
  382. .icon {
  383. color: #D43030;
  384. }
  385. :deep .uni-easyinput {
  386. margin-top: 10rpx;
  387. background-color: #F2F2F2;
  388. }
  389. :deep .uni-stat__select {
  390. margin-top: 10rpx;
  391. background-color: #F2F2F2;
  392. }
  393. :deep .uni-data-checklist {
  394. margin-top: 10rpx !important;
  395. background-color: #F2F2F2;
  396. }
  397. }
  398. .form_button {
  399. margin-top: 65rpx;
  400. background-color: #1E7DFB;
  401. color: #fff;
  402. font-size: 28rpx;
  403. }
  404. .footer {
  405. margin: 70rpx 0;
  406. text-align: center;
  407. font-size: 24rpx;
  408. color: #999999;
  409. }
  410. }
  411. }
  412. </style>