_id.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <div class="point-detail">
  3. <div class="good">
  4. <img :src="ware.waresPic" alt="" srcset="" />
  5. </div>
  6. <div class="title">
  7. <div class="text">{{ ware.waresName }}</div>
  8. <div class="price">
  9. <span class="icon"></span>
  10. <span class="amount">{{ ware.saleIntegral }}</span>
  11. </div>
  12. <div class="sold">已兑换 {{ ware.waresOutCount }}</div>
  13. </div>
  14. <!-- <div class="selected">
  15. <div class="text">已选</div>
  16. <div class="content">儿童情商课+智慧课堂,1</div>
  17. <div class="icon"></div>
  18. </div> -->
  19. <!-- <div class="pictures">
  20. <div class="text">- 图文详情 -</div>
  21. </div> -->
  22. <div class="buy">
  23. <button @click="exchange">立刻兑换</button>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. import { mapActions, mapState, mapGetters } from "vuex";
  29. export default {
  30. validate({ params }) {
  31. // 必须是number类型
  32. return /^\d{1,}$/.test(params.id);
  33. },
  34. head() {
  35. return {
  36. title: "积分商品详情页",
  37. };
  38. },
  39. data() {
  40. return {
  41. ware: {},
  42. id: this.$route.params.id,
  43. };
  44. },
  45. mounted() {
  46. this.getPointInfo();
  47. this.init();
  48. },
  49. computed: {
  50. ...mapState({
  51. pointInfo:state=>state.point.pointInfo
  52. }),
  53. ...mapGetters({
  54. findWare: "point/findWare",
  55. }),
  56. },
  57. methods: {
  58. ...mapActions({
  59. getPointInfo: "point/getPointInfo",
  60. }),
  61. init() {
  62. this.ware = this.findWare(this.id);
  63. },
  64. exchange() {
  65. if (this.ware.waresCount <= 0) {
  66. alert("该商品库存不足");
  67. } else if (this.ware.saleIntegral > this.pointInfo.points) {
  68. alert("您的积分不足");
  69. } else {
  70. this.$router.push({
  71. path: "/point/pay/" + this.id,
  72. });
  73. }
  74. },
  75. },
  76. };
  77. </script>
  78. <style>
  79. .point-detail {
  80. display: flex;
  81. width: 100vw;
  82. flex-direction: column;
  83. box-sizing: border-box;
  84. background: #f8f8f8;
  85. }
  86. .point-detail .good {
  87. box-sizing: border-box;
  88. width: 100vw;
  89. height: 100vw;
  90. padding: 15vw;
  91. background: #ffffff;
  92. }
  93. .point-detail .good img {
  94. width: 100%;
  95. height: 100%;
  96. }
  97. .point-detail .title {
  98. width: 100%;
  99. height: 26.66vw;
  100. padding: 4vw;
  101. background: #ffffff;
  102. position: relative;
  103. box-sizing: border-box;
  104. }
  105. .point-detail .title .text {
  106. width: 3.6rem;
  107. height: 0.5rem;
  108. font-size: 0.36rem;
  109. font-family: PingFangSC-Medium, PingFang SC;
  110. font-weight: 800;
  111. color: #111111;
  112. line-height: 0.5rem;
  113. position: absolute;
  114. left: 0.3rem;
  115. top: 0.3rem;
  116. }
  117. .point-detail .title .price {
  118. height: 0.7rem;
  119. font-size: 0.28rem;
  120. font-family: PingFangSC-Semibold, PingFang SC;
  121. font-weight: 600;
  122. color: #fe9700;
  123. line-height: 0.7rem;
  124. position: absolute;
  125. left: 0.57rem;
  126. bottom: 0.27rem;
  127. }
  128. .point-detail .title .price .icon {
  129. display: inline-block;
  130. width: 0.3rem;
  131. height: 0.3rem;
  132. background: url("../../../static/common/a01_jifen@2x.png") no-repeat;
  133. background-size: cover;
  134. margin-right: 0.1rem;
  135. }
  136. .point-detail .title .price .amount {
  137. display: inline-block;
  138. font-size: 0.5rem;
  139. }
  140. .point-detail .title .sold {
  141. height: 0.4rem;
  142. font-size: 0.28rem;
  143. font-family: PingFangSC-Regular, PingFang SC;
  144. font-weight: 400;
  145. color: #666666;
  146. line-height: 0.4rem;
  147. position: absolute;
  148. right: 0.45rem;
  149. bottom: 0.3rem;
  150. }
  151. .point-detail .selected {
  152. width: 100%;
  153. height: 1.1rem;
  154. background: #ffffff;
  155. margin-top: 0.2rem;
  156. position: relative;
  157. }
  158. .point-detail .selected .text {
  159. width: 0.56rem;
  160. height: 1.1rem;
  161. font-size: 0.28rem;
  162. font-family: PingFangSC-Regular, PingFang SC;
  163. font-weight: 400;
  164. color: #aaaaaa;
  165. line-height: 1.1rem;
  166. position: absolute;
  167. left: 0.31rem;
  168. top: 0rem;
  169. }
  170. .point-detail .selected .content {
  171. width: 3.09rem;
  172. height: 1.1rem;
  173. font-size: 0.28rem;
  174. font-family: PingFangSC-Regular, PingFang SC;
  175. font-weight: 500;
  176. color: #111111;
  177. line-height: 1.1rem;
  178. position: absolute;
  179. left: 1.17rem;
  180. }
  181. .point-detail .selected .icon {
  182. width: 0.42rem;
  183. height: 0.1rem;
  184. background: url("../../../static/point/6_d02_more.png") no-repeat 0px 0px;
  185. background-size: cover;
  186. position: absolute;
  187. left: 6.3rem;
  188. top: 0.49rem;
  189. }
  190. .point-detail .pictures {
  191. width: 100%;
  192. height: 3.2rem;
  193. background: #ffffff;
  194. margin-top: 0.21rem;
  195. position: relative;
  196. }
  197. .point-detail .pictures .text {
  198. width: 1.74rem;
  199. height: 1.1rem;
  200. font-size: 0.28rem;
  201. font-family: PingFangSC-Regular, PingFang SC;
  202. font-weight: 400;
  203. color: #aaaaaa;
  204. line-height: 1.1rem;
  205. position: absolute;
  206. top: 0rem;
  207. left: 2.88rem;
  208. }
  209. .point-detail .buy {
  210. position: fixed;
  211. bottom: 0.83rem;
  212. left: 0;
  213. right: 0;
  214. height: 1.03rem;
  215. }
  216. .point-detail .buy button {
  217. border: none;
  218. background-color: transparent;
  219. outline: none;
  220. display: block;
  221. width: 6.9rem;
  222. height: 0.8rem;
  223. background: #fe9700;
  224. border-radius: 0.45rem;
  225. font-size: 0.28rem;
  226. font-family: PingFangSC-Regular, PingFang SC;
  227. font-weight: 400;
  228. color: #ffffff;
  229. line-height: 0.4rem;
  230. margin: 0 auto;
  231. }
  232. </style>