index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. },
  51. onShow: function() {
  52. const that = this;
  53. that.searchConfig();
  54. that.searchOther();
  55. that.search();
  56. },
  57. methods: {
  58. // 查询基本设置
  59. searchConfig() {
  60. const that = this;
  61. uni.getStorage({
  62. key: 'config',
  63. success: function(res) {
  64. if (res.data) that.$set(that, `config`, res.data)
  65. }
  66. })
  67. },
  68. async search() {
  69. const that = this;
  70. let info = {};
  71. if (that.type == '1') info.tags = that.tags;
  72. else if (that.type == '2') info.act_tags = that.act_tags;
  73. let res = await that.$api(`/goods`, 'GET', {
  74. ...info,
  75. status: '1'
  76. });
  77. if (res.errcode == '0') {
  78. that.$set(that, `list`, res.data)
  79. }
  80. },
  81. // 查询其他信息
  82. async searchOther() {
  83. const that = this;
  84. let type = that.type;
  85. let act_tags = that.act_tags;
  86. let tags = that.tags;
  87. let topUrl = [];
  88. let res;
  89. if (type == '1') {
  90. res = await that.$api(`/goodsTags/getData`, 'GET', {
  91. code: tags
  92. })
  93. } else if (type == '2') {
  94. res = await that.$api(`/actTags/getData`, 'GET', {
  95. value: act_tags
  96. })
  97. }
  98. if (res.errcode == '0') {
  99. let data = res.data;
  100. uni.setNavigationBarTitle({
  101. title: data.label
  102. });
  103. if (that.type == '1' && data.tags_file.length > 0) topUrl = data.tags_file
  104. else if (that.type == '2' && data.file.length > 0) topUrl = data.file
  105. }
  106. if (topUrl.length > 0) {
  107. that.$set(that, `topUrl`, topUrl[0].url)
  108. } else {
  109. that.$set(that, `topUrl`, that.config.config.logo[0].url)
  110. }
  111. },
  112. // 购买
  113. toBuy(e) {
  114. const that = this;
  115. uni.navigateTo({
  116. url: `/pagesHome/order/detail?id=${e._id}`
  117. })
  118. },
  119. }
  120. }
  121. </script>
  122. <style lang="scss">
  123. .main {
  124. display: flex;
  125. flex-direction: column;
  126. width: 100vw;
  127. height: 100vh;
  128. .one {
  129. padding: 2vw;
  130. background-color: #ffffff;
  131. .image {
  132. width: 100%;
  133. height: 200px;
  134. box-shadow: 0 0 5px #f1f1f1;
  135. border-radius: 10px;
  136. }
  137. }
  138. .two {
  139. padding: 0 2vw;
  140. margin: 0 0 2vw 0;
  141. .pubu {
  142. // column-count: 2;
  143. // column-gap: 3vw;
  144. display: flex;
  145. justify-content: space-between;
  146. flex-wrap: wrap;
  147. .list {
  148. width: 43vw;
  149. // break-inside: avoid;
  150. margin: 0 0 2vw 0;
  151. box-shadow: 0 0 5px #f1f1f1;
  152. padding: 2vw;
  153. border-radius: 5px;
  154. .list_1 {
  155. margin: 0 0 1vw 0;
  156. .image {
  157. width: 100%;
  158. height: 30vh;
  159. border-radius: 10px;
  160. box-shadow: 0 0 5px #f1f1f1;
  161. }
  162. }
  163. .name {
  164. font-size: 16px;
  165. }
  166. }
  167. }
  168. }
  169. }
  170. .is_bottom {
  171. text-align: center;
  172. text {
  173. padding: 2vw 0;
  174. display: inline-block;
  175. color: #858585;
  176. font-size: 14px;
  177. }
  178. }
  179. </style>