index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <view>
  3. <view class="order_status_list">
  4. <view class="order_status_item" :class="requestParam.status==0?'active':''" @click="setStatus(0)"> 全部 </view>
  5. <view class="order_status_item" :class="requestParam.status==1?'active':''" @click="setStatus(1)"> 待跟进 </view>
  6. <view class="order_status_item" :class="requestParam.status==4?'active':''" @click="setStatus(4)"> 已取消 </view>
  7. <view class="order_status_item" :class="requestParam.status==8?'active':''" @click="setStatus(8)"> 已完成 </view>
  8. </view>
  9. <view class="to_bottom" v-if="!orderList.length"> -----还没有订单-----</view>
  10. <view class="order_list">
  11. <view class="order_item" v-for="(item,index) in orderList" :key="index" >
  12. <view class="order_title" @click="item.product_list.length > 1">
  13. <view class="business_name">{{item.business_name}}</view>
  14. <view class="order_status">{{item.state}}</view>
  15. </view>
  16. <view class="product_list" :class="item.contents_class?'active':''">
  17. <view class="product_item" v-for="(product_info,k) in item.product_list" :key="k" >
  18. <image class="product_img" :src="product_info.product_thumb" mode="" @click="navToProduct(product_info.product_id)"></image>
  19. <view class="product_info">
  20. <view @click="navToProduct(product_info.product_id)" class="product_name">
  21. <text v-if="product_info.is_rebate">【赠】</text> {{product_info.product_name}}
  22. </view>
  23. <view @click="navToProduct(product_info.product_id)" class="product_spec">
  24. {{product_info.product_spec}}
  25. </view>
  26. </view>
  27. <view class="buy_num">
  28. x{{product_info.buy_num}}
  29. </view>
  30. </view>
  31. </view>
  32. <view class="show_more" v-if="item.product_list.length > 1" @click.stop="changeHeight(index)">
  33. <uni-icons :type="item.contents_class?'up':'down'" size="20" ></uni-icons>
  34. </view>
  35. <view class="order_price">
  36. <button class="order_cancel" v-if="item.status == 1" @click="cancelOrder(index)">取消订单</button>
  37. <view class="pay_total">¥{{item.pay_total}}</view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="to_bottom" v-if="isLast"> -----到底啦-----</view>
  42. </view>
  43. </template>
  44. <script>
  45. export default {
  46. data() {
  47. return {
  48. // 产品列表
  49. orderList:[],
  50. // 请求参数
  51. requestParam:{
  52. page:1,
  53. status:0,
  54. },
  55. // 是否最后一页
  56. isLast:false,
  57. // 是否请求中
  58. isReqing:false,
  59. };
  60. },
  61. onLoad() {
  62. // 初始化页码为1
  63. this.requestParam.page = 1;
  64. // 是否是最后一页
  65. this.isLast = false;
  66. // 设置请求中
  67. this.isReqing = true;
  68. // 登录提示
  69. if( !this.$checkAccess.alterLogin() ) return ;
  70. // 请求列表
  71. this.$http.request('api/orders/get_list',this.requestParam).then((re)=>{
  72. // 设置非请求中
  73. this.isReqing = false;
  74. // 成功结果
  75. if( re.code == 'success' ){
  76. if(re.data.last_page <= this.requestParam.page ) this.isLast = true;
  77. this.orderList = re.data.data;
  78. }
  79. });
  80. },
  81. onShow() {
  82. // 登录提示
  83. if( !this.$checkAccess.alterLogin() ) return ;
  84. // 没有数据的话,或者请求中,不允许刷新
  85. if( this.orderList.length > 0 || this.isReqing ) return ;
  86. // 设置请求中
  87. this.isReqing = true;
  88. // 请求列表
  89. this.$http.request('api/orders/get_list',this.requestParam).then((re)=>{
  90. // 设置非请求中
  91. this.isReqing = false;
  92. // 成功结果
  93. if( re.code == 'success' ){
  94. if(re.data.last_page <= this.requestParam.page ) this.isLast = true;
  95. this.orderList = re.data.data;
  96. }
  97. });
  98. },
  99. onPullDownRefresh() {
  100. // 登录提示
  101. if( !this.$checkAccess.alterLogin() ) return ;
  102. // 如果请求中,不允许请求,
  103. if( this.isReqing ) return false;
  104. // 初始化页码为1
  105. this.requestParam.page = 1;
  106. // 是否是最后一页
  107. this.isLast = false;
  108. // 设置请求中
  109. this.isReqing = true;
  110. // 请求列表
  111. this.$http.request('api/orders/get_list',this.requestParam).then((re)=>{
  112. // 设置非请求中
  113. this.isReqing = false;
  114. // 成功结果
  115. if( re.code == 'success' ){
  116. if(re.data.last_page <= this.requestParam.page ) this.isLast = true;
  117. this.orderList = re.data.data;
  118. }
  119. });
  120. uni.stopPullDownRefresh();
  121. },
  122. onReachBottom() {
  123. // 登录提示
  124. if( !this.$checkAccess.alterLogin() ) return ;
  125. // 如果页码是0,避免第一页重复
  126. if( this.requestParam.page < 1 ) return;
  127. // 最后一页不请求
  128. if( this.isLast ) return;
  129. // 请求中,不再请求
  130. if( this.isReqing ) return;
  131. // 增加一页
  132. this.requestParam.page = this.requestParam.page+1;
  133. // 设置请求中
  134. this.isReqing = true;
  135. // 请求列表
  136. this.$http.request('api/orders/get_list',this.requestParam).then((re)=>{
  137. // 设置非请求中
  138. this.isReqing = false;
  139. // 成功结果
  140. if( re.code == 'success' ){
  141. if(re.data.last_page <= this.requestParam.page ) this.isLast = true;
  142. // 追加数据
  143. this.orderList.push(... re.data.data);
  144. }
  145. });
  146. },
  147. methods:{
  148. setStatus(status){
  149. // 登录提示
  150. if( !this.$checkAccess.alterLogin() ) return ;
  151. // 请求中,不再请求
  152. if( this.isReqing ) return;
  153. // 初始化页码为1
  154. this.requestParam.page = 1;
  155. // 是否是最后一页
  156. this.isLast = false;
  157. // 状态变更
  158. this.requestParam.status = status;
  159. // 设置请求中
  160. this.isReqing = true;
  161. // 请求列表
  162. this.$http.request('api/orders/get_list',this.requestParam).then((re)=>{
  163. // 设置非请求中
  164. this.isReqing = false;
  165. // 成功结果
  166. if( re.code == 'success' ){
  167. if(re.data.last_page >= this.requestParam.page ) this.isLast = true;
  168. this.orderList = re.data.data;
  169. }
  170. });
  171. },
  172. changeHeight(index){
  173. this.orderList[index].contents_class = this.orderList[index].contents_class ? 0:1;
  174. },
  175. // 取消订单
  176. cancelOrder(index){
  177. uni.showModal({
  178. title:"确认取消该订单?",
  179. success:res=>{
  180. if (res.confirm) {
  181. // 请求列表
  182. this.$http.request('api/orders/cancel',{id:this.orderList[index].id}).then(re=>{
  183. this.orderList[index].state = '已取消';
  184. this.orderList[index].status = 4;
  185. });
  186. }
  187. }
  188. })
  189. },
  190. navToProduct(id){
  191. if( id ){
  192. uni.navigateTo({
  193. url:"/pages/product/index?product_id="+id
  194. })
  195. }
  196. }
  197. }
  198. }
  199. </script>
  200. <style lang="less">
  201. .order_status_list{
  202. display: block;
  203. height: 60rpx;
  204. color: #666666;
  205. line-height: 60rpx;
  206. background: #FFFFFF;
  207. padding: 10rpx 35rpx;
  208. .order_status_item{
  209. float: left;
  210. font-size: 28rpx;
  211. padding: 0rpx 20rpx;
  212. }
  213. .order_status_item.active{
  214. color: #000000;
  215. font-weight: bold;
  216. }
  217. }
  218. .order_list{
  219. display:block;
  220. overflow: hidden;
  221. margin: 0rpx auto;
  222. .order_item{
  223. display: block;
  224. background: #FFFFFF;
  225. margin: 0rpx auto;
  226. padding: 0rpx 35rpx;
  227. margin-bottom: 10rpx;
  228. .order_title{
  229. width: 100%;
  230. height: 60rpx;
  231. display: block;
  232. overflow: hidden;
  233. line-height: 60rpx;
  234. .business_name{
  235. float: left;
  236. font-size: 32rpx;
  237. }
  238. .order_status{
  239. float: right;
  240. color: #999999;
  241. font-size: 24rpx;
  242. }
  243. }
  244. .product_list{
  245. display: block;
  246. height: 100rpx;
  247. overflow: hidden;
  248. margin: 15rpx auto;
  249. .product_item{
  250. display: block;
  251. height: 100rpx;
  252. overflow: hidden;
  253. .product_img{
  254. float: left;
  255. width: 80rpx;
  256. height: 80rpx;
  257. display: block;
  258. margin-top: 10rpx;
  259. margin-right: 30rpx;
  260. }
  261. .product_info{
  262. float: left;
  263. width: 480rpx;
  264. height: 100rpx;
  265. display: block;
  266. overflow: hidden;
  267. .product_name{
  268. display: block;
  269. height: 60rpx;
  270. display: block;
  271. font-size: 28rpx;
  272. line-height: 60rpx;
  273. overflow: hidden;
  274. }
  275. .product_spec{
  276. color: #999999;
  277. height: 40rpx;
  278. display: block;
  279. font-size: 24rpx;
  280. line-height: 40rpx;
  281. overflow: hidden;
  282. }
  283. }
  284. .buy_num{
  285. float: right;
  286. height: 100rpx;
  287. color: #999999;
  288. font-size: 26rpx;
  289. text-align: right;
  290. position: relative;
  291. line-height: 100rpx;
  292. }
  293. }
  294. }
  295. .product_list.active{
  296. height: auto !important;
  297. }
  298. .order_price{
  299. display: block;
  300. height: 60rpx;
  301. overflow: hidden;
  302. line-height: 60rpx;
  303. .order_cancel{
  304. float: left;
  305. color: #999999;
  306. height: 60rpx;
  307. font-size: 24rpx;
  308. padding: 0rpx 0rpx;
  309. line-height: 60rpx;
  310. margin-left: 10rpx;
  311. background-color: transparent;
  312. }
  313. .order_cancel::after{
  314. border: none;
  315. }
  316. .pay_total{
  317. float: right;
  318. height: 60rpx;
  319. color: #E03519;
  320. font-size: 28rpx;
  321. line-height: 60rpx;
  322. }
  323. }
  324. .show_more{
  325. display: block;
  326. font-size: 20rpx;
  327. text-align: center;
  328. padding: 20rpx 0rpx;
  329. }
  330. }
  331. }
  332. </style>