index.vue 4.0 KB

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