index.vue 9.6 KB

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