application.js 4.3 KB

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