index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <view class="container">
  3. <u-sticky style="margin-top: 15rpx; margin-left: 20rpx" bgColor="#fff">
  4. <u-tabs lineWidth="40" :list="list" :current="current" @change="handlerChangeItem"
  5. itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;" />
  6. </u-sticky>
  7. <!-- 订单 -->
  8. <view class="order">
  9. <view class="order-box">
  10. <view class="order-item" v-for="(item, index) of init_list" :key="index">
  11. <view class="" @click="handlerSkipDetail(item)">
  12. <view class="item-top">
  13. <view class="top-left gray-color">订单编号 : {{ item.orderSn }}</view>
  14. <view class="top-right">{{ type_name }}</view>
  15. </view>
  16. <view class="item-top">
  17. <view class="top-left gray-color">支付时间 : {{ item.createTimeText }}</view>
  18. <view class="top-right"></view>
  19. </view>
  20. </view>
  21. <u-line margin="20rpx 0"></u-line>
  22. <view class="item-center" :key="idx" v-for="(itm, idx) of item.goodsInfo">
  23. <view class="center-left">
  24. <image :src="itm.goodsPic" class="img"></image>
  25. </view>
  26. <view class="center-right">
  27. <view class="r-l">
  28. <view class="right-name"> {{ itm.goodsName }} </view>
  29. <view class="right-descript"> 测试商品描述111 </view>
  30. <view class="l-box">
  31. <view class="right-price"> ¥{{ itm.goodsPrice }} </view>
  32. <view class="right-numb"> ×{{ itm.goodsQuantity }} </view>
  33. </view>
  34. </view>
  35. <view class="r-r">
  36. <view class="r-item" @click.stop="handlerSkipComment(item, itm)"
  37. v-if="type == 4 && itm.assessStatus == 0">
  38. <u-icon name="chat" color="#000" size="28"></u-icon>
  39. <span>评价</span>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <u-line margin="20rpx 0" dashed="true"></u-line>
  45. <view class="item-allnumb-box">
  46. <view class="allnumb-left"> {{ item.allNumb }}件商品 </view>
  47. <view class="allnumb-right">
  48. <span class="r-text">共计</span>¥{{ item.allPrice }}
  49. </view>
  50. </view>
  51. <view class="item-bottom">
  52. <button class="btn" v-if="current == 0" @click='handlerCancelOrder(item)'>取消订单</button>
  53. <!-- <button class="btn" v-if='current == 1' @click='handlerOrderBtn(1)'>申请退款</button> -->
  54. <!-- <button class="btn" v-if='current == 2' @click='handlerOrderBtn(2)'>售后</button> -->
  55. </view>
  56. </view>
  57. </view>
  58. <view v-if="init_list.length == 0" style="margin-top: 40rpx">
  59. <u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" />
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import {
  66. userOrdersApi,
  67. getUserOrderList,
  68. cancelOrder
  69. } from '@/api/client/order';
  70. export default {
  71. data() {
  72. return {
  73. current: 0,
  74. type: 0,
  75. type_name: '',
  76. size: 20,
  77. // 订单状态:0->待付款;1->已付款;2->已发货;3->已完成;4->已关闭;5->无效订单
  78. list: [{
  79. name: '待付款',
  80. type: 0,
  81. },
  82. {
  83. name: '已付款',
  84. type: 1,
  85. },
  86. // {
  87. // name: '待发货',
  88. // type: 2,
  89. // },
  90. // {
  91. // name: '已发货',
  92. // type: 3,
  93. // },
  94. {
  95. name: '已完成',
  96. type: 3,
  97. },
  98. {
  99. name: '已关闭',
  100. type: 4,
  101. }
  102. // ,
  103. // {
  104. // name: '无效订单',
  105. // type: 5,
  106. // },
  107. ],
  108. init_list: [],
  109. };
  110. },
  111. mounted() {
  112. // this.userOrdersPage();
  113. },
  114. onShow() {
  115. let cur = this.$store.state.order.skip_order_type.type;
  116. switch (cur) {
  117. case 0:
  118. this.current = 0;
  119. this.userOrdersPage(cur);
  120. break;
  121. case 1:
  122. this.current = 2;
  123. this.userOrdersPage(cur);
  124. break;
  125. case 2:
  126. this.current = 3;
  127. this.userOrdersPage(cur);
  128. break;
  129. }
  130. },
  131. computed: {
  132. allNumber() {
  133. this.init_list.map(rs => {
  134. let sum = 0;
  135. let price = 0;
  136. rs.goodsInfo.map(rc => {
  137. sum += rc.goodsQuantity;
  138. price += rc.goodsPrice;
  139. });
  140. rs.allNumb = sum;
  141. rs.allPrice = price;
  142. });
  143. return;
  144. },
  145. },
  146. methods: {
  147. handlerChangeItem(data) {
  148. this.current = data.index;
  149. this.type = data.type;
  150. this.type_name = data.name;
  151. this.userOrdersPage(this.type);
  152. },
  153. async userOrdersPage(type) {
  154. let orderStatus = type == undefined ? 0 : `${type}`;
  155. let res = await getUserOrderList({
  156. status: orderStatus,
  157. paging: '1,20',
  158. });
  159. if ((res.code = 200 && res.data)) {
  160. this.init_list = res.data.records;
  161. this.init_list.map(rs => {
  162. rs.createTimeText = uni.$u.timeFormat(rs.createTime, 'yyyy-mm-dd hh:MM:ss');
  163. })
  164. }
  165. },
  166. // 跳转到订单详情
  167. handlerSkipDetail(e) {
  168. uni.navigateTo({
  169. url: `/PageMine/orderModules/orderDetail?orderList=${JSON.stringify(e)}`,
  170. });
  171. },
  172. // 取消订单
  173. handlerCancelOrder(e) {
  174. cancelOrder(e.id).then(res => {
  175. if (res.code == 'OK') {
  176. uni.showToast({
  177. title: '订单取消成功',
  178. icon: 'none',
  179. });
  180. this.userOrdersPage(this.type);
  181. } else {
  182. uni.showToast({
  183. title: res.message,
  184. icon: 'none',
  185. });
  186. return
  187. }
  188. });
  189. },
  190. // 点击跳转到商品评价
  191. handlerSkipComment(item, itm) {
  192. uni.navigateTo({
  193. url: `/PageMine/orderModules/orderComment?orderList=${JSON.stringify(item)}&goodsList=${JSON.stringify(itm)}`,
  194. });
  195. },
  196. },
  197. };
  198. </script>
  199. <style lang="scss" scoped>
  200. .order {
  201. margin-top: 10px;
  202. padding: 10rpx 20rpx 20rpx;
  203. box-sizing: border-box;
  204. .order-box {
  205. .order-item {
  206. margin-bottom: 20rpx;
  207. background-color: #fff;
  208. border-radius: 20rpx;
  209. padding: 20rpx;
  210. box-shadow: 0 8rpx 15rpx 0 rgba(0, 0, 0, 0.08);
  211. .item-top {
  212. display: flex;
  213. justify-content: space-between;
  214. margin-bottom: 10rpx;
  215. }
  216. .item-center {
  217. display: flex;
  218. align-items: center;
  219. margin-bottom: 10rpx;
  220. .center-left {
  221. height: 160rpx;
  222. .img {
  223. width: 160rpx;
  224. height: 160rpx;
  225. }
  226. }
  227. .center-right {
  228. width: 100%;
  229. height: 160rpx;
  230. display: flex;
  231. justify-content: space-between;
  232. margin-left: 20rpx;
  233. .r-l {
  234. display: flex;
  235. flex-direction: column;
  236. justify-content: space-around;
  237. .right-name {
  238. color: #4d5671;
  239. font-size: 32rpx;
  240. font-weight: bold;
  241. }
  242. .right-descript {
  243. font-size: 28rpx;
  244. color: #858797;
  245. }
  246. .l-box {
  247. display: flex;
  248. font-size: 24rpx;
  249. align-items: center;
  250. font-style: italic;
  251. .right-price {
  252. margin-right: 20rpx;
  253. font-weight: bold;
  254. font-size: 28rpx;
  255. color: #f57f32;
  256. }
  257. .right-numb {
  258. font-size: 24rpx;
  259. color: #858797;
  260. }
  261. }
  262. }
  263. .r-r {
  264. .r-item {
  265. align-items: center;
  266. }
  267. }
  268. }
  269. }
  270. .item-allnumb-box {
  271. display: flex;
  272. justify-content: space-between;
  273. align-items: center;
  274. font-weight: bold;
  275. .allnumb-left {
  276. font-size: 32rpx;
  277. }
  278. .allnumb-right {
  279. font-size: 26rpx;
  280. color: #f57f32;
  281. .r-text {
  282. color: #000;
  283. }
  284. }
  285. }
  286. }
  287. }
  288. }
  289. .item-bottom {
  290. width: 100%;
  291. margin-top: 20rpx;
  292. .btn {
  293. height: 70rpx;
  294. background-color: rgba(248, 213, 53, 0.8);
  295. color: #4e5059;
  296. font-size: 28rpx;
  297. text-align: center;
  298. line-height: 70rpx;
  299. border-radius: 20rpx;
  300. }
  301. }
  302. .gray-color {
  303. color: #858797;
  304. }
  305. ::deep .u-tabs__wrapper__nav__item__text {
  306. font-size: 30px;
  307. }
  308. </style>