index.vue 3.7 KB

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