index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <view class="list" @tap="toView">
  6. <image class="image" :src="goodsInfo.file&&goodsInfo.file.length>0?goodsInfo.file[0].url:''"
  7. mode="">
  8. </image>
  9. <view class="list_1_1">
  10. <view class="name">
  11. {{goodsInfo.name||'暂无'}}
  12. </view>
  13. <view class="money">
  14. <text>¥</text>
  15. <text>{{specsInfo.sell_money}}</text>
  16. </view>
  17. <view class="other">
  18. <view class="other_1">
  19. {{goodsInfo.view_num||0}}人浏览
  20. </view>
  21. <view class="other_2">
  22. <text @tap.stop="toDel" class="iconfont icon-del"></text>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </mobile-frame>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. query: {},
  36. user: {},
  37. // 商品详情
  38. goodsInfo: {},
  39. // 规格详情
  40. specsInfo: {},
  41. };
  42. },
  43. onLoad: async function(e) {
  44. const that = this;
  45. that.$set(that, `query`, {
  46. goods_id: e.goods_id || '6343878989bdcb128d846990',
  47. specs_id: e.specs_id || '634394bc32c3065a80eb14ad'
  48. });
  49. },
  50. onShow: function() {
  51. const that = this;
  52. that.watchLogin();
  53. that.search();
  54. },
  55. methods: {
  56. // 监听用户是否登录
  57. watchLogin() {
  58. const that = this;
  59. uni.getStorage({
  60. key: 'token',
  61. success: function(res) {
  62. let user = that.$jwt(res.data);
  63. that.$set(that, `user`, user);
  64. },
  65. fail: function(err) {}
  66. })
  67. },
  68. // 查询列表
  69. async search() {
  70. const that = this;
  71. let res;
  72. res = await that.$api(`/goods/${that.query.goods_id}`, 'GET')
  73. if (res.errcode == '0') {
  74. that.$set(that, `goodsInfo`, res.data);
  75. }
  76. res = await that.$api(`/goodsSpec/${that.query.specs_id}`, 'GET')
  77. if (res.errcode == '0') {
  78. that.$set(that, `specsInfo`, res.data);
  79. }
  80. },
  81. }
  82. }
  83. </script>
  84. <style lang="scss">
  85. .main {
  86. display: flex;
  87. flex-direction: column;
  88. width: 100vw;
  89. height: 100vh;
  90. .one {
  91. .list {
  92. display: flex;
  93. flex-direction: row;
  94. justify-content: space-between;
  95. width: 91vw;
  96. border: 1px solid var(--f1Color);
  97. margin: 2vw 2vw 0 2vw;
  98. padding: 2vw;
  99. border-radius: 5px;
  100. .image {
  101. width: 25vw;
  102. height: 25vw;
  103. border-radius: 5px;
  104. margin: 0 2vw 0 0;
  105. }
  106. .list_1_1 {
  107. display: flex;
  108. flex-direction: column;
  109. flex-grow: 1;
  110. padding: 2vw 0;
  111. .name {
  112. font-size: var(--font16Size);
  113. margin: 0 0 1vw 0;
  114. }
  115. .money {
  116. color: var(--fFB1Color);
  117. font-size: var(--font14Size);
  118. margin: 0 0 1vw 0;
  119. }
  120. .other {
  121. display: flex;
  122. justify-content: space-between;
  123. .name {
  124. font-size: var(--font16Size);
  125. font-weight: bold;
  126. }
  127. .other_1 {
  128. font-size: var(--font14Size);
  129. color: var(--f85Color);
  130. text {
  131. font-weight: bold;
  132. padding: 0 2vw;
  133. color: var(--ff0Color);
  134. }
  135. }
  136. }
  137. }
  138. }
  139. }
  140. }
  141. </style>