You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
4.9 KiB
TypeScript

1 year ago
// 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 Word1951Ted Saucier Bottoms Up
2005Murray Stenson Zigzag Café
The Last WordThe Last Word绿使绿
The Last Word绿Murray StensonThe Last Word绿
The Last WordLast 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
})
}
}
})