BookItem.vue 8.0 KB

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