index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view :style="{ minHeight: sys.windowHeight + 'px' }" :class="[$tm.vx.state().tmVuetify.black ? 'black' : ' ']">
  3. <tm-menubars title="分类列表" :shadow="0" :showback="true"></tm-menubars>
  4. <div class="zhuti">
  5. <tm-sheet class="kuang" style="padding-bottom: 30px !important;" >
  6. <view style="width: 94%;margin:0 auto;" class="remen">
  7. <view v-for="(item,index) in listdata" class="round-5 contone black mt-20" :class="index%2==0?'fl':'fr'" @click="goDetail(item)">
  8. <image class="logo" :src="item.image" mode="widthFix"></image>
  9. <view class="pa-15 text-size-s">
  10. <view class="text-overflow-2">
  11. <text class="text-size-lg">{{item.goods_name}}</text>
  12. <view class="text-gray mt-6">销量:{{item.sale_num}}</view>
  13. </view>
  14. <view class="mt-2 flex-between flex-center">
  15. <view class="touxiang mt-30">
  16. <text class="text-white text-size-m text-weight-b">¥ {{item.sale_price}}</text>
  17. </view>
  18. <view >
  19. <image @click.stop="jiarufuFun(item)" class="remenzan" src="/static/img/86.png" mode="widthFix"></image>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <tm-empty v-if="listdata.length ==0" label="暂无数据" color="white" icon="icon-paperplane-fill"></tm-empty>
  25. <view style="clear: both;"></view>
  26. <view style="clear: both;" class="more ma-40 pt-40" @click="gengmore()" v-if="listdata.length<total" >
  27. <image src="/static/img/30.png" mode="widthFix"></image>
  28. <text class="text-size-s">下拉加载更多~</text>
  29. </view>
  30. </view>
  31. </tm-sheet>
  32. <view style="height:60px"></view>
  33. </div>
  34. <!-- 弹出层消息 -->
  35. <tm-message ref="toast"></tm-message>
  36. </view>
  37. </template>
  38. <script>
  39. import{myRequest} from '@/api/request.js'
  40. export default {
  41. data() {
  42. return {
  43. typeclick:1,
  44. listdata:{},
  45. soId:'',
  46. page:1,
  47. pagesize:8,
  48. total:0
  49. };
  50. },
  51. onLoad(op) {
  52. console.log(op);
  53. this.soId=op.id
  54. },
  55. created() {
  56. if (!uni.getStorageSync("token")) {
  57. uni.navigateTo({
  58. url: "/pages/login/index",
  59. })
  60. }
  61. this.sys = uni.getSystemInfoSync();
  62. // this.randouh()
  63. this.getSort()
  64. },
  65. methods: {
  66. // 加载更多
  67. gengmore(){
  68. if(this.listdata.length<this.total){
  69. this.page++;
  70. this.getSort();
  71. }else{
  72. }
  73. },
  74. // 加入购物车
  75. jiarufuFun(data){
  76. let that=this;
  77. myRequest({
  78. url: "/api/ShopCart/addShopCart",
  79. method:'post',
  80. data:{
  81. goods_id:data.id,
  82. goods_name:data.goods_name,
  83. goods_image:data.image,
  84. goods_price:data.sale_price,
  85. goods_num:1
  86. }
  87. }).then(res => {
  88. if (res.data.code == 200) {
  89. that.$refs.toast.show({model:'success',label:res.data.msg})
  90. }else{
  91. that.$refs.toast.show({model:'error',label:res.data.msg})
  92. }
  93. })
  94. // console.log(data)
  95. // this.gouwuche.push(data)
  96. },
  97. // 获取列表数据
  98. getSort(){
  99. let that=this;
  100. myRequest({
  101. url:'/api/ShopGoods/childrenClassificationList',
  102. method:'post',
  103. data:{id:that.soId,page:that.page,pagesize:that.pagesize}
  104. }).then(res=>{
  105. if(res.data.code==200){
  106. if(res.data.data.length!=0){
  107. console.log(res.data.data,'liebiao');
  108. that.total=res.data.data.total;
  109. that.listdata=res.data.data.data;
  110. }else{
  111. that.listdata=[]
  112. }
  113. }else{
  114. that.listdata=[]
  115. that.$refs.toast.show({
  116. model: 'error',
  117. label: res.data.msg
  118. })
  119. }
  120. })
  121. },
  122. goindex(){
  123. uni.navigateBack();
  124. },
  125. // 去详情
  126. goDetail(data){
  127. uni.navigateTo({
  128. url:'/pages/shopdetail/index?cartId='+data.id+'&classId='+data.category_id
  129. })
  130. },
  131. change(e){
  132. console.log(e)
  133. },
  134. sosoFun(){
  135. }
  136. },
  137. }
  138. </script>
  139. <style lang="scss">
  140. /deep/ .tm-menubars .body{
  141. background-color: #1b1b1b !important;
  142. }
  143. /deep/ .zhuti{padding: 10px 10px;}
  144. /deep/ .kuang{margin:0 !important;padding: 0px !important;}
  145. /deep/ .icon-search{
  146. font-size: 23px !important;
  147. color: #8E8E93 !important;
  148. }
  149. /deep/ .tm-search{
  150. width: 66%;
  151. background-color: #414141 !important;
  152. border-radius: 10px;
  153. }
  154. /deep/ .tm-search .grey-darken-5{
  155. background-color: #414141 !important;
  156. }
  157. .dingwei{width: 21%;margin-top:3%;}
  158. .shuruk{width: 77%;}
  159. .sousuo{width:94%;margin:0 auto;}
  160. .quxiao{color: #707070;line-height: 47px;}
  161. .contone{width: 48%;}
  162. .logo{width: 100%;}
  163. .remenzan{width: 18px !important;margin-top: 10px;}
  164. .more{text-align: center;}
  165. .more image{margin-right: 10px;vertical-align: middle;width: 30px;}
  166. </style>