12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- // page/component/details/details.js
- Page({
- data:{
- goods: {
- id: 1,
- image: '/image/goods1.png',
- title: '新鲜梨花带雨',
- price: 0.01,
- stock: '有货',
- detail: '这里是梨花带雨详情。',
- parameter: '125g/个',
- service: '不支持退货'
- },
- num: 1,
- totalNum: 0,
- hasCarts: false,
- curIndex: 0,
- show: false,
- scaleCart: false
- },
- addCount() {
- let num = this.data.num;
- num++;
- this.setData({
- num : num
- })
- },
- addToCart() {
- const self = this;
- const num = this.data.num;
- let total = this.data.totalNum;
- self.setData({
- show: true
- })
- setTimeout( function() {
- self.setData({
- show: false,
- scaleCart : true
- })
- setTimeout( function() {
- self.setData({
- scaleCart: false,
- hasCarts : true,
- totalNum: num + total
- })
- }, 200)
- }, 300)
- },
- bindTap(e) {
- const index = parseInt(e.currentTarget.dataset.index);
- this.setData({
- curIndex: index
- })
- }
-
- })
|