rightsProtection.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. // pages/form/rightsProtection/rightsProtection.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. tortStoreAdinSite:'美国站',
  15. tortType:'发明专利',
  16. tortClassify:'产品侵权',
  17. ifHaveRightProof:true,
  18. problemDescription:'商品详细页上使用了未经授权的图片'
  19. },
  20. labelWidth:200,
  21. //站点
  22. countrys:[
  23. { text: '美国站', value: '美国站' },
  24. { text: '日本站', value: '日本站' },
  25. { text: '德国站', value: '德国站' },
  26. { text: '英国站', value: '英国站' },
  27. ],
  28. //侵权类型
  29. typeOptions:[
  30. { text: '发明专利', value: '发明专利' },
  31. { text: '外观设计', value: '外观设计' },
  32. { text: '实用新型', value: '实用新型' },
  33. { text: '商标', value: '商标' },
  34. { text: '版权', value: '版权' },
  35. ],
  36. //侵权分类
  37. typeOptions2:[
  38. { text: '产品侵权', value: '产品侵权' },
  39. { text: '图片侵权', value: '图片侵权' },
  40. { text: '背景侵权', value: '背景侵权' },
  41. { text: '文字侵权', value: '文字侵权' },
  42. ],
  43. //问题描述
  44. problemDescriptions:[
  45. { text: '商品详情页上使用了未经授权的图片', value: '商品详情页上使用了未经授权的图片' },
  46. { text: '实际商品或其包装包含非盗版的未授权的内容', value: '实际商品或其包装包含非盗版的未授权的内容' },
  47. { text: '商品详情页面上使用了未经授权的文本', value: '商品详情页面上使用了未经授权的文本' },
  48. { text: '商品或其包装为盗版(全盘复制受版权保护的商品)', value: '商品或其包装为盗版(全盘复制受版权保护的商品)' },
  49. ],
  50. proofGuids:[],
  51. },
  52. /**
  53. * 生命周期函数--监听页面加载
  54. */
  55. onLoad(options) {
  56. },
  57. /**
  58. * 生命周期函数--监听页面初次渲染完成
  59. */
  60. onReady() {
  61. this.setData(
  62. {
  63. proofGuids:[],
  64. form:{
  65. tortStoreAdinSite:'美国站',
  66. tortType:'发明专利',
  67. tortClassify:'产品侵权',
  68. ifHaveRightProof:true,
  69. problemDescription:'商品详情页上使用了未经授权的图片'
  70. },
  71. }
  72. )
  73. },
  74. /**
  75. * 生命周期函数--监听页面显示
  76. */
  77. onShow() {
  78. },
  79. /**
  80. * 页面方法集合
  81. */
  82. //表单栏位值发生变化时
  83. onValuesChange(e) {
  84. const { changedValues, allValues } = e.detail
  85. // this.setValues(changedValues)
  86. Object.keys(changedValues).forEach((field) => {
  87. this.setData({
  88. ['form.'+field]: changedValues[field],
  89. })
  90. })
  91. },
  92. //手机号校验
  93. checkPhone(rule, value){
  94. if(!value){
  95. return Promise.reject(new Error('手机号不能为空!'))
  96. }
  97. const isTel = (value) => /^1[34578]\d{9}$/.test(value)
  98. if(!isTel(value)){
  99. return Promise.reject(new Error('手机号输入错误!'))
  100. }
  101. return Promise.resolve()
  102. },
  103. //上传文件
  104. beforeUpload(e){
  105. if(e.detail.errMsg=="chooseMedia:ok"){
  106. var that = this
  107. var tempFilePaths = e.detail.tempFiles
  108. tempFilePaths.forEach(item=>{
  109. let tempFilePath = item.tempFilePath
  110. // this.setData({ imageUrl:e.detail.tempFiles[0].tempFilePath })
  111. upload.upload(tempFilePath).then(res=>{
  112. if(res.code == 200){
  113. // var arr = []
  114. // arr.push(res.data[0])
  115. var guid = res.data[0]
  116. var arr = that.data.proofGuids
  117. arr.push(
  118. {
  119. url:tempFilePath,
  120. guid:guid,
  121. status:"done"
  122. }
  123. )
  124. that.setData(
  125. {
  126. // ["form.fileGuids"]:arr
  127. proofGuids:arr
  128. }
  129. )
  130. }
  131. })
  132. })
  133. }
  134. },
  135. //移除
  136. onRemove(e){
  137. const { file, fileList } = e.detail
  138. wx.showModal({
  139. content: '确定删除?',
  140. success: (res) => {
  141. if (res.confirm) {
  142. this.setData({
  143. proofGuids: this.data.proofGuids.filter((n) => n.guid !== file.guid),
  144. })
  145. }
  146. },
  147. })
  148. },
  149. //输入备注
  150. changRemark(e){
  151. this.setData(
  152. {
  153. ["form.description"]:e.detail.value
  154. }
  155. )
  156. },
  157. //修改是否拥有专利号
  158. onChange(e){
  159. this.setData(
  160. {
  161. ["form.ifHaveRightProof"]:e.detail
  162. }
  163. )
  164. },
  165. //修改哪一项最能描述您的问题?
  166. onChange1(e){
  167. this.setData(
  168. {
  169. ["form.problemDescription"]:e.detail
  170. }
  171. )
  172. },
  173. //修改下拉菜单值
  174. changeVanDropdownnValue(e){
  175. var label = e.currentTarget.dataset.label
  176. if(label){
  177. var detail = e.detail
  178. this.setData(
  179. {
  180. ["form."+label]:detail
  181. }
  182. )
  183. }
  184. },
  185. //提交工单
  186. submit(){
  187. var key = api.isLogin()
  188. if(!key){
  189. return false
  190. }
  191. const { validateFields } = $wuxForm()
  192. console.log(this.data.form)
  193. validateFields((err, values) => {
  194. console.log(err)
  195. if (!err) {
  196. if(this.data.proofGuids && this.data.proofGuids.length>0){
  197. this.data.form.proofGuids = this.data.proofGuids.map(item=>item.guid)
  198. }
  199. var params = {
  200. ticketType:2,
  201. contactPerson:this.data.form.contactPerson,
  202. contactPhone:this.data.form.contactPhone,
  203. contactMail:this.data.form.contactMail,
  204. fileGuids:this.data.form.fileGuids,
  205. protectionAddDTO:this.data.form
  206. }
  207. wx.showLoading({
  208. title: '加载中',
  209. })
  210. api.addTicket(params).then(res=>{
  211. if(res.code == 200){
  212. wx.navigateTo({
  213. url: '/pages/successReminder/successReminder?id=2',
  214. })
  215. }
  216. })
  217. }else{
  218. var error = Object.keys(err)
  219. var key = error[0]
  220. var len = err[key].errors.length
  221. var message = err[key].errors[len-1].message
  222. wx.showModal({
  223. title: '提示',
  224. content: message,
  225. complete: (res) => {
  226. if (res.cancel) {
  227. }
  228. if (res.confirm) {
  229. }
  230. }
  231. })
  232. }
  233. })
  234. },
  235. /**
  236. * 生命周期函数--监听页面隐藏
  237. */
  238. onHide() {
  239. },
  240. /**
  241. * 生命周期函数--监听页面卸载
  242. */
  243. onUnload() {
  244. },
  245. /**
  246. * 页面相关事件处理函数--监听用户下拉动作
  247. */
  248. onPullDownRefresh() {
  249. },
  250. /**
  251. * 页面上拉触底事件的处理函数
  252. */
  253. onReachBottom() {
  254. },
  255. /**
  256. * 用户点击右上角分享
  257. */
  258. onShareAppMessage() {
  259. }
  260. })