BookItem.vue 8.5 KB

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