index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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.goodsRealPrice }}</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. formData:{
  68. status:'0,1',
  69. pageNum:1,
  70. pageSize:8
  71. }
  72. };
  73. },
  74. onPullDownRefresh() {},
  75. onLoad(option) {},
  76. onShow() {
  77. this.getOrderList();
  78. /* if(this.current === 2 && this.$method.isLogin()){
  79. this.$refs.refMy.init();
  80. } */
  81. },
  82. //分享功能
  83. onShareAppMessage(res) {
  84. var self = this;
  85. return {
  86. title: '中正',
  87. path: `/pages/index/index?inviteCode=` + userInfo == null ? '' : userInfo.userAccount
  88. };
  89. },
  90. onReachBottom(){
  91. this.formData.pageNum++
  92. console.log(this.formData.pageNum)
  93. },
  94. methods: {
  95. openPopup() {},
  96. //删除订单
  97. delOrder(item) {
  98. var self = this;
  99. uni.showModal({
  100. content: '确定要删除该订单吗',
  101. success: function(res) {
  102. if (res.confirm) {
  103. self.$api
  104. .eddOrder({
  105. orderId: item.orderId,
  106. status: -1
  107. })
  108. .then(res => {
  109. if (res.data.code === 200) {
  110. self.$method.showToast('订单删除成功');
  111. self.getOrderList();
  112. }
  113. });
  114. }
  115. }
  116. });
  117. },
  118. //取消订单
  119. closeOrder(item) {
  120. var self = this;
  121. uni.showModal({
  122. content: '确定要取消该订单吗',
  123. success: function(res) {
  124. if (res.confirm) {
  125. self.$api
  126. .eddOrder({
  127. orderId: item.orderId,
  128. orderStatus: -1
  129. })
  130. .then(res => {
  131. if (res.data.code === 200) {
  132. self.$method.showToast('订单取消成功', 'success');
  133. self.getOrderList();
  134. }
  135. });
  136. }
  137. }
  138. });
  139. },
  140. getFY(){
  141. if (this.current === 0) {
  142. this.formData.orderStatus = 0;
  143. }
  144. if (this.current === 1) {
  145. this.formData.orderStatus = [1, 2];
  146. }
  147. if (this.current === 2) {
  148. this.formData.orderStatus = [-1, -2];
  149. }
  150. this.$api.getorderlists(this.formData).then(res => {
  151. if (res.data.code === 200) {
  152. this.order.push(res.data.rows)
  153. }
  154. });
  155. },
  156. //获取订单
  157. getOrderList() {
  158. this.formData.pageNum = 1
  159. if (this.current === 0) {
  160. this.formData.orderStatus = 0;
  161. }
  162. if (this.current === 1) {
  163. this.formData.orderStatus = [1, 2];
  164. }
  165. if (this.current === 2) {
  166. this.formData.orderStatus = [-1, -2];
  167. }
  168. this.$api.getorderlists(this.formData).then(res => {
  169. if (res.data.code === 200) {
  170. this.order = res.data.rows;
  171. }
  172. });
  173. },
  174. change(index) {
  175. if (this.current === index) {
  176. return;
  177. }
  178. this.current = index;
  179. this.getOrderList();
  180. }
  181. },
  182. onReachBottom() {},
  183. computed: { ...mapGetters(['userInfo']) }
  184. };
  185. </script>
  186. <style>
  187. page {
  188. background: #eaeef1;
  189. }
  190. </style>
  191. <style scoped>
  192. .lisChild:last-child {
  193. margin-bottom: 34rpx;
  194. }
  195. .noData {
  196. text-align: center;
  197. font-size: 32rpx;
  198. font-family: PingFang SC;
  199. font-weight: 500;
  200. color: #999999;
  201. margin: 160rpx 0;
  202. }
  203. .btn2 {
  204. width: 144rpx;
  205. height: 46rpx;
  206. background: #ffffff;
  207. border: 2rpx solid #007aff;
  208. border-radius: 16rpx;
  209. text-align: center;
  210. line-height: 48rpx;
  211. color: #007aff;
  212. margin: 0 8rpx;
  213. }
  214. .btn1 {
  215. width: 144rpx;
  216. height: 48rpx;
  217. background: #ffffff;
  218. border: 2rpx solid #999999;
  219. border-radius: 16rpx;
  220. text-align: center;
  221. line-height: 48rpx;
  222. color: #999999;
  223. margin: 0 8rpx;
  224. }
  225. .item {
  226. width: 100%;
  227. background: #ffffff;
  228. border-radius: 16rpx;
  229. /* margin-bottom: 20rpx; */
  230. padding: 15rpx;
  231. }
  232. .priceTag {
  233. font-size: 30rpx;
  234. font-family: PingFang SC;
  235. font-weight: bold;
  236. color: #ff2d55;
  237. display: flex;
  238. flex-direction: row-reverse;
  239. }
  240. .bottomBox {
  241. position: fixed;
  242. bottom: 0;
  243. width: 100%;
  244. left: 0;
  245. height: 98rpx;
  246. background-color: #ffffff;
  247. display: flex;
  248. justify-content: space-between;
  249. align-items: center;
  250. padding: 0 30rpx;
  251. }
  252. </style>