list.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view>
  3. <u-tabs :list="tab" active-color="#c74547" :is-scroll="false" :current="current" @change="change"></u-tabs>
  4. <view class="list">
  5. <view class="item" v-for="(item, key) in list" :key="key" @click="detail(item)">
  6. <view class="order_title">
  7. <text>广安农机农技智慧服务</text>
  8. <view class="zhu">
  9. <text class="theme_bg" v-if="item.state == 0">待支付</text>
  10. <text style="color: #4CAF50;" v-if="item.state == 1">支付成功,待确认</text>
  11. <text style="color: #4CAF50;" v-if="item.state == 2">进行中...</text>
  12. <text style="color: #4CAF50;" v-if="item.state == 3">完成交易</text>
  13. <text style="color: #4CAF50;" v-if="item.state == -1">已退款</text>
  14. </view>
  15. </view>
  16. <view class="order_item" v-for="(it, index) in item.orderList" :key="index">
  17. <image :src="ip + it.pic" class="pic" :class="it.goods.state == 1||it.goods.state==null? 'gray' : ''" mode="aspectFill"></image>
  18. <view class="con">
  19. <view class="title">{{ it.title }}</view>
  20. <view class="price">
  21. <text>¥{{ it.price }}</text>
  22. <text class="day">/天</text>
  23. </view>
  24. <view class="err" v-if="it.goods.state == 1||it.goods.state==null">已下架</view>
  25. </view>
  26. <view class="clear"></view>
  27. </view>
  28. <view class="hj">
  29. 合计:
  30. <text class="theme_bg bo pad_left_5">¥ {{ item.totalPrice }}</text>
  31. </view>
  32. <view>
  33. <button class="btn" v-if="item.state == 0" @click.stop="pay(item)">去支付</button>
  34. <button class="btn cancel" v-if="item.state == 0" @click.stop="cancel(item)">取消订单</button>
  35. </view>
  36. <view class="clear"></view>
  37. <view class="tk" v-if="item.state == -1">抱歉,由于我们无法提供服务,该订单由系统取消,你的款项将原路退回。</view>
  38. </view>
  39. <view class="loading"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. ip: this.$http.urls.ip,
  48. tab: [{ name: '所有订单', state: '' }, { name: '待付款', state: 0 }, { name: '进行中', state: 2 }, { name: '已完成', state: 3 }],
  49. current: 0,
  50. list: [],
  51. param: { pageNum: 1, state: '', openId: this.$getUser().openId },
  52. loadMore: true
  53. };
  54. },
  55. onLoad() {
  56. this.getData();
  57. },
  58. methods: {
  59. //获取数据
  60. getData() {
  61. this.$http.request({
  62. url: this.$http.urls.order_list,
  63. data: this.param,
  64. loading: 'false',
  65. success: res => {
  66. this.loadMore = res.data.pages > this.param.pageNum ? true : false;
  67. res.data.rows.forEach(item => {
  68. this.list.push(item);
  69. });
  70. }
  71. });
  72. },
  73. change(index) {
  74. this.current = index;
  75. this.param.state = this.tab[index].state;
  76. this.refresh();
  77. },
  78. detail(item) {
  79. uni.navigateTo({
  80. url: 'detail?orderNum=' + item.orderNum
  81. });
  82. },
  83. //取消订单
  84. cancel(item) {
  85. uni.showModal({
  86. title: '提示',
  87. content: '是否取消该订单?',
  88. success: res => {
  89. if (res.confirm) {
  90. this.$http.request({
  91. url: this.$http.urls.order_cancel,
  92. data: { orderNum: item.orderNum },
  93. success: res => {
  94. this.list.splice(this.list.indexOf(item), 1);
  95. uni.showToast({ title: '取消成功' });
  96. }
  97. });
  98. }
  99. }
  100. });
  101. },
  102. //付款
  103. pay(item) {
  104. this.$http.request({
  105. url: this.$http.urls.pay,
  106. method: 'POST',
  107. data: item,
  108. success: res => {
  109. //调起微信支付
  110. wx.requestPayment({
  111. timeStamp: res.data.data.timeStamp,
  112. nonceStr: res.data.data.nonceStr,
  113. package: res.data.data.package,
  114. signType: res.data.data.signType,
  115. paySign: res.data.data.paySign,
  116. success: r => {
  117. uni.showToast({ title: '支付成功' });
  118. item.state = 1;
  119. },
  120. fail: r => {
  121. uni.showToast({ title: '取消支付' });
  122. }
  123. });
  124. }
  125. });
  126. },
  127. //刷新数据
  128. refresh() {
  129. this.loadMore = true;
  130. this.param.pageNum = 1;
  131. this.list = [];
  132. this.getData();
  133. }
  134. },
  135. //下拉刷新
  136. onPullDownRefresh() {
  137. setTimeout(() => {
  138. uni.stopPullDownRefresh();
  139. this.refresh();
  140. }, 1000);
  141. },
  142. //上拉加载
  143. onReachBottom() {
  144. if (this.loadMore) {
  145. this.param.pageNum++;
  146. this.getData();
  147. }
  148. }
  149. };
  150. </script>
  151. <style lang="scss">
  152. page {
  153. background-color: $page;
  154. }
  155. .list {
  156. padding: 0px 15px 25px 15px;
  157. .item {
  158. background-color: white;
  159. padding: 5px 13px 13px 13px;
  160. margin-top: 10px;
  161. border-radius: 5px;
  162. .hj {
  163. text-align: right;
  164. padding-top: 13px;
  165. .pirce {
  166. padding-left: 10px;
  167. color: $theme-color;
  168. }
  169. }
  170. .btn {
  171. margin-top: 10px;
  172. }
  173. .cancel {
  174. background-color: $dar;
  175. }
  176. }
  177. }
  178. </style>