| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358 |
- <template>
- <view class="book-item" :class="{ disabled: book.status != 1 }">
- <view class="book-info">
- <view class="book-image-container">
- <u-image
- width="140rpx"
- height="140rpx"
- :src="book.cover"
- mode="aspectFill"
- />
- <view class="no-recycle" v-if="book.status != 1">
- <text>已收满</text>
- </view>
- </view>
- <view class="book-detail">
- <view class="book-title">
- <view class="book-name">{{ book.bookName }}</view>
- <view class="book-price-labels">
- <view
- class="book-upsell has-upsell"
- v-if="book.currUpsellMoney > 0 && book.canInvite !== 1"
- >已涨价{{ book.currUpsellMoney }}元
- <image
- src="/static/img/activity/up3.png"
- mode="aspectFill"
- style="width: 22rpx; height: 16rpx; margin-left: 6rpx"
- />
- </view>
- <view
- class="book-upsell enable-upsell"
- v-if="book.canInvite === 1 && book.upsellMoney"
- >
- 可涨价{{ book.upsellMoney }}元
- <image
- src="/static/img/activity/up.png"
- mode="aspectFill"
- style="width: 16rpx; height: 16rpx; margin-left: 6rpx"
- />
- </view>
- </view>
- </view>
- <view class="flex flex-j-b flex-a-c mb-10">
- <view class="top-info">
- <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="countdown-wrap" v-if="book.restTime > 0">
- <text>加价即将结束</text>
- <u-count-down
- :timestamp="book.restTime"
- format="HH:mm:ss"
- autoStart
- color="#db0702"
- font-size="24"
- separator-color="#db0702"
- separator-size="24"
- @finish="onCountdownFinish"
- ></u-count-down>
- </view>
- </view>
- <view class="flex flex-j-b" style="align-items: center">
- <view class="price-action">
- <view class="book-price"
- >回收价
- <text style="font-weight: 600; color: #db0702; margin-left: 8rpx">
- ¥{{ book.recycleMoney }}</text
- ></view
- >
- <button
- class="up-price-btn"
- @tap="handleUpsell"
- v-if="book.canInvite === 1"
- >
- 去加价
- </button>
- </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)"
- :disabled="book.status != 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>{{
- book.upsellMoney
- ? "此书为限时加价收图书,删除后再次添加将失去加价收资格,确定删除吗?"
- : "确定删除这本图书吗?"
- }}</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 {};
- },
- computed: {
- recycleMoney() {
- return (this.book.recyclePrice * (this.book.num || 1)).toFixed(2);
- },
- },
- methods: {
- onDelete() {
- this.$emit("delete", this.book);
- // this.$refs.deleteDialog.openPopup();
- },
- confirmDelete() {
- this.$emit("delete", this.book);
- },
- // /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.code == 200) {
- if (res.data == 1) {
- this.$emit("quantity-change", this.book);
- let { upsellMoney, upsellNum, maxUpsellNum, num } = this.book;
- let bool = upsellMoney && maxUpsellNum >= num && changeNum == 1 && maxUpsellNum > upsellNum
- if (bool) {
- this.handleUpsell();
- }
- }
- } else {
- uni.$u.toast(res.msg);
- }
- });
- },
- onQuantityChange(data) {
- 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);
- }
- });
- },
- handleUpsell() {
- this.$emit("upsell", this.book);
- },
- onCountdownFinish() {
- this.$emit("countdown-finish", this.book);
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .book-item {
- background: #ffffff;
- padding: 20rpx;
- margin-top: 20rpx;
- border-radius: 10rpx;
- &.disabled {
- background: #f9ccc9;
- }
- ::v-deep .u-countdown-colon {
- font-size: 24rpx !important;
- }
- .book-info {
- display: flex;
- align-items: center;
- position: relative;
- .book-image-container {
- position: relative;
- .no-recycle {
- position: absolute;
- bottom: 0;
- left: 50%;
- transform: translateX(-50%);
- background-color: #ff5252;
- color: #ffffff;
- padding: 4rpx 10rpx;
- border-radius: 4rpx 4rpx 0 0;
- font-size: 24rpx;
- text-align: center;
- width: 100%;
- }
- }
- .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 {
- width: calc(100% - 60rpx);
- margin-bottom: 10rpx;
- display: flex;
- align-items: center;
- }
- .book-name {
- font-size: 28rpx;
- color: #333;
- line-height: 1.4;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- font-family: Source Han Sans CN;
- font-weight: bold;
- word-break: break-all;
- margin-right: 10rpx;
- }
- .book-price-labels {
- display: flex;
- margin-top: -2rpx;
- flex-shrink: 0;
- }
- .book-price {
- font-family: Source Han Sans CN;
- font-weight: 400;
- font-size: 24rpx;
- color: #999999;
- }
- .price-action {
- display: flex;
- align-items: center;
- .up-price-btn {
- background-color: #38c148;
- color: #ffffff;
- font-size: 24rpx;
- height: 48rpx;
- line-height: 48rpx;
- padding: 0 10rpx;
- border-radius: 24rpx;
- margin-left: 10rpx;
- }
- }
- }
- .countdown-wrap {
- display: flex;
- align-items: center;
- font-size: 24rpx !important;
- color: #db0702;
- margin-left: 6rpx;
- text {
- margin-right: 6rpx;
- }
- }
- .book-upsell {
- font-size: 22rpx;
- padding: 2rpx 10rpx;
- border-radius: 4rpx;
- margin-right: 10rpx;
- display: inline-flex;
- align-items: center;
- &.has-upsell {
- color: #276f1e;
- background-color: #a8dda2;
- }
- &.enable-upsell {
- color: #ff0e11;
- background-color: #ffe9eb;
- }
- .u-image {
- margin-left: 4rpx;
- }
- }
- .delete-btn {
- position: absolute;
- right: 0;
- top: -10rpx;
- padding: 10rpx;
- }
- }
- }
- </style>
|