index.vue 6.1 KB

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