order.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <view class="content">
  3. <u-sticky>
  4. <view class="navbar dfsb"><u-tabs :list="goodList" :current="tabcur" :activeStyle="{color:'#87C477'}" @click="tabType"></u-tabs></view>
  5. <view class="navbarTwo dfsb">
  6. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.name }}</view>
  7. </view>
  8. </u-sticky>
  9. <!-- 订单列表 -->
  10. <view class="box">
  11. <navigator :url="'./orderInfo?id=' + item.id + '&tabcur=' + tabcur" v-for="(item, index) in orderList" :key="index" class="order-item bb">
  12. <view class="ordtitle dfsb">
  13. <text class="prosecond flex1">{{ item.status_name }}</text>
  14. </view>
  15. <block v-if="tabcur == 0">
  16. <view v-for="(ite, ind) in item.comments" class="shopshead dfsb">
  17. <image :src="ite.goods_img" mode=""></image>
  18. <view class="shopsInfo dffd">
  19. <view class="oneelli">{{ ite.goods_name }}</view>
  20. <view class="attr textgrey">{{ ite.sku_val }}</view>
  21. <view class="allInfo dfsb prosecond">
  22. {{ ite.goods_price || 0.0 }}
  23. <text class="textgrey fontsm">x{{ ite.goods_num }}</text>
  24. </view>
  25. </view>
  26. </view>
  27. </block>
  28. <block v-if="tabcur != 0">
  29. <view class="shopshead dfsb">
  30. <image :src="item.goods_img" mode=""></image>
  31. <view class="shopsInfo dffd">
  32. <view class="oneelli">{{ item.goods_name }}</view>
  33. <view class="attr textgrey">{{ item.sku_val }}</view>
  34. <view class="allInfo dfsb prosecond">
  35. {{ item.goods_price || 0.0 }}
  36. <text class="textgrey fontsm">x{{ item.num||item.goods_num }}</text>
  37. </view>
  38. </view>
  39. </view>
  40. </block>
  41. <view class="other dfsb">
  42. <text>总计</text>
  43. <text>{{ item.goods_total }}</text>
  44. </view>
  45. <view class="btns dffs">
  46. <view v-if="item.status == 1" @tap.stop="sureOrd(item, 0)" class="cancle">取消</view>
  47. <view v-if="item.status > 1 && item.status < 5 && tabcur == 0" @tap.stop="sureOrd(item, 3)" class="cancle">售后</view>
  48. <view v-if="item.status == 1" @tap.stop="sureOrd(item, 1)" class="clickbtn">去付款</view>
  49. <view v-if="item.status == 3" @tap.stop="sureOrd(item, 2)" class="clickbtn">确认收货</view>
  50. <!-- <view v-if="item.status > 2 && item.status < 5" @tap.stop="sureOrd(item, 4)" class="clickbtn">查看物流</view> -->
  51. </view>
  52. </navigator>
  53. <view class="nodata" v-if="orderList.length < 1"><u-empty icon-size="200" text="还没有订单哦" mode="order"></u-empty></view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import { mixin } from './mixin.js';
  59. export default {
  60. mixins: [mixin],
  61. data() {
  62. return {
  63. tabcur: 0,
  64. tabCurrentIndex: 0, //1 代付款 2 待发货 3 待收货 4 已完成 0全部
  65. goodList: [{ name: '普通订单' }, { name: '拼团订单' }, { name: '秒杀订单' }],
  66. navList: [
  67. {
  68. state: 5,
  69. name: '全部'
  70. },
  71. {
  72. state: 1,
  73. name: '待付款'
  74. },
  75. {
  76. state: 2,
  77. name: '待发货'
  78. },
  79. {
  80. state: 3,
  81. name: '待收货'
  82. },
  83. {
  84. state: 4,
  85. name: '已完成'
  86. }
  87. ],
  88. orderList: [
  89. // {
  90. // id: 1,
  91. // num: 2,
  92. // goods_img: '',
  93. // goods_name: '山东烟台黄元帅苹果 奶油富士 黄金帅香蕉粉面苹果 新鲜水果可刮泥',
  94. // price: 44,
  95. // status: 0
  96. // },
  97. ],
  98. selItem: '', // 选中item
  99. loadType: 'loadmore',
  100. page: 1,
  101. limit: 10
  102. };
  103. },
  104. onLoad(opt) {
  105. this.tabCurrentIndex = Number(opt.state);
  106. // this.loadData();
  107. },
  108. onShow() {
  109. this.orderList = [];
  110. this.page = 1;
  111. this.loadData();
  112. },
  113. onPullDownRefresh() {
  114. this.page = 1;
  115. this.orderList = [];
  116. this.loadData();
  117. setTimeout(res => {
  118. uni.stopPullDownRefresh();
  119. }, 1000);
  120. },
  121. onReachBottom() {
  122. if (this.loadType == 'nomore') return;
  123. this.loadType = 'loadmore';
  124. this.page = ++this.page;
  125. this.loadData();
  126. },
  127. methods: {
  128. tabType(e) {
  129. console.log(e);
  130. this.tabcur = e.index;
  131. console.log(this.tabCurrentIndex);
  132. this.orderList = [];
  133. this.page = 1;
  134. this.loadData();
  135. },
  136. //获取订单列表
  137. loadData(source) {
  138. this.loadType = 'loadmore';
  139. this.$api
  140. .request('orders/my_order_lists', {
  141. type: Number(this.tabcur + 1),
  142. status: this.tabCurrentIndex || 0,
  143. page: this.page,
  144. limit: this.limit
  145. })
  146. .then(data => {
  147. if (data.code == '200') {
  148. this.orderList = this.orderList.concat(data.data);
  149. if (data.data.length < this.limit) {
  150. this.loadType = 'nomore';
  151. return;
  152. }
  153. } else {
  154. this.$api.toast(data.msg);
  155. }
  156. })
  157. .catch(function(error) {
  158. console.log(error);
  159. });
  160. },
  161. //顶部tab点击
  162. tabClick(index) {
  163. this.tabCurrentIndex = index;
  164. this.page = 1;
  165. this.orderList = [];
  166. this.loadData();
  167. }
  168. }
  169. };
  170. </script>
  171. <style lang="scss">
  172. page,
  173. .content {
  174. // height: 100%;
  175. // padding-top: 60rpx;
  176. background-color: #f5f5f5;
  177. .swiper-box {
  178. width: 100%;
  179. min-height: 100vh;
  180. // min-height: 100rpx;
  181. }
  182. }
  183. .tab-content {
  184. .list-scroll-content {
  185. height: 100%;
  186. }
  187. .moredata {
  188. height: 50rpx;
  189. }
  190. }
  191. .navbar {
  192. // position: fixed;
  193. // width: 100%;
  194. // top: 0rpx;
  195. // /* #ifdef H5 */
  196. // top: 44px;
  197. // /* #endif */
  198. // left: 0rpx;
  199. // display: flex;
  200. height: 100rpx;
  201. background-color: #fff;
  202. // z-index: 10;
  203. }
  204. .navbarTwo {
  205. padding: 0 30rpx;
  206. background-color: #fff;
  207. .current {
  208. color: $prosecond;
  209. }
  210. }
  211. .uni-swiper-item {
  212. height: auto;
  213. }
  214. .list-scroll-content {
  215. padding: 0 30rpx;
  216. background: #fff;
  217. }
  218. .box {
  219. background-color: #fff;
  220. padding: 30rpx;
  221. }
  222. .order-item {
  223. display: flex;
  224. flex-direction: column;
  225. padding: 30rpx 0;
  226. .ordtitle {
  227. image {
  228. width: 40rpx;
  229. height: 40rpx;
  230. }
  231. text {
  232. text-align: right;
  233. // &:nth-of-type(1) {
  234. // font-size: 32rpx;
  235. // font-family: PingFangSC-Semibold, PingFang SC;
  236. // font-weight: 600;
  237. // line-height: 44rpx;
  238. // flex: 1;
  239. // margin: 0 10rpx;
  240. // }
  241. }
  242. }
  243. .shopshead {
  244. height: 170rpx;
  245. margin: 13rpx 0 26rpx;
  246. image {
  247. width: 170rpx;
  248. height: 100%;
  249. margin-right: 20rpx;
  250. }
  251. .shopsInfo {
  252. width: 502rpx;
  253. flex: 1;
  254. height: 100%;
  255. align-items: flex-start;
  256. justify-content: space-between;
  257. .oneelli {
  258. width: 100%;
  259. line-height: 40rpx;
  260. }
  261. .attr {
  262. font-size: 26rpx;
  263. }
  264. .allInfo {
  265. width: 100%;
  266. font-size: 26rpx;
  267. }
  268. }
  269. }
  270. .btns {
  271. justify-content: flex-end;
  272. .clickbtn,
  273. .cancle {
  274. width: 156rpx;
  275. height: 60rpx;
  276. line-height: 60rpx;
  277. font-size: 28rpx;
  278. border-radius: 4rpx;
  279. margin: 0;
  280. margin-left: 30rpx;
  281. background: transparent;
  282. border: 1rpx solid #979797;
  283. color: #979797;
  284. text-align: center;
  285. }
  286. }
  287. }
  288. .other {
  289. margin-bottom: 20rpx;
  290. text,
  291. input {
  292. font-size: 28rpx;
  293. }
  294. input {
  295. flex: 1;
  296. margin-left: 10rpx;
  297. }
  298. }
  299. .tuiBox {
  300. margin: 30rpx;
  301. border: 1rpx solid #f5f5f5;
  302. height: 60rpx;
  303. padding: 10rpx;
  304. line-height: 60rpx;
  305. }
  306. </style>