index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <image class="image" :src="topUrl" mode="aspectFit"></image>
  6. </view>
  7. <view class="two">
  8. <view class="pubu">
  9. <view class="list" v-for="(item,index) in list" :key="index" @tap="toBuy(item)">
  10. <view class="list_1">
  11. <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''" mode=""></image>
  12. </view>
  13. <view class="name textOver">
  14. {{item.name}}
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="is_bottom" v-if="is_bottom">
  20. <text>{{config.bottom_title}}</text>
  21. </view>
  22. </view>
  23. </mobile-frame>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. // 系统设置
  30. config: {},
  31. // 路由参数
  32. type: '1',
  33. tags: '',
  34. act_tags: '',
  35. topUrl: '',
  36. // 数据列表
  37. list: [],
  38. is_bottom: false
  39. };
  40. },
  41. onLoad(e) {
  42. const that = this;
  43. if (e && e.tags) {
  44. that.$set(that, `type`, '1')
  45. that.$set(that, `tags`, e.tags || '');
  46. } else if (e && e.act_tags) {
  47. that.$set(that, `type`, '2')
  48. that.$set(that, `act_tags`, e.act_tags || '');
  49. }
  50. that.searchConfig();
  51. that.searchOther();
  52. that.search();
  53. },
  54. methods: {
  55. // 查询基本设置
  56. searchConfig() {
  57. const that = this;
  58. uni.getStorage({
  59. key: 'config',
  60. success: function(res) {
  61. if (res.data) that.$set(that, `config`, res.data)
  62. }
  63. })
  64. },
  65. async search() {
  66. const that = this;
  67. let info = {};
  68. if (that.type == '1') info.tags = that.tags;
  69. else if (that.type == '2') info.act_tags = that.act_tags;
  70. let res = await that.$api(`/goods`, 'GET', {
  71. ...info,
  72. status: '1'
  73. });
  74. if (res.errcode == '0') {
  75. that.$set(that, `list`, res.data)
  76. }
  77. },
  78. // 查询其他信息
  79. async searchOther() {
  80. const that = this;
  81. let type = that.type;
  82. let act_tags = that.act_tags;
  83. let tags = that.tags;
  84. let topUrl = [];
  85. let res;
  86. if (type == '1') {
  87. res = await that.$api(`/goodsTags/getData`, 'GET', {
  88. code: tags
  89. })
  90. } else if (type == '2') {
  91. res = await that.$api(`/actTags/getData`, 'GET', {
  92. value: act_tags
  93. })
  94. }
  95. if (res.errcode == '0') {
  96. let data = res.data;
  97. uni.setNavigationBarTitle({
  98. title: data.label
  99. });
  100. if (that.type == '1' && data.tags_file.length > 0) topUrl = data.tags_file
  101. else if (that.type == '2' && data.file.length > 0) topUrl = data.file
  102. }
  103. if (topUrl.length > 0) {
  104. that.$set(that, `topUrl`, topUrl[0].url)
  105. } else {
  106. that.$set(that, `topUrl`, that.config.config.logo[0].url)
  107. }
  108. },
  109. // 购买
  110. toBuy(e) {
  111. const that = this;
  112. uni.navigateTo({
  113. url: `/pagesHome/order/detail?id=${e._id}`
  114. })
  115. },
  116. }
  117. }
  118. </script>
  119. <style lang="scss">
  120. .main {
  121. display: flex;
  122. flex-direction: column;
  123. width: 100vw;
  124. height: 100vh;
  125. .one {
  126. padding: 2vw;
  127. background-color: #ffffff;
  128. .image {
  129. width: 100%;
  130. height: 200px;
  131. box-shadow: 0 0 5px #f1f1f1;
  132. border-radius: 10px;
  133. }
  134. }
  135. .two {
  136. padding: 0 2vw;
  137. margin: 0 0 2vw 0;
  138. .pubu {
  139. // column-count: 2;
  140. // column-gap: 3vw;
  141. display: flex;
  142. justify-content: space-between;
  143. flex-wrap: wrap;
  144. .list {
  145. width: 43vw;
  146. // break-inside: avoid;
  147. margin: 0 0 2vw 0;
  148. box-shadow: 0 0 5px #f1f1f1;
  149. padding: 2vw;
  150. border-radius: 5px;
  151. .list_1 {
  152. margin: 0 0 1vw 0;
  153. .image {
  154. width: 100%;
  155. height: 30vh;
  156. border-radius: 10px;
  157. box-shadow: 0 0 5px #f1f1f1;
  158. }
  159. }
  160. .name {
  161. font-size: 16px;
  162. }
  163. }
  164. }
  165. }
  166. }
  167. .is_bottom {
  168. text-align: center;
  169. text {
  170. padding: 2vw 0;
  171. display: inline-block;
  172. color: #858585;
  173. font-size: 14px;
  174. }
  175. }
  176. </style>