Purchasehitory.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <!-- 购买记录 -->
  3. <div class="Purchasehitory">
  4. <div class="cut">
  5. <div class="sele">
  6. <div
  7. @click="SelectShowEvent('1')"
  8. :class="SelectShow == '1' ? 'select' : ''"
  9. >
  10. 已购买
  11. </div>
  12. <div
  13. @click="SelectShowEvent('2')"
  14. :class="SelectShow == '1' ? '' : 'select'"
  15. >
  16. 待付款
  17. </div>
  18. </div>
  19. </div>
  20. <div class="list">
  21. <!-- 已购买 -->
  22. <div v-if="SelectShow == '1'" class="haveBought">
  23. <div>
  24. <div class="image">
  25. <img src="../../assets/Personalcenter/image/img1.png" alt="" />
  26. </div>
  27. <div class="text">
  28. <p class="title">
  29. <span>Learn Chinese with Ease-Learn Chinese with Ease</span>
  30. <span>2021-05-21 16:43:12</span>
  31. </p>
  32. <p>Beijing language and Culture University</p>
  33. <p>Esther Howard</p>
  34. <div class="buy">
  35. <span class="price">
  36. $
  37. <span class="price_1" v-text="changePrice('1', '19.99')"></span>
  38. <span class="price_2" v-text="changePrice('2', '19.99')"></span>
  39. </span>
  40. <button>已购买</button>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <!-- 待付款 -->
  46. <div v-else class="obligation">
  47. <div>
  48. <div class="image">
  49. <img src="../../assets/Personalcenter/image/img1.png" alt="" />
  50. </div>
  51. <div class="text">
  52. <p class="title">
  53. <span>Learn Chinese with Ease-Learn Chinese with Ease</span>
  54. <span>2021-05-21 16:43:12</span>
  55. </p>
  56. <p>Beijing language and Culture University</p>
  57. <p>Esther Howard</p>
  58. <div class="buy">
  59. <span class="price">
  60. $
  61. <span class="price_1" v-text="changePrice('1', '19.99')"></span>
  62. <span class="price_2" v-text="changePrice('2', '19.99')"></span>
  63. </span>
  64. <button>购买</button>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </template>
  72. <script>
  73. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  74. //例如:import 《组件名称》from ‘《组件路径》';
  75. export default {
  76. //import引入的组件需要注入到对象中才能使用
  77. components: {},
  78. props: {},
  79. data() {
  80. //这里存放数据
  81. return {
  82. SelectShow: "1",
  83. };
  84. },
  85. //计算属性 类似于data概念
  86. computed: {},
  87. //监控data中数据变化
  88. watch: {},
  89. //方法集合
  90. methods: {
  91. // 选择已购买还是待付款
  92. SelectShowEvent(num) {
  93. this.SelectShow = num;
  94. },
  95. // 处理价格
  96. changePrice(type, item) {
  97. if (item.indexOf(".") != -1) {
  98. if (type == 1) {
  99. return item.split(".")[0];
  100. } else if (type == 2) {
  101. return "." + item.split(".")[1];
  102. }
  103. } else {
  104. if (type == 1) {
  105. return item;
  106. }
  107. }
  108. },
  109. },
  110. //生命周期 - 创建完成(可以访问当前this实例)
  111. created() {},
  112. //生命周期 - 挂载完成(可以访问DOM元素)
  113. mounted() {},
  114. //生命周期-创建之前
  115. beforeCreated() {},
  116. //生命周期-挂载之前
  117. beforeMount() {},
  118. //生命周期-更新之前
  119. beforUpdate() {},
  120. //生命周期-更新之后
  121. updated() {},
  122. //生命周期-销毁之前
  123. beforeDestory() {},
  124. //生命周期-销毁完成
  125. destoryed() {},
  126. //如果页面有keep-alive缓存功能,这个函数会触发
  127. activated() {},
  128. };
  129. </script>
  130. <style lang="scss" scoped>
  131. /* @import url(); 引入css类 */
  132. .Purchasehitory {
  133. .cut {
  134. margin: 32px;
  135. .sele {
  136. width: 318px;
  137. height: 48px;
  138. background: #ebebeb;
  139. border-radius: 30px;
  140. color: #9f9f9f;
  141. font-size: 20px;
  142. display: flex;
  143. align-items: center;
  144. > div {
  145. width: 158px;
  146. height: 48px;
  147. border-radius: 30px;
  148. line-height: 48px;
  149. text-align: center;
  150. cursor: pointer;
  151. }
  152. .select {
  153. background: #ff9900;
  154. color: white;
  155. box-shadow: 0px 2px 8px rgba(255, 153, 0, 0.15);
  156. }
  157. }
  158. }
  159. .list {
  160. .haveBought {
  161. > div {
  162. display: flex;
  163. height: 160px;
  164. width: 100%;
  165. padding: 16px 16px 16px 32px;
  166. border-bottom: 1px solid #9f9f9f;
  167. .image {
  168. img {
  169. width: 96px;
  170. height: 128px;
  171. }
  172. }
  173. .text {
  174. width: 800px;
  175. margin-left: 16px;
  176. margin-right: 16px;
  177. p {
  178. margin: 0;
  179. font-size: 16px;
  180. }
  181. .title {
  182. font-weight: 600;
  183. color: #2c2c2c;
  184. display: flex;
  185. justify-content: space-between;
  186. :nth-child(2) {
  187. color: #2c2c2c;
  188. opacity: 0.7;
  189. }
  190. }
  191. p:not(.title) {
  192. margin-top: 8px;
  193. color: #2c2c2c;
  194. opacity: 0.7;
  195. }
  196. .buy {
  197. text-align: right;
  198. button {
  199. width: 120px;
  200. height: 40px;
  201. background: #d5d5d5;
  202. border-radius: 4px;
  203. border: none;
  204. outline: none;
  205. cursor: pointer;
  206. color: white;
  207. margin-left: 16px;
  208. }
  209. }
  210. }
  211. }
  212. }
  213. .obligation {
  214. > div {
  215. display: flex;
  216. height: 160px;
  217. width: 100%;
  218. padding: 16px 16px 16px 32px;
  219. border-bottom: 1px solid #9f9f9f;
  220. .image {
  221. img {
  222. width: 96px;
  223. height: 128px;
  224. }
  225. }
  226. .text {
  227. width: 800px;
  228. margin-left: 16px;
  229. margin-right: 16px;
  230. p {
  231. margin: 0;
  232. font-size: 16px;
  233. }
  234. .title {
  235. font-weight: 600;
  236. color: #2c2c2c;
  237. display: flex;
  238. justify-content: space-between;
  239. :nth-child(2) {
  240. color: #2c2c2c;
  241. opacity: 0.7;
  242. }
  243. }
  244. p:not(.title) {
  245. margin-top: 8px;
  246. color: #2c2c2c;
  247. opacity: 0.7;
  248. }
  249. .buy {
  250. text-align: right;
  251. button {
  252. width: 120px;
  253. height: 40px;
  254. background: #ff9900;
  255. border-radius: 4px;
  256. border: none;
  257. outline: none;
  258. cursor: pointer;
  259. color: white;
  260. margin-left: 16px;
  261. }
  262. }
  263. }
  264. }
  265. }
  266. .price {
  267. font-weight: 600;
  268. font-size: 24px;
  269. .price_2 {
  270. font-size: 16px;
  271. }
  272. }
  273. }
  274. }
  275. </style>