searchResults.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. // pages/searchResults/searchResults.js
  2. const app = getApp()
  3. const api = require('../../api/index')
  4. import { $startWuxRefresher, $stopWuxRefresher,$stopWuxLoader} from '../../miniprogram_npm/wux-weapp/index'
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. imgHttp:app.globalData.imghttp,
  11. queryParams:{
  12. current:1,
  13. size:10
  14. },
  15. total:0,
  16. loading:false,
  17. tableData:[],
  18. keyword:'',
  19. scrollTop: 0,
  20. searchType:1,//检索类型
  21. product:{},//产品信息
  22. patentNoList:[],
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad(options) {
  28. this.setData(
  29. {
  30. searchType:options.type,
  31. product:JSON.parse(decodeURIComponent(options.product))
  32. }
  33. )
  34. this.init()
  35. },
  36. /**
  37. * 生命周期函数--监听页面初次渲染完成
  38. */
  39. onReady() {
  40. },
  41. /**
  42. * 生命周期函数--监听页面显示
  43. */
  44. onShow() {
  45. },
  46. /**
  47. * 页面功能
  48. */
  49. //初始化加载
  50. init(){
  51. var params = {
  52. current:1,
  53. size:10
  54. }
  55. this.setData(
  56. {
  57. queryParams:params,
  58. total:0,
  59. tableData:[],
  60. patentNoList:[]
  61. }
  62. )
  63. this.getPatentVectors()
  64. },
  65. //下拉
  66. onPulling() {
  67. console.log('onPulling')
  68. },
  69. //下拉刷新
  70. onRefresh() {
  71. console.log('onRefresh')
  72. this.init()
  73. },
  74. //查看图片
  75. previewImage(e) {
  76. console.log(e)
  77. var { current,imglist } = e.currentTarget.dataset
  78. var imgs = []
  79. for(var i =0;i<imglist.length;i++){
  80. imgs.push(this.data.imgHttp + imglist[i].guid)
  81. }
  82. current = this.data.imgHttp + current
  83. wx.previewImage({
  84. current,
  85. urls:imgs,
  86. })
  87. },
  88. //修改输入的关键词
  89. changeKeyword(e){
  90. this.setData(
  91. {
  92. keyword:e.detail
  93. }
  94. )
  95. },
  96. //点击输入框内部图标
  97. clickInnerIcon(e){
  98. // console.log(e)
  99. },
  100. //点击搜索按钮
  101. search(e){
  102. // console.log(e)
  103. },
  104. //一键导出
  105. export(e){
  106. wx.navigateTo({
  107. url: '/pages/selectedPatents/selectedPatents',
  108. })
  109. },
  110. //查询产品相关专利
  111. getPatentVectors(){
  112. console.log(this.data.product)
  113. var params = {
  114. pageNum:this.data.queryParams.current,
  115. pageSize:this.data.queryParams.size
  116. }
  117. if(this.data.product.id){
  118. params.productId = this.data.product.id
  119. }else{
  120. params.key = this.data.product.key
  121. params.description = this.data.product.description
  122. }
  123. var vectorDTO = JSON.stringify(params)
  124. var url = 'getPatentVectors'
  125. var data = {
  126. vectorDTO:vectorDTO
  127. }
  128. if(this.data.product.filePath){
  129. url = "getPatentVectorsByImage"
  130. }
  131. api[url](data,this.data.product.filePath).then(res=>{
  132. if(res.code == 200){
  133. console.log(res)
  134. var len1 = this.data.tableData.length
  135. var len = len1>0?len1-1: 0
  136. this.setData(
  137. {
  138. tableData:this.data.tableData.concat(res.data.data),
  139. total:res.data.total
  140. }
  141. )
  142. for(let i = 0;i<res.data.data.length;i++){
  143. this.getPictureByNo(res.data.data[i],len)
  144. len += 1
  145. }
  146. // res.data.data(item=>{
  147. // this.getPictureByNo(item,len)
  148. // len += 1
  149. // })
  150. }
  151. })
  152. },
  153. //根据专利号获取相关图片
  154. getPictureByNo(data,index){
  155. var params = {
  156. appNo:data.appNo
  157. }
  158. api.getPictureByNo(params).then(res=>{
  159. if(res.code == 200){
  160. this.setData(
  161. {
  162. ["tableData["+index+"].imageList"]:res.data
  163. }
  164. )
  165. }
  166. })
  167. },
  168. //加载更多
  169. loadMore(){
  170. var current = this.data.queryParams.current
  171. this.setData(
  172. {
  173. ['queryParams.current']:current+1
  174. }
  175. )
  176. this.getPatentVectors()
  177. },
  178. //选择专利
  179. changePatentNoList(event) {
  180. console.log(event)
  181. this.setData({
  182. patentNoList: event.detail,
  183. });
  184. },
  185. onchange(e){
  186. console.log(1)
  187. },
  188. //查看已选择的专利
  189. clickButton(e){
  190. },
  191. /**
  192. * 生命周期函数--监听页面隐藏
  193. */
  194. onHide() {
  195. },
  196. /**
  197. * 生命周期函数--监听页面卸载
  198. */
  199. onUnload() {
  200. },
  201. /**
  202. * 页面相关事件处理函数--监听用户下拉动作
  203. */
  204. onPullDownRefresh() {
  205. },
  206. /**
  207. * 页面上拉触底事件的处理函数
  208. */
  209. onReachBottom() {
  210. },
  211. /**
  212. * 用户点击右上角分享
  213. */
  214. onShareAppMessage() {
  215. }
  216. })