index.vue 6.0 KB

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