BookItem.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <view class="book-item" :class="{ disabled: book.status != 1 }">
  3. <view class="book-info">
  4. <view class="book-image-container">
  5. <u-image width="160rpx" height="160rpx" :src="book.cover" mode="aspectFill" />
  6. <view class="no-recycle" v-if="book.status != 1">
  7. <text>已收满</text>
  8. </view>
  9. </view>
  10. <view class="book-detail">
  11. <view class="book-title">
  12. <view class="book-name">{{ book.bookName }}</view>
  13. <view class="book-price-labels">
  14. <view class="book-upsell has-upsell" v-if="book.currUpsellMoney > 0">已涨价{{ book.currUpsellMoney }}元</view>
  15. <view class="book-upsell enable-upsell" v-if="!book.currUpsellMoney && book.upsellMoney">
  16. 可涨价{{ book.upsellMoney }}元
  17. <image src="/static/img/activity/up.png" mode="aspectFill" style="width: 16rpx; height: 16rpx;margin-left: 6rpx;" />
  18. </view>
  19. </view>
  20. </view>
  21. <view class="flex flex-j-b flex-a-c mb-10">
  22. <view class="top-info">
  23. <view class="book-tags">
  24. <text class="tzs tag-text" v-if="book.suit == 1">套装书</text>
  25. <text class="kmdb tag-text" v-if="book.maxNum > 1">可卖多本</text>
  26. </view>
  27. </view>
  28. <u-number-box
  29. class="number-box"
  30. bg-color="#38c148"
  31. color="#ffffff"
  32. v-model="book.num"
  33. :min="1"
  34. :max="book.maxNum || 40"
  35. @blur="onQuantityChange"
  36. @minus="addReduceNum(-1)"
  37. @plus="addReduceNum(1)"
  38. :disabled="book.status != 1"
  39. ></u-number-box>
  40. </view>
  41. <view class="flex flex-a-c" style="align-items: center;">
  42. <view class="book-price"
  43. >回收价
  44. <text style="font-weight: 600; color: #db0702; margin-left: 8rpx">
  45. ¥{{ recycleMoney }}</text
  46. ></view
  47. >
  48. <view class="price-action" style="margin-left: 20rpx;">
  49. <button class="up-price-btn" @tap="handleUpsell" v-if="book.canInvite === 1">去加价</button>
  50. <view class="countdown-wrap" v-if="book.restTime > 0">
  51. <text>加价剩余</text>
  52. <u-count-down
  53. :timestamp="book.restTime"
  54. format="HH:mm:ss"
  55. autoStart
  56. color="#db0702"
  57. separator-color="#db0702"
  58. @finish="onCountdownFinish"
  59. ></u-count-down>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="delete-btn" @tap="onDelete">
  65. <u-icon name="close" size="26" color="#999"></u-icon>
  66. </view>
  67. </view>
  68. <common-dialog ref="deleteDialog" title="温馨提示" @confirm="confirmDelete">
  69. <text>确定删除这本图书吗?</text>
  70. </common-dialog>
  71. </view>
  72. </template>
  73. <script>
  74. import commonDialog from "@/components/common-dialog.vue";
  75. export default {
  76. components: {
  77. commonDialog,
  78. },
  79. props: {
  80. book: {
  81. type: Object,
  82. required: true,
  83. },
  84. },
  85. data() {
  86. return {};
  87. },
  88. computed: {
  89. recycleMoney() {
  90. return (this.book.recyclePrice * (this.book.num || 1)).toFixed(2);
  91. },
  92. },
  93. methods: {
  94. onDelete() {
  95. this.$refs.deleteDialog.openPopup();
  96. },
  97. confirmDelete() {
  98. this.$emit("delete", this.book);
  99. },
  100. // /api/token/order/addReduceNum
  101. addReduceNum(changeNum) {
  102. uni.$u.http
  103. .post("/token/order/addReduceNum", {
  104. orderId: this.book.orderId,
  105. isbn: this.book.isbn,
  106. changeNum,
  107. })
  108. .then((res) => {
  109. if (res.data == 1) {
  110. this.$emit("quantity-change", this.book);
  111. }
  112. });
  113. },
  114. onQuantityChange(data) {
  115. uni.$u.http
  116. .post("/token/order/changeNum", {
  117. orderId: this.book.orderId,
  118. isbn: this.book.isbn,
  119. afterNum: data.value,
  120. })
  121. .then((res) => {
  122. if (res.data == 1) {
  123. this.$emit("quantity-change", this.book);
  124. }
  125. });
  126. },
  127. handleUpsell() {
  128. this.$emit("upsell", this.book);
  129. },
  130. onCountdownFinish() {
  131. this.$emit("countdown-finish", this.book);
  132. }
  133. },
  134. };
  135. </script>
  136. <style lang="scss" scoped>
  137. .book-item {
  138. background: #ffffff;
  139. padding: 20rpx;
  140. margin-top: 20rpx;
  141. border-radius: 10rpx;
  142. &.disabled {
  143. background: #f9ccc9;
  144. }
  145. .book-info {
  146. display: flex;
  147. align-items: center;
  148. position: relative;
  149. .book-image-container {
  150. position: relative;
  151. .no-recycle {
  152. position: absolute;
  153. bottom: 0;
  154. left: 50%;
  155. transform: translateX(-50%);
  156. background-color: #ff5252;
  157. color: #ffffff;
  158. padding: 4rpx 10rpx;
  159. border-radius: 4rpx 4rpx 0 0;
  160. font-size: 24rpx;
  161. text-align: center;
  162. width: 100%;
  163. }
  164. }
  165. .book-cover {
  166. width: 140rpx;
  167. height: 196rpx;
  168. border-radius: 8rpx;
  169. }
  170. .tag-text {
  171. font-family: Source Han Sans CN;
  172. font-weight: 400;
  173. font-size: 24rpx;
  174. color: #ffffff;
  175. }
  176. .tzs {
  177. width: 91rpx;
  178. height: 30rpx;
  179. background: linear-gradient(263deg, #98e05f, #0de3ac);
  180. border-radius: 2rpx;
  181. padding: 4rpx 10rpx;
  182. margin-right: 10rpx;
  183. }
  184. .kmdb {
  185. width: 117rpx;
  186. height: 30rpx;
  187. background: linear-gradient(263deg, #f7cb6b, #fba980);
  188. border-radius: 2rpx;
  189. padding: 4rpx 10rpx;
  190. margin-right: 10rpx;
  191. }
  192. .book-detail {
  193. flex: 1;
  194. margin-left: 20rpx;
  195. display: flex;
  196. flex-direction: column;
  197. justify-content: space-between;
  198. :v-deep .u-number-input {
  199. background: #f9f9f9 !important;
  200. border-radius: 6rpx;
  201. }
  202. .book-title {
  203. max-width: 400rpx;
  204. margin-bottom: 10rpx;
  205. display: flex;
  206. align-items: center;
  207. }
  208. .book-name {
  209. font-size: 28rpx;
  210. color: #333;
  211. line-height: 1.4;
  212. display: -webkit-box;
  213. -webkit-box-orient: vertical;
  214. -webkit-line-clamp: 2;
  215. overflow: hidden;
  216. font-family: Source Han Sans CN;
  217. font-weight: bold;
  218. word-break: break-all;
  219. margin-right: 10rpx;
  220. }
  221. .book-price-labels {
  222. display: flex;
  223. margin-top: -2rpx;
  224. flex-shrink: 0;
  225. }
  226. .book-price {
  227. font-family: Source Han Sans CN;
  228. font-weight: 400;
  229. font-size: 24rpx;
  230. color: #999999;
  231. }
  232. .price-action {
  233. display: flex;
  234. align-items: center;
  235. .up-price-btn {
  236. background-color: #38c148;
  237. color: #ffffff;
  238. font-size: 24rpx;
  239. height: 48rpx;
  240. line-height: 48rpx;
  241. padding: 0 20rpx;
  242. border-radius: 24rpx;
  243. }
  244. .countdown-wrap {
  245. display: flex;
  246. align-items: center;
  247. font-size: 22rpx;
  248. color: #db0702;
  249. text {
  250. margin-right: 10rpx;
  251. }
  252. :v-deep .u-count-down {
  253. .u-count-down__text {
  254. color: #db0702;
  255. font-size: 20rpx;
  256. }
  257. }
  258. }
  259. }
  260. }
  261. .book-upsell {
  262. font-size: 22rpx;
  263. padding: 2rpx 10rpx;
  264. border-radius: 4rpx;
  265. margin-right: 10rpx;
  266. display: inline-flex;
  267. align-items: center;
  268. &.has-upsell {
  269. color: #276f1e;
  270. background-color: #a8dda2;
  271. }
  272. &.enable-upsell {
  273. color: #ff0e11;
  274. background-color: #ffe9eb;
  275. }
  276. .u-image {
  277. margin-left: 4rpx;
  278. }
  279. }
  280. .delete-btn {
  281. position: absolute;
  282. right: 0;
  283. top: -10rpx;
  284. padding: 10rpx;
  285. }
  286. }
  287. }
  288. </style>