index.vue 9.1 KB

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