BookItem.vue 9.9 KB

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