myorder.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <view class="page">
  3. <u-tabs :font-size='28' :list="list" :is-scroll="false" :current="current" @change="change"></u-tabs>
  4. <view class="list">
  5. <view class="box" v-for="(item,index) in orderlist" :key="index">
  6. <view class="u-flex u-row-between">
  7. <text class="order">订单编号:{{item.order_on}}</text>
  8. <view class="">
  9. <text v-if="item.status==0" class="state">
  10. {{item.status_text}}
  11. </text>
  12. <text v-else class="state" style="color: rgba(0, 0, 0, 0.60);">
  13. {{item.status_text}}
  14. </text>
  15. </view>
  16. </view>
  17. <view class="book">
  18. <view class="u-flex" style="margin-top: 26rpx;" v-for="(item1,index) in item.goods">
  19. <view class="" style="padding: 0 20rpx;">
  20. <image :src="item1.good_item.image" style="width: 120rpx;height: 160rpx;" mode=""></image>
  21. </view>
  22. <view class="" style="margin-left: 20rpx;">
  23. <view class="name u-line-1">{{item1.good_item.title}}</view>
  24. <view class="type">资源类型:付费资源</view>
  25. <view class="money">¥{{item1.good_item.price}}</view>
  26. </view>
  27. </view>
  28. <view class="shapping u-flex " style="justify-content: end;">
  29. <text class="font1">商品金额:</text>
  30. <text class="font3">¥</text>
  31. <text class="font2">{{item.total_price}}</text>
  32. </view>
  33. <view class="u-flex " style="margin-top: 28rpx;justify-content: end;">
  34. <view v-if="item.status ==0" class="cancel" @click="cancel(item.id)">取消订单</view>
  35. <view v-if="item.status ==0" class="pay" style="color: #fff;">立即付款</view>
  36. <view v-if="item.status ==-1" class=" cancel" @click="delect(item.id)">删除订单</view>
  37. <view v-if="item.status ==1||item.status ==0" class="details cancel"
  38. @click="orderinfo(item.id)">查看详情</view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. data() {
  48. return {
  49. list: [{
  50. name: '全部'
  51. }, {
  52. name: '待支付'
  53. }, {
  54. name: '已完成',
  55. }, {
  56. name: '已取消',
  57. }],
  58. current: 0,
  59. page: 1,
  60. limit: 10,
  61. status: '',
  62. orderlist: []
  63. };
  64. },
  65. onLoad() {
  66. if (uni.getStorageSync('token')) {
  67. this.getOrderList()
  68. }
  69. },
  70. onPullDownRefresh() {
  71. },
  72. methods: {
  73. orderinfo(id) {
  74. uni.navigateTo({
  75. url: '/pages/success?id=' + id
  76. })
  77. },
  78. change(index) {
  79. this.current = index;
  80. if (this.current == 0) {
  81. this.status = ''
  82. } else if (this.current < 3) {
  83. this.status = index - 1
  84. } else if (this.current == 3) {
  85. this.status = -1
  86. }
  87. this.getOrderList()
  88. },
  89. //删除订单
  90. delect(id) {
  91. var that = this
  92. uni.showModal({
  93. title: '提示',
  94. content: '确定删除该订单吗',
  95. success: function(res) {
  96. if (res.confirm) {
  97. that.delect1(id)
  98. } else if (res.cancel) {
  99. console.log('用户点击取消');
  100. }
  101. }
  102. });
  103. },
  104. delect1(id) {
  105. this.$u.post('api/order/delOrder', {
  106. id: id
  107. }).then(res => {
  108. if (res.code == 1) {
  109. this.$u.toast('订单已删除')
  110. this.getOrderList()
  111. }
  112. })
  113. },
  114. cancel(id) {
  115. var that = this
  116. uni.showModal({
  117. title: '提示',
  118. content: '确定取消该订单吗',
  119. success: function(res) {
  120. if (res.confirm) {
  121. that.cancel1(id)
  122. } else if (res.cancel) {
  123. console.log('用户点击取消');
  124. this.getOrderList()
  125. }
  126. }
  127. });
  128. },
  129. cancel1(id) {
  130. this.$u.post('api/order/cancellationOrder', {
  131. id: id
  132. }).then(res => {
  133. if (res.code == 1) {
  134. this.$u.toast('订单已取消')
  135. }
  136. })
  137. },
  138. getOrderList() {
  139. this.$u.post('api/order/getOrderList', {
  140. page: this.page,
  141. limit: this.limit,
  142. status: this.status
  143. }).then(res => {
  144. if (res.code == 1) {
  145. this.orderlist = res.data.data
  146. }
  147. })
  148. }
  149. }
  150. }
  151. </script>
  152. <style lang="scss">
  153. .cancel {
  154. width: 148rpx;
  155. height: 68rpx;
  156. border-radius: 8rpx;
  157. border: 2rpx solid #979797;
  158. line-height: 68rpx;
  159. text-align: center;
  160. margin-left: 20rpx;
  161. }
  162. .pay {
  163. width: 160rpx;
  164. height: 68rpx;
  165. background: #06A971;
  166. border-radius: 8rpx;
  167. line-height: 68rpx;
  168. text-align: center;
  169. margin-left: 20rpx;
  170. }
  171. .name {
  172. font-size: 28rpx;
  173. font-family: PingFangHK, PingFangHK;
  174. font-weight: 400;
  175. color: #333333;
  176. width: 500rpx;
  177. }
  178. .font1 {
  179. font-size: 26rpx;
  180. font-family: PingFangSC, PingFang SC;
  181. font-weight: 400;
  182. color: #222222;
  183. }
  184. .font2 {
  185. font-size: 36rpx;
  186. font-family: JDZhengHT, JDZhengHT;
  187. font-weight: 500;
  188. color: #222222;
  189. }
  190. .font3 {
  191. font-size: 26rpx;
  192. font-family: JDZhengHT, JDZhengHT;
  193. font-weight: 300;
  194. color: #222222;
  195. margin-left: 14rpx;
  196. margin-top: 10rpx;
  197. }
  198. .type {
  199. font-size: 24rpx;
  200. font-family: PingFangSC, PingFang SC;
  201. font-weight: 400;
  202. color: #444444;
  203. margin-top: 8rpx;
  204. }
  205. .shapping {
  206. margin-top: 28rpx;
  207. }
  208. .money {
  209. font-size: 32rpx;
  210. font-family: SFPro, SFPro;
  211. font-weight: 400;
  212. color: #333333;
  213. margin-top: 42rpx;
  214. }
  215. ::v-deep .u-tab-bar {
  216. background-color: #06A971 !important;
  217. }
  218. .state {
  219. font-size: 24rpx;
  220. font-family: PingFangSC, PingFang SC;
  221. font-weight: 400;
  222. color: #CF1534;
  223. }
  224. ::v-deep .u-tab-item {
  225. color: #222 !important
  226. }
  227. .book {
  228. margin: 28rpx 0 0 0;
  229. border-top: 2rpx solid rgba(151, 151, 151, 0.2);
  230. }
  231. .order {
  232. font-size: 24rpx;
  233. font-family: SFPro, SFPro;
  234. font-weight: 400;
  235. color: #222222;
  236. }
  237. .box {
  238. width: 694rpx;
  239. // height: 472rpx;
  240. background: #FFFFFF;
  241. border-radius: 16rpx;
  242. padding: 28rpx 20rpx 30rpx;
  243. margin-top: 20rpx;
  244. box-sizing: border-box;
  245. }
  246. .list {
  247. padding: 20rpx 28rpx;
  248. }
  249. .page {
  250. background: #F6F6F6;
  251. min-height: 100vh;
  252. }
  253. </style>