index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. typeclick:4,//1加入购物车,2购物车
  42. page:1,
  43. pagesize:5,
  44. total:0,
  45. isBottom:false,
  46. isEmpty:false,
  47. sel:-1
  48. };
  49. },
  50. onLoad() {
  51. },
  52. created() {
  53. if(!uni.getStorageSync("token")){
  54. uni.navigateTo({
  55. url: "/pages/login/index",
  56. })
  57. }
  58. this.sys = uni.getSystemInfoSync();
  59. this.getOrderList(-1);
  60. },
  61. onReachBottom() {
  62. this.loadMore(this.sel)
  63. },
  64. methods: {
  65. changeTab(e){ // 切换tab
  66. this.activeIndex=e;
  67. if(e==0){
  68. this.sel=-1;
  69. }else if(e==1){
  70. this.sel=0;
  71. }else if(e==2){
  72. this.sel=1;
  73. }else if(e==3){
  74. this.sel=2;
  75. }
  76. this.getOrderList(this.sel)
  77. },
  78. // 获取订单列表
  79. getOrderList(index){
  80. let that=this;
  81. this.page=1;
  82. this.pagesize=5;
  83. myRequest({
  84. url:'/api/Order/orderList',
  85. method:'post',
  86. data:{type:this.sel,page:that.page,pagesize:that.pagesize}
  87. }).then(res=>{
  88. if (res.data.code == 200) {
  89. that.total=res.data.data.total;
  90. if (res.data.data.length != 0) {
  91. that.isEmpty=false;
  92. that.test = [];
  93. for (let i = 0; i < res.data.data.data.length; i++) {
  94. var obj = {
  95. img: res.data.data.data[i].orderGoods.goods_img,
  96. title: res.data.data.data[i].orderGoods.goods_name,
  97. // label: '黑色 - 6518/320',
  98. // size:'S',
  99. price: res.data.data.data[i].pay_money,
  100. id: res.data.data.data[i].id,
  101. buy: res.data.data.data[i].goods_num,
  102. itemId: res.data.data.data[i].id,
  103. checked: false,
  104. goods_id:res.data.data.data[i].goods_id,
  105. orderStatus:res.data.data.data[i].order_status,
  106. orderNo:res.data.data.data[i].order_sn,
  107. isEval:res.data.data.data[i].is_evaluate
  108. };
  109. that.test.push(obj)
  110. }
  111. }else {
  112. that.test = [];
  113. that.isEmpty=true;
  114. that.isBottom=false;
  115. }
  116. }
  117. console.log(res.data.data.data,'订单列表');
  118. })
  119. },
  120. goSure(ids){
  121. let that=this;
  122. myRequest({
  123. url:'/api/Order/receipt',
  124. method:'post',
  125. data:{
  126. id:ids
  127. }
  128. }).then(res=>{
  129. if(res.data.code==200){
  130. that.$refs.toast.show({
  131. model: 'success',
  132. label: res.data.msg
  133. })
  134. }else{
  135. that.$refs.toast.show({
  136. model: 'error',
  137. label: res.data.msg
  138. })
  139. }
  140. })
  141. },
  142. goEval(ids){
  143. uni.navigateTo({
  144. url:'/pages/pingjia/index?id='+ids
  145. })
  146. },
  147. loadMore(index){ //加载更多
  148. if(this.isBottom) return;
  149. this.page++;
  150. let that=this;
  151. myRequest({
  152. url:'/api/Order/orderList',
  153. method:'post',
  154. data:{type:this.sel,page:that.page,pagesize:that.pagesize}
  155. }).then(res=>{
  156. if (res.data.code == 200) {
  157. if(that.test.length < res.data.data.total){
  158. let newList=[];
  159. for (let i = 0; i < res.data.data.data.length; i++) {
  160. var obj = {
  161. img: res.data.data.data[i].orderGoods.goods_img,
  162. title: res.data.data.data[i].orderGoods.goods_name,
  163. // label: '黑色 - 6518/320',
  164. // size:'S',
  165. price: res.data.data.data[i].pay_money,
  166. id: res.data.data.data[i].id,
  167. buy: res.data.data.data[i].goods_num,
  168. itemId: res.data.data.data[i].id,
  169. checked: false,
  170. goods_id:res.data.data.data[i].goods_id,
  171. orderStatus:res.data.data.data[i].order_status,
  172. orderNo:res.data.data.data[i].order_sn,
  173. isEval:res.data.data.data[i].is_evaluate
  174. };
  175. newList.push(obj)
  176. }
  177. that.test=that.test.concat(newList)
  178. } else {
  179. that.isBottom=true;
  180. that.page--;
  181. console.log(that.page);
  182. }
  183. } else {
  184. that.isBottom=true;
  185. that.page--;
  186. }
  187. })
  188. }
  189. },
  190. }
  191. </script>
  192. <style lang="scss">
  193. /deep/ .tm-menubars .body{background-color: #1b1b1b !important;}
  194. /deep/ .qiehuan1 .text-primary{color: white !important;}
  195. /deep/ .qiehuan1 .tm-tabs-wk{border-top: 1px solid #262628;}
  196. /deep/ .shuliang .text-size-n{color: white !important;}
  197. /deep/ .shangpin .white.bk{background-color:#1b1b1b!important;}
  198. /deep/ .shangpin .tm-cartCellListFood{padding: 0px 0px 15px 0px !important;
  199. margin-top: 5px !important;margin-bottom: 20px !important;
  200. border-bottom: 1px solid #1B1B1B;}
  201. /deep/ .shangpin .border-t-1.bk{border-top:1px solid #1b1b1b!important;}
  202. /deep/ .shangpin .title{color: white !important;}
  203. /deep/ .shangpin .text-red{color: white !important;}
  204. /deep/ .shangpin .round-3{width:90px !important;height:90px !important;}
  205. /deep/ .shangpin .tm-cartCellListFood-img{width:90px !important;height:90px !important;}
  206. /deep/ .shuliang .text-size-n{color: white !important;}
  207. /deep/ .jiaoxi{margin:0 !important;padding: 8px !important;margin-top: 10px !important;}
  208. .empty,.bottom{display: flex;justify-content:center;align-items: center;color: #AAAAAA;}
  209. .empty{padding-top: 100px;}
  210. .bottom{padding-bottom: 10px;height: 30px;width: 100%;}
  211. </style>