index.vue 11 KB

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