BookItem.vue 8.5 KB

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