index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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" :value="biddingTime" @change="bindDateChange">
  38. <uni-easyinput 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. const projectName = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).projectName : '')
  87. // 项目金额
  88. const projectAmount = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).projectAmount : '')
  89. // 预计投标时间
  90. const biddingTime = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).biddingTime : '')
  91. // 所属行业
  92. const industry = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).industry : '')
  93. // 产品类型
  94. const productType = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).productType : [])
  95. // 项目基本情况
  96. const projectInformation = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content')).projectInformation : '')
  97. // 微信手机号码绑定数据
  98. const wxPhone = ref(uni.getStorageSync('wxPhone') || '')
  99. // 所属行业数组数据
  100. const range = ref(
  101. [{
  102. value: 0,
  103. text: "政府"
  104. },
  105. {
  106. value: 1,
  107. text: "教育"
  108. },
  109. {
  110. value: 2,
  111. text: "医疗"
  112. },
  113. {
  114. value: 3,
  115. text: "企业"
  116. },
  117. {
  118. value: 4,
  119. text: "公检法"
  120. },
  121. {
  122. value: 5,
  123. text: "交通"
  124. },
  125. {
  126. value: 6,
  127. text: "分销&SMB"
  128. },
  129. {
  130. value: 7,
  131. text: "其他"
  132. }
  133. ]
  134. )
  135. // 产品类型数组
  136. const hobby = ref(
  137. [{
  138. text: '网络',
  139. value: 0
  140. }, {
  141. text: '安全',
  142. value: 1
  143. }, {
  144. text: 'IT',
  145. value: 2
  146. }, {
  147. text: '云智',
  148. value: 3
  149. }, {
  150. text: 'PC',
  151. value: 4
  152. }, {
  153. text: 'AI视觉',
  154. value: 5
  155. }]
  156. )
  157. // 日期选择框绑定回调
  158. const bindDateChange = (e) => {
  159. const val = e.detail.value
  160. biddingTime.value = val
  161. }
  162. // 提交按钮回调
  163. const handleSubmit = () => {
  164. const flag = handleValidate()
  165. if (flag) {
  166. uni.setStorageSync('form_name', name.value);
  167. uni.setStorageSync('form_phone', phone.value);
  168. uni.setStorageSync('form_company', company.value);
  169. const formContent = {
  170. clientName: clientName.value,
  171. projectName: projectName.value,
  172. projectAmount: projectAmount.value,
  173. biddingTime: biddingTime.value,
  174. industry: industry.value,
  175. productType: productType.value,
  176. projectInformation: projectInformation.value,
  177. }
  178. uni.setStorageSync('form_content', JSON.stringify(formContent));
  179. if (!wxPhone.value) {
  180. uni.showModal({
  181. title: '提示',
  182. content: '本次操作需要获取您的手机号码',
  183. success: (res) => {
  184. if (res.confirm) {
  185. uni.navigateTo({
  186. url: "/pages/authorization/authorization"
  187. })
  188. } else if (res.cancel) {}
  189. }
  190. });
  191. } else {
  192. uni.showModal({
  193. title: '提示',
  194. content: '确认提交吗',
  195. success: (res) => {
  196. if (res.confirm) {
  197. submit()
  198. } else if (res.cancel) {}
  199. }
  200. });
  201. }
  202. }
  203. }
  204. // 验证表格信息是否符合规范
  205. const handleValidate = () => {
  206. const reName = /^[\u4e00-\u9fa5]{2,4}$/
  207. const rePhone = /^[1][3,4,5,7,8,9][0-9]{9}$/
  208. if (name.value == '') {
  209. uni.showToast({
  210. title: '请输入姓名',
  211. icon: 'none'
  212. })
  213. return false
  214. }
  215. if (!reName.test(name.value)) {
  216. uni.showToast({
  217. title: '姓名格式有误',
  218. icon: 'none'
  219. })
  220. return false
  221. }
  222. if (phone.value == '') {
  223. uni.showToast({
  224. title: '请输入手机号',
  225. icon: 'none'
  226. })
  227. return false
  228. }
  229. if (!rePhone.test(phone.value)) {
  230. uni.showToast({
  231. title: '手机格式有误',
  232. icon: 'none'
  233. })
  234. return false
  235. }
  236. if (company.value == '') {
  237. uni.showToast({
  238. title: '请输入单位名称',
  239. icon: 'none'
  240. })
  241. return false
  242. }
  243. if (clientName.value == '') {
  244. uni.showToast({
  245. title: '请输入客户名称',
  246. icon: 'none'
  247. })
  248. return false
  249. }
  250. if (projectName.value == '') {
  251. uni.showToast({
  252. title: '请输入项目名称',
  253. icon: 'none'
  254. })
  255. return false
  256. }
  257. if (projectAmount.value == '') {
  258. uni.showToast({
  259. title: '请输入项目金额',
  260. icon: 'none'
  261. })
  262. return false
  263. }
  264. if (biddingTime.value == '') {
  265. uni.showToast({
  266. title: '请选择预计投标时间',
  267. icon: 'none'
  268. })
  269. return false
  270. }
  271. if (industry.value === '') {
  272. uni.showToast({
  273. title: '请选择所属行业',
  274. icon: 'none'
  275. })
  276. return false
  277. }
  278. if (productType.value.length == 0) {
  279. uni.showToast({
  280. title: '请选择产品类型',
  281. icon: 'none'
  282. })
  283. return false
  284. }
  285. return true
  286. }
  287. // 请求提交接口回调
  288. const submit = async () => {
  289. const bProduct =[]
  290. productType.value.forEach(item=>{
  291. bProduct.push(hobby.value[item].text)
  292. })
  293. const res = await myRequest({
  294. url: "/informationReporting/add",
  295. method: "post",
  296. data: {
  297. name: name.value,
  298. phone: phone.value,
  299. company: company.value,
  300. customerName:clientName.value,
  301. entryName:projectName.value,
  302. projectAmount:projectAmount.value,
  303. tenderTime:biddingTime.value,
  304. content:projectInformation.value,
  305. trade:range.value[industry.value].text,
  306. bProduct,
  307. wxPhone: wxPhone.value,
  308. }
  309. })
  310. // console.log(res)
  311. if (res.success && res.code == 1) {
  312. uni.showToast({
  313. title: '提交成功',
  314. duration: 3000
  315. })
  316. clientName.value = ''
  317. projectName.value = ''
  318. projectAmount.value = ''
  319. biddingTime.value = ''
  320. industry.value = ''
  321. productType.value = []
  322. projectInformation.value = ''
  323. uni.removeStorageSync('form_content')
  324. uni.setStorageSync('accredit', false)
  325. } else {
  326. uni.showToast({
  327. title: res.message,
  328. icon: 'error'
  329. })
  330. }
  331. }
  332. </script>
  333. <style lang="scss" scoped>
  334. .content {
  335. width: 100vw;
  336. .header {
  337. width: 750rpx;
  338. height: 300rpx;
  339. border-radius: 0 0 10% 10%;
  340. background-color: #1E7DFB;
  341. }
  342. .form {
  343. position: absolute;
  344. top: 42rpx;
  345. left: 30rpx;
  346. right: 30rpx;
  347. padding: 0 32rpx;
  348. border-radius: 10rpx;
  349. background-color: #fff;
  350. .form_title {
  351. line-height: 105rpx;
  352. font-weight: bold;
  353. font-size: 34rpx;
  354. }
  355. .form_item {
  356. margin-bottom: 20rpx;
  357. font-size: 28rpx;
  358. .icon {
  359. color: #D43030;
  360. }
  361. :deep .uni-easyinput {
  362. margin-top: 10rpx;
  363. background-color: #F2F2F2;
  364. }
  365. :deep .uni-stat__select {
  366. margin-top: 10rpx;
  367. background-color: #F2F2F2;
  368. }
  369. :deep .uni-data-checklist {
  370. margin-top: 10rpx !important;
  371. background-color: #F2F2F2;
  372. }
  373. }
  374. .form_button {
  375. margin-top: 65rpx;
  376. background-color: #1E7DFB;
  377. color: #fff;
  378. font-size: 28rpx;
  379. }
  380. .footer {
  381. margin: 70rpx 0;
  382. text-align: center;
  383. font-size: 24rpx;
  384. color: #999999;
  385. }
  386. }
  387. }
  388. </style>