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