application.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. // pages/form/application/application.js
  2. const upload = require("../../../utils/upload")
  3. import { $wuxForm} from '../../../miniprogram_npm/wux-weapp/index'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. validateMessages: {
  10. required: '%s 字段为必填',
  11. },
  12. form:{
  13. type:0,
  14. isApplyOverseas:1,
  15. hagueCertification:1,
  16. },
  17. labelWidth:350,
  18. typeOptions:[
  19. { text: '发明专利', value: 0 },
  20. { text: '外观设计', value: 1 },
  21. { text: '实用新型', value: 2 },
  22. { text: '商标', value: 3 },
  23. { text: '版权', value: 4 },
  24. ]
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad(options) {
  30. },
  31. /**
  32. * 生命周期函数--监听页面初次渲染完成
  33. */
  34. onReady() {
  35. },
  36. /**
  37. * 生命周期函数--监听页面显示
  38. */
  39. onShow() {
  40. },
  41. /**
  42. * 页面方法集合
  43. */
  44. //表单栏位值发生变化时
  45. onValuesChange(e) {
  46. console.log(e)
  47. const { changedValues, allValues } = e.detail
  48. // this.setValues(changedValues)
  49. Object.keys(changedValues).forEach((field) => {
  50. this.setData({
  51. ['form.'+field]: changedValues[field],
  52. })
  53. })
  54. console.log('onValuesChange \n', changedValues, allValues)
  55. },
  56. //手机号校验
  57. checkPhone(rule, value){
  58. if(!value){
  59. return Promise.reject(new Error('手机号不能为空!'))
  60. }
  61. const isTel = (value) => /^1[34578]\d{9}$/.test(value)
  62. if(!isTel(value)){
  63. return Promise.reject(new Error('手机号输入错误!'))
  64. }
  65. return Promise.resolve()
  66. },
  67. //上传文件
  68. uploadFile(){
  69. const that = this;
  70. wx.chooseMessageFile({
  71. count: 1, // 默认9,表示一次最多可以选择的文件个数
  72. type: 'file', // 可以指定是文件
  73. success(res) {
  74. // 返回选定文件的本地文件路径列表,tempFilePath可以作为文件上传的标识
  75. const tempFilePaths = res.tempFilePaths[0];
  76. upload(tempFilePaths).then(res=>{
  77. console.log(res)
  78. })
  79. }
  80. });
  81. },
  82. //输入备注
  83. changRemark(e){
  84. this.setData(
  85. {
  86. ["form.remark"]:e.detail.value
  87. }
  88. )
  89. },
  90. //修改是否海外申请
  91. onChange2(e){
  92. this.setData(
  93. {
  94. ["form.isApplyOverseas"]:e.detail.value
  95. }
  96. )
  97. },
  98. //修改一同申请海牙认证
  99. onChange1(e){
  100. this.setData(
  101. {
  102. ["form.hagueCertification"]:e.detail.value
  103. }
  104. )
  105. },
  106. //提交工单
  107. submit(){
  108. const { validateFields } = $wuxForm()
  109. wx.navigateTo({
  110. url: '/pages/successReminder/successReminder?id=3',
  111. })
  112. validateFields((err, values) => {
  113. console.log(err)
  114. if (!err) {
  115. }
  116. })
  117. },
  118. /**
  119. * 生命周期函数--监听页面隐藏
  120. */
  121. onHide() {
  122. },
  123. /**
  124. * 生命周期函数--监听页面卸载
  125. */
  126. onUnload() {
  127. },
  128. /**
  129. * 页面相关事件处理函数--监听用户下拉动作
  130. */
  131. onPullDownRefresh() {
  132. },
  133. /**
  134. * 页面上拉触底事件的处理函数
  135. */
  136. onReachBottom() {
  137. },
  138. /**
  139. * 用户点击右上角分享
  140. */
  141. onShareAppMessage() {
  142. }
  143. })