index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <view :class="[$tm.vx.state().tmVuetify.black ? 'black' : ' ']"
  3. class="bodycont">
  4. <tm-menubars ref="fenleig" title="分类" :shadow="0" :showback="true"></tm-menubars>
  5. <div class="cont">
  6. <tm-sliderNav :activeIndex="activeIndex" class="zuo fl" @change="change" :list="list" text color="red"></tm-sliderNav>
  7. <view class="fr you">
  8. <view class="huadong">
  9. <view class="py-10 text-size-g dianz mingri text-align-center mt-40">
  10. <image src="/static/img/88.png" mode="widthFix"></image>
  11. <text class="text-white">精选推荐</text>
  12. </view>
  13. <view class="yiguicla mt-20 fl" v-for="item in quanbuList" @click="sort(item.id)">
  14. <view class="waicont">
  15. <image :src="item.src" mode="widthFix"></image>
  16. <view class="wenzi text-align-center text-size-m mt-8">{{item.text}}</view>
  17. </view>
  18. </view>
  19. <tm-empty v-if="quanbuList.length ==0" label="暂无数据" color="white" icon="icon-paperplane-fill"></tm-empty>
  20. <view style="width:100%;height:40px;clear: both;"></view>
  21. </view>
  22. </view>
  23. <view style="clear: both;"></view>
  24. </div>
  25. <!-- 弹出层消息 -->
  26. <tm-message ref="toast"></tm-message>
  27. </view>
  28. </template>
  29. <script>
  30. import {
  31. myRequest
  32. } from '@/api/request.js'
  33. export default {
  34. data() {
  35. return {
  36. list: [],
  37. quanbuList: {},
  38. activeIndex:0,
  39. frist:2,
  40. };
  41. },
  42. onLoad(e) {
  43. this.activeIndex=e.index?e.index:0;
  44. this.frist=e.index?1:2;
  45. console.log(this.activeIndex)
  46. },
  47. created() {
  48. this.sys = uni.getSystemInfoSync();
  49. this.getTop();
  50. },
  51. methods: {
  52. // 获取一级分类
  53. getTop() {
  54. let that = this;
  55. myRequest({
  56. url: '/api/ShopGoods/getMallClassification',
  57. method: 'get',
  58. data: that.reqData
  59. }).then(res => {
  60. if (res.data.code == 200) {
  61. res.data.data.forEach(item => {
  62. that.list.push({
  63. id: item.id,
  64. img: item.image,
  65. title: item.category_name
  66. })
  67. })
  68. this.change(this.activeIndex)
  69. } else {
  70. that.$refs.toast.show({
  71. model: 'error',
  72. label: res.data.msg
  73. })
  74. }
  75. })
  76. },
  77. // 切换更换二级分类
  78. change(e) {
  79. let that = this;
  80. if(this.frist==2){
  81. this.activeIndex=e;
  82. }
  83. this.frist=2;
  84. console.log(e)
  85. myRequest({
  86. url: '/api/ShopGoods/getMallChildrenClassification',
  87. method: 'post',
  88. data: {
  89. 'id': that.list[e].id
  90. }
  91. }).then(res => {
  92. if (res.data.code == 200) {
  93. that.quanbuList = [];
  94. res.data.data.forEach(item => {
  95. that.quanbuList.push({
  96. id:item.id,
  97. src: item.image,
  98. text: item.category_name
  99. })
  100. })
  101. } else {
  102. that.$refs.toast.show({
  103. model: 'error',
  104. label: res.data.msg
  105. })
  106. }
  107. })
  108. // uni.$tm.toast(`您选中了:${e}`)
  109. },
  110. sort(id){
  111. console.log(id);
  112. uni.navigateTo({
  113. url:'/pages/sort/index?id='+id
  114. })
  115. }
  116. },
  117. }
  118. </script>
  119. <style lang="scss">
  120. page,uni-page-body,.bodycont{
  121. height: 100% !important;
  122. overflow: hidden;
  123. }
  124. // /deep/ .tm-menubars .body {
  125. // background-color: #1b1b1b !important;
  126. // }
  127. .huadong{
  128. width: 90%;
  129. margin: 0 auto;
  130. }
  131. /deep/ .cont {
  132. overflow: hidden;
  133. height: calc(100% - 45px) !important;
  134. }
  135. /deep/ .kuang {
  136. margin: 0 !important;
  137. padding: 0px !important;
  138. }
  139. /deep/ .zuo .grey-darken-4.bk {
  140. background-color: #0D0D0D !important;
  141. }
  142. // /deep/ .zuo .uni-scroll-view-content {
  143. // background-color: #0D0D0D !important;
  144. // }
  145. /deep/ .cont .shadow-white-5 {
  146. padding: 0px !important;
  147. margin: 0px !important
  148. }
  149. /deep/ .zuo .border-red-l-2.bk {
  150. border-left-color: #0178FD !important;
  151. }
  152. /deep/ .zuo .text-red,
  153. /deep/ .zuo .text-grey-darken-1 {
  154. color: white !important;
  155. }
  156. .yiguicla image {
  157. width: 100%;
  158. display: block;
  159. margin-top: 5px;
  160. border-radius: 10px;
  161. }
  162. .waicont{
  163. overflow: hidden;
  164. border-radius: 10px;
  165. width: 80%;
  166. height: 100%;
  167. margin: 0 auto;
  168. position: relative;
  169. }
  170. .yiguicla{
  171. width: 50%;
  172. position: relative;
  173. padding: 0px !important;
  174. text-align: center;
  175. }
  176. .wenzi {
  177. position: absolute;
  178. bottom: 0px;
  179. background: rgba(158,165,172,0.8);
  180. color: white;
  181. width: 100%;
  182. height: 27px;
  183. line-height: 27px;
  184. font-size: 13px;
  185. }
  186. .mingri image {
  187. width: 25px;
  188. margin-right: 12px;
  189. vertical-align: middle;
  190. }
  191. .mingri text {
  192. vertical-align: middle;
  193. }
  194. .you {
  195. width: calc(100% - 80px);
  196. overflow: auto;
  197. background-color: #1b1b1b !important;
  198. height: 100%;
  199. overflow: auto;
  200. }
  201. .zuo {
  202. overflow: hidden;
  203. width: 80px !important;
  204. text-align: center;
  205. background-color: #0D0D0D !important;
  206. }
  207. /deep/ uni-scroll-view{
  208. width: 80px !important;
  209. }
  210. </style>