微信商品详细信息页面html,微信小程序商品展示页面(仿咸鱼)

//pages/myRelease/myRelease.js

var app =getApp();

Page({/**

* 页面的初始数据*/data: {

releases: [],

low_mon:0, //降价至

now_mon: 0, //现价

image: "", //降价图片

productID: 0,

limit:5,

release:false,

showMore:false,

showLowMoney:false,

lowMoney: [{

money:0,

tip:"打1折,极速卖"},

{

money:0,

tip:"打3折,出手快"},

{

money:0,

tip:"打5折,有竞争力"}, {

money:0,

tip:"打8折"}

],

lowind:0,

productState:false,

},/**

* 生命周期函数--监听页面显示*/onShow:function(options) {this.getMyRelease();

},/**

* 降价显示*/onClickShowMoney(e) {

let index=e.currentTarget.dataset.index;

let productID=e.currentTarget.dataset.productid;

let product= this.data.releases[index];

let one= "lowMoney[" + 0 + "].money";

let three= "lowMoney[" + 1 + "].money";

let five= "lowMoney[" + 2 + "].money";

let eight= "lowMoney[" + 3 + "].money";this.setData({

showLowMoney:!this.data.showLowMoney,

now_mon: product.currentPrice,

[one]: (product.currentPrice* 0.1).toFixed(2), //1折

[three]: (product.currentPrice * 0.3).toFixed(2), //3折

[five]: (product.currentPrice * 0.5).toFixed(2), //5折

[eight]: (product.currentPrice * 0.8).toFixed(2), //8折

low_mon: (product.currentPrice * 0.1).toFixed(2), //默认1折

productID: productID,

image: product.image

})

},/**

* 更多显示*/onClickShowMore(e) {this.setData({

showMore:!this.data.showMore,

productID: e.currentTarget.dataset.productid

});if (e.currentTarget.dataset.state === 0) {this.setData({

productState:true})

}else{this.setData({

productState:false})

}

},/**

* 降价&更多隐藏*/onClickHidden(e) {

let that= this;switch(e.currentTarget.dataset.id) {case '0':

that.setData({

showLowMoney:!this.data.showLowMoney,

lowind:0});break;case '1':

that.setData({

showMore:!this.data.showMore

});break;

}

},/**

* 修改价钱

* updatePrice*/updatePrice(e) {

let params={

userID: app.globalData.userID,

id:this.data.productID,

price:this.data.low_mon,

}

app.updatePrice(params).then(res=>{if (res.state === 1) {this.getMyRelease();this.setData({

showLowMoney:!this.data.showLowMoney,

lowind:0})

}

})

},/**

* 下架

* soldOut*/soldOut() {

let params={

userID: app.globalData.userID,

id:this.data.productID,

flag:this.data.productState

}

app.soldOut(params).then(res=>{if (res.state === 1) {

wx.showToast({

title:'已下架',

icon:"none",

duration:1000,

mask:true,

})this.getMyRelease();this.setData({

showMore:!this.data.showMore,

lowind:0})

}

})

},/**

* 上架

*putaway*/putaway() {

let params={

userID: app.globalData.userID,

id:this.data.productID,

flag:this.data.productState

}

app.soldOut(params).then(res=>{if (res.state === 1) {

wx.showToast({

title:'已上架',

icon:"none",

duration:1000,

mask:true,

})this.getMyRelease();this.setData({

showMore:!this.data.showMore,

lowind:0})

}

})

},/**

* 删除

* productDel*/productDel() {

let params={

userID: app.globalData.userID,

id:this.data.productID

}

app.productDel(params).then(res=>{if (res.state === 1) {this.getMyRelease();this.setData({

showMore:!this.data.showMore,

lowind:0})

}

})

},/**

* 选择打折力度*/clickLowMoney(e) {

let price= this.data.lowMoney[e.currentTarget.dataset.index].money;if (this.data.lowind ==e.currentTarget.dataset.index) {this.setData({

lowind:-1})

}else{this.setData({

lowind: e.currentTarget.dataset.index,

low_mon: price

})

}

},/**

* 编辑*/edit(e) {

let productID=e.currentTarget.dataset.productid

wx.navigateTo({

url:'../productReleased/productReleased?productID=' +productID,

})

},/**

* 新建我的发布*/newRelease() {

wx.navigateTo({

url:'../productReleased/productReleased?productID=' + 0,

})

},

productDetail(e) {

wx.navigateTo({

url:'../product/product?id=' +e.currentTarget.dataset.id,

})

},//上拉事件

onReachBottom: function() {this.data.limit = this.data.limit + 5

this.getMyRelease();

},/**

* 获取我的发布*/getMyRelease() {

let params={

userID: app.globalData.userID,

limit:this.data.limit,

offset:0,

}

app.getMyRelease(params).then(res=>{

let release=res.data.releasethis.setData({

releases: release

})

})

},

})

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值