index.vue 9.7 KB

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