| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <template>
- <view class="book-item">
- <view class="book-info">
- <image class="book-cover" :src="book.cover" mode="aspectFill" />
- <view class="book-detail">
- <view class="top-info">
- <view class="book-title">{{ book.bookName }}</view>
- <view class="book-tags">
- <text class="tzs tag-text" v-if="book.suit==1">套装书</text>
- <text class="kmdb tag-text" v-if="book.maxNum>1">可卖多本</text>
- </view>
- </view>
- <view class="flex flex-j-b flex-a-c">
- <view class="book-price">回收价: ¥{{ book.recycleMoney }}</view>
- <u-number-box class="number-box" bg-color="#38c148" color="#ffffff" v-model="book.num" :min="1"
- :max="book.maxNum||40" @blur="onQuantityChange" @minus="addReduceNum(-1)"
- @plus="addReduceNum(1)"></u-number-box>
- </view>
- </view>
- <view class="delete-btn" @tap="onDelete">
- <u-icon name="close" size="26" color="#999"></u-icon>
- </view>
- </view>
- <common-dialog ref="deleteDialog" title="温馨提示" @confirm="confirmDelete">
- <text>确定删除这本图书吗?</text>
- </common-dialog>
- </view>
- </template>
- <script>
- import commonDialog from '@/components/common-dialog.vue';
- export default {
- components: {
- commonDialog
- },
- props: {
- book: {
- type: Object,
- required: true
- }
- },
- data() {
- return {}
- },
- methods: {
- onDelete() {
- this.$refs.deleteDialog.openPopup()
- },
- confirmDelete() {
- this.$emit('delete', this.book.isbn)
- },
- // /api/token/order/addReduceNum
- addReduceNum(changeNum) {
- uni.$u.http.post('/token/order/addReduceNum', {
- orderId: this.book.orderId,
- isbn: this.book.isbn,
- changeNum
- }).then(res => {
- if (res.data == 1) {
- this.$emit('quantity-change', this.book)
- }
- })
- },
- onQuantityChange(data) {
- console.log(this.book, 'xxxxx')
- uni.$u.http.post('/token/order/changeNum', {
- orderId: this.book.orderId,
- isbn: this.book.isbn,
- afterNum: data.value
- }).then(res => {
- if (res.data == 1) {
- this.$emit('quantity-change', this.book)
- }
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .book-item {
- background: #FFFFFF;
- padding: 20rpx;
- margin-top: 20rpx;
- border-radius: 10rpx;
- .book-info {
- display: flex;
- position: relative;
- .book-cover {
- width: 140rpx;
- height: 196rpx;
- border-radius: 8rpx;
- }
- .tag-text {
- font-family: Source Han Sans CN;
- font-weight: 400;
- font-size: 24rpx;
- color: #FFFFFF;
- }
- .tzs {
- width: 91rpx;
- height: 30rpx;
- background: linear-gradient(263deg, #98E05F, #0DE3AC);
- border-radius: 2rpx;
- padding: 4rpx 10rpx;
- margin-right: 10rpx;
- }
- .kmdb {
- width: 117rpx;
- height: 30rpx;
- background: linear-gradient(263deg, #F7CB6B, #FBA980);
- border-radius: 2rpx;
- padding: 4rpx 10rpx;
- margin-right: 10rpx;
- }
- .book-detail {
- flex: 1;
- margin-left: 20rpx;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- :v-deep .u-number-input {
- background: #F9F9F9 !important;
- border-radius: 6rpx;
- }
- .book-title {
- max-width: 400rpx;
- font-size: 28rpx;
- color: #333;
- line-height: 1.4;
- margin-bottom: 20rpx;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- font-family: Source Han Sans CN;
- font-weight: bold;
- }
- .book-price {
- font-family: Source Han Sans CN;
- font-weight: 400;
- font-size: 24rpx;
- color: #999999;
- }
- }
- .delete-btn {
- position: absolute;
- right: 0;
- top: -10rpx;
- padding: 10rpx;
- }
- }
- }
- </style>
|