| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- var app = getApp();
- Component({
- properties: {
- iSplus: {
- type: Boolean,
- value: true
- },
- iSbnt: {
- type: Number,
- value: 0
- },
- limitNum: {
- type: Number,
- value: 0
- },
- attribute: {
- type: Object,
- value: {}
- },
- attrList: {
- type: Object,
- value: [],
- },
- productAttr: {
- type: Object,
- value: [],
- },
- productSelect: {
- type: Object,
- value: {
- image: '',
- store_name: '',
- price: 0,
- unique: '',
- stock: 0,
- }
- },
- },
- data: {
- attrValue: [],
- attrIndex: 0,
- isShow: false
- },
- attached: function () {
- let pages = getCurrentPages();
- let currPage = null;
- if (pages.length) {
- currPage = pages[pages.length - 1];
- }
- let route = currPage.route
- this.setData({
- isShow: route.indexOf("goods_details") !== -1
- });
- },
- methods: {
- /**
- * 购物车手动输入数量
- */
- bindCode: function (e) {
- this.triggerEvent('iptCartNum', e.detail.value);
- },
- close: function () {
- this.triggerEvent('myevent', {
- 'window': false
- });
- },
- goCat: function () {
- this.triggerEvent('goCat');
- },
- CartNumDes: function () {
- this.triggerEvent('ChangeCartNum', false);
- },
- CartNumInt: function () {
- this.triggerEvent('ChangeCartNum', true);
- },
- tapAttr: function (e) {
- //父级index
- var indexw = e.currentTarget.dataset.indexw;
- //子集index
- var indexn = e.currentTarget.dataset.indexn;
- //每次点击获得的属性
- var attr = this.data.productAttr[indexw].attr_value[indexn];
- //设置当前点击属性
- this.data.productAttr[indexw].checked = attr['attr'];
- this.setData({
- productAttr: this.data.productAttr,
- });
- var value = this.getCheckedValue().sort().join(',');
- this.triggerEvent('ChangeAttr', value);
- },
- getCheckedValue: function () {
- return this.data.productAttr.map(function (attr) {
- return attr.checked;
- });
- },
-
- ResetAttr: function () {
- for (var k in this.data.productAttr) this.data.productAttr[k].checked = '';
- this.setData({
- productAttr: this.data.productAttr
- });
- },
- }
- })
|