index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view :style="{ minHeight: sys.windowHeight + 'px' }"
  3. :class="[$tm.vx.state().tmVuetify.black ? 'black' : ' ']">
  4. <tm-menubars title="我的订单" :shadow="0" :showback="true"></tm-menubars>
  5. <tm-tabs align="split" class="qiehuan1" v-model="activeIndex" :list="list2" range-key="title" @change="changeTab"></tm-tabs>
  6. <div class="zhuti shangpin">
  7. <tm-sheet class="jiaoxi" style="" v-for="item in test">
  8. <tm-cartCellListFood class="shuliang" :typeclick="typeclick" :mdata="item" v-on:sure="goSure(item.id)" v-on:Eval="goEval(item.id)" :cart-num.sync="item.buy"></tm-cartCellListFood>
  9. </tm-sheet>
  10. </div>
  11. <view class="empty" v-if="isEmpty">
  12. 暂无内容~
  13. </view>
  14. <view class="bottom" v-if="isBottom">
  15. 没有更多~
  16. </view>
  17. <!-- 弹出层消息 -->
  18. <tm-message ref="toast"></tm-message>
  19. </view>
  20. </template>
  21. <script>
  22. import{myRequest} from '@/api/request.js'
  23. export default {
  24. data() {
  25. return {
  26. list2:[ '全部','待付款','已付款','已完成'],
  27. activeIndex:0,
  28. test: [
  29. // {
  30. // img: '../../static/img/83.png',
  31. // title: '丝缎质感纹理风衣',
  32. // label: '黑色 - 6518/320',
  33. // size:'S',
  34. // price: '1299',
  35. // id: 3,
  36. // buy: 0,
  37. // itemId: 0,
  38. // checked:false,
  39. // status:0
  40. // },
  41. ],
  42. typeclick:4,//1加入购物车,2购物车
  43. page:1,
  44. pagesize:5,
  45. total:0,
  46. isBottom:false,
  47. isEmpty:false,
  48. sel:-1
  49. };
  50. },
  51. onLoad() {
  52. },
  53. created() {
  54. if(!uni.getStorageSync("token")){
  55. uni.navigateTo({
  56. url: "/pages/login/index",
  57. })
  58. }
  59. this.sys = uni.getSystemInfoSync();
  60. this.getOrderList(-1);
  61. },
  62. onReachBottom() {
  63. this.loadMore(this.sel)
  64. },
  65. methods: {
  66. changeTab(e){ // 切换tab
  67. this.activeIndex=e;
  68. if(e==0){
  69. this.sel=-1;
  70. }else if(e==1){
  71. this.sel=0;
  72. }else if(e==2){
  73. this.sel=1;
  74. }else if(e==3){
  75. this.sel=2;
  76. }
  77. this.getOrderList(this.sel)
  78. },
  79. // 获取订单列表
  80. getOrderList(index){
  81. this.page=1;
  82. this.pagesize=5;
  83. this.isBottom=false;
  84. let that=this;
  85. myRequest({
  86. url:'/api/Order/orderList',
  87. method:'post',
  88. data:{type:this.sel,page:that.page,pagesize:that.pagesize}
  89. }).then(res=>{
  90. if (res.data.code == 200) {
  91. that.total=res.data.data.total;
  92. if (res.data.data.length != 0) {
  93. that.isEmpty=false;
  94. that.test = [];
  95. for (let i = 0; i < res.data.data.data.length; i++) {
  96. var obj = {
  97. img: res.data.data.data[i].orderGoods.goods_img,
  98. title: res.data.data.data[i].orderGoods.goods_name,
  99. // label: '黑色 - 6518/320',
  100. // size:'S',
  101. price: res.data.data.data[i].pay_money,
  102. id: res.data.data.data[i].id,
  103. buy: res.data.data.data[i].goods_num,
  104. itemId: res.data.data.data[i].id,
  105. checked: false,
  106. goods_id:res.data.data.data[i].goods_id,
  107. orderStatus:res.data.data.data[i].order_status,
  108. orderNo:res.data.data.data[i].order_sn,
  109. isEval:res.data.data.data[i].is_evaluate
  110. };
  111. that.test.push(obj)
  112. }
  113. }else {
  114. that.test = [];
  115. that.isEmpty=true;
  116. that.isBottom=false;
  117. }
  118. }
  119. console.log(res.data.data.data,'订单列表');
  120. })
  121. },
  122. goSure(ids){
  123. let that=this;
  124. myRequest({
  125. url:'/api/Order/receipt',
  126. method:'post',
  127. data:{
  128. id:ids
  129. }
  130. }).then(res=>{
  131. if(res.data.code==200){
  132. that.$refs.toast.show({
  133. model: 'success',
  134. label: res.data.msg
  135. })
  136. }else{
  137. that.$refs.toast.show({
  138. model: 'error',
  139. label: res.data.msg
  140. })
  141. }
  142. })
  143. },
  144. goEval(ids){
  145. uni.navigateTo({
  146. url:'/pages/pingjia/index?id='+ids
  147. })
  148. },
  149. loadMore(){ //加载更多
  150. if(this.isBottom) return;
  151. this.page++;
  152. let that=this;
  153. myRequest({
  154. url:'/api/Order/orderList',
  155. method:'post',
  156. data:{type:this.sel,page:that.page,pagesize:that.pagesize}
  157. }).then(res=>{
  158. if (res.data.code == 200) {
  159. if(that.test.length < res.data.data.total){
  160. let newList=[];
  161. for (let i = 0; i < res.data.data.data.length; i++) {
  162. var obj = {
  163. img: res.data.data.data[i].orderGoods.goods_img,
  164. title: res.data.data.data[i].orderGoods.goods_name,
  165. // label: '黑色 - 6518/320',
  166. // size:'S',
  167. price: res.data.data.data[i].pay_money,
  168. id: res.data.data.data[i].id,
  169. buy: res.data.data.data[i].goods_num,
  170. itemId: res.data.data.data[i].id,
  171. checked: false,
  172. goods_id:res.data.data.data[i].goods_id,
  173. orderStatus:res.data.data.data[i].order_status,
  174. orderNo:res.data.data.data[i].order_sn,
  175. isEval:res.data.data.data[i].is_evaluate
  176. };
  177. newList.push(obj)
  178. }
  179. that.test=that.test.concat(newList)
  180. } else {
  181. that.isBottom=true;
  182. that.page--;
  183. console.log(that.page);
  184. }
  185. } else {
  186. that.isBottom=true;
  187. that.page--;
  188. }
  189. })
  190. }
  191. },
  192. }
  193. </script>
  194. <style lang="scss">
  195. /deep/ .tm-menubars .body{background-color: #1b1b1b !important;}
  196. /deep/ .qiehuan1 .text-primary{color: white !important;}
  197. /deep/ .qiehuan1 .tm-tabs-wk{border-top: 1px solid #262628;}
  198. /deep/ .shuliang .text-size-n{color: white !important;}
  199. /deep/ .shangpin .white.bk{background-color:#1b1b1b!important;}
  200. /deep/ .shangpin .tm-cartCellListFood{padding: 0px 0px 15px 0px !important;
  201. margin-top: 5px !important;margin-bottom: 20px !important;
  202. border-bottom: 1px solid #1B1B1B;}
  203. /deep/ .shangpin .border-t-1.bk{border-top:1px solid #1b1b1b!important;}
  204. /deep/ .shangpin .title{color: white !important;}
  205. /deep/ .shangpin .text-red{color: white !important;}
  206. /deep/ .shangpin .round-3{width:90px !important;height:90px !important;}
  207. /deep/ .shangpin .tm-cartCellListFood-img{width:90px !important;height:90px !important;}
  208. /deep/ .shuliang .text-size-n{color: white !important;}
  209. /deep/ .jiaoxi{margin:0 !important;padding: 8px !important;margin-top: 10px !important;}
  210. .empty,.bottom{display: flex;justify-content:center;align-items: center;color: #AAAAAA;}
  211. .empty{padding-top: 100px;}
  212. .bottom{padding-bottom: 10px;height: 30px;width: 100%;}
  213. </style>