|
@@ -1,7 +1,7 @@
|
|
|
// pages/searchResults/searchResults.js
|
|
|
const app = getApp()
|
|
|
const api = require('../../api/index')
|
|
|
-import { $startWuxRefresher, $stopWuxRefresher,$stopWuxLoader} from '../../miniprogram_npm/wux-weapp/index'
|
|
|
+import { $startWuxRefresher, $stopWuxRefresher,$stopWuxLoader,$wuxGallery} from '../../miniprogram_npm/wux-weapp/index'
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
@@ -9,18 +9,43 @@ Page({
|
|
|
*/
|
|
|
data: {
|
|
|
imgHttp:app.globalData.imghttp,
|
|
|
+ phone:app.globalData.phone,
|
|
|
queryParams:{
|
|
|
current:1,
|
|
|
size:10
|
|
|
},
|
|
|
+ ifAddSearchRecord:true,
|
|
|
total:0,
|
|
|
loading:false,
|
|
|
tableData:[],
|
|
|
keyword:'',
|
|
|
scrollTop: 0,
|
|
|
- searchType:1,//检索类型
|
|
|
+ searchType:1,//检索类型1是爆款产品0是手动检索
|
|
|
product:{},//产品信息
|
|
|
patentNoList:[],
|
|
|
+ patentList:[],
|
|
|
+ buttons:[
|
|
|
+ {
|
|
|
+ label: '提交工单',
|
|
|
+ method:'check'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '一键导出',
|
|
|
+ method:'export'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label:'人工客服',
|
|
|
+ method:'makePhoneCall'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ concernType:{
|
|
|
+ '0':'myIconicon-test',//黑
|
|
|
+ '1':'myIconanquanbangzhu',//白
|
|
|
+ '2':'myIcongroup43'//灰
|
|
|
+ },
|
|
|
+ showDialog:false,
|
|
|
+ followType:null,
|
|
|
+ isAdd:false
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -33,6 +58,7 @@ Page({
|
|
|
product:JSON.parse(decodeURIComponent(options.product))
|
|
|
}
|
|
|
)
|
|
|
+ console.log(this.data.product)
|
|
|
this.init()
|
|
|
},
|
|
|
|
|
@@ -86,10 +112,18 @@ Page({
|
|
|
imgs.push(this.data.imgHttp + imglist[i].guid)
|
|
|
}
|
|
|
current = this.data.imgHttp + current
|
|
|
- wx.previewImage({
|
|
|
+ $wuxGallery().show({
|
|
|
current,
|
|
|
- urls:imgs,
|
|
|
+ urls: imgs.map((n) => ({ image: n, remark: n })),
|
|
|
+ indicatorDots: true,
|
|
|
+ indicatorColor: '#fff',
|
|
|
+ indicatorActiveColor: '#04BE02',
|
|
|
+ showDelete:false
|
|
|
})
|
|
|
+ // wx.previewImage({
|
|
|
+ // current,
|
|
|
+ // urls:imgs,
|
|
|
+ // })
|
|
|
},
|
|
|
//修改输入的关键词
|
|
|
changeKeyword(e){
|
|
@@ -107,21 +141,16 @@ Page({
|
|
|
search(e){
|
|
|
// console.log(e)
|
|
|
},
|
|
|
- //一键导出
|
|
|
- export(e){
|
|
|
- wx.navigateTo({
|
|
|
- url: '/pages/selectedPatents/selectedPatents',
|
|
|
- })
|
|
|
- },
|
|
|
|
|
|
//查询产品相关专利
|
|
|
getPatentVectors(){
|
|
|
console.log(this.data.product)
|
|
|
var params = {
|
|
|
pageNum:this.data.queryParams.current,
|
|
|
- pageSize:this.data.queryParams.size
|
|
|
+ pageSize:this.data.queryParams.size,
|
|
|
+ ifAddSearchRecord:this.data.ifAddSearchRecord
|
|
|
}
|
|
|
- if(this.data.product.id){
|
|
|
+ if(this.data.searchType == 1){
|
|
|
params.productId = this.data.product.id
|
|
|
}else{
|
|
|
params.key = this.data.product.key
|
|
@@ -135,6 +164,9 @@ Page({
|
|
|
if(this.data.product.filePath){
|
|
|
url = "getPatentVectorsByImage"
|
|
|
}
|
|
|
+ wx.showLoading({
|
|
|
+ title: '加载中',
|
|
|
+ })
|
|
|
api[url](data,this.data.product.filePath).then(res=>{
|
|
|
if(res.code == 200){
|
|
|
console.log(res)
|
|
@@ -144,7 +176,8 @@ Page({
|
|
|
this.setData(
|
|
|
{
|
|
|
tableData:this.data.tableData.concat(res.data.data),
|
|
|
- total:res.data.total
|
|
|
+ total:res.data.total,
|
|
|
+ ifAddSearchRecord:false
|
|
|
}
|
|
|
)
|
|
|
for(let i = 0;i<res.data.data.length;i++){
|
|
@@ -186,8 +219,21 @@ Page({
|
|
|
//选择专利
|
|
|
changePatentNoList(event) {
|
|
|
console.log(event)
|
|
|
+ var {item,appNo} = event.currentTarget.dataset
|
|
|
+ var data = event.detail
|
|
|
+ var patent = this.data.patentList
|
|
|
+ var index = data.indexOf(appNo)
|
|
|
+ if(index != -1){
|
|
|
+ var index1 = patent.findIndex(item=>{
|
|
|
+ return item.appNo == appNo
|
|
|
+ })
|
|
|
+ patent.splice(index1,1)
|
|
|
+ }else{
|
|
|
+ patent.push(item)
|
|
|
+ }
|
|
|
this.setData({
|
|
|
patentNoList: event.detail,
|
|
|
+ patentList:patent
|
|
|
});
|
|
|
},
|
|
|
|
|
@@ -197,8 +243,218 @@ Page({
|
|
|
|
|
|
//查看已选择的专利
|
|
|
clickButton(e){
|
|
|
+ console.log(e)
|
|
|
+ var that = this
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/selectedPatents/selectedPatents',
|
|
|
+ events: {
|
|
|
+ // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
|
|
|
+ acceptDataFromOpenedPage: function(data) {
|
|
|
+ console.log(data)
|
|
|
+ },
|
|
|
+ someEvent: function(data) {
|
|
|
+ console.log(data)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ success: function(res) {
|
|
|
+ // 通过eventChannel向被打开页面传送数据
|
|
|
+ res.eventChannel.emit('acceptDataFromOpenerPage', { data: that.data.patentList })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ //关注产品
|
|
|
+ open(){
|
|
|
+ this.setData(
|
|
|
+ {
|
|
|
+ showDialog:true
|
|
|
+ }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ //取消关注
|
|
|
+ closeDialog(){
|
|
|
+ this.setData(
|
|
|
+ {
|
|
|
+ showDialog:false,
|
|
|
+ followType:null,
|
|
|
+ }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ attention(e){
|
|
|
+ var {type} = e.currentTarget.dataset
|
|
|
+ this.setData(
|
|
|
+ {
|
|
|
+ followType:type
|
|
|
+ }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ //是否收藏
|
|
|
+ changeIsAdd(e){
|
|
|
+
|
|
|
+ this.setData(
|
|
|
+ {
|
|
|
+ isAdd:e.detail
|
|
|
+ }
|
|
|
+ )
|
|
|
+ console.log(e)
|
|
|
+ },
|
|
|
+ //确认关注
|
|
|
+ confirm(){
|
|
|
+ console.log(this.data.followType)
|
|
|
+ if(this.data.followType != 0 && !this.data.followType){
|
|
|
+ api.notify(
|
|
|
+ {
|
|
|
+ type:'warning',
|
|
|
+ message:'请选择关注类型',
|
|
|
+ top:'90'
|
|
|
+ }
|
|
|
+ )
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ var that = this
|
|
|
+ if(this.data.searchType == 0){
|
|
|
+ console.log(1)
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `/pages/form/addProduct/addProduct`,
|
|
|
+ success: function(res) {
|
|
|
+ // 通过eventChannel向被打开页面传送数据
|
|
|
+ var data = {
|
|
|
+ ...that.data.product,
|
|
|
+ concernType:that.data.followType
|
|
|
+ }
|
|
|
+ res.eventChannel.emit('acceptDataFromOpenerPage', data)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ var params = {
|
|
|
+ productId:this.data.product.id,
|
|
|
+ concernType:this.data.followType
|
|
|
+ }
|
|
|
+ wx.showLoading({
|
|
|
+ title: '加载中',
|
|
|
+ })
|
|
|
+
|
|
|
+ api.follow(params).then(res=>{
|
|
|
+ if(res.code == 200){
|
|
|
+ var obj = {
|
|
|
+ type: 'success',
|
|
|
+ message: '关注成功',
|
|
|
+ top:'90'
|
|
|
+ }
|
|
|
+ api.notify(obj)
|
|
|
+ that.setData({
|
|
|
+ ['product.concernType'] : that.data.followType,
|
|
|
+ })
|
|
|
+ that.closeDialog()
|
|
|
+ // console.log(that.data.isAdd,this.data.patentNoList)
|
|
|
+ if(that.data.isAdd ){
|
|
|
+ that.setData(
|
|
|
+ {
|
|
|
+ idAdd:false
|
|
|
+ }
|
|
|
+ )
|
|
|
+ if(that.data.patentNoList && that.data.patentNoList.length>0){
|
|
|
+ var params1 = {
|
|
|
+ productId:that.data.product.id,
|
|
|
+ patentNos:that.data.patentNoList
|
|
|
+ }
|
|
|
+ api.collectPatent(params1).then(res=>{
|
|
|
+ if(res.code == 200){
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
|
|
|
+ //取消关注
|
|
|
+ cancelFollow(e){
|
|
|
+ if(!this.data.product.id){
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '确认取消关注?',
|
|
|
+ complete: (res) => {
|
|
|
+ if (res.cancel) {}
|
|
|
+ if (res.confirm) {
|
|
|
+ var product = this.data.product
|
|
|
+ var params = {
|
|
|
+ productId:product.id
|
|
|
+ }
|
|
|
+ wx.showLoading({
|
|
|
+ title: '取消中',
|
|
|
+ })
|
|
|
+ api.unFollow(params).then(res=>{
|
|
|
+ if(res.code == 200){
|
|
|
+ var obj = {
|
|
|
+ type: 'success',
|
|
|
+ message: '取关成功',
|
|
|
+ }
|
|
|
+ if(this.properties.isFollow){
|
|
|
+ obj.top = '90'
|
|
|
+ }
|
|
|
+ api.notify(obj)
|
|
|
+ this.setData({
|
|
|
+ ['product.concernType'] : null
|
|
|
+ })
|
|
|
+ if(this.data.searchType == 0){
|
|
|
+ this.setData({
|
|
|
+ ['product.id'] : null
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
+ //监控
|
|
|
+ control(e){
|
|
|
+ // var index = e.currentTarget.dataset.index
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '敬请期待!',
|
|
|
+ complete: (res) => {
|
|
|
+ if (res.cancel) {}
|
|
|
+ if (res.confirm) {}
|
|
|
+ }
|
|
|
+ })
|
|
|
+},
|
|
|
+//点击button
|
|
|
+onClick(e){
|
|
|
+ console.log(e)
|
|
|
+ var btn = e.detail.value
|
|
|
+ this[btn.method]()
|
|
|
+},
|
|
|
+//导出
|
|
|
+export(){
|
|
|
+
|
|
|
+ if(!this.data.patentNoList || this.data.patentNoList.length==0){
|
|
|
+ wx.showToast({
|
|
|
+ title: '您未选择专利!',
|
|
|
+ icon:'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+},
|
|
|
+//我要查风险
|
|
|
+check(){
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/form/riskAssessment/riskAssessment',
|
|
|
+ })
|
|
|
+},
|
|
|
+makePhoneCall(){
|
|
|
+ wx.makePhoneCall({
|
|
|
+ phoneNumber: this.data.phone
|
|
|
+ })
|
|
|
+},
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|