wineList-MiniApp/miniprogram/pages/detail/detail.ts

193 lines
4.9 KiB
TypeScript
Raw Normal View History

2023-04-28 18:04:49 +08:00
// pages/detail/detail.ts
Page({
/**
*
*/
data: {
title:'',
measure_flag:false,
person_number:1,
measure_show_types:[
{
name:'小数'
},
{
name:'分数'
}
],
measure_show_types_index:0,
measure_units:[
{
name:'shot'
},
{
name:'oz'
},
{
name:'ml'
},
{
name:'cl'
}
],
measure_units_index:0,
material_data:[
{
name:'金酒',
unit:'shot',
per_percent:0.5
},
{
name:'绿查特酒',
unit:'shot',
per_percent:0.5
},
{
name:'路萨朵樱桃酒',
unit:'shot',
per_percent:0.5
},
{
name:'青柠汁',
unit:'shot',
per_percent:0.5
}
],
steps:[
{
desc:'奖所有原料和冰块一起加入到摇酒壶中摇匀'
},
{
desc:'可选的酒渍樱桃装饰'
}
],
deep_info:`这款酒起源于一个世纪以前的底特律,但是它的名字典故已经不可考据。
The Last Word是一款在现代复活的典型古典鸡尾酒1951Ted Saucier Bottoms Up
2005Murray Stenson Zigzag Café的菜单中
The Last Word的重新出现吸引了很多鸡尾酒媒体的关注The Last Word的重新出现是一个重大发现绿使绿
The Last Word是一款草药风味非常突出的鸡尾酒绿Murray StensonThe Last Word的出现吸引了更多人探索一些失传的鸡尾酒配方绿
The Last Word和Last CallThe Last Word来作为最后一杯酒`,
top:0
},
/**
* --
*/
onLoad(e) {
console.log(e.tag);
wx.setNavigationBarTitle({
title: e.tag || '详情'
})
this.setData({
title:e.name
})
},
/**
* --
*/
onReady() {
},
/**
* --
*/
onShow() {
},
/**
* --
*/
onHide() {
},
/**
* --
*/
onUnload() {
},
/**
* --
*/
onPullDownRefresh() {
},
/**
*
*/
onReachBottom() {
},
/**
*
*/
onShareAppMessage() {
},
measureShowTypesChange(e:any) {
// console.log(e.detail.value);
this.setData({
measure_show_types_index:Number(e.detail.value)
})
},
openMeasureFunc(){
const _this = this
var query = wx.createSelectorQuery();
query.select("#detail-container").boundingClientRect((rect)=> {
if(!this.data.measure_flag) {
_this.setData({
top:Math.abs(rect.top)
})
}
// console.log(rect)//width等
this.setData({
measure_flag:!this.data.measure_flag
})
wx.pageScrollTo({
scrollTop: _this.data.top,
// scrollTop:230,
duration: 100
})
}).exec();
},
measureUnitsChange(e:any) {
this.setData({
measure_units_index:Number(e.detail.value)
})
},
closeFunc() {
// this.setData({
// measure_flag:!this.data.measure_flag
// })
this.openMeasureFunc()
},
personNumberFunc(params:any) {
const type = params.currentTarget.dataset.type
// console.log(type);
if(type == 1) { // 减
if(this.data.person_number>1) {
this.setData({
person_number:--this.data.person_number
})
}
}
else{ // 加
this.setData({
person_number:++this.data.person_number
})
}
}
})