index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <view>
  3. <view style="width: 100%;text-align: center;position: fixed;height: 96rpx;z-index: 999;">
  4. <u-tabs :list="list" sticky :current="current" @change="change" active-color="#007AFF"></u-tabs>
  5. </view>
  6. <view style="position: absolute;top: 96rpx;width: 100%;">
  7. <view>
  8. <view v-if="!order.length" class="noData">您暂无相关订单哦~</view>
  9. <view v-else v-for="(item, index) in order" style="padding: 20rpx 20rpx 0rpx 20rpx" class="lisChild">
  10. <view class="item">
  11. <view style="display: flex;justify-content: space-between;align-items: center;height: 50rpx;" @click="openPopup(index)">
  12. <view style="color: #666666;font-size: 24rpx;">订单编号:{{ item.orderSn }}</view>
  13. <view style="color: #999999;font-size: 24rpx;">{{ $method.timestampToTime(item.createTime) }}</view>
  14. </view>
  15. <u-line color="#D6D6DB" />
  16. <view
  17. style="display: flex;justify-content: space-between;padding: 25rpx 0;border-bottom: 1rpx solid #eee;"
  18. v-for="(items, indexs) in item.orderGoodsList"
  19. :key="indexs"
  20. >
  21. <image :src="$method.splitImgHost(items.coverUrl)" style="height: 134rpx;width: 278rpx;border-radius: 16rpx;flex-shrink: 0;"></image>
  22. <view style="margin-left: 20rpx;flex:1;display: flex;flex-direction: column;">
  23. <view style="color: #333333;font-size: 30rpx;font-weight: bold;flex:1">{{ items.goodsName }}</view>
  24. <view class="priceTag">¥ {{ items.goodsPrice }}</view>
  25. </view>
  26. </view>
  27. <view style="height: 80rpx;display: flex;justify-content: space-between;align-items: center;">
  28. <view>
  29. <text style="color:#999;font-size: 24rpx;margin-right: 8rpx;">共{{ item.orderGoodsList.length }}项</text>
  30. <text style="color: #333;font-size: 30rpx;font-weight: bold;">合计</text>
  31. <text style="color:#ff2d55;font-size: 30rpx;font-weight: bold;">¥{{ item.payPrice }}</text>
  32. </view>
  33. <view style="display: flex;align-items: center;">
  34. <view class="btn2" v-if="item.orderStatus === 0">继续支付</view>
  35. <view class="btn2" v-if="item.orderStatus === -1 || item.orderStatus === -2">重新购买</view>
  36. <view class="btn2" v-if="item.orderStatus === 1 || item.orderStatus === 2">退款</view>
  37. <view class="btn1" v-if="item.orderStatus === -1 || item.orderStatus === -2" @click="delOrder(item)">删除订单</view>
  38. <view class="btn1" @click="closeOrder(item)" v-if="item.orderStatus === 0">取消订单</view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import { mapGetters } from 'vuex';
  49. export default {
  50. components: {},
  51. data() {
  52. return {
  53. list: [
  54. {
  55. name: '待支付'
  56. },
  57. {
  58. name: '已支付'
  59. },
  60. {
  61. name: '已取消'
  62. }
  63. ],
  64. list1: [1, 2, 3, 4, 5, 6, 7],
  65. current: 0,
  66. order: [],
  67. order1: [],
  68. order2: [],
  69. order3: []
  70. };
  71. },
  72. onPullDownRefresh() {},
  73. onLoad(option) {},
  74. onShow() {
  75. this.getOrderList();
  76. /* if(this.current === 2 && this.$method.isLogin()){
  77. this.$refs.refMy.init();
  78. } */
  79. },
  80. //分享功能
  81. onShareAppMessage(res) {
  82. var self = this;
  83. return {
  84. title: '中正',
  85. path: `/pages/index/index?inviteCode=` + userInfo == null ? '' : userInfo.userAccount
  86. };
  87. },
  88. methods: {
  89. openPopup() {},
  90. //删除订单
  91. delOrder(item) {
  92. var self = this;
  93. uni.showModal({
  94. content: '确定要删除该订单吗',
  95. success: function(res) {
  96. if (res.confirm) {
  97. self.$api
  98. .eddOrder({
  99. orderId: item.orderId,
  100. status: 0
  101. })
  102. .then(res => {
  103. if (res.data.code === 200) {
  104. self.$method.showToast('订单删除成功');
  105. self.getOrderList();
  106. }
  107. });
  108. }
  109. }
  110. });
  111. },
  112. //取消订单
  113. closeOrder(item) {
  114. var self = this;
  115. uni.showModal({
  116. content: '确定要取消该订单吗',
  117. success: function(res) {
  118. if (res.confirm) {
  119. self.$api
  120. .eddOrder({
  121. orderId: item.orderId,
  122. orderStatus: -1
  123. })
  124. .then(res => {
  125. if (res.data.code === 200) {
  126. self.$method.showToast('订单取消成功', 'success');
  127. self.getOrderList();
  128. }
  129. });
  130. }
  131. }
  132. });
  133. },
  134. //获取订单
  135. getOrderList() {
  136. this.$api.getorderlists({ status: 1 }).then(res => {
  137. if (res.data.code === 200) {
  138. var array1 = []; //待支付
  139. var array2 = []; //已支付
  140. var array3 = []; //已取消
  141. res.data.rows.forEach(item => {
  142. if (item.orderStatus === 0) {
  143. array1.push(item);
  144. }
  145. if (item.orderStatus === 1 || item.orderStatus === 2) {
  146. array2.push(item);
  147. }
  148. if (item.orderStatus === -1 || item.orderStatus === -2) {
  149. array3.push(item);
  150. }
  151. });
  152. this.order1 = array1;
  153. this.order2 = array2;
  154. this.order3 = array3;
  155. this.change(this.current);
  156. }
  157. });
  158. },
  159. change(index) {
  160. this.current = index;
  161. if (index === 0) {
  162. this.order = JSON.parse(JSON.stringify(this.order1));
  163. }
  164. if (index === 1) {
  165. this.order = JSON.parse(JSON.stringify(this.order2));
  166. }
  167. if (index === 2) {
  168. this.order = JSON.parse(JSON.stringify(this.order3));
  169. }
  170. }
  171. },
  172. onReachBottom() {},
  173. computed: { ...mapGetters(['userInfo']) }
  174. };
  175. </script>
  176. <style>
  177. page {
  178. background: #eaeef1;
  179. }
  180. </style>
  181. <style scoped>
  182. .lisChild:last-child {
  183. margin-bottom: 34rpx;
  184. }
  185. .noData {
  186. text-align: center;
  187. font-size: 32rpx;
  188. font-family: PingFang SC;
  189. font-weight: 500;
  190. color: #999999;
  191. margin: 160rpx 0;
  192. }
  193. .btn2 {
  194. width: 144rpx;
  195. height: 46rpx;
  196. background: #ffffff;
  197. border: 2rpx solid #007aff;
  198. border-radius: 16rpx;
  199. text-align: center;
  200. line-height: 48rpx;
  201. color: #007aff;
  202. margin: 0 8rpx;
  203. }
  204. .btn1 {
  205. width: 144rpx;
  206. height: 48rpx;
  207. background: #ffffff;
  208. border: 2rpx solid #999999;
  209. border-radius: 16rpx;
  210. text-align: center;
  211. line-height: 48rpx;
  212. color: #999999;
  213. margin: 0 8rpx;
  214. }
  215. .item {
  216. width: 100%;
  217. background: #ffffff;
  218. border-radius: 16rpx;
  219. /* margin-bottom: 20rpx; */
  220. padding: 15rpx;
  221. }
  222. .priceTag {
  223. font-size: 30rpx;
  224. font-family: PingFang SC;
  225. font-weight: bold;
  226. color: #ff2d55;
  227. display: flex;
  228. flex-direction: row-reverse;
  229. }
  230. .bottomBox {
  231. position: fixed;
  232. bottom: 0;
  233. width: 100%;
  234. left: 0;
  235. height: 98rpx;
  236. background-color: #ffffff;
  237. display: flex;
  238. justify-content: space-between;
  239. align-items: center;
  240. padding: 0 30rpx;
  241. }
  242. </style>