Blogger Information
Blog 62
fans 3
comment 1
visits 29566
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
vue 已购课程页面调用数据
kiraseo_wwwkiraercom
Original
359 people have browsed it

vue 已购课程页面调用数据的处理

代码如下

  1. const data = reactive({
  2. bind_phone : false,
  3. course : [],
  4. hot : [],
  5. course_open : false,
  6. })
  7. const router = useRouter();
  8. let token = window.localStorage.getItem('token');
  9. Purchased({token:token}).then( (e)=> {
  10. data.course = e.data.data.course;
  11. data.course_open = true;
  12. data.hot = e.data.data.hot;
  13. console.log(data.hot);
  14. })
  15. const colse_phone = ()=>{
  16. data.bind_phone = false;
  17. }
  1. public function purchased(){
  2. $data =Request::param();
  3. $user=Ticket::get($data['token'],'phpcn');
  4. $datalist= Db::table('bew_order')
  5. ->field('w.*')
  6. ->alias('a')
  7. ->leftJoin('bew_course w','a.cou_id = w.id')
  8. ->where('a.uid','=',$user)
  9. ->where('a.status','=',2)
  10. ->select()->toArray();
  11. foreach ($datalist as &$datalist_v){
  12. $datalist_v['img_s']= $this->get_url().(explode(';',$datalist_v['img']))[0];
  13. $datalist_v['label_s']= explode(';',$datalist_v['label']);
  14. }
  15. //排除调用当前用户已购买过推荐的课程
  16. $course_id = Db::table('bew_order')
  17. ->field(' cou_id')
  18. ->distinct(true)
  19. ->where('uid','=',$user)
  20. ->where('status','=',2)
  21. ->select()->toArray();
  22. $hot = Db::table('bew_course')
  23. ->where('is_hot','=',1)
  24. ->where('id','<>',$course_id[0]['cou_id'])
  25. ->select()->toArray();
  26. foreach ($hot as &$hot_v){
  27. $hot_v['img_s']= $this->get_url().(explode(';',$hot_v['img']))[0];
  28. $hot_v['label_s']= explode(';',$hot_v['label']);
  29. }
  30. //排除调用当前用户已购买过推荐的课程
  31. $arr= [
  32. 'code'=>0,
  33. 'msg'=>'成功',
  34. 'data'=>[
  35. 'course'=>$datalist,
  36. 'hot'=>$hot
  37. ]
  38. ];
  39. echo json_encode($arr);
  40. }

效果图

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post