index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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)" @shanchu="goShanChu(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. goShanChu(ids){
  123. let that=this;
  124. myRequest({
  125. url:'/api/order/deleteOrder',
  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. that.getOrderList()
  137. }else{
  138. that.$refs.toast.show({
  139. model: 'error',
  140. label: res.data.msg
  141. })
  142. }
  143. })
  144. },
  145. goSure(ids){
  146. let that=this;
  147. myRequest({
  148. url:'/api/Order/receipt',
  149. method:'post',
  150. data:{
  151. id:ids
  152. }
  153. }).then(res=>{
  154. if(res.data.code==200){
  155. that.$refs.toast.show({
  156. model: 'success',
  157. label: res.data.msg
  158. })
  159. }else{
  160. that.$refs.toast.show({
  161. model: 'error',
  162. label: res.data.msg
  163. })
  164. }
  165. })
  166. },
  167. goEval(ids){
  168. uni.navigateTo({
  169. url:'/pages/pingjia/index?id='+ids
  170. })
  171. },
  172. loadMore(){ //加载更多
  173. if(this.isBottom) return;
  174. this.page++;
  175. let that=this;
  176. myRequest({
  177. url:'/api/Order/orderList',
  178. method:'post',
  179. data:{type:this.sel,page:that.page,pagesize:that.pagesize}
  180. }).then(res=>{
  181. if (res.data.code == 200) {
  182. if(that.test.length < res.data.data.total){
  183. let newList=[];
  184. for (let i = 0; i < res.data.data.data.length; i++) {
  185. var obj = {
  186. img: res.data.data.data[i].orderGoods.goods_img,
  187. title: res.data.data.data[i].orderGoods.goods_name,
  188. // label: '黑色 - 6518/320',
  189. // size:'S',
  190. price: res.data.data.data[i].pay_money,
  191. id: res.data.data.data[i].id,
  192. buy: res.data.data.data[i].goods_num,
  193. itemId: res.data.data.data[i].id,
  194. checked: false,
  195. goods_id:res.data.data.data[i].goods_id,
  196. orderStatus:res.data.data.data[i].order_status,
  197. orderNo:res.data.data.data[i].order_sn,
  198. isEval:res.data.data.data[i].is_evaluate
  199. };
  200. newList.push(obj)
  201. }
  202. that.test=that.test.concat(newList)
  203. } else {
  204. that.isBottom=true;
  205. that.page--;
  206. console.log(that.page);
  207. }
  208. } else {
  209. that.isBottom=true;
  210. that.page--;
  211. }
  212. })
  213. }
  214. },
  215. }
  216. </script>
  217. <style lang="scss">
  218. /deep/ .tm-menubars .body{background-color: #1b1b1b !important;}
  219. /deep/ .qiehuan1 .text-primary{color: white !important;}
  220. /deep/ .qiehuan1 .tm-tabs-wk{border-top: 1px solid #262628;}
  221. /deep/ .shuliang .text-size-n{color: white !important;}
  222. /deep/ .shangpin .white.bk{background-color:#1b1b1b!important;}
  223. /deep/ .shangpin .tm-cartCellListFood{padding: 0px 0px 15px 0px !important;
  224. margin-top: 5px !important;margin-bottom: 20px !important;
  225. border-bottom: 1px solid #1B1B1B;}
  226. /deep/ .shangpin .border-t-1.bk{border-top:1px solid #1b1b1b!important;}
  227. /deep/ .shangpin .title{color: white !important;}
  228. /deep/ .shangpin .text-red{color: white !important;}
  229. /deep/ .shangpin .round-3{width:90px !important;height:90px !important;}
  230. /deep/ .shangpin .tm-cartCellListFood-img{width:90px !important;height:90px !important;}
  231. /deep/ .shuliang .text-size-n{color: white !important;}
  232. /deep/ .jiaoxi{margin:0 !important;padding: 8px !important;margin-top: 10px !important;}
  233. .empty,.bottom{display: flex;justify-content:center;align-items: center;color: #AAAAAA;}
  234. .empty{padding-top: 100px;}
  235. .bottom{padding-bottom: 10px;height: 30px;width: 100%;}
  236. </style>