index.vue 4.3 KB

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