123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- // myComponents/product/product.js
- const app = getApp()
- const api = require('../../api/index')
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- tableData:{
- type:Array,
- value:[],
- observers:function(val){
- // console.log(val)
- }
- },
- total:{
- type:Number,
- value:null
- },
- loading:{
- type:Boolean,
- value:false
- }
- },
- /**
- * 组件的初始数据
- */
- data: {
- imgHttp:app.globalData.imghttp
- },
- /**
- * 组件的方法列表
- */
- methods: {
- //查看图片
- previewImage(e) {
- const { current,imglist } = e.currentTarget.dataset
- var imgs = []
- for(var i =0;i<imglist.length;i++){
- imgs.push(this.data.imgHttp + imglist[i].guid)
- }
- current = this.data.imgHttp + current
- wx.previewImage({
- current,
- urls:imgs,
- })
- },
- //打开关注类型
- open(e){
- var index = e.currentTarget.dataset.index
- this.setData({
- ['tableData['+ index + '].show'] : true
- })
- },
- //关闭关注类型
- cancel(e){
- var index = e.currentTarget.dataset.index
- this.setData({
- ['tableData['+ index + '].show'] : false
- })
- },
- //关注
- attention(e){
- var {type,index} = e.currentTarget.dataset
- },
- //监控
- control(e){
- var index = e.currentTarget.dataset.index
- },
- //加载更多
- loadMore(){
- this.triggerEvent('loadMore')
- },
- //查看爆款产品专利
- checkMessage(e){
- var key = api.isLogin()
- if(!key){
- return false
- }
- var data = e.currentTarget.dataset.item
- var product = '{}'
- if(data){
- product = JSON.stringify(data)
- }
- wx.navigateTo({
- url: '/pages/searchResults/searchResults?type=1&product='+encodeURIComponent(product),
- })
- },
- },
- /**
- * 组件的生命周期函数列表
- */
- lifetimes: {
- // 在组件实例进入页面节点树时执行
- attached: function () {
- // 初始化操作
- console.log(this.properties.tableData);
- // ...
- },
- // 在组件实例被移除出页面节点树时执行
- detached: function () {
- // 清理工作
- console.log('组件销毁');
- // ...
- },
- // ...
- },
- })
|