| | |
| | | }) |
| | | return totalprice.toFixed(2) |
| | | }, |
| | | methods: { |
| | | async submitPay() { |
| | | // order/confirm/info |
| | | var arr = [] |
| | | for (var j = 0; j < this.list.flowerList; j++) { |
| | | }, |
| | | methods: { |
| | | async submitPay() { |
| | | // order/confirm/info |
| | | var arr = [] |
| | | for (var j = 0; j < this.list.flowerList; j++) { |
| | | |
| | | if (this.ids.indexOf(this.list.flowerList[j].id) >= 0) { |
| | | arr.push({ |
| | | id: this.list.flowerList[j].id, |
| | | num: this.list.flowerList[j].num |
| | | }) |
| | | } |
| | | } |
| | | if (this.arr.length < 1) { |
| | | return |
| | | } |
| | | this.$message.showLoading() |
| | | const {code, data} = await http.request('post', '/api/api/customer/order/confirm/info', { |
| | | data: { |
| | | flowers: arr, |
| | | } |
| | | } |
| | | ) |
| | | this.$message.hideLoading() |
| | | if (code === 0) { |
| | | uni.navigateTo({ |
| | | url: '/sub_pages/customer/shopping/confirm?dto=' + +encodeURIComponent(JSON.stringify(data)) |
| | | if (this.ids.indexOf(this.list.flowerList[j].id) >= 0) { |
| | | arr.push({ |
| | | id: this.list.flowerList[j].id, |
| | | num: this.list.flowerList[j].num |
| | | }) |
| | | } |
| | | }, |
| | | async clickSwipeButton(item) { |
| | | //删除商品,重新加载数据? |
| | | |
| | | this.$message.showLoading() |
| | | const {code} = await http.request('post', '/api/api/customer/flower/cart/change-num', { |
| | | data: { |
| | | id: dto.id, |
| | | num: addnum |
| | | } |
| | | } |
| | | if (this.arr.length < 1) { |
| | | return |
| | | } |
| | | this.$message.showLoading() |
| | | const {code, data} = await http.request('post', '/api/api/customer/order/confirm/info', { |
| | | data: { |
| | | flowers: arr, |
| | | } |
| | | ) |
| | | this.$message.hideLoading() |
| | | if (code === 0) { |
| | | if (this.ids.indexOf(item.id) >= 0) { |
| | | this.ids.splice(this.ids.indexOf(item.id), 1) |
| | | } |
| | | for (var i = 0; i < this.list.length; i++) { |
| | | if (this.list[i].id === dto.supplierId) { |
| | | this.list[i].splice(i, 1) |
| | | if (this.list.flowerList.length === 1) { |
| | | if (this.ids.indexOf(this.list[i].id) >= 0) { |
| | | this.ids.splice(this.ids.indexOf(this.list[i].id), 1) |
| | | ) |
| | | this.$message.hideLoading() |
| | | if (code === 0) { |
| | | uni.navigateTo({ |
| | | url: '/sub_pages/customer/shopping/confirm?dto=' + +encodeURIComponent(JSON.stringify(data)) |
| | | }) |
| | | } |
| | | }, |
| | | async clickSwipeButton(item) { |
| | | //删除商品,重新加载数据? |
| | | |
| | | this.$message.showLoading() |
| | | const {code} = await http.request('post', '/api/customer/flower/cart/change-num', { |
| | | data: { |
| | | id: dto.id, |
| | | num: addnum |
| | | } |
| | | } |
| | | ) |
| | | this.$message.hideLoading() |
| | | if (code === 0) { |
| | | if (this.ids.indexOf(item.id) >= 0) { |
| | | this.ids.splice(this.ids.indexOf(item.id), 1) |
| | | } |
| | | for (var i = 0; i < this.list.length; i++) { |
| | | if (this.list[i].id === dto.supplierId) { |
| | | this.list[i].splice(i, 1) |
| | | if (this.list.flowerList.length === 1) { |
| | | if (this.ids.indexOf(this.list[i].id) >= 0) { |
| | | this.ids.splice(this.ids.indexOf(this.list[i].id), 1) |
| | | } |
| | | this.list[i].flowerList.splice(0, 1) |
| | | this.list.splice(i, 1) |
| | | } else { |
| | | //只需要清楚这个元素 |
| | | var k = -1 |
| | | for (var j = 0; j < this.list[i].flowerList.length; j++) { |
| | | if (this.list[i][j].id === item.id) { |
| | | k = j; |
| | | break |
| | | } |
| | | this.list[i].flowerList.splice(0, 1) |
| | | this.list.splice(i, 1) |
| | | } else { |
| | | //只需要清楚这个元素 |
| | | var k = -1 |
| | | for (var j = 0; j < this.list[i].flowerList.length; j++) { |
| | | if (this.list[i][j].id === item.id) { |
| | | k = j; |
| | | break |
| | | } |
| | | } |
| | | this.list[i].flowerList.splice(k, 1) |
| | | } |
| | | break |
| | | this.list[i].flowerList.splice(k, 1) |
| | | } |
| | | break |
| | | } |
| | | } |
| | | }, |
| | | |
| | | selectAll() { |
| | | console.log('selectAll', this.checkall) |
| | | if (this.checkall) { |
| | | this.ids = [] |
| | | this.checkall = false |
| | | // this.$forceUpdate() |
| | | } else { |
| | | this.list.forEach(dto => { |
| | | if (this.ids.indexOf(dto.id) < 0) { |
| | | this.ids.push(dto.id) |
| | | } |
| | | dto.flowerList.forEach(item => { |
| | | if (this.ids.indexOf(item.id) < 0) { |
| | | this.ids.push(item.id) |
| | | } |
| | | }) |
| | | }) |
| | | this.checkall = true |
| | | } |
| | | }, |
| | | changeItem(dto, type) { |
| | | if (type === 'supplier') { |
| | | //全选上 |
| | | if (this.ids.indexOf(dto.id) < 0) { |
| | | this.ids.push(dto.id) |
| | | dto.flowerList.forEach(item => { |
| | | if (this.ids.indexOf(item.id) < 0) { |
| | | this.ids.push(item.id) |
| | | } |
| | | }) |
| | | } else { |
| | | this.checkall = false |
| | | this.ids.splice(this.ids.indexOf(dto.id), 1) |
| | | dto.flowerList.forEach(item => { |
| | | this.ids.splice(this.ids.indexOf(item.id), 1) |
| | | }) |
| | | } |
| | | |
| | | } else { |
| | | //更换个人的 |
| | | if (this.ids.indexOf(dto.id) < 0) { |
| | | this.ids.push(dto.id) |
| | | } else { |
| | | this.checkall = false |
| | | |
| | | if (this.ids.indexOf(dto.supplierId) >= 0) { |
| | | this.ids.splice(this.ids.indexOf(dto.supplierId), 1) |
| | | } |
| | | } |
| | | |
| | | } |
| | | }, |
| | | async addnum(dto, addnum) { |
| | | if (dto.num + addnum >= 0) { |
| | | |
| | | } else { |
| | | return |
| | | } |
| | | this.$message.showLoading() |
| | | const {code} = await http.request('post', '/api/api/customer/flower/cart/change-num', { |
| | | data: { |
| | | id: dto.id, |
| | | num: addnum |
| | | } |
| | | } |
| | | ) |
| | | this.$message.hideLoading() |
| | | if (code === 0) { |
| | | dto.num += addnum |
| | | } |
| | | }, |
| | | async init() { |
| | | this.$message.showLoading() |
| | | await this.$store.dispatch('sign_clear', 'shopping'); |
| | | const {code, data} = await this.$http.request('get', '/api/customer/flower/cart/list', {}) |
| | | this.$message.hideLoading() |
| | | this.list = [] |
| | | if (code === 0) { |
| | | this.list = data.list || [] |
| | | |
| | | } |
| | | } |
| | | }, |
| | | |
| | | selectAll() { |
| | | console.log('selectAll', this.checkall) |
| | | if (this.checkall) { |
| | | this.ids = [] |
| | | this.checkall = false |
| | | // this.$forceUpdate() |
| | | } else { |
| | | this.list.forEach(dto => { |
| | | if (this.ids.indexOf(dto.id) < 0) { |
| | | this.ids.push(dto.id) |
| | | } |
| | | dto.flowerList.forEach(item => { |
| | | if (this.ids.indexOf(item.id) < 0) { |
| | | this.ids.push(item.id) |
| | | } |
| | | }) |
| | | }) |
| | | this.checkall = true |
| | | } |
| | | }, |
| | | changeItem(dto, type) { |
| | | if (type === 'supplier') { |
| | | //全选上 |
| | | if (this.ids.indexOf(dto.id) < 0) { |
| | | this.ids.push(dto.id) |
| | | dto.flowerList.forEach(item => { |
| | | if (this.ids.indexOf(item.id) < 0) { |
| | | this.ids.push(item.id) |
| | | } |
| | | }) |
| | | } else { |
| | | this.checkall = false |
| | | this.ids.splice(this.ids.indexOf(dto.id), 1) |
| | | dto.flowerList.forEach(item => { |
| | | this.ids.splice(this.ids.indexOf(item.id), 1) |
| | | }) |
| | | } |
| | | |
| | | } else { |
| | | //更换个人的 |
| | | if (this.ids.indexOf(dto.id) < 0) { |
| | | this.ids.push(dto.id) |
| | | } else { |
| | | this.checkall = false |
| | | |
| | | if (this.ids.indexOf(dto.supplierId) >= 0) { |
| | | this.ids.splice(this.ids.indexOf(dto.supplierId), 1) |
| | | } |
| | | } |
| | | |
| | | } |
| | | }, |
| | | async addnum(dto, addnum) { |
| | | if (dto.num + addnum >= 0) { |
| | | |
| | | } else { |
| | | return |
| | | } |
| | | this.$message.showLoading() |
| | | const {code} = await http.request('post', '/api/customer/flower/cart/change-num', { |
| | | data: { |
| | | id: dto.id, |
| | | num: addnum |
| | | } |
| | | } |
| | | ) |
| | | this.$message.hideLoading() |
| | | if (code === 0) { |
| | | dto.num += addnum |
| | | } |
| | | }, |
| | | async init() { |
| | | this.$message.showLoading() |
| | | await this.$store.dispatch('sign_clear', 'shopping'); |
| | | const {code, data} = await this.$http.request('get', '/api/customer/flower/cart/list', {}) |
| | | this.$message.hideLoading() |
| | | this.list = [] |
| | | if (code === 0) { |
| | | this.list = data.list || [] |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |