index.vue 8.8 KB

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